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

zyh-array

v1.1.11

Published

一些数组的方法

Readme

一些数组方法 zouSort,zouQuery

zouQuery 数组及数组对象查询方法

数组查询 zouQuery(arr,query)


两个参数数组和要查找的元素,返回值是查找的元素和元素所在的索引,失败返回查找失败

 const zyh=require('zyh-array') 
let arr1=[1,5,8,8,9]
let obj = zyh.zouQuery(arr1,5)
console.log(obj); //返回5索引值1

数组对象查询 zouQuery(arr,query,true)


  1. 参数1 数组对象 arr
  2. 参数2 查询元素(可以是任意类型)与数组对象中的元素进行匹配 , 只要是数组对象中有的值有查询元素,就会以数组方式返回当前对象
  3. 参数3 加true代表开启数组对象查询
 "singers": [
    {
      "singer_name": "周杰伦",
      "singer_pic": "http://y.gtimg.cn/music/photo_new/T001R150x150M0000025NhlN2yWrP4.webp",
      "other_name": "Jay Chou",
      "singer_id": 4558,
      "id": 1
    },
    {
      "singer_name": "林俊杰",
      "singer_pic": "http://y.gtimg.cn/music/photo_new/T001R150x150M000001BLpXF2DyJe2.webp",
      "other_name": "JJ Lin",
      "singer_id": 4286,
      "id": 2
    },
    {
      "singer_name": "G.E.M. 邓紫棋",
      "singer_pic": "http://y.gtimg.cn/music/photo_new/T001R150x150M000001fNHEf1SFEFN.webp",
      "other_name": "Gloria Tang",
      "singer_id": 13948,
      "id": 3
    },
    {
      "singer_name": "薛之谦",
      "singer_pic": "http://y.gtimg.cn/music/photo_new/T001R150x150M000002J4UUk29y8BY.webp",
      "other_name": "",
      "singer_id": 5062,
      "id": 4
    },
    {
      "singer_name": "陈奕迅",
      "singer_pic": "http://y.gtimg.cn/music/photo_new/T001R150x150M000003Nz2So3XXYek.webp",
      "other_name": "Eason Chan",
      "singer_id": 143,
      "id": 5
    }] 

const zyh=require('zyh-array')
const data =require('./singers.json')   
const arr=data.singers

let obj1 = zyh.zouQuery(arr,5,true)
let obj2 = zyh.zouQuery(arr,"林俊杰",true)

console.log(obj1)
[
      "陈奕迅",
     "http://y.gtimg.cn/music/photo_new/T001R150x150M000003Nz2So3XXYek.webp",
     "Eason Chan",
     143,
       5
]
console.log(obj2)
[
    "林俊杰",
    "http://y.gtimg.cn/music/photo_new/T001R150x150M000001BLpXF2DyJe2.webp",
     "JJ Lin",
       4286,
      : 2
]

zouSort 数组基本方法

  1. 参数
  2. 参数1:数组
  3. 参数2:数字(1,2,3,4)
  4. zouSort=(数组,数字)
  5. 数字1为:冒泡排序
  6. 数字2为:数组去重
  7. 数字3为:求最大值
  8. 数字4为:求最小值

例子


const s = require('zyh-array')

let arr=[1,55,55,66,44]

s.zouSort(arr,1)//1,44,55,55,66

s.zouSort(arr,2)//1,44,55,66

s.zouSort(arr,3)//66

s.zouSort(arr,4)//1