Destructuring library methods. It's possible? #743
-
Hi! 🖖 import faker from 'faker'
export const customFaker = {
...faker,
datatype: {
...faker.datatype,
object: (): Record<any, any> => JSON.parse(faker.datatype.json()),
},
} I tried with |
Beta Was this translation helpful? Give feedback.
Answered by
ST-DDT
Apr 1, 2022
Replies: 1 comment
-
Yes, its possible on faker level, but not on module level: import { faker, UsableLocale } from "@faker-js/faker";
export const customFaker = {
// Class level functions
seed: (seed: number | number[]): void => faker.seed(seed),
setLocale: (locale: UsableLocale): void => faker.setLocale(locale),
// Original modules
...faker,
// Custom Modules
custom: {
object: (): Record<any, any> => JSON.parse(faker.datatype.json()),
},
};
console.log(customFaker.datatype.number());
console.log(customFaker.custom.object()); See also: #704 |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
ST-DDT
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes, its possible on faker level, but not on module level:
See also: #704