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

imitatejs

v1.0.1

Published

用于前端开发小伙伴模拟数据的js工具库

Downloads

1

Readme

此插件主要为了前端小伙伴在编写页面时能更加真实的模拟仿真数据而提供的js插件库,内置了dayjs插件,支持人名、身份证号码、手机号、住址、随机数、主键id、随机日期等多种数据的模拟

1.下载

$npm install imitatejs

2.引入

import { imitatejs } from 'imitatejs'//在项目入口文件引入

3.使用

批量生成数据

    let peopleData = Array(10).fill('').map(() => {
        return {
            id: imitatejs().randomStr(),
            idCard: imitatejs().idCard(),
            name: imitatejs().fullName(),
            score: imitatejs().randomIntNum(100),
            address: imitatejs().address('p-C-c'),
            text: imitatejs().str(300),
            phone: imitatejs().phone()
        }
    })
    console.log(peopleData)
	//(10) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}]

生成随机中文人名

fullName( )

let name = imitatejs().fullName()
consloe.log(name)//王刚

生成随机不重复字符

randomStr( )

let id = imitatejs().randomStr()//
consloe.log(id)//"krl1qv1m4ed"

生成生成随机整数

randomIntNum( max: Number )

let num1 = imitatejs().randomIntNum()
let num2 = imitatejs().randomIntNum(100)
consloe.log(num1)//4584
consloe.log(num2)//55

生成随机身份证号码

idCard( )

let idCard = imitatejs().idCard()
consloe.log(name)//"420101198101010695"

生成随机手机号

phone( )

let phone = imitatejs().phone()
consloe.log(name)//"15156448716"

生成随机测试文字

str( max: Number )

let phone = imitatejs().str(10)
consloe.log(name)//"测试测试"

生成随机地址

address( format: String )

| 字符 | 英文释义 | 中文释义 | | ---- | -------------- | ---------- | | p | province | 省 | | C | city | 市 | | c | county | 区县 | | s | street | 街道 | | v | village | 小区、村庄 | | d | detail address | 详细住址 |

let adr1 = imitatejs().address()
let adr2 = imitatejs().address('p-C-c')
consloe.log(adr1)//青海省西宁市城西区金银街紫云山庄2栋13单元
consloe.log(adr2)//山西省-大同市-新荣区