Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

apply-or

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apply-or - npm Package Compare versions

Comparing version 0.5.0 to 0.5.1

4

changelog.md
# Change Log
All notable changes to this project will be documented in this file.
## 0.5.1 - 2015-05-07
### Changed
- updated examples.
## 0.5.0 - 2015-04-29

@@ -5,0 +9,0 @@ ### Changed

2

package.json
{
"name": "apply-or",
"description": "Invoke .apply if value is a function, otherwise, return default value.",
"version": "0.5.0",
"version": "0.5.1",
"author": "Wil Moore III <wil.moore@wilmoore.com>",

@@ -6,0 +6,0 @@ "bugs": {

@@ -16,9 +16,24 @@ # apply-or

`Function.prototype.bind` 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.
`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.
## Example
## Examples
###### [delay.js](examples/delay.js)
```js
var apply = require('apply-or');
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
```
###### [divmax.js](examples/divmax.js)
```js
var apply = require('apply-or')
function divmax (divisor) {

@@ -25,0 +40,0 @@ return Math.max.apply(null, this.val) / divisor

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc