@stacksjs/faker 0.70.370 → 0.70.375
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -86,7 +86,7 @@ export declare const faker: EnhancedFaker;
|
|
|
86
86
|
* @stacksjs/ts-faker uses different module names, so we create aliases
|
|
87
87
|
*/
|
|
88
88
|
declare interface DatatypeCompatibility {
|
|
89
|
-
boolean: (options?: { probability?: number }) => boolean
|
|
89
|
+
boolean: (options?: number | { probability?: number }) => boolean
|
|
90
90
|
number: (options?: { min?: number; max?: number }) => number
|
|
91
91
|
float: (options?: { min?: number; max?: number; precision?: number }) => number
|
|
92
92
|
uuid: () => string
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{faker as z}from"@stacksjs/ts-faker";var T={boolean(q){return z.random.boolean(
|
|
2
|
+
import{faker as z}from"@stacksjs/ts-faker";var T={boolean(q){let B=typeof q==="number"?q:q?.probability;return z.random.boolean(B)},number(q){return z.number.int({min:q?.min??0,max:q?.max??100})},float(q){return z.number.float({min:q?.min??0,max:q?.max??1,precision:q?.precision??2})},uuid(){return z.string.uuid()},string(q){return z.string.alphanumeric({length:q??10})},array(q,B){let G=[],H=B??z.number.int({min:1,max:10});for(let J=0;J<H;J++)G.push(q());return G}},K=Object.create(z.number);K.int=(q)=>{return z.number.int(typeof q==="number"?{max:q}:q)};K.float=(q)=>{if(!q)return z.number.float();let{fractionDigits:B,...G}=q;return z.number.float({...G,precision:G.precision??B})};var M=Object.create(z.string);M.alpha=(q)=>{return z.string.alpha(typeof q==="number"?{length:q}:q)};M.alphanumeric=(q)=>{return z.string.alphanumeric(typeof q==="number"?{length:q}:q)};var O=Object.create(z.finance);O.creditCardNumber=(q)=>{if(typeof q!=="string")return z.finance.creditCardNumber(q);return q.replace(/#/g,()=>z.string.numeric(1))};var Q=Object.create(z.image);Q.url=(q)=>{let B=q?.width??640,G=q?.height??480;return`https://picsum.photos/seed/${z.string.alphanumeric({length:12}).toLowerCase()}/${B}/${G}`};var U={street(){return z.address.street()},streetAddress(q){return z.address.streetAddress({useFullAddress:q})},city(){return z.address.city()},state(){return z.address.state()},stateAbbr(){return z.address.stateAbbr()},country(){return z.address.country()},countryCode(){return z.address.countryCode()},zipCode(){return z.address.zipCode()},latitude(q){return z.address.latitude(q)},longitude(q){return z.address.longitude(q)},direction(){return z.address.direction()},buildingNumber(){return z.address.buildingNumber()}},V={...z.company,name(){return z.company.name()},catchPhrase(){let q=z.company;return q.buzzPhrase?.()??q.catchphrase?.()??`${z.word.adjective()} ${z.word.noun()}`},buzzPhrase(){return z.company.buzzPhrase?.()??z.lorem.sentence(3)}},X={...z.vehicle,vrm(){return`${"ABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(Math.random()*26)]}${"ABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(Math.random()*26)]}${"0123456789"[Math.floor(Math.random()*10)]}${"0123456789"[Math.floor(Math.random()*10)]} ${"ABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(Math.random()*26)]}${"ABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(Math.random()*26)]}${"ABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(Math.random()*26)]}`},vehicle(){let q=["Toyota","Honda","Ford","Chevrolet","BMW","Mercedes","Audi","Tesla","Nissan","Hyundai"],B=["Sedan","SUV","Truck","Coupe","Hatchback","Wagon","Van","Crossover"];return`${q[Math.floor(Math.random()*q.length)]} ${B[Math.floor(Math.random()*B.length)]}`},type(){let q=["Sedan","SUV","Truck","Van","Coupe","Convertible","Wagon","Hatchback"];return q[Math.floor(Math.random()*q.length)]??"Sedan"},manufacturer(){let q=["Toyota","Honda","Ford","Chevrolet","BMW","Mercedes-Benz","Audi","Tesla","Nissan","Hyundai","Kia","Volkswagen"];return q[Math.floor(Math.random()*q.length)]??"Toyota"},model(){let q=["Camry","Accord","F-150","Silverado","3 Series","C-Class","A4","Model 3","Altima","Elantra"];return q[Math.floor(Math.random()*q.length)]??"Camry"},fuel(){let q=["Gasoline","Diesel","Electric","Hybrid","Plug-in Hybrid"];return q[Math.floor(Math.random()*q.length)]??"Gasoline"},vin(){let B="";for(let G=0;G<17;G++)B+="0123456789ABCDEFGHJKLMNPRSTUVWXYZ"[Math.floor(Math.random()*33)];return B},color(){let q=["Black","White","Silver","Gray","Red","Blue","Green","Brown","Orange","Yellow"];return q[Math.floor(Math.random()*q.length)]??"Black"}},R={...z.helpers,arrayElement(q){if(q.length===0)throw Error("arrayElement: cannot pick from an empty array");return q[Math.floor(Math.random()*q.length)]},arrayElements(q,B){let G=B??Math.floor(Math.random()*q.length)+1;return R.shuffle(q).slice(0,Math.min(G,q.length))},shuffle(q){let B=[...q];for(let G=B.length-1;G>0;G--){let H=Math.floor(Math.random()*(G+1)),J=B[G],S=B[H];B[G]=S,B[H]=J}return B},maybe(q,B){let G=B?.probability??0.5;return Math.random()<G?q():void 0},objectKey(q){let B=Object.keys(q);if(B.length===0)throw Error("objectKey: object has no keys");return B[Math.floor(Math.random()*B.length)]},objectValue(q){let B=Object.values(q);if(B.length===0)throw Error("objectValue: object has no values");return B[Math.floor(Math.random()*B.length)]},slugify(q){return q.normalize("NFKD").replace(/[\u0300-\u036F]/g,"").toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}};function N(q,B=1){let G=Math.max(B,Math.floor(Math.min(q.min,q.max))),H=Math.max(G,Math.floor(Math.max(q.min,q.max)));return Math.floor(Math.random()*(H-G+1))+G}var Y={...z.lorem,word(){return z.lorem.word()},words(q){return z.lorem.words(q??3)},sentence(q){if(typeof q==="object")return z.lorem.sentence(N(q));if(q!==void 0){let B=Math.max(1,Math.floor(q)),G=Math.min(3,B),H=Math.floor(Math.random()*(B-G+1))+G;return z.lorem.sentence(H)}return z.lorem.sentence()},sentences(q,B){return z.lorem.sentences(q??3,B??" ")},paragraph(q){return z.lorem.paragraph(q)},paragraphs(q,B){let G=typeof q==="object"?N(q):q??3;return z.lorem.paragraphs(G,B??`
|
|
3
3
|
|
|
4
4
|
`)},text(q){return z.lorem.text(q)},slug(q){return z.lorem.slug(q??3)},lines(q){return z.lorem.lines(q??3)}},_={...z,lorem:Y,datatype:T,image:Q,location:U,company:V,vehicle:X,helpers:R,number:K,string:M,finance:O};export{_ as faker};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/faker",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.70.
|
|
4
|
+
"version": "0.70.375",
|
|
5
5
|
"description": "Faker functions.",
|
|
6
6
|
"author": "Chris Breuer",
|
|
7
7
|
"contributors": [
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
"prepublishOnly": "bun run build"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@stacksjs/cli": "0.70.
|
|
62
|
-
"@stacksjs/config": "0.70.
|
|
61
|
+
"@stacksjs/cli": "0.70.375",
|
|
62
|
+
"@stacksjs/config": "0.70.375",
|
|
63
63
|
"better-dx": "^0.2.17",
|
|
64
64
|
"@stacksjs/ts-faker": "^0.1.7"
|
|
65
65
|
},
|