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

xrk-tools

v1.0.30

Published

A Component Library for Vue.js.

Readme

xrk-tools-test

安装

npm i xrk-tools-test

完整引入

import xkrTools from 'xrk-tool-test'

按需引入

借助 babel-plugin-component

首先,安装 babel-plugin-component

npm i babel-plugin-component -D

然后,修改.babelrc 或者 babel.config.js

{

  "plugins": [
    [
      "component",
      { libraryName: "xrk-tools-test", style: false },
      "xrk-tools-test",
    ],
  ]

}

最后,只需在项目中引入需要部分

import { file } from 'xrk-tool-test'

文档

  • base

    • 格式化数值

      numberFormat(
        num: Number | String,
        divisor?: Number,
        decimalPlaces?: Number,
        unit?: String
      ): String;
    • 简易深克隆(无法克隆 Function Map Set undefined)

      easyDeepClone(content: any): any;
    • 深克隆

      deepClone(content: any): any;
    • 创建冻结对象

      craeteFreezeObject(
        value: Object | Array | Set | Map
      ): ProxyConstructor;
  • check

    • 判断是否为数字 (数字字符串也是数字,例如'23'、'123.213')

      isNumber(num: Number | String): Boolean;
    • 判断是否为手机号

      isTel(num: Number | String): Boolean;
    • 判断是否有值,但是值为 false

      isFalseValue(value: any): Boolean;
    • 判断是否为函数

      isFunction(params: any): Boolean;
    • 判断是否为时间对象

      isDate(params: any): Boolean;
    • 判断是否为 Object 对象

      isObject(params: any): Boolean;
    • 判断是否为 Map 断是否为 Set

      isMap(params: any): Boolean;
    • 判断是否为字符串

      isString(params: any): Boolean;
    • 判断是否为 Boolean

      isBoolean(params: any): Boolean;
  • date

    • 格式化时间

      dateFormat(
        date: Number | String | Date,
        fmt?: String,
        autoFillZero?: Boolean
      ): String;
  • file

    • base64 转为 Blob

      dataURLToBlob(base64: String): Blob;
    • Blob 转为 base64g;将 img 标签转为 base64

      blobToDataURI(blob: Blob): Promise<String>;
    • 将 img 网络资源转为 base64

      imgUrl2Base64(imgUrl: String): Promise<String>;
    • 获取网络资源文件

      getNetFile(
        url: String,
        responseType?: "blob"
      ): Promise<Blob>;
    • 将内容转为二维码图片

      contentToQrcodeUrl(content: any): Promise\<String>;
  • money

    • 将分格式化为元,保留两位小数

      moneyFixed(
        num: Number | String,
        decimalPlaces?: Number,
        unit?: String
      ): String;
    • 将元格式化为分,主要用于向服务端传递参数时使用

      moneyComplete(num: Number | String): Number;
    • 给 c 端计算税率

      afterTaxPrice(num: Number | String): Number;
  • storage

    • 本地数据存储

      setStorage(
        key: String,
        value: any,
        isLocal?: Boolean
      ): void;
    • 读取本地存储的数据

      getStorage(
        key: String,
        isLocal?: Boolean
      ): String;
  • transform

    • 将字符串指定位置替换为指定字符

      hideSomeString(
        str: Number | String,
        start?: Number,
        end?: Number,
        replaceStr?: String
      ): String;
  • config

    • 问卷&可配置场景 题目配置

      CONFIG_QUESTION: Array<{
        label: number | string;
        value: number | string;
      }>;
    • 项目类型

      CONFIG_PROJECT: Array<{
        label: number | string;
        value: number | string;
      }>;
    • 业务结构

      CONFIG_BUSINESS:Array<{
        id: number;
        name: string;
        children: Array<{
          id: number;
          name: string;
          hasIndustry?: boolean; // 是否有工业方
          hasEnterprise?: boolean; // 是否有服务商
          hasSupplier?: boolean; //是否有供应商
          hasPerson?: boolean; // 是否有自然人
          hasIndividual?: boolean; // 是否有个体
        }>;
      }>;
    • 业务结构

      CONFIG_BACKGROUND:Array<{
        label: number | string;
        value: number | string;
      }>;
    • 职责名称

      CONFIG_DUTY_NAME: Array<{
        label: number | string;
        value: number | string;
      }>;
    • 税筹结构

      CONFIG_TAX_STRUCTURE: Array<{
        id: number;
        name: string;
        children: Array<{
          id: number;
          name: string;
          hasIndustry?: boolean; // 是否有工业方
          hasEnterprise?: boolean; // 是否有服务商
          hasSupplier?: boolean; //是否有供应商
          hasPerson?: boolean; // 是否有自然人
          hasIndividual?: boolean; // 是否有个体
        }>;
      }>;