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 🙏

© 2026 – Pkg Stats / Ryan Hefner

json-mocker-tool

v1.0.0

Published

前端简易的mock数据工具

Readme

使用方法

一:基本使用方法:

  1. 下载安装执行命令: npm install --save-dev json-mocker-tool

  2. 在webpack中的devServer中的before配置下,如下:

// webpack.config.js
const mocker = require('json-mocker-tool');

module.exports = {
  devServer: {
    //....
    before: app => {
      mocker({
        mockDir: path.resolve('./mock')
      })(app);
    }
    //....
  }
}
  1. 在项目的根目录下新建mock文件夹。
  2. 在mock文件夹下新建json文件,该json文件是根据接口来命名的,比如你接口为 /api/xxxx/widget.json 的话,那么在mock文件夹下新建 widget.json 即可,然后把和后端约定好的数据复制进去即可。如果有多个接口,命名方式和上面一样。
  3. 默认请求的是正式环境的地址,如果我们想要使用本地的mock数据的话,需要在地址栏上 加上 mode=dev ,刷新下页面即可请求到本地mock数据了。

二:特点

1)默认是正式环境的接口,如想使用mock数据,需要在地址栏中加上 mode = dev; 2) json文件命名是根据接口名来命名的。比如接口为 'api/xxxx/yyy/widget.json', 那么在mock文件夹下新建 widget.json文件即可。然后把约定的json数据复制进去。 3) Mock 文件支持热更新,修改后立即生效。 4)只支持get请求进行mock数据。

更多使用,请看 这篇文章