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 🙏

© 2024 – Pkg Stats / Ryan Hefner

arst

v1.2.5

Published

这是一个处理字符串,数组,对象的库,如:去重,排序,替换等等

Downloads

1

Readme

介绍

这是一个处理字符串,数组,对象的库,如:去重,排序,替换等等

安装使用

//源码
https://gitee.com/cheng-yunfen/arst
//下载
npm i arst
// 引入使用
import As from 'arst'
const as = new As()

dupRem:数组对象去重

import As from 'arst'
const as = new As()
let arr = [{id:1},{id:2},{id:1}]
const arr1 = as.dupRem(arr)
console.log(arr1)//[{id:1},{id:2}]

arrDupRem:普通数组去重

import As from 'arst'
const as = new As()
const arr = [1,2,3,1,2,3]
const arr1 = as.arrDupRem(arr1)
console.log(arr1)//[1,2,3]

arrObj:遍历指定多维数组对象

import As from 'arst'
const as = new As()
const arr = [{id:1,name:jack},[{id:1,name:'mac'}]]
const arr1 = as.arrObj(arr)
console.log(arr1)//[{name:'jack'},{name:mac}]

mulArrDupRem:多维数组去扁平化

import As from 'arst'
const as = new As()
const arr = [1,2,[3,4,[5,6]]]
const arr1 = as.mulArrDupRem(arr)
console.log(arr1)//[1,2,3,4,5,6]

strRemSpace:清除字符串里面的空格,如果只是左右有空格可以直接用trim

import As from 'arst'
const as = new As()
const str = '  5  6  '
const str1 = as.strRemSpace(str)
console.log(str1) // 56

strNumber:选出字符串中的数字bl传入布尔值true则为找出字母,false则为数字 默认为false

import As from 'arst'
const as = new As()
const str = 'asd56fas56fas5'
const str1 = as.strNumber(str)
console.log(str1) // 56565
const str2 = as.strNumber(str,true)
console.log(str2) // asdfasfas

strIn:指定替换字符

import As from 'arst'
const as = new As()
const str = '1563'
const str1 = as.strIn(str,5,'a')
console.log(str1) // 1a63

throtStab: 节流和防抖fn调用的方法,day延迟多久

<input type="text">
import As from 'arst'
const as = new As()
let input = document.querySelector('input')
input.oninput = as.throtStab(function(){
    console.log(this.value) //input里面的值 onscroll事件也可以一起用注意这里要用普通函数用箭头函数this会指向window
},500)

objRecursive: 找出对象最里面的每一个子孩子obj对象,返回的是一个数组

import As from 'arst'
const as = new As()
let obj = {
      a:'1',
      b:{
        a:'2',
        b:{
          a:'3',
          id:88
        }
      }
    }
 console.log(as.objRecursive(obj,'b')); //[ { a:'1' } , {a:'2'  },{ a:'3',id:88}]

arrSorting:数组对象根据指定排序数字为从小到大,汉字字母则是a,b,c,英文同汉字一起 则汉字在前 英文在后

import As from 'arst'
const as = new As()
const data = [
    { id: 1, name: '张三', age: 15 },
    { id: 1, name: '奥张三', age: 15 },
    { id: 2, name: 'John', age: 18 },
    { id: 3, name: '李四', age: 18 },
    { id: 4, name: 'Jack', age: 18 },
    { id: 5, name: '王五', age: 10},
  ];
const arr = as.arrSorting(data,'name')
console.log(arr) //[{id: 1, name: '奥张三', age: 15},{ id: 3, name: '李四', age: 18 },{ id: 5, name: '王五', age: 10}, { id: 1, name: '张三', age: 15 },{ id: 2, name: 'John', age: 18 },{ id: 4, name: 'Jack', age: 18 }]
const arr1 = as.arrSorting(data,'id')
console.log(arr1) // [{id:1..},{id:1..},{id:2..}..]同上