Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Invoke .apply if value is a function, otherwise, return default value.
npm install apply-or --save
Function.prototype.apply
is normally sufficient; however, there are situations where it is useful to treat a value as a Function
(invoke it) only if it is indeed a Function
; otherwise, return it as-is. Calling .apply
on a value that is not a function would cause an error.
var apply = require('apply-or')
function delay (cb) {
setTimeout(apply.bind(null, cb))
}
delay('Hello') // does nothing (because argument is not a function)
delay(console.log.bind(console, 'Hello, World')) // prints 'Hello, World' to stdout
var apply = require('apply-or')
function divmax (divisor) {
return Math.max.apply(null, this.val) / divisor
}
var data = {
val: [9, 7, 15, 12]
}
apply(divmax, 5, data)
//=> divmax.apply({ val: [9, 7, 15, 12] }, [5])
//=> 15 / 5
//=> 3
apply(func, args, self)
func: (Function)
Function to be invoked.args: (Array|*)
Arguments to apply to function.self: (Object)
this
value.(*)
Result of applying function or default value.0.5.2 - 2015-05-30
npm run release-*
scripts.FAQs
Invoke .apply if value is a function, otherwise, return default value.
The npm package apply-or receives a total of 0 weekly downloads. As such, apply-or popularity was classified as not popular.
We found that apply-or 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
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.