Skip to content
/ funcjs Public

Disable the specified function within a period of time

License

Notifications You must be signed in to change notification settings

bitores/funcjs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

funcjs

npm i --save @huangzj/funcjs

  • unpack:函数解包,分解为 [argument string, function body]
  • pack: 多函数合并,function a + function b = function c
  • throttle: 函数执行后,一段时间内无执行能力-防抖,节流
  • delay: 函数延迟执行
  • once: 函数只能执行一次
  • limit:设置函数可执行次数

e.g.

function demo(x){
  console.log('demo')
}
unpack(demo)
// output: 
["x","console.log('demo')"]

function s(g){
  console.log('g')
}

pack(demo, s)
//output: 
function (x, g) {
  console.log('demo')
  console.log('g')
}


var demoFun = disable(demo, 5000) 
// After the demoFun function is executed, it can be executed again after 5 seconds.

var onceFun = once(demo)
// The onceFun function is executed only once.
 
var limitFun = limit(demo, 6)
// The limitFun function is executed 6 times.


About

Disable the specified function within a period of time

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published