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

water-design-utils

v1.0.3

Published

一个javascript工具库

Readme

综述

集成 javascript 工具函数

使用

filterByType

import waterUtils from 'water-design-utils';
const arr = [1, '2', {}, []];

const filterArr = waterUtils.filterByType({
  array: arr,
  type: ['number', 'object'],
});
// filterArr = [1, {}]

generateByLength

import { generateByLength } from 'water-design-utils';
const arr = [1, 2, 3, 4, 5, 6, 7];
const generateArr = generateByLength({ array: arr });
// generateArr = [[1, 2], [3, 4], [5, 6], [7]]

memorize

import { memorize } from 'water-design-utils';
const sum = memorize(function (params) {
  let sum = 0;
  for (let i = 0; i < params.length; i++) {
    sum += params[i];
  }
  console.log('执行');
  return sum;
});
sum([1, 2, 3]);
sum([1, 2, 3]); // 再次调用因入参相同将不再执行计算,直接返回缓存结果

API

| 名称 | 说明 | 版本 | | :----------------- | :--------------------------------------------------------------------------------- | :----- | | throttle | 节流函数,在固定时间内只会执行一次函数 | ^1.0.0 | | debounce | 防抖函数,在固定时间内连续触发只会在最后执行一次函数 | ^1.0.0 | | getType | 获取数据类型,可判断对象 | ^1.0.0 | | isValidArray | 判断是否是一个有效(是数组&长度不为 0)的数组 | ^1.0.0 | | isValidObject | 判断是否是一个有效(是对象&至少有一个属性)的对象 | ^1.0.0 | | filterByType | 通过传入一个数组和相应的筛选子项的类型,可过滤出符合条件的数组 | ^1.0.0 | | generateByLength | 将数组切割为指定 length 的二维数组,可传参过滤掉最后一段长度小于指定 length 的数组 | ^1.0.0 | | deepClone | 对传入的对象和数组进行深拷贝,不支持包含函数等非对象和数组的复杂数据类型的拷贝 | ^1.0.0 | | random | 获取 min <= x < max 之间的随机整数 | ^1.0.1 | | memorize | 缓存函数,入参相同,记忆上次结果,优化性能 | ^1.0.2 |