Casual 数据生成器开源项目

我要开发同款
匿名用户2019年12月02日
41阅读
开发技术JavaScript
所属分类大数据
授权协议未知

作品详情

Casual是一款基于JavaScript的数据生成器。

安装

npminstallcasual

使用

varcasual=require('casual');//Generaterandomsentence//Youdon'tneedfunctioncalloperatorhere//becausemostofgeneratorsusepropertiesmechanismvarsentence=casual.sentence;//Generaterandomcitynamevarcity=casual.city;//Definecustomgeneratorcasual.define('point',function(){return{x:Math.random(),y:Math.random()};});//Generaterandompointvarpoint=casual.point;//Andsoon..

Casual使用Javascript属性作为生成器,所以不需要调用函数方法。

内置生成器

//Addresscasual.country//'UnitedKingdom'casual.city//'NewOrtizchester'casual.zip(digits={5,9})//'26995-7979'(ifnodigitsspecifiedthenrandomselectionbetweenZIPandZIP+4)casual.street//'JadynIslands'casual.address//'6390TremblayPinesSuite784'casual.address1//'8417VedaCircles'casual.address2//'Suite648'casual.state//'Michigan'casual.state_abbr//'CO'casual.latitude//90.0610casual.longitude//180.0778casual.building_number//2413//Textcasual.sentence//'Laborumeiusporroconsequatur.'casual.sentences(n=3)//'Dolorumfuganobissitnatusconsequatur.Laboriosamsapiente.Natusquosut.'casual.title//'Systematicnobis'casual.text//'Nemotemporenatusnonaccusamuseosplaceatnesciunt.etfugitutodionisidolorenon...(longtext)'casual.description//'Veletrerumnostrumquia.Dolorumfuganobissitnatusconsequatur.'casual.short_description//'Quiistesimiliqueiusto.'casual.string//'saepequiamolestiasvoluptateset'casual.word//'voluptatem'casual.words(n=7)//'sedquisutbeataeidadipisciaut'casual.array_of_words(n=7)//['voluptas','atque','vitae','vel','dolor','saepe','ut']casual.letter//'k'//Internetcasual.ip//'21.44.122.149'casual.domain//'darrion.us'casual.url//'germaine.net'casual.email//'Josue.Hessel@claire.us'casual.user_agent//'Mozilla/5.0(WindowsNT6.1;WOW64;rv:34.0)Gecko/20100101Firefox/34.0'//Personcasual.name//'Alberto'casual.username//'Darryl'casual.first_name//'Derek'casual.last_name//'Considine'casual.full_name//'KadinTorphy'casual.password//'(205)580-1350Schumm'casual.name_prefix//'Miss'casual.name_suffix//'Jr.'casual.company_name//'Cole,WuckertandStrosin'casual.company_suffix//'Inc'casual.catch_phrase//'Synchronisedoptimalconcept'casual.phone//'982-790-2592'//Numberscasual.random//0.7171590146608651(coregenerator)casual.integer(from=-1000,to=1000)//632casual.double(from=-1000,to=1000)//-234.12987444casual.array_of_digits(n=7)//[4,8,3,1,7,6,6]casual.array_of_integers(n=7)//[-105,-7,-532,-596,-430,-957,-234]casual.array_of_doubles(n=7)//[-866.3755785673857,-166.62194719538093,...]casual.coin_flip//true//Datecasual.unix_time//659897901casual.moment//moment.jsobjectseehttps://momentjs.com/docs/casual.date(format='YYYY-MM-DD')//'2001-07-06'(seeavailableformattershttps://momentjs.com/docs/#/parsing/string-format/)casual.time(format='HH
声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论