Comparing version 1.9.0 to 1.10.0
@@ -85,4 +85,20 @@ export declare const addLocale: (name: string, locale: any) => void; | ||
export declare const port: () => number; | ||
export declare const adjective: (options?: { | ||
export declare const ipv6: () => string; | ||
export declare const color: (options?: { | ||
r?: number; | ||
g?: number; | ||
b?: number; | ||
}) => string; | ||
export declare enum WordType { | ||
VERB = "verb", | ||
PREPOSITION = "preposition", | ||
NOUN = "noun", | ||
INTERJECTION = "interjection", | ||
CONJUNCTION = "conjunction", | ||
ADVERB = "adverb", | ||
ADJECTIVE = "adjective" | ||
} | ||
export declare const word: (options?: { | ||
locale?: string; | ||
type?: WordType; | ||
filter?: (word: string) => void; | ||
@@ -159,7 +175,14 @@ }) => string; | ||
port: () => number; | ||
adjective: (options?: { | ||
word: (options?: { | ||
locale?: string; | ||
type?: WordType; | ||
filter?: (word: string) => void; | ||
}) => string; | ||
ipv6: () => string; | ||
color: (options?: { | ||
r?: number; | ||
g?: number; | ||
b?: number; | ||
}) => string; | ||
}; | ||
export default _default; |
@@ -14,4 +14,4 @@ var __defProp = Object.defineProperty; | ||
PlaceImgFilter: () => PlaceImgFilter, | ||
WordType: () => WordType, | ||
addLocale: () => addLocale, | ||
adjective: () => adjective, | ||
array: () => array, | ||
@@ -24,2 +24,3 @@ arrayElement: () => arrayElement, | ||
citySufix: () => citySufix, | ||
color: () => color, | ||
default: () => src_default, | ||
@@ -30,2 +31,3 @@ firstName: () => firstName, | ||
ip: () => ip, | ||
ipv6: () => ipv6, | ||
jobArea: () => jobArea, | ||
@@ -41,6 +43,10 @@ jobDescriptor: () => jobDescriptor, | ||
port: () => port, | ||
setDefaultLocale: () => setDefaultLocale | ||
setDefaultLocale: () => setDefaultLocale, | ||
word: () => word | ||
}); | ||
var locales = {}; | ||
var defaultLocale = null; | ||
var throwNoDefaultLocale = () => { | ||
throw new Error(`No default locale defined. Import at least one locale!`); | ||
}; | ||
var throwNoLocale = (locale) => { | ||
@@ -56,2 +62,4 @@ throw new Error(`The locale [${locale}] is not imported or supported.`); | ||
var getLocaleData = ({ locale: _locale, key }) => { | ||
if (!defaultLocale) | ||
throwNoDefaultLocale(); | ||
const locale = _locale || defaultLocale; | ||
@@ -215,5 +223,31 @@ if (!locales[locale]) | ||
}; | ||
var adjective = (options = {}) => { | ||
const { locale, filter } = options; | ||
const adjectives = getLocaleData({ locale, key: "adjectives" }); | ||
var ipv6 = () => { | ||
return array(8, () => number({ max: 65535 }).toString(16)).join(":"); | ||
}; | ||
var color = (options = {}) => { | ||
const { r, g, b } = options; | ||
const leadingZero = (value) => { | ||
if (value.length === 1) | ||
return `0${value}`; | ||
return value; | ||
}; | ||
const red = (r || number({ max: 256 })).toString(16); | ||
const green = (g || number({ max: 256 })).toString(16); | ||
const blue = (b || number({ max: 256 })).toString(16); | ||
return `#${leadingZero(red)}${leadingZero(green)}${leadingZero(blue)}`; | ||
}; | ||
var WordType; | ||
(function(WordType2) { | ||
WordType2["VERB"] = "verb"; | ||
WordType2["PREPOSITION"] = "preposition"; | ||
WordType2["NOUN"] = "noun"; | ||
WordType2["INTERJECTION"] = "interjection"; | ||
WordType2["CONJUNCTION"] = "conjunction"; | ||
WordType2["ADVERB"] = "adverb"; | ||
WordType2["ADJECTIVE"] = "adjective"; | ||
})(WordType || (WordType = {})); | ||
var word = (options = {}) => { | ||
const { type, locale, filter } = options; | ||
const _type = type || arrayElement(Object.values(WordType)); | ||
const adjectives = getLocaleData({ locale, key: `${_type}s` }); | ||
if (typeof filter === "function") | ||
@@ -247,3 +281,5 @@ return arrayElement(adjectives.filter(filter)); | ||
port, | ||
adjective | ||
word, | ||
ipv6, | ||
color | ||
}; | ||
@@ -255,4 +291,4 @@ // Annotate the CommonJS export names for ESM import in node: | ||
PlaceImgFilter, | ||
WordType, | ||
addLocale, | ||
adjective, | ||
array, | ||
@@ -265,2 +301,3 @@ arrayElement, | ||
citySufix, | ||
color, | ||
firstName, | ||
@@ -270,2 +307,3 @@ imageUrlFromPlaceIMG, | ||
ip, | ||
ipv6, | ||
jobArea, | ||
@@ -281,3 +319,4 @@ jobDescriptor, | ||
port, | ||
setDefaultLocale | ||
setDefaultLocale, | ||
word | ||
}); |
{ | ||
"name": "minifaker", | ||
"version": "1.9.0", | ||
"version": "1.10.0", | ||
"description": "lightweight faker.js", | ||
@@ -5,0 +5,0 @@ "types": "./dist/index.d.ts", |
@@ -97,2 +97,4 @@ # minifaker | ||
port|n/a|port | ||
adjective|en|adjective | ||
adjective,adverb,conjunction, interjection,noun,preposition,verb|en|word | ||
ipv6|n/a|ipv6 | ||
color|n/a|color |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
517102
38123
100
1