Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
decorators-js
Advanced tools
Readme
Common javascript decorators and combinators I use all the time. While I love libraries like Ramda this is a lightweight poor man's alternative.
n=f.length -> f: Function -> * -> *
Curries function f
allowing arguments to be received piecemeal. Can be set to a specific arity,
defaults to the arity of the curried function. Works for class constructors as well.
(f: Function, strict=true) -> * -> null|*
Returns a function that returns null
if any of its arguments are null
or undefined
,
otherwise returns the result of applying the function to the arguments. If the passed-in function
has an arity of 0 it may be successfully called with no arguments. If strict is set to false the
pre-emptive null is only returned if all the arguments are null
or undefined
.
(delay: Integer, immediate=false, f: Function) -> * -> Integer
Delay in milliseconds. Returns the timer ID so caller can cancel. The optional boolean parameter is whether the function fires on the leading edge or trailing edge.
delay: Integer -> f: Function -> * -> Integer
Throttles passed in function. Returns the setTimeout
handle so caller can cancel.
f: Function -> * -> Promise<*>
Takes a function that accepts a nodejs-style (error-first) callback and returns a function that returns a Promise of the result instead. If the callback receives multiple non-error parameters then it will return a Promise of an array of the results.
f: Function -> args: Array<*> -> *
Takes a function that takes positional arguments and returns a function that takes an Array of arguments.
class: Class -> args: Array<*> -> Object
Allows a class constructor that takes positional arguments to be given an Array instead. Useful for mapping a constructor over an Array of initialization data.
n: Integer -> f: Function -> * -> *
Applies only the first n
received arguments to f
. Useful for e.g. mapping parseInt
over an
Array of Strings: [1, 2, 3] === ["1", "2", "3"].map(d.bindArity(1, parseInt))
.
A partial application of bindArity
and 1.
(f: Function, g: Function ...) -> * -> *
Forward function composition. All functions except the first should be unary.
f: Function -> * -> *
Uses bounded stack space to run thunk-returning tail-recursive functions.
f: Function -> * -> *
Caches the result of function calls to avoid re-computation.
f: Function -> Promise<*> -> Promise<*>
Takes a function f
from a -> b
or a -> Promise b
and returns a function Promise a -> Promise b
.
FAQs
Common javascript decorators
The npm package decorators-js receives a total of 12 weekly downloads. As such, decorators-js popularity was classified as not popular.
We found that decorators-js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.