Skip to content

Commit b1c0f00

Browse files
committed
chore: run transform script (dirty)
1 parent d6751fa commit b1c0f00

261 files changed

Lines changed: 11646 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import type { FakerCore } from '../../faker-core';
2+
import { enumValue } from '../helpers/enum-value';
3+
4+
/**
5+
* Returns a random aircraft type.
6+
*
7+
* @param fakerCore The FakerCore to use.
8+
*
9+
* @example
10+
* aircraftType(fakerCore) // 'narrowbody'
11+
*
12+
* @since 8.0.0
13+
*/
14+
export function aircraftType(fakerCore: FakerCore): AircraftType {
15+
return enumValue(fakerCore, Aircraft);
16+
}

src/modules/airline/airline.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import type { FakerCore } from '../../faker-core';
2+
import { resolveLocaleData } from '../../utils/resolve-locale-data';
3+
import { arrayElement } from '../helpers/array-element';
4+
5+
/**
6+
* Generates a random airline.
7+
*
8+
* @param fakerCore The FakerCore to use.
9+
*
10+
* @example
11+
* airline(fakerCore) // { name: 'American Airlines', iataCode: 'AA' }
12+
*
13+
* @since 8.0.0
14+
*/
15+
export function airline(fakerCore: FakerCore): Airline {
16+
return arrayElement(
17+
fakerCore,
18+
resolveLocaleData(fakerCore, 'airline', 'airline')
19+
);
20+
}

src/modules/airline/airplane.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import type { FakerCore } from '../../faker-core';
2+
import { resolveLocaleData } from '../../utils/resolve-locale-data';
3+
import { arrayElement } from '../helpers/array-element';
4+
5+
/**
6+
* Generates a random airplane.
7+
*
8+
* @param fakerCore The FakerCore to use.
9+
*
10+
* @example
11+
* airplane(fakerCore) // { name: 'Airbus A321neo', iataTypeCode: '32Q' }
12+
*
13+
* @since 8.0.0
14+
*/
15+
export function airplane(fakerCore: FakerCore): Airplane {
16+
return arrayElement(
17+
fakerCore,
18+
resolveLocaleData(fakerCore, 'airline', 'airplane')
19+
);
20+
}

src/modules/airline/airport.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import type { FakerCore } from '../../faker-core';
2+
import { resolveLocaleData } from '../../utils/resolve-locale-data';
3+
import { arrayElement } from '../helpers/array-element';
4+
5+
/**
6+
* Generates a random airport.
7+
*
8+
* @param fakerCore The FakerCore to use.
9+
*
10+
* @example
11+
* airport(fakerCore) // { name: 'Dallas Fort Worth International Airport', iataCode: 'DFW' }
12+
*
13+
* @since 8.0.0
14+
*/
15+
export function airport(fakerCore: FakerCore): Airport {
16+
return arrayElement(
17+
fakerCore,
18+
resolveLocaleData(fakerCore, 'airline', 'airport')
19+
);
20+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import type { FakerCore } from '../../faker-core';
2+
import { numeric } from '../string/numeric';
3+
4+
/**
5+
* Returns a random flight number. Flight numbers are always 1 to 4 digits long. Sometimes they are
6+
* used without leading zeros (e.g.: `American Airlines flight 425`) and sometimes with leading
7+
* zeros, often with the airline code prepended (e.g.: `AA0425`).
8+
*
9+
* To generate a flight number prepended with an airline code, combine this function with the
10+
* `airline()` function and use template literals:
11+
* ```
12+
* `${airline(fakerCore).iataCode}${flightNumber(fakerCore, { addLeadingZeros: true })}` // 'AA0798'
13+
* ```
14+
*
15+
* @param fakerCore The FakerCore to use.
16+
* @param options The options to use.
17+
* @param options.length The number or range of digits to generate. Defaults to `{ min: 1, max: 4 }`.
18+
* @param options.addLeadingZeros Whether to pad the flight number up to 4 digits with leading zeros. Defaults to `false`.
19+
*
20+
* @example
21+
* flightNumber(fakerCore) // '2405'
22+
* flightNumber(fakerCore, { addLeadingZeros: true }) // '0249'
23+
* flightNumber(fakerCore, { addLeadingZeros: true, length: 2 }) // '0042'
24+
* flightNumber(fakerCore, { addLeadingZeros: true, length: { min: 2, max: 3 } }) // '0624'
25+
* flightNumber(fakerCore, { length: 3 }) // '425'
26+
* flightNumber(fakerCore, { length: { min: 2, max: 3 } }) // '84'
27+
*
28+
* @since 8.0.0
29+
*/
30+
export function flightNumber(
31+
fakerCore: FakerCore,
32+
options: {
33+
/**
34+
* The number or range of digits to generate.
35+
*
36+
* @default { min: 1, max: 4 }
37+
*/
38+
length?:
39+
| number
40+
| {
41+
/**
42+
* The minimum number of digits to generate.
43+
*/
44+
min: number;
45+
/**
46+
* The maximum number of digits to generate.
47+
*/
48+
max: number;
49+
};
50+
/**
51+
* Whether to pad the flight number up to 4 digits with leading zeros.
52+
*
53+
* @default false
54+
*/
55+
addLeadingZeros?: boolean;
56+
} = {}
57+
): string {
58+
const { length = { min: 1, max: 4 }, addLeadingZeros = false } = options;
59+
const flightNumber = numeric(fakerCore, {
60+
length,
61+
allowLeadingZeros: false,
62+
});
63+
return addLeadingZeros ? flightNumber.padStart(4, '0') : flightNumber;
64+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import type { FakerCore } from '../../faker-core';
2+
import { alphanumeric } from '../string/alphanumeric';
3+
4+
/**
5+
* Generates a random [record locator](https://en.wikipedia.org/wiki/Record_locator). Record locators
6+
* are used by airlines to identify reservations. They're also known as booking reference numbers,
7+
* locator codes, confirmation codes, or reservation codes.
8+
*
9+
* @param fakerCore The FakerCore to use.
10+
* @param options The options to use.
11+
* @param options.allowNumerics Whether to allow numeric characters. Defaults to `false`.
12+
* @param options.allowVisuallySimilarCharacters Whether to allow visually similar characters such as '1' and 'I'. Defaults to `false`.
13+
*
14+
* @example
15+
* recordLocator(fakerCore) // 'KIFRWE'
16+
* recordLocator(fakerCore, { allowNumerics: true }) // 'E5TYEM'
17+
* recordLocator(fakerCore, { allowVisuallySimilarCharacters: true }) // 'ANZNEI'
18+
* recordLocator(fakerCore, { allowNumerics: true, allowVisuallySimilarCharacters: true }) // '1Z2Z3E'
19+
*
20+
* @since 8.0.0
21+
*/
22+
export function recordLocator(
23+
fakerCore: FakerCore,
24+
options: {
25+
/**
26+
* Whether to allow numeric characters.
27+
*
28+
* @default false
29+
*/
30+
allowNumerics?: boolean;
31+
/**
32+
* Whether to allow visually similar characters such as '1' and 'I'.
33+
*
34+
* @default false
35+
*/
36+
allowVisuallySimilarCharacters?: boolean;
37+
} = {}
38+
): string {
39+
const { allowNumerics = false, allowVisuallySimilarCharacters = false } =
40+
options;
41+
const excludedChars: string[] = [];
42+
if (!allowNumerics) {
43+
excludedChars.push(...numerics);
44+
}
45+
46+
if (!allowVisuallySimilarCharacters) {
47+
excludedChars.push(...visuallySimilarCharacters);
48+
}
49+
50+
return alphanumeric(fakerCore, {
51+
length: 6,
52+
casing: 'upper',
53+
exclude: excludedChars,
54+
});
55+
}

src/modules/airline/seat.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import type { FakerCore } from '../../faker-core';
2+
import { arrayElement } from '../helpers/array-element';
3+
import { int } from '../number/int';
4+
5+
/**
6+
* Generates a random seat.
7+
*
8+
* @param fakerCore The FakerCore to use.
9+
* @param options The options to use.
10+
* @param options.aircraftType The aircraft type. Can be one of `narrowbody`, `regional`, `widebody`. Defaults to `narrowbody`.
11+
*
12+
* @example
13+
* seat(fakerCore) // '22C'
14+
* seat(fakerCore, { aircraftType: 'regional' }) // '7A'
15+
* seat(fakerCore, { aircraftType: 'widebody' }) // '42K'
16+
*
17+
* @since 8.0.0
18+
*/
19+
export function seat(
20+
fakerCore: FakerCore,
21+
options: {
22+
/**
23+
* The aircraft type. Can be one of `narrowbody`, `regional`, `widebody`.
24+
*
25+
* @default 'narrowbody'
26+
*/
27+
aircraftType?: AircraftType;
28+
} = {}
29+
): string {
30+
const { aircraftType = Aircraft.Narrowbody } = options;
31+
const maxRow = aircraftTypeMaxRows[aircraftType];
32+
const allowedSeats = aircraftTypeSeats[aircraftType];
33+
const row = int(fakerCore, { min: 1, max: maxRow });
34+
const seat = arrayElement(fakerCore, allowedSeats);
35+
return `${row}${seat}`;
36+
}

src/modules/animal/bear.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import type { FakerCore } from '../../faker-core';
2+
import { resolveLocaleData } from '../../utils/resolve-locale-data';
3+
import { arrayElement } from '../helpers/array-element';
4+
5+
/**
6+
* Returns a random bear species.
7+
*
8+
* @param fakerCore The FakerCore to use.
9+
*
10+
* @example
11+
* bear(fakerCore) // 'Asian black bear'
12+
*
13+
* @since 5.5.0
14+
*/
15+
export function bear(fakerCore: FakerCore): string {
16+
return arrayElement(
17+
fakerCore,
18+
resolveLocaleData(fakerCore, 'animal', 'bear')
19+
);
20+
}

src/modules/animal/bird.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import type { FakerCore } from '../../faker-core';
2+
import { resolveLocaleData } from '../../utils/resolve-locale-data';
3+
import { arrayElement } from '../helpers/array-element';
4+
5+
/**
6+
* Returns a random bird species.
7+
*
8+
* @param fakerCore The FakerCore to use.
9+
*
10+
* @example
11+
* bird(fakerCore) // 'Buller's Shearwater'
12+
*
13+
* @since 5.5.0
14+
*/
15+
export function bird(fakerCore: FakerCore): string {
16+
return arrayElement(
17+
fakerCore,
18+
resolveLocaleData(fakerCore, 'animal', 'bird')
19+
);
20+
}

src/modules/animal/cat.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import type { FakerCore } from '../../faker-core';
2+
import { resolveLocaleData } from '../../utils/resolve-locale-data';
3+
import { arrayElement } from '../helpers/array-element';
4+
5+
/**
6+
* Returns a random cat breed.
7+
*
8+
* @param fakerCore The FakerCore to use.
9+
*
10+
* @example
11+
* cat(fakerCore) // 'Singapura'
12+
*
13+
* @since 5.5.0
14+
*/
15+
export function cat(fakerCore: FakerCore): string {
16+
return arrayElement(fakerCore, resolveLocaleData(fakerCore, 'animal', 'cat'));
17+
}

0 commit comments

Comments
 (0)