Comparing version 0.5.0 to 0.5.1
# 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 |
{ | ||
"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 |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6114
69