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

@cmtlyt/cl-utils

v0.5.0

Published

常用的工具函数

Readme

类型检查主要函数声明

interface ITypeConfig {
  type: string
  required?: boolean
  nullable?: boolean
  subPropsType?: ITypeConfig
  subProps?: ITypeConfig[]
  key?: string
  regexp?: TRegType[]
}

interface ITypeConfigOption {
  props: ITypeConfig[]
  return?: ITypeConfig
}

/**
 *
 * @param {Function} callback
 * @param {ITypeConfigOption} typeConfig
 * @returns {(...args) => Promise<any>}
 */
useTypeCheckHandle(callback, typeConfig)
/**
 * 直接检查数据类型
 * @param {T} data
 * @param {ITypeConfig[] | ITypeConfig} typeConfig
 * @returns {boolean}
 */
checkTypeHandle(data, typeConfig)

0.5.0

  • 新增 lodash 模块 复刻了 lodash.js 包的部分方法
  • baseFunc 模块新增 flatObj, getDOMSelector, getDOMXPath 方法
  • upgradeObject 模块 flat 方法支持自定义分隔符
  • checkType 模块 checkTypeHandle 方法直接返回布尔值

0.4.2

  • baseFunc 模块新增 getHashcreateUUID 方法

0.4.0

  • 新增字符串正则验证
  • 修改 useCheckType 函数为useTypeCheckHandle
  • 新增 checkTypeHandle 用于直接检查数据类型

0.3.8

  • 对象类型支持对所有字段进行统一类型判断

0.3.7

  • 复合类型 复杂检查 失败问题修复

0.3.6

  • 增加多类型检查及 any 类型
function test(id) {
  return id
}
useCheckType(test, { props: [{ type: any }], return: { type: 'string,object' } })

0.3.5

  • 增加异步方法支持

0.3.4

  • 修改 package.json 脚本
  • 新增 package.json module 字段

0.3.0

添加了useCheckType方法 - 用于对函数的入参和出参进行类型检查

function test(obj, num, str, bool, arr) {
  return {}
}

useCheckType(test, {
  props: [
    {
      type: 'object',
      subProps: [
        { key: 'name', type: 'string' },
        { key: 'age', type: 'number' },
        { key: 'hasDel', type: 'boolean' },
        {
          key: 'other',
          type: 'object',
          required: false,
          nullable: true,
          subProps: [
            { key: 'othre_num', type: 'number' },
            { key: 'other_string', type: 'string' },
            { key: 'other_boolean', type: 'boolean' },
            { key: 'other_arr', type: 'array', subPropsType: { type: 'string' } },
          ],
        },
      ],
    },
    {
      type: 'number',
    },
    {
      type: 'string',
    },
    {
      type: 'boolean',
    },
    {
      type: 'array',
      subProps: [
        { type: 'number' },
        { type: 'string', nullable: true },
        { type: 'boolean' },
        {
          type: 'object',
          subProps: [
            { key: 'arr_n', type: 'number', nullable: false },
            { key: 'arr_s', type: 'string', nullable: true },
            { key: 'arr_NaN', type: 'number', nullable: true },
          ],
        },
      ],
    },
  ],
  return: {
    type: 'object',
  },
})(
  {
    name: '123',
    age: 1,
    hasDel: true,
  },
  1,
  'a',
  true,
  [1, '', true, { arr_n: 123, arr_s: '', arr_NaN: NaN }],
)