npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

siwi-faker

v1.0.0

Published

nodejs faker data

Downloads

2

Readme

siwi-faker

node Build Status npm npm Github file size

node 假数据生成(node version > 8)

安装

use yarn

yarn add siwi-faker

use npm

npm i siwi-faker

目录结构

├── README.md
├── docs
│   └── README.md
├── index.js
├── lib
│   ├── index.js
│   ├── json
│   │   └── chinese
│   │       ├── area.json
│   │       ├── email.json
│   │       ├── phone.json
│   │       ├── telephone.json
│   │       ├── user.json
│   │       └── zipcode.json
│   └── utils
│       └── index.js
├── package.json
├── storage
│   └── design
├── test
│   ├── index.test.js
│   └── utils.test.js
└── yarn.lock

单元测试

npm run test

请确保运行该指令前您的机器安装了mocha & chai 如果您未安装 运行如下指令

yarn add mocha chai -D

1.4. json文件的获取

  • area.json 由 siwi-area 爬取国家统计局城乡数据提供
  • email.json 来自网络 可以自己扩充
  • phone.json 来自网络(支持移动 联通 电信 手机号码创建) 可以自己扩充
  • telephone.json 来自网络 可以自己扩充
  • user.json 来自网络 可以自己扩充
  • zipcode.json 来自网络 可以自己扩充

数据来源暂时缺少稳定支持

api

username

| 参数 | 含义 | 示例 | | --- | --- | --- | | length | 名字长度 默认2 | 2|

const faker = require('siwi-faker')

class Example {
    construct() {

    }
    async demo() {
        const username = await faker.username()
        console.log(username)
    }
}

firstName

const faker = require('siwi-faker')

class Example {
    construct() {

    }
    async demo() {
        const firstname = await faker.firstName()
        console.log(firstname)
    }
}

lastName

const faker = require('siwi-faker')

class Example {
    construct() {

    }
    async demo() {
        const lastname = await faker.lastName()
        console.log(lastname)
    }
}

password

const faker = require('siwi-faker')

class Example {
    construct() {

    }
    async demo() {
        const password = await faker.password()
        console.log(password)
    }
}

email

const faker = require('siwi-faker')

class Example {
    construct() {

    }
    async demo() {
        const email = await faker.email()
        console.log(email)
    }
}

phone

const faker = require('siwi-faker')

class Example {
    construct() {

    }
    async demo() {
        const phone = await faker.phone()
        console.log(phone)
    }
}

telephone

const faker = require('siwi-faker')

class Example {
    construct() {

    }
    async demo() {
        const telephone = await faker.telephone()
        console.log(telephone)
    }
}

zipcode

const faker = require('siwi-faker')

class Example {
    construct() {

    }
    async demo() {
        const zipcode = await faker.zipcode()
        console.log(zipcode)
    }
}

province

const faker = require('siwi-faker')

class Example {
    construct() {

    }
    async demo() {
        const province = await faker.province()
        console.log(province)
    }
}

city

| 参数 | 含义 | 示例 | | --- | --- | --- | | province | 省| 河南省 |

const faker = require('siwi-faker')

class Example {
    construct() {

    }
    async demo() {
        const province = '河南省'
        const city = await faker.city(province)
        console.log(city)
    }
}

county

| 参数 | 含义 | 示例 | | --- | --- | --- | | city | 城市| 郑州市 | | province | 省| 河南省 |

const faker = require('siwi-faker')

class Example {
    construct() {

    }
    async demo() {
        const province = '河南省'
        const city = '周口市'
        const county = await faker.county(city, province)
        console.log(county)
    }
}

address

| 参数 | 含义 | 示例 | | --- | --- | --- | | city | 城市| 周口市 | | province | 省| 河南省 | | county | 县区| 鹿邑县 |

const faker = require('siwi-faker')

class Example {
    construct() {

    }
    async demo() {
        const province = '河南省'
        const city = '周口市'
        const county = '鹿邑县'
        const address = await faker.address(province , city, county )
        console.log(address)
    }
}

code

| 参数 | 含义 | 示例 | | --- | --- | --- | | id | id| 996 | | prefix | 前缀| POD | | pad | 填充元素| 0 | | length | 生成code的长度| 15 |

const faker = require('siwi-faker')

class Example {
    construct() {

    }
    async demo() {
        const code = await faker.code(id = 100, prefix = 'POD', pad = '0', length = 15)
        console.log(code)
    }
}

order

const faker = require('siwi-faker')

class Example {
    construct() {

    }
    async demo() {
        const code = await faker.order()
        console.log(code)
    }
}

randomArray

| 参数 | 含义 | 示例 | | --- | --- | --- | | arr | 数据源| ['北京', '上海', '天津'] | | length | 随机长度| 2 | | unique | 是否重复| false |

const faker = require('siwi-faker')

class Example {
    construct() {

    }
    async demo() {
        const arr = await faker.randomArray()
        console.log(arr)
    }
}

randomStr

const faker = require('siwi-faker')

class Example {
    construct() {

    }
    async demo() {
        const str = await faker.randomStr()
        console.log(str)
    }
}

randomIndex

| 参数 | 含义 | 示例 | | --- | --- | --- | | length | 数组长度| 100 |

const faker = require('siwi-faker')

class Example {
    construct() {

    }
    async demo() {
        const index = await faker.randomIndex()
        console.log(index)
    }
}

Thanks

  • siwi-area
  • siwi-json
  • siwi-uniquestring