https://github.com/distributedlife/unfurler
Support functions for unfurling arrays
https://github.com/distributedlife/unfurler
Last synced: over 1 year ago
JSON representation
Support functions for unfurling arrays
- Host: GitHub
- URL: https://github.com/distributedlife/unfurler
- Owner: distributedlife
- Created: 2014-11-02T06:35:09.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2015-05-07T23:47:16.000Z (about 11 years ago)
- Last Synced: 2025-02-20T00:41:23.684Z (over 1 year ago)
- Language: JavaScript
- Size: 152 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# unfurler
Support functions for unfurling an array
# Usage
Takes an array of functions and returns a function that calls all the functions within it.
```javascript
var a = function() { console.log("a"); };
var b = function() { console.log("b"); };
var unfurled = require('unfurler').array([a, b]);
unfurled();
//a
//b
```
If given a single function it just returns that function.
```javascript
var a = function() { console.log("a"); };
var unfurled = require('unfurler').array(a);
unfurled();
//a
```
If asked for a guarantee it will return an empty function rather than return undefined.
```javascript
var unfurled = require('unfurler').arrayWithGuarentee();
unfurled(); //doesn't crap out.
```
And you can pass functions to the unfurled function and the arguments will be pass down to all the inner functions.
```javascript
var a = function(a, b, c) { console.log(a, b, c); };
var b = function(a, b, c) { console.log(a * 2, b * 2, c * 2); };
var unfurled = require('unfurler').array([a, b]);
unfurled(1,2,3);
//1, 2, 3
//2, 4, 6
```