Skip to content

zenggpzqbx/fun-plus

Repository files navigation

引入方式

import方式

import {count, countBy} from '@zqbx/fun-plus'

umd方式

// 默认使用的全局变量:f

函数用例

count

count([1,2,2,2,23,4,2,3,4,5])
// => { '1': 1, '2': 4, '3': 2, '4': 2, '5': 1, '23': 1 }

countBy

countBy([{zmb:'123'}, {zmb:'123'}, {zmb:'12344'}],  item => item.zmb)
// => { '123': 2, '12344': 1 }

countBy([6.1, 4.2, 6.3])
// => {'6': 2,'4': 1}

pick

pick({name:'abc', age:28, sex:'男'}, 'name')
// => { 'name': 'abc'}

pick({name:'abc', age:28, sex:'男'}, ['name', 'age'])
// => { 'name': 'abc', 'age': 28 }

pick({name:'abc', age:28, sex:'男', true}, ['name', 'age'])
// => ['abc',28 ]

debounce

let debounced = debounce(callbackFun, 1000)

throttle

//第三个参数是一个boolean,false:代表非立即运行;ture:代表立即运行
let throttle_one = throttle(callbackFun, 1000)
let throttle_two = throttle(callbackFun, 1000, ture)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published