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 🙏

© 2025 – Pkg Stats / Ryan Hefner

summary-utils

v1.1.3

Published

Personal summary of some tools and methods

Downloads

12

Readme

工具库方法

  • MyPromise 符合promiseA+规范的promise库。

    • 在原promise基础上增加了abort中断方法。
        例如:
         场景,请求一个接口,此接口返回时间不定。但是,假如超过3S没响应。就默认这个接口失败了
            let ms = 5000;(此毫秒数代表请求响应的事件。超过3S视为超时)
            let p = MyPromise.warp(new Promise((resolve,reject)=>{
                setTimeput(()=>{
                    resolve("成功")
                },ms)
            })).then(data=>console.log(data),err=>console.log(err))
    
            setTimeout(()=>{p.abort("超时,废弃此次请求的响应")},3000)
  • deepClone 深拷贝。

    • 支持循环应用
        例如:
        let obj = {a:1}
        obj.b = obj;
        然后拷贝obj不会死循环,而是一个循环的引用
  • randomColor 产生随机色

    • options
      • 1.colorStart,colorEnd颜色限制,如果没有限制则生成的颜色为0~255之间。如果要限制colorStart代表起始位置,值为0-255。colorEnd代表结束位置值为0-255并且值要大于colorStart
      • 2.isHex 生成的颜色是要rgba的形式还是16进制。true为生成16进制,false为rgba,默认值为false
      • 3.isRandomOpacity 透明度是否随机生成,默认false透明度为1,如果设置为true 生成值在0 - 1之间。并且如果指定生成16进制格式则此项默认无效
          //示例
          randomColor({
              colorStart: 100,
              colorEnd: 200,
              isHex: true
          })
          randomColor({
             colorStart: 100,
             colorEnd: 200,
             isRandomOpacity: true
          })
  • curring 柯里化

    • 可用于开发者使用的类型判断等需要柯里化的功能方法
      例如开发者需要封装一些自己的验证类型工具库:
         function isType(b,a) {
         	console.log(Object.prototype.toString.call(a),`[object ${b}]`);
         	return Object.prototype.toString.call(a) === `[object ${b}]`
         }
         let obj = {}
         let utils = ["String","Number","Boolean"];
         utils.forEach(type=>{
         	obj["is"+type] = test(isType)(type);
         })
         let res = obj.isString("12");
         let res1 = obj.isNumber(12);
         console.log(res,res1);
  • uncurring 反柯里化

  • mergeOptions 对象的合并方法。

    //值的合并,将两者的属性进行合并返回一个全新的值。
    let o1 = {
    	obj:{ a: 1, b: 2 },
    	arr: [1,2,3],
    	str: "123",
    	num: 18
    }
    let o2 = {
    	obj:{ a: 3, c: 4 },
    	arr: [4,5,6],
    	str2: "567",
    	num: 15
    }
      
    let result = test(o1,o2); 
      
    // result = { 
         obj: { a: 3, b: 2, c: 4 },
         arr: [ 1, 2, 3, 4, 5, 6 ],
         str: '123',
         num: 15,
         str2: '567'
       }

使用方法

  • 1.导入工具包,然后将需要使用的方法解构出来使用。
  • 2.本工具库大写字母代表类,需要new。其余方法直接调用即可。

接下去要实现的功能

  • 1.防抖节流
  • ...

更新记录

  • 1.1.3 补全README的使用说明,修复mergeOptions存在的问题。