Helper functions are a collection of commonly used function. This collection should help you to avoid the need of external modules like "underscore" or similiar and allows you to writer smaler plugins.
- debounce(func, wait[, immediate]) [source]
- extend(target, ...sources) [source]
- infinity(worker[,delay]) [source]
- iterate(obj, cb) [source]
- mixins(objs, options[, lookup]) [source]
- observe(target[, options, setter, getter]) [source]
- promisify(worker, cb) [source]
- queue(counter, cb) [source]
- request(url[, options, cb]) [source]
- sanitize.encode(input[,rules]) [source]
- sanitize.decode(input[,rules]) [source]
- timeout(time, cb) [source]
Debounce a function call.
func{Function} Function that is called afterwaitelapsed.wait{Number} Time in ms to wait before callfnc.immediate{Boolean} Callfuncimmediatly when return function is called.
Returns a function that is called instead directly of func.
Merges one or more sources into a single target.
target{Object} Target where all sources are merged into....sources{Array|Object} Things that are merged into target.
Calls the worker function, passes a "retry" function as only argument. If the retry function is called, its wait the time set as
delayand call then the worker code again
worker{Function} Worker callback that is with a delay oftimecalled.delay{Number} Delay to wait before callingworkeragain.
Ifinity function handling. For "redo" every time the "retery" function is called.
Iterate over everything inside the object. Including ever item in arrays/sub-objects.
obj{Object} Target object on which the iteration is procceded.cb{Function} Function that is called on each iteration step.
Mix/merge a bunch of objects into a single one.
objs{Array} Array of objects to merged. First item in the array has a special purpose.options{Object} Options object.lookup{Function} That is called when on the target object a propertie is get, see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/Proxy/get
Observe changes on a object.
target{Object} to observe.options{Object} Options object.options.intercept{Boolean} Intercept get/set calls. If set,setter/gettermust returntrue/falseto permit the opertiongetter{Function} Function that is called on get opertions. See handler.get()setter{Function} Function that is called on set opertions. See handler.set()
Returns the observed object, where changes trigger setter/getter
Promsify a callback function.
worker{Function} Function which is wrapped.cb{Function} Callback, which can be omited. Ifundefinedor set to "falsly" value, a promise is returned.
Queue a function call to
counter.
counter{Number} Counter, how often the returned function needed to be called to firecb.cb{Function} Callback which is fired when the returned function is calledcountertimes.
Returns a function, that needs to be called x times.
Does a HTTP/HTTPS request to
url
Just axios or fetch with build in node.js modules
See http module for more information
url{String} URL to the resourceoptions{Object} Options for http requestcb{Function} Callback with the result for the request
Replace malicious chars with html encoded entities
input{String} String that contains potential malicious inputrules{Array} additional rule set
Return the encoded string
Replace html encoded entites with original chars
input{String} String that contains potential malicious inputrules{Array} additional rule set
Return the decoded string
Calls a callback function automaticly after
time, unless the returned function is not called before timeout is reached.
time{Number} Timeout it ms to wait before callcb.cb{Function} Callback which should be called aftertime.
Return a function that can be called to trigger cb.