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

simple-d

v1.0.29

Published

data processing

Readme

Simple Data

主要是集合的处理,收集一些以及工作中用到过,或者会用到的一些集合处理方法,不喜勿喷,励志做一个合格的小开发

let a = [ {"a":"aaaa", "b": "bbbbbbb", "c": "cccccccccccc", "d": "dddddddddd", e: "test", f: "1ee", num: 12, num1: -45}, {"a":"wer", "b": "11313", "c": "s3fdd", "d": "041", e: "e", f: "f",num: 3, num1: -60}, {"a":"aa", "b": "bb", "c": "cc", "d": "dd", num: 100, num1: 2}, {"a":"aa1", "b1": "bb1", "c1": "cc1", "d1": "dd1", num: 100, num1: 21}, {"a":"a112", "b": "b11", "c": "c00", "d": "dkc", e: "test", f: "test1",num: -100, num1: 1}, {"a":"aa", "b": "bb", "c": "000", "d00": "7800", e: "e", f: "0f0",num: -10, num1: 10}, {"a":"aa", "b": "bb", "c": "asd", "d": "dd", e: "eyt", f: "0f0",num: -17, num1: 11}, {"a":"f", "b": "u", "c": "c", "d": "k", e: "!", f: "!!",num: 5, num1: 5} ];

let b = [2,"ad", undefined,null,"2", 2, 4, 5, "e12", 1, 3, 3, 2, "sdf", "12",null, undefined,"fuck", "fuckup", "sdf"]

let b_1 = [100,"qwe", "as","sd",-911, 2, "12ds","sd","fd","ds","as","sd","dx1","100t","50g","128g","256g","100t","100","1001","1022"]

let b_2 = [12,343,44,33,-132,0,-1,31,3,4,65,-9,0,3,11,1,2]

let b_3 = ['12', '3430', '44', 33, '-132', 0, -1, 31, 3, '4', 65, -9, 0, '3', 11, '1', '2', 0, undefined, false, null,NaN,'']

let c = [ {name:"dragon", win:3, lose:2, status: false}, {name:"jack", win:3.5, lose:1, status: false}, {name:"ben", win:1, lose:1.5, status: true}, {name:"skip", win:4, lose:0.5, status: false}, {name:"bobi", win:1.1, lose:1.6, status: true} ]

let d = [ // { // title: "dragon", num: 440, children: [{money: "25000", time: 12},{money: "25000", time: 13},{money: "25000", time: 6}] // }, // { // title: "jack", num: 227, children: [{money: "35000", time: 48},{money: "25000", time: 24},{money: "25000", time: 36}] // }, // { // title: "ben", num: 428, children: [{money: "30000", time: 31},{money: "30000", time: 22},{money: "25000", time: 100000}] // }, { title: "skip", num: 428, children: [ {base: "2019", angele: true, child: [ {time: 324}, {time: 100}, {time: 475} ]} ] }, { title: "duck", num: 338, children: [ {base: "2017", angele: true, child: [ {time: 3424}, {time: 70}, {time: 71} ]} ] } ]

data_item_array

data_item_number

数组里的元素为 number 元素

最大值 getMax: true

最小值 getMin: true

simpArr_Num(b_3, {getMax: true, getMin: true});

data_item_string

数组里的元素为 string 元素

去重 repeat:true

得到集合每个元素出现的次数 same: true ,100 和 "100" 视为同一个

simpArr_Str(b_1, {same: true, repeat:true});

data_item_object

数组里的元素为 object 元素

为每个item添加索引:key:true (渲染列表时有时需要key=index)

filterObj: {[key]:[value]} 筛选得到,对应所出现的item阵列:{e: [{……},{……}], f: …… ……, filterIndex;[]} ,filterResult为出现的索引集合

sortKey:[arg1, arg2] 排序默认取arg1的值排序,相同值的话则取arg2的值排序

direction: "asc" | "desc" 排序字段是升序还是降序,一定要配合sortKey使用, 因为要匹配 sortKey:[] 里的key

repeatKeys: ["a", "b","f"] 以repeatKeys里的元素为key取得每条item对应key的value值,拼接在一起,查看是否有相同的 repeatKeysResult["res"]为最终不重复的集合,repeatKeysResult["repeat"]为筛选出重复的item

max:["num"]: 得到数组里[num]对应key的最大值的那条item

min:["num"]: 得到数组里[num]对应key的最小值的那条item

keyVlaue:{key:"title", value:"time", child:["children", "child"]} key对应最终返回的对象那个Key,value对应的是你所要取的值那个Key, child对应你所要遍历几层才能拿到value

selectAmountKey: [key, key] key是数组单个元素里对应的key , 最终计算出数组元素以key的值为参考,得到[value]出现的次数

simpArr_Obj(a, {
    key:true, 
    filterObj:{e: "test",f: "0f0"}, 
    sortKey:["num", "num1"],
    direction: "asc",   //升序和降序 Ascending Descending
    repeatKeys: ["a", "b","f"],
    max:["num"], 
    min:["num"] 
})
simpArr_Obj(d, {
    keyVlaue: {key: "title", value: "time", child: ["children", "child"]}
})

SetArray()

不断往数组里unshift最新的元素,并且不能有重复的,不能超过设定长度

setArray.spliceItem(33, 4):预想阵列length为4,传入第一个数为33,后续继续调用方法传入,每次传入unshift到阵列的第0个,如果下次传入的值在之前的阵列里存在,就把之前那个旧值删掉,新值依旧unshift在第0个,之后查看最新的阵列是否大于length为4,如果大于则切掉后面多余的

setArray.spliceItem(obj, key, length):预想阵列长度lengthobj为预想插入的itemObj, key为预想用来判断的[key]:[value]

const setArray = new SetArray();

const { spliceItem, spliceObjItem } = setArray;

SetBroad()

广播效果,排序,以及类似主播开和关的socket推送

sortObjItem(c, "status"): 上面定义的c数组,以"status"为key排序,筛选出true或false的值

subscribeMes(msg, "status", "name"): 接收一条msgObj, 通过"status", "name"为key的对应的值,来改变原数组对应namestatus值,类似于主播开播和关播的推送状态到前端

const setBroad = new SetBroad();

const {sortObjItem, subscribeMes, resSort: {active, other, result}} = SetBroad();

var msg = {name:"jack", status: true}

var msg1 = {name:"skip", status: true}

var msg2 = {name:"ben", status: false}

sortObjItem(c, "status") 需要先`sort`一遍

setBroad.subscribeMes(msg, "status", "name")
setBroad.subscribeMes(msg1, "status", "name")
setBroad.subscribeMes(msg2, "status", "name")