Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wankdanker/node-ifeerv
If Function Execute Else Return Value
https://github.com/wankdanker/node-ifeerv
Last synced: 14 days ago
JSON representation
If Function Execute Else Return Value
- Host: GitHub
- URL: https://github.com/wankdanker/node-ifeerv
- Owner: wankdanker
- Created: 2016-11-09T21:08:14.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2016-11-09T21:08:21.000Z (about 8 years ago)
- Last Synced: 2024-12-06T03:39:17.866Z (about 1 month ago)
- Language: JavaScript
- Size: 1000 Bytes
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
ifeerv
------If Function Execute Else Return Value
example
-------```js
var ife = require('ifeerv');var obj = {
a : 'test'
, b : function () {
return 'test2'
}
};var obj2 = {
a : ife(obj.a)
, b : ife(obj.b)
};```
use case
--------I pass a lot of objects around and sometimes I need sometimes a value isn't
good enough. I need to get some bit of data that is in some other scope. This
is pretty easy to do by just setting the value of some object property to a
function and call the function. But, I'm annoyed with having to check to see if
a given property is a function and if so, execute it otherwise just use the
value directly. This tiny module wraps up the test-for-function-type-and-
execute-else-return-the-value logic.license
-------MIT