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

wisdin-utils

v1.0.1

Published

一个实用的JavaScript工具库,提供各种常用的数组操作函数。

Readme

wisdin-utils

一个实用的JavaScript工具库,提供各种常用的数组操作函数。

安装

npm install wisdin-utils

使用

// 导入所有数组工具函数
import * as arrayUtils from 'wisdin-utils';

// 或者按需导入
import { unique, flatten, sort } from 'wisdin-utils';

// 使用示例
const arr = [1, 2, 2, 3, 3, 3];
console.log(arrayUtils.unique(arr)); // [1, 2, 3]

数组操作函数

unique

数组去重

unique([1, 2, 2, 3, 3, 3]); // [1, 2, 3]

flatten

数组扁平化

flatten([1, [2, [3]]]); // [1, 2, [3]]
flatten([1, [2, [3]]], 2); // [1, 2, 3]
flatten([1, [2, [3]]], Infinity); // [1, 2, 3]

sort

数组排序

sort([3, 1, 2]); // [1, 2, 3]
sort([{ age: 30 }, { age: 20 }, { age: 40 }], (a, b) => a.age - b.age);
// [{ age: 20 }, { age: 30 }, { age: 40 }]

filter

数组过滤

filter([1, 2, 3, 4, 5], (num) => num % 2 === 0); // [2, 4]

map

数组映射

map([1, 2, 3], (num) => num * 2); // [2, 4, 6]

concat

数组合并

concat([1, 2], [3, 4], [5, 6]); // [1, 2, 3, 4, 5, 6]

isEqual

数组比较

isEqual([1, 2, 3], [1, 2, 3]); // true
isEqual([1, 2, 3], [3, 2, 1]); // false
isEqual([{ id: 1 }], [{ id: 1 }], (a, b) => a.id === b.id); // true

find

数组查找

find([1, 2, 3, 4, 5], (num) => num > 3); // 4
find([1, 2, 3, 4, 5], (num) => num > 10); // undefined

indexOf

数组查找索引

indexOf([1, 2, 3, 2, 1], 2); // 1
indexOf([1, 2, 3, 2, 1], 2, 2); // 3
indexOf([1, 2, 3], 4); // -1

includes

数组包含

includes([1, 2, 3], 2); // true
includes([1, 2, 3], 4); // false

fill

数组填充

fill([1, 2, 3, 4, 5], 0, 1, 4); // [1, 0, 0, 0, 5]

slice

数组切片

slice([1, 2, 3, 4, 5], 1, 4); // [2, 3, 4]

reverse

数组反转

reverse([1, 2, 3, 4, 5]); // [5, 4, 3, 2, 1]

sum

数组求和

sum([1, 2, 3, 4, 5]); // 15
sum([]); // 0

average

数组平均值

average([1, 2, 3, 4, 5]); // 3
average([]); // 0

max

数组最大值

max([1, 2, 3, 4, 5]); // 5
max([]); // undefined

min

数组最小值

min([1, 2, 3, 4, 5]); // 1
min([]); // undefined

测试

运行测试:

npm test

许可证

ISC