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

kd-base-tool

v1.0.2

Published

simple tools

Readme

KD Base Tool

一个轻量级的JavaScript基础工具库,提供常用的工具函数。

功能特性

  • 样式工具:提供基础样式配置函数
  • 数字验证:提供严格的数字验证函数
  • ESM模块:支持Tree Shaking优化
  • 零依赖:不依赖任何第三方库

安装

npm install kd-base-tool
# 或
yarn add kd-base-tool
# 或
pnpm add kd-base-tool

使用方法

导入全部功能

import * as kdBaseTool from 'kd-base-tool';

按需导入

import { getBaseTooltip, isValidNumber } from 'kd-base-tool';

API 文档

样式工具

getBaseTooltip()

获取基础提示框样式配置。

返回值Object

  • backgroundColor: 背景颜色(默认:"rgba(50,50,50,0.7)"
  • textStyle.color: 文字颜色(默认:"#fff"
  • borderColor: 边框颜色(默认:"#fff"

示例

const tooltipStyle = getBaseTooltip();
// 返回:{ backgroundColor: "rgba(50,50,50,0.7)", textStyle: { color: "#fff" }, borderColor: "#fff" }

数字验证工具

isValidNumber(value)

验证一个值是否为有效的数字。

参数

  • value: 任意类型 - 需要验证的值

返回值Boolean

  • true: 值是有效的数字
  • false: 值不是有效的数字

验证规则

  1. 空字符串或纯空格字符串返回 false
  2. 使用 Number() 转换后不是 NaN
  3. 转换后的值是有限数(排除 Infinity-Infinity
  4. 排除布尔值、null、空数组等特殊情况

示例

isValidNumber(123);        // true
isValidNumber("123");      // true
isValidNumber("123.45");   // true
isValidNumber("");         // false
isValidNumber("   ");      // false
isValidNumber(null);       // false
isValidNumber(true);       // false
isValidNumber([]);         // false
isValidNumber(NaN);        // false
isValidNumber(Infinity);   // false

开发

项目结构

src/
├── index.js          # 主入口文件
├── style/
│   └── index.js     # 样式工具
└── number/
    └── index.js     # 数字验证工具

构建

npm run build

构建后的文件将输出到 dist/ 目录。

技术栈

  • 打包工具: Rollup
  • 模块格式: ESM
  • 转译工具: Babel
  • 代码规范: ESLint

许可证

MIT License

作者

fozei