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

ec-utils

v1.0.2

Published

一款自用的前端工具库

Downloads

2

Readme

自定义工具函数库

说明

1. 包含以下8个方面

1). 函数相关
2). 数组相关
3). 对象相关
4). 字符串相关
5). 事件总线
6). 消息订阅与发布
7). Promise
8). ajax函数axios
9). 数据结构与算法

2. 使用

1). 下载: 
    npm install -S ec-utils
    yarn add ec-utils

2). 网页中使用
    <script src="./node_modules/ec-utils/dist/ec-utils.js"></script>
    <script>
      console.log(ecUtils.flatten1([1, [3, [2, 4]]]))  // [1, 3, 2, 4]
    </script>

3). 模块化引入
    import {flatten1} from 'ec-utils'
    const {flatten2} = require('ec-utils')
    console.log(ecUtils.flatten1([1, [3, [2, 4]]]))
    console.log(ecUtils.flatten2([1, [3, [2, 4]]]))

4). 完整的功能函数测试
    test文件夹下都一系列测试页面

API

1. 函数相关

call()

语法: call(fn, obj, ...args)
功能: 等同于函数对象的call方法

apply()

语法: apply(fn, obj, args)
功能: 等同于函数对象的apply方法

bind(fn, obj, args)

语法: bind(fn, obj, ...args)
功能: 等同于函数对象的bind方法

throttle()

语法: throttle(callback, delay)
功能: 用来生成节流函数的工具函数

debounce()

语法: debounce(callback, delay)
功能: 用来生成防抖函数的工具函数

2. 数组相关

map()

reduce()

filter()

find()

findIndex()

every()

some()

unique1() / unique2() / unique3()

concat()

slice()

flatten()

compact()

chunk() / chunk2()

difference()

mergeArray()

pull()

pullAll()

drop()

dropRight()

3. 对象相关

newInstance()

myInstanceOf()

mergeObject()

clone1() / clone2()

deepClone1() / deepClone2() / deepClone3() / deepClone4()

4. 字符串相关

reverseString()

palindrome()

truncate()

5. 事件总线: eventBus

eventBus.on()

eventBus.emit()

eventBus.off()

6. 消息订阅与发布: PubSub

PubSub.subscribe()

PubSub.publish()

PubSub.unsubscribe()

7. Promise

Promise()

Promise.prototype.then()

Promise.prototype.catch()

Promise.resolve()

Promise.reject()

Promise.all()

Promise.race()

Promise.resolveDelay()

Promise.rejectDelay()

8. ajax函数axios

axios()

axios.get()

axios.post()

axios.delete()

axios.put()