Skip to content

Commit

Permalink
Merge branch 'main' into docs/generate-docs-for-injected-methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinigami92 authored Mar 1, 2022
2 parents e60b7b0 + 442812f commit 282a824
Show file tree
Hide file tree
Showing 84 changed files with 154 additions and 96 deletions.
4 changes: 1 addition & 3 deletions .prettierrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
* @type {import('prettier').Options}
*/
module.exports = {
plugins: [
/* require.resolve("prettier-plugin-organize-imports") */
],
plugins: [require.resolve('prettier-plugin-organize-imports')],
singleQuote: true,
overrides: [
{
Expand Down
2 changes: 1 addition & 1 deletion docs/.vitepress/theme/components/index.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Playground from './Playground.vue';
import Badge from './Badge.vue';
import Playground from './Playground.vue';

export default {
Playground,
Expand Down
4 changes: 2 additions & 2 deletions docs/.vitepress/theme/index.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import './index.css';
import GlobalComponents from './components';
import DefaultTheme from 'vitepress/theme';
import GlobalComponents from './components';
import './index.css';

export default {
...DefaultTheme,
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
"npm-run-all": "~4.1.5",
"picocolors": "~1.0.0",
"prettier": "2.5.1",
"prettier-plugin-organize-imports": "~2.3.4",
"rimraf": "~3.0.2",
"sanitize-html": "~2.7.0",
"simple-git-hooks": "~2.7.0",
Expand Down
12 changes: 12 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion scripts/verifyCommit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

// Invoked on the commit-msg git hook by simple-git-hooks.

import colors from 'picocolors';
import { readFileSync } from 'fs';
import colors from 'picocolors';

// get $1 from commit-msg script
const msgPath = process.argv[2];
Expand Down
14 changes: 6 additions & 8 deletions src/datatype.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import type { Faker } from '.';
* Module to generate various primitive values and data types.
*/
export class Datatype {
constructor(private readonly faker: Faker, seed?: any[] | any) {
constructor(private readonly faker: Faker, seed?: number | number[]) {
// Use a user provided seed if it is an array or number
if (Array.isArray(seed) && seed.length) {
this.faker.mersenne.seed_array(seed);
} else if (!isNaN(seed)) {
} else if (!Array.isArray(seed) && !isNaN(seed)) {
this.faker.mersenne.seed(seed);
}

Expand Down Expand Up @@ -269,13 +269,11 @@ export class Datatype {
* faker.datatype.array(3) // [ 61845, 'SK7H$W3:d*', 'm[%7N8*GVK' ]
*/
array(length = 10): Array<string | number> {
const returnArray = new Array(length);
for (let i = 0; i < length; i++) {
returnArray[i] = this.faker.datatype.boolean()
return Array.from<string | number>({ length }).map(() =>
this.faker.datatype.boolean()
? this.faker.datatype.string()
: this.faker.datatype.number();
}
return returnArray;
: this.faker.datatype.number()
);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/definitions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ export type {
export type { CompanyDefinitions } from './company';
export type { DatabaseDefinitions } from './database';
export type { DateDefinitions, DateEntryDefinition } from './date';
export type { DefinitionTypes, LocaleDefinition } from './definitions';
export { DEFINITIONS } from './definitions';
export type { DefinitionTypes, LocaleDefinition } from './definitions';
export type {
FinanceCurrencyEntryDefinitions,
FinanceDefinitions,
Expand Down
4 changes: 2 additions & 2 deletions src/faker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class Faker {
// Will be lazy init
readonly definitions: LocaleDefinition = {} as LocaleDefinition;

seedValue?: any[] | any;
seedValue?: number | number[];

readonly fake: Fake['fake'] = new Fake(this).fake;
readonly unique: Unique['unique'] = new Unique().unique;
Expand Down Expand Up @@ -127,7 +127,7 @@ export class Faker {
});
}

seed(value?: any[] | any): void {
seed(value?: number | number[]): void {
this.seedValue = value;
this.random = new Random(this, this.seedValue);
this.datatype = new Datatype(this, this.seedValue);
Expand Down
9 changes: 6 additions & 3 deletions src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export class Helpers {
*
* Takes an array and returns a random element of the array.
*
* @template T The type of the entries to pick from.
* @param array The array to select an element from.
*
* @see faker.random.arrayElement()
Expand Down Expand Up @@ -396,6 +397,7 @@ export class Helpers {
*
* Uses the modern version of the Fisher–Yates algorithm.
*
* @template T The type of the entries to shuffle.
* @param o The array to shuffle. Defaults to `[]`.
*
* @example
Expand Down Expand Up @@ -423,13 +425,14 @@ export class Helpers {
* and outputs a unique array of strings based on that source.
* This method does not store the unique state between invocations.
*
* @template T The type of the entries.
* @param source The strings to choose from or a function that generates a string.
* @param length The number of elements to generate.
*
* @example
* uniqueArray(faker.random.word, 50)
* uniqueArray(faker.definitions.name.first_name, 6)
* uniqueArray(["Hello", "World", "Goodbye"], 2)
* faker.helpers.uniqueArray(faker.random.word, 50)
* faker.helpers.uniqueArray(faker.definitions.name.first_name, 6)
* faker.helpers.uniqueArray(["Hello", "World", "Goodbye"], 2)
*/
uniqueArray<T>(source: T[] | (() => T), length: number): T[] {
if (Array.isArray(source)) {
Expand Down
2 changes: 1 addition & 1 deletion src/image.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Faker } from '.';
import { LoremPicsum } from './image_providers/lorempicsum';
import { Lorempixel } from './image_providers/lorempixel';
import { Unsplash } from './image_providers/unsplash';
import { LoremPicsum } from './image_providers/lorempicsum';

/**
* Module to generate placeholder images.
Expand Down
1 change: 0 additions & 1 deletion src/internet.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { Faker } from '.';

import * as random_ua from './vendor/user-agent';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/locale/en_AU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
*/

import { Faker } from '../faker';
import en_AU from '../locales/en_AU';
import en from '../locales/en';
import en_AU from '../locales/en_AU';

const faker = new Faker({
locale: 'en_AU',
Expand Down
2 changes: 1 addition & 1 deletion src/locale/en_AU_ocker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
*/

import { Faker } from '../faker';
import en_AU_ocker from '../locales/en_AU_ocker';
import en from '../locales/en';
import en_AU_ocker from '../locales/en_AU_ocker';

const faker = new Faker({
locale: 'en_AU_ocker',
Expand Down
2 changes: 1 addition & 1 deletion src/locale/en_BORK.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
*/

import { Faker } from '../faker';
import en_BORK from '../locales/en_BORK';
import en from '../locales/en';
import en_BORK from '../locales/en_BORK';

const faker = new Faker({
locale: 'en_BORK',
Expand Down
2 changes: 1 addition & 1 deletion src/locale/en_CA.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
*/

import { Faker } from '../faker';
import en_CA from '../locales/en_CA';
import en from '../locales/en';
import en_CA from '../locales/en_CA';

const faker = new Faker({
locale: 'en_CA',
Expand Down
2 changes: 1 addition & 1 deletion src/locale/en_GB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
*/

import { Faker } from '../faker';
import en_GB from '../locales/en_GB';
import en from '../locales/en';
import en_GB from '../locales/en_GB';

const faker = new Faker({
locale: 'en_GB',
Expand Down
2 changes: 1 addition & 1 deletion src/locale/en_GH.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
*/

import { Faker } from '../faker';
import en_GH from '../locales/en_GH';
import en from '../locales/en';
import en_GH from '../locales/en_GH';

const faker = new Faker({
locale: 'en_GH',
Expand Down
2 changes: 1 addition & 1 deletion src/locale/en_IE.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
*/

import { Faker } from '../faker';
import en_IE from '../locales/en_IE';
import en from '../locales/en';
import en_IE from '../locales/en_IE';

const faker = new Faker({
locale: 'en_IE',
Expand Down
2 changes: 1 addition & 1 deletion src/locale/en_IND.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
*/

import { Faker } from '../faker';
import en_IND from '../locales/en_IND';
import en from '../locales/en';
import en_IND from '../locales/en_IND';

const faker = new Faker({
locale: 'en_IND',
Expand Down
2 changes: 1 addition & 1 deletion src/locale/en_NG.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
*/

import { Faker } from '../faker';
import en_NG from '../locales/en_NG';
import en from '../locales/en';
import en_NG from '../locales/en_NG';

const faker = new Faker({
locale: 'en_NG',
Expand Down
2 changes: 1 addition & 1 deletion src/locale/en_US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
*/

import { Faker } from '../faker';
import en_US from '../locales/en_US';
import en from '../locales/en';
import en_US from '../locales/en_US';

const faker = new Faker({
locale: 'en_US',
Expand Down
2 changes: 1 addition & 1 deletion src/locale/en_ZA.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
*/

import { Faker } from '../faker';
import en_ZA from '../locales/en_ZA';
import en from '../locales/en';
import en_ZA from '../locales/en_ZA';

const faker = new Faker({
locale: 'en_ZA',
Expand Down
2 changes: 1 addition & 1 deletion src/locale/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
*/

import { Faker } from '../faker';
import es from '../locales/es';
import en from '../locales/en';
import es from '../locales/es';

const faker = new Faker({
locale: 'es',
Expand Down
2 changes: 1 addition & 1 deletion src/locale/es_MX.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
*/

import { Faker } from '../faker';
import es_MX from '../locales/es_MX';
import en from '../locales/en';
import es_MX from '../locales/es_MX';

const faker = new Faker({
locale: 'es_MX',
Expand Down
2 changes: 1 addition & 1 deletion src/locale/fa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
*/

import { Faker } from '../faker';
import fa from '../locales/fa';
import en from '../locales/en';
import fa from '../locales/fa';

const faker = new Faker({
locale: 'fa',
Expand Down
2 changes: 1 addition & 1 deletion src/locale/fi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
*/

import { Faker } from '../faker';
import fi from '../locales/fi';
import en from '../locales/en';
import fi from '../locales/fi';

const faker = new Faker({
locale: 'fi',
Expand Down
2 changes: 1 addition & 1 deletion src/locale/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
*/

import { Faker } from '../faker';
import fr from '../locales/fr';
import en from '../locales/en';
import fr from '../locales/fr';

const faker = new Faker({
locale: 'fr',
Expand Down
2 changes: 1 addition & 1 deletion src/locale/fr_BE.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
*/

import { Faker } from '../faker';
import fr_BE from '../locales/fr_BE';
import en from '../locales/en';
import fr_BE from '../locales/fr_BE';

const faker = new Faker({
locale: 'fr_BE',
Expand Down
2 changes: 1 addition & 1 deletion src/locale/fr_CA.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
*/

import { Faker } from '../faker';
import fr_CA from '../locales/fr_CA';
import en from '../locales/en';
import fr_CA from '../locales/fr_CA';

const faker = new Faker({
locale: 'fr_CA',
Expand Down
2 changes: 1 addition & 1 deletion src/locale/fr_CH.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
*/

import { Faker } from '../faker';
import fr_CH from '../locales/fr_CH';
import en from '../locales/en';
import fr_CH from '../locales/fr_CH';

const faker = new Faker({
locale: 'fr_CH',
Expand Down
2 changes: 1 addition & 1 deletion src/locale/ge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
*/

import { Faker } from '../faker';
import ge from '../locales/ge';
import en from '../locales/en';
import ge from '../locales/ge';

const faker = new Faker({
locale: 'ge',
Expand Down
2 changes: 1 addition & 1 deletion src/locale/he.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
*/

import { Faker } from '../faker';
import he from '../locales/he';
import en from '../locales/en';
import he from '../locales/he';

const faker = new Faker({
locale: 'he',
Expand Down
Loading

0 comments on commit 282a824

Please sign in to comment.