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

crossbow-dingtalk-json-rules

v0.0.3

Published

crossbow-dingtalk-json-rules

Readme

@bnc/crossbow-dingtalk-json-rules

开发/维护请点击 CONTRIBUTING.md

类型查看请点击index.d.ts

安装

# 推荐使用pnpm 替代 npm

npm install @bnc/crossbow-dingtalk-json-rules@latest -S

# or
pnpm add @bnc/crossbow-dingtalk-json-rules@latest
# or
yarn add @bnc/crossbow-dingtalk-json-rules@latest

使用

全局引用

import { stringify } from '@bnc/crossbow-dingtalk-json-rules'

stringify({})

按需引用

import stringify from '@bnc/crossbow-dingtalk-json-rules/lib/isObject'

stringify({})

API

参数和类型说明请查看安装后包里面的*.d.ts文件,如:@bnc/crossbow-dingtalk-json-rules/dist/lib/common/isObject.d.ts

或者可以直接查看src目录源码

stringify

调用JSON.stringify格式化,处理带函数的值 点击查看ts类型声明文件

import { stringify } from '@bnc/crossbow-dingtalk-json-rules'

stringify({})

transferRules

根据json规则,转换来源的数据 点击查看ts类型声明文件

import { transferRules } from '@bnc/crossbow-dingtalk-json-rules'
// 字符串中, {{item.XXX}} 属于变量读取的模式,item代表当前key的同级对象
const source = {
    "title": "金额(万元)",
    "list": [
        {
            "label": "本年销售",
            "value": "2300",
            "compare": "同比",
            "percent": "2.9%",
            "sign": 1
        },
        {
            "label": "本年销售",
            "value": "2300",
            "compare": "同比",
            "percent": "2.9%",
            "sign": 1,
            "date": "2024-12-12 17:00:00"
        }
    ]
  }

  const configStr = `{
    "title": "title",
    "list": [
      {
        "key1": "label",
        "key2": "compare"
      },
      {
        "key1": "label",
        "key2": "compare",
        "key3": "function (item) { return '22222' }",
        "key4": {
            "type": "settle-formatter",
            "value": "111-2121"
        },
        "key5": {
            "type": "date-formatter",
            "value": ["YYYY-MM-DD", "{{item.date}}"]
        },
        "key6": {
            "type": "operator-formatter",
            "value": ["+", "{{item.label}}", "{{item.value}}", "{{item.date}}"]
        },
        "key7": {
            "type": "random-formatter",
            "value": ["number"]
        },
        "key8": {
            "type": "logic-formatter",
            "value": [
                {
                    "compareLeft": "{{item.value}}",
                    "operator": ">",
                    "compareRight": 2300,
                    "result": "{{item.value}}",
                    "next": true
                },
                {
                    "result": "{{item.percent}}",
                    "next": false
                }
            ]
        }
      },
      {
        "key1": "label",
        "key2": "compare"
      }
    ]
  }`
transferRules(source, configStr)
// result:
//  {
//     title: '金额(万元)',
//     list: [
//       {
//         key1: '本年销售',
//         key2: '同比'
//       },
//       {
//         key1: '本年销售',
//         key2: '同比',
//         key3: '22222',
//         key4: '111-2121',
//         key5: '2024-12-12',
//         key6: '本年销售23002024-12-12 17:00:00',
//         key7: 0.37817872182,
//         key8: '2.9%'
//       }
//     ]
//   }