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

@lidongfang/js-tool

v1.5.0

Published

一个基于javascript的工具库。

Readme

js工具

一个基于javascript的工具库。

安装

npm install @lidongfang/js-tool

用法

// 默认导出
import F from '@lidongfang/js-tool'

F.add(1,2) //=>3

// 按需加载
import { add } from '@lidongfang/js-tool'

add(1,2) //=>3

API

语言

F.isSymbol

F.isSymbol(value)

检查 value 是否是原始 Symbol 或者对象。

添加版本

1.0.2

参数 value (*): 要检查的值。 返回 (boolean): 如果 value 为一个symbol,那么返回 true,否则返回 false。

例子

F.isSymbol(Symbol.iterator);
// => true

F.isSymbol('jqk');
// => false

F.isArray

F.isArray(value)

检查 value 是否是 Array 类对象。

添加版本

1.1.0

参数

value (*): 要检查的值。

返回

(boolean) : 如果 value是一个数组返回 true,否则返回 false

例子

F.isArray([1, 2, 3]);
// => true
 
F.isArray(document.body.children);
// => false
 
F.isArray('abc');
// => false

F.isBoolean

F.isBoolean(value)

检查 value 是否是原始 boolean 类型。

添加版本

1.4.0

参数

value (*): 要检查的值。

返回

(boolean) : 如果 value是一个boolean 类型返回 true,否则返回 false

例子

F.isBoolean(false);
// => true

F.isBoolean(null);
// => false

F.toString

F.toString(value)

转换 value 为字符串。 nullundefined 将返回空字符串。-0 将被转换为字符串 "-0"

添加版本

1.1.0

参数

value (*): 要检查的值。

返回

(string) : 返回字符串。

例子

F.toString(null);
// => ''
 
F.toString(-0);
// => '-0'
 
F.toString([1, 2, 3]);
// => '1,2,3'

F.isObject

F.isArray(value)

检查 value 是否是 Object 类对象。

添加版本

1.3.0

参数

value (*): 要检查的值。

返回

(boolean) : 如果 value是一个返回对象 true,否则返回 false

例子

F.isObject({});
// => true
 
F.isObject([1, 2, 3]);
// => true

F.isObject(null);
// => false

F.isJsonString

F.isJsonString(value)

检查 value 是否是有效的 JSON

添加版本

1.5.0

参数

value (*): 要检查的值。

返回

(boolean) : 如果 value是一个返回 JSON true,否则返回 false

例子

F.isJsonString('{"name": "John", "age": 30}');
// => true
 
F.isJsonString('{"name": "John", "age": 30');
// => false

F.isJsonString('Hello');
// => false

F.isJsonObject

F.isJsonObject(value)

检查 value 是否是有效的 JSON对象。

添加版本

1.5.0

参数

value (*): 要检查的值。

返回

(boolean) : 如果 value是一个返回 JSON 对象 true,否则返回 false

例子

F.isJsonObject({ name: "John" });
// => true
 
F.isJsonObject('Hello');
// => false

F.isJsonObject(new Date());
// => false

F.isJsonSerializable

F.isJsonSerializable(value)

检查 value 是否可以转换为 JSON。

添加版本

1.5.0

参数

value (*): 要检查的值。

返回

(boolean) : 如果 value可以转换为 JSON true,否则返回 false

例子

F.isJsonSerializable({ name: "John" });
// => true
 
F.isJsonSerializable('Hello');
// => false

F.isJsonSerializable(() => {});
// => false

数学

F.add

F.add(augend, addend)

两个数相加。

添加版本

1.0.1

参数

  1. augend (number): 相加的第一个数。
  2. addend (number): 相加的第二个数。

返回 (number): 返回总和。

例子

F.add(5, 4);
// => 9

F.subtract

F.subtract(augend, addend)

两数相减。

添加版本

1.0.1

参数

  1. minuend (number) : 相减的第一个数。
  2. subtrahend (number) : 相减的第二个数。

返回 (number) : 返回差。

例子

F.subtract(6, 4);
// => 2

F.multiply

F.multiply(multiplier, multiplicand)

两个数相乘。

添加版本

1.0.1

参数

  1. multiplier (number) : 相乘的第一个数。
  2. multiplicand (number) : 相乘的第二个数。

返回 (number) : 返回乘积。

例子

F.multiply(6, 4);
// => 24

F.divide

F.divide(dividend, divisor)

两数相除。

添加版本

1.0.1

参数

  1. dividend (number) : 相除的第一个数。
  2. divisor (number) : 相除的第二个数。

返回 (number) : 返回商数。

例子

F.divide(6, 4);
// => 1.5

F.sum

F.sum(array)

计算 array 中值的总和。

添加版本

1.0.1

参数

  1. array (Array) : 要迭代的数组。

返回 (number) : 返回总和。

例子

F.sum([4, 2, 8, 6]);
// => 20

数字

F.digitToChinese

F.digitToChinese(123456789.12)

数字转中文金额

添加版本

1.4.0

参数

  1. num (number) : 需要处理的数

例子

F.digitToChinese(123456789.12)
// => 壹亿贰仟叁佰肆拾伍万陆仟柒佰捌拾玖元壹角贰分

数组

F.chunk

F.chunk(array, [size=1])

将数组(array)拆分成多个 size 长度的区块,并将这些区块组成一个新数组。 如果 array 无法被分割成全部等长的区块,那么最后剩余的元素将组成一个区块。

添加版本

1.1.0

参数

  1. array (Array) : 需要处理的数组
  2. [size=1] (number) : 每个数组区块的长度

例子

F.chunk(['a', 'b', 'c', 'd'], 2);
// => [['a', 'b'], ['c', 'd']]
 
F.chunk(['a', 'b', 'c', 'd'], 3);
// => [['a', 'b', 'c'], ['d']]

字符串

F.camelCase

F.camelCase(value)

转换字符串string为驼峰写法。

添加版本

1.5.0

参数

value (*): 要转换的字符串。

返回

Returns string

例子

F.camelCase("hello world");
// => "hello world"
 
F.camelCase("convert_to_camel");
// => "convert_to_camel"

F.camelCase("this-is-a-test");
// =>"this-is-a-test"