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

@kunlunjs/mock

v0.0.4

Published

基于 @faker-js/faker 和 msw 的语义化 mock 数据能力

Downloads

4

Readme

@kunlunjs/mock

基于 @faker-js/fakerMock.jsmsw 的语义化、智能化 mock 数据能力

Features

  • 支持任何 Mock.js API, 优先级高于 @faker-js/faker 同名 API
  • 支持任何 @faker-js/faker API
  • 中文 Mock 能力
  • 语义化字段理解,example: name - 姓名、createdAt - 创建时间

TODO

  • [ ] 使 mock 出来的数据字段间保持含义准确性和一致性,如 country(国家)、province(省份)、district(地区)等
  • [ ] 完全集成 msw,暴露其 mock 接口能力
  • [ ] 更细粒度的字段 mock 配置
  • [ ] 预置更多常用字段
  • [ ] 设置最大嵌套深度
  • [ ] 支持分页
  • [ ] 支持服务端数据推送
  • [ ] 建设中文语义化词库、句库

Usage

Installation

pnpm i @kunlunjs/mock
import { mock } from '@kunlunjs/mock'

type Item = {
  id: number
  name: string
}
// 第二个参数表示mock数据数量,默认 11
const data = mock<Item>(['id', 'name'], 2)

Example

pnpm examples
# or
ts-node examples/mock-nested.ts

result 🔽

[
  {
    "id": 1,
    "name": "邹娜",
    "uuid": "be9f8f4e-930e-4ab0-a8d9-0fb8c2068ab8",
    "gender": "Transexual",
    "birthday": "1956-07-07",
    "address": "山东省 莆田市 -",
    "country": "法国",
    "province": "黑龙江省",
    "region": "华北",
    "city": "重庆市",
    "district": "勐腊县",
    "date": "2013-05-15",
    "createdAt": "1995-02-23 18:45:13",
    "updatedAt": "2005-09-05 12:57:03",
    "deletedAt": "2000-10-29 06:21:34",
    "children": [
      {
        "name": "邓勇",
        "gender": "Two* person",
        "birthday": "1980-03-22",
        "address": "四川省 绵阳市 沙河市",
        "country": "俄罗斯",
        "province": "澳门特别行政区",
        "region": "华北",
        "city": "天津市",
        "district": "香山区",
        "date": "1971-02-05"
      }
      //...
    ]
  }
  //...
]

Local development

pnpm i
# or
yarn