@stacksjs/faker 0.72.56 → 0.72.60
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.js +2 -2
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{faker as
|
|
2
|
+
import{faker as r}from"@stacksjs/ts-faker";var h={boolean(e){let n=typeof e==="number"?e:e?.probability;return r.random.boolean(n)},number(e){return r.number.int({min:e?.min??0,max:e?.max??100})},float(e){return r.number.float({min:e?.min??0,max:e?.max??1,precision:e?.precision??2})},uuid(){return r.string.uuid()},string(e){return r.string.alphanumeric({length:e??10})},array(e,n){let t=[],a=n??r.number.int({min:1,max:10});for(let i=0;i<a;i++)t.push(e());return t}},o=Object.create(r.number);o.int=(e)=>r.number.int(typeof e==="number"?{max:e}:e);o.float=(e)=>{if(!e)return r.number.float();let{fractionDigits:n,...t}=e;return r.number.float({...t,precision:t.precision??n})};var s=Object.create(r.string);s.alpha=(e)=>r.string.alpha(typeof e==="number"?{length:e}:e);s.alphanumeric=(e)=>r.string.alphanumeric(typeof e==="number"?{length:e}:e);var u=Object.create(r.finance);u.creditCardNumber=(e)=>{if(typeof e!=="string")return r.finance.creditCardNumber(e);return e.replace(/#/g,()=>r.string.numeric(1))};var l=Object.create(r.image);l.url=(e)=>{let n=e?.width??640,t=e?.height??480;return`https://picsum.photos/seed/${r.string.alphanumeric({length:12}).toLowerCase()}/${n}/${t}`};var g={street(){return r.address.street()},streetAddress(e){return r.address.streetAddress({useFullAddress:e})},city(){return r.address.city()},state(){return r.address.state()},stateAbbr(){return r.address.stateAbbr()},country(){return r.address.country()},countryCode(){return r.address.countryCode()},zipCode(){return r.address.zipCode()},latitude(e){return r.address.latitude(e)},longitude(e){return r.address.longitude(e)},direction(){return r.address.direction()},buildingNumber(){return r.address.buildingNumber()}},p={...r.company,name(){return r.company.name()},catchPhrase(){let e=r.company;return e.buzzPhrase?.()??e.catchphrase?.()??`${r.word.adjective()} ${r.word.noun()}`},buzzPhrase(){return r.company.buzzPhrase?.()??r.lorem.sentence(3)}},d={...r.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 e=["Toyota","Honda","Ford","Chevrolet","BMW","Mercedes","Audi","Tesla","Nissan","Hyundai"],n=["Sedan","SUV","Truck","Coupe","Hatchback","Wagon","Van","Crossover"];return`${e[Math.floor(Math.random()*e.length)]} ${n[Math.floor(Math.random()*n.length)]}`},type(){let e=["Sedan","SUV","Truck","Van","Coupe","Convertible","Wagon","Hatchback"];return e[Math.floor(Math.random()*e.length)]??"Sedan"},manufacturer(){let e=["Toyota","Honda","Ford","Chevrolet","BMW","Mercedes-Benz","Audi","Tesla","Nissan","Hyundai","Kia","Volkswagen"];return e[Math.floor(Math.random()*e.length)]??"Toyota"},model(){let e=["Camry","Accord","F-150","Silverado","3 Series","C-Class","A4","Model 3","Altima","Elantra"];return e[Math.floor(Math.random()*e.length)]??"Camry"},fuel(){let e=["Gasoline","Diesel","Electric","Hybrid","Plug-in Hybrid"];return e[Math.floor(Math.random()*e.length)]??"Gasoline"},vin(){let n="";for(let t=0;t<17;t++)n+="0123456789ABCDEFGHJKLMNPRSTUVWXYZ"[Math.floor(Math.random()*33)];return n},color(){let e=["Black","White","Silver","Gray","Red","Blue","Green","Brown","Orange","Yellow"];return e[Math.floor(Math.random()*e.length)]??"Black"}},c={...r.helpers,arrayElement(e){if(e.length===0)throw Error("arrayElement: cannot pick from an empty array");return e[Math.floor(Math.random()*e.length)]},arrayElements(e,n){let t=n??Math.floor(Math.random()*e.length)+1;return c.shuffle(e).slice(0,Math.min(t,e.length))},shuffle(e){let n=[...e];for(let t=n.length-1;t>0;t--){let a=Math.floor(Math.random()*(t+1)),i=n[t],b=n[a];n[t]=b,n[a]=i}return n},maybe(e,n){let t=n?.probability??0.5;return Math.random()<t?e():void 0},objectKey(e){let n=Object.keys(e);if(n.length===0)throw Error("objectKey: object has no keys");return n[Math.floor(Math.random()*n.length)]},objectValue(e){let n=Object.values(e);if(n.length===0)throw Error("objectValue: object has no values");return n[Math.floor(Math.random()*n.length)]},slugify(e){return e.normalize("NFKD").replace(/[\u0300-\u036F]/g,"").toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}};function m(e,n=1){let t=Math.max(n,Math.floor(Math.min(e.min,e.max))),a=Math.max(t,Math.floor(Math.max(e.min,e.max)));return Math.floor(Math.random()*(a-t+1))+t}var y={...r.lorem,word(){return r.lorem.word()},words(e){return r.lorem.words(e??3)},sentence(e){if(typeof e==="object")return r.lorem.sentence(m(e));if(e!==void 0){let n=Math.max(1,Math.floor(e)),t=Math.min(3,n),a=Math.floor(Math.random()*(n-t+1))+t;return r.lorem.sentence(a)}return r.lorem.sentence()},sentences(e,n){return r.lorem.sentences(e??3,n??" ")},paragraph(e){return r.lorem.paragraph(e)},paragraphs(e,n){let t=typeof e==="object"?m(e):e??3;return r.lorem.paragraphs(t,n??`
|
|
3
3
|
|
|
4
|
-
`)},text(
|
|
4
|
+
`)},text(e){return r.lorem.text(e)},slug(e){return r.lorem.slug(e??3)},lines(e){return r.lorem.lines(e??3)}},M={...r,lorem:y,datatype:h,image:l,location:g,company:p,vehicle:d,helpers:c,number:o,string:s,finance:u};export{M as faker};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/faker",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.72.
|
|
4
|
+
"version": "0.72.60",
|
|
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.72.
|
|
62
|
-
"@stacksjs/config": "0.72.
|
|
61
|
+
"@stacksjs/cli": "0.72.60",
|
|
62
|
+
"@stacksjs/config": "0.72.60",
|
|
63
63
|
"better-dx": "^0.2.24",
|
|
64
64
|
"@stacksjs/ts-faker": "^0.1.7"
|
|
65
65
|
},
|