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

sp-mockjs

v1.0.3

Published

Common mock data by mockjs

Downloads

5

Readme

sp-mock

Common mock data by mockjs

Install

  npm i mockjs sp-mockjs //or yarn add mockjs sp-mockjs

CDN

  <script src="https://unpkg.com/mockjs/dist/mock-min.js"></script>
  <script src="https://unpkg.com/sp-mockjs/dist/index.min.js"></script>
  <script>
    __Mock.name();
    // return '陈玲'
  </script>

Usage

  const {
    name,
    number,
    text,
    email,
    phoneNumber,
    date,
    image,
    ip,
    url,
    color,
    region,
    idCard
  } = require("sp-mockjs")
  • name(obj = {})

    • {Object} obj
      • {Number} len
      • {Boolean} isEnglish = false
      name();
      // return '陈玲'
      name({
        len: 2
      })
      // return ['李殊','张爽']
      name({
        isEnglish: true
      })
      // return 'Alice Paul'
      name({
        len: 2,
        isEnglish: true
      })
      // return ['Jan Sen','Sword Hadon']
  • number(obj = {})

    • {Object} obj
      • {Number} len
      • {Number} min = 0
      • {Number} max = 100
      • {Boolean} isFloat = false
      • {Number} toFixedLen = 2
      number()
      // return 13
      number({
        len: 2
      })
      // return [24, 2]
      number({
        isFloat: true
      })
      // return 1.32
      number({
        len: 2,
        min: -10,
        max: 10,
        isFloat: true,
        toFixedLen: 3
      })
      // return [ '-10.355', '1.319' ]
  • phoneNumber(obj = {})

    • {Object} obj
      • {Number} len
      phoneNumber()
      // return '13718239930'
      phoneNumber({
        len: 2
      })
      //return ['13829120020', '15920393302']
  • text(obj = {})

    • {Object} obj
      • {Number} len
      • {Boolean} isEnglish = false
      text()
      // return '放两文示后和再万用值候院容位委它半。'
      text({
        len: 2
      })
      //return ['放两文示后和再万用值候院容位委它半。', '好三生毛去任七真山世完相。']
      text({
        isEnglish: true
      })
      //return 'Ncwthzxmu emkjjvo nop lbenqup emhumxqv exc qgw cpsfjihu khbri qyfqbbr nyfviby ugiz ehdsoe ctjnoq jwcdqt.'
  • date(obj = {})

    • {Object} obj
      • {Number} len
      • {String} format = 'yyyy-MM-dd': see more
      date()
      // return '2001-11-02'
      date({
        len: 2
      })
      //return ['2001-11-02', '2011-01-22']
      date({
        len: 2,
        format: 'MM-dd'
      })
      //return ['11-02', '01-22']
  • email(obj = {})

    • {Object} obj
      • {Number} len
      • {String} domain = 'mockdata.com'
      email()
      // return '[email protected]'
      email({
        len: 2
      })
      //return ['[email protected]', '[email protected]']
      email({
        len: 2,
        domain: 'alipay.one'
      })
      //return ['[email protected]', '[email protected]']
  • ip(obj = {})

    • {Object} obj
      • {Number} len
      ip()
      // return '104.74.140.197'
      ip({
        len: 2
      })
      //return [ '220.215.41.236', '202.168.91.147' ]
  • url(obj = {})

    • {Object} obj
      • {Number} len
      • {String} protocol
      • {String} domain
      url()
      // return 'http://mockdata.com/voyxd'
      url({
        len: 2
      })
      //return [ 'http://mockdata.com/qdwhqywr', 'http://mockdata.com/glenhg' ]
      url({
        len: 2,
        protocol: 'https',
        domain: 'alipay.one'
      })
      //return [ 'https://alipay.one/qdwhqywr', 'https://alipay.one/glenhg' ]
  • image(obj = {})

    • {Object} obj
      • {String} size = '400x300'
      • {String} background = '#000000'
      • {String} foreground = '#FFFFFF'
      • {String} format = 'png'、'gif'、'jpg'
      • {String} text
      image()
      // return ''http://dummyimage.com/400x300''
      image({
        len: 2
      })
      //return [ 'http://dummyimage.com/400x300', 'http://dummyimage.com/400x300']
  • color(obj = {})

    • {Object} obj
      • {Number} len
      • {String} type = 'hex'、'rgb'、'rbga'、'hsl'
      color()
      // return '#b9f279'
      color({
        len: 2
      })
      //return ['#f2dd79', '#f2dd79']
      color({
        len: 2,
        type: 'hsl'
      })
      //return [ 'hsl(82, 82, 71)', 'hsl(82, 82, 71)' ]
  • region(obj = {})

    • {Object} obj
      • {Number} len
      • {String} type = 'country'、'province'、'city'、'county'
      • {Boolean} showParent = false
      region()
      // return '澳门特别行政区'
      region({
        len: 2
      })
      //return [ '四川省', '河北省' ]
      region({
        len: 2,
        type: 'country'
      })
      //return [ '智利', '孟加拉' ]
      region({
        len: 2,
        type: 'county',
        showParent: true
      })
      //return [ '河北省秦皇岛市北戴河区', '江苏省常州市金坛市' ]
  • idCard(obj = {})

    • {Object} obj
      • {Object} obj
      • {Number} obj.area 6位地区编码
      • {Number} obj.year 4位年
      • {Number} obj.month 2位月
      • {Number} obj.day 2位日
      • {Number} obj.policeNum 2位派出所识别号
      • {Number} obj.gender 1位性别 0:女 1:南 2:不限
      • {Number} obj.len 长度
      idCard()
      // return 513592194904256072
      idCard({
        len: 2
      })
      // return [ '55276319660824862X', '194483193107205410' ]
      idCard({
        area: '520100',
        year: '1969',
        month: '09',
        day: '13',
        policeNum: '99',
        gender: 0,
        len: 2
      })
      // return [ '520100196909139907', '52010019690913994X' ]