This repository has been archived by the owner on Dec 12, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit efba29e
Showing
7 changed files
with
131 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.DS_Store | ||
node_modules | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
language: node_js | ||
|
||
notifications: | ||
email: | ||
on_success: never | ||
on_failure: change | ||
|
||
node_js: | ||
- "0.10" | ||
|
||
after_script: "npm install coveralls@2 && cat ./coverage/lcov.info | coveralls" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2014 Blake Embrey (hello@blakeembrey.com) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Invoke | ||
|
||
[![NPM version][npm-image]][npm-url] | ||
[![Build status][travis-image]][travis-url] | ||
[![Test coverage][coveralls-image]][coveralls-url] | ||
[![Gittip][gittip-image]][gittip-url] | ||
|
||
Functional utility for creating a function that will invoke the same method on every passed in object. | ||
|
||
## Installation | ||
|
||
``` | ||
npm install util-invoke --save | ||
``` | ||
|
||
## Usage | ||
|
||
```javascript | ||
var children = [1, 2, 3, true]; | ||
|
||
children.map(invoke('toString')); //=> ['1', '2', '3', 'true'] | ||
``` | ||
|
||
## License | ||
|
||
MIT | ||
|
||
[npm-image]: https://img.shields.io/npm/v/util-invoke.svg?style=flat | ||
[npm-url]: https://npmjs.org/package/util-invoke | ||
[travis-image]: https://img.shields.io/travis/blakeembrey/invoke.svg?style=flat | ||
[travis-url]: https://travis-ci.org/blakeembrey/invoke | ||
[coveralls-image]: https://img.shields.io/coveralls/blakeembrey/invoke.svg?style=flat | ||
[coveralls-url]: https://coveralls.io/r/blakeembrey/invoke?branch=master | ||
[gittip-image]: https://img.shields.io/gittip/blakeembrey.svg?style=flat | ||
[gittip-url]: https://www.gittip.com/blakeembrey |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
var __slice = Array.prototype.slice; | ||
|
||
/** | ||
* Automatically invoke a predefined method on every passed in object. | ||
* | ||
* @param {String} method | ||
* @return {Function} | ||
*/ | ||
module.exports = function (method /*, ...args */) { | ||
var args = __slice.call(arguments, 1); | ||
|
||
return function (obj /*, ..args */) { | ||
return obj[method].apply(obj, args.concat(__slice.call(arguments, 1))); | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"name": "util-invoke", | ||
"version": "1.0.0", | ||
"description": "Functional utility for invoking the same method on every call.", | ||
"main": "invoke.js", | ||
"scripts": { | ||
"test": "istanbul cover _mocha -- -R spec" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/blakeembrey/invoke.git" | ||
}, | ||
"keywords": [ | ||
"invoke", | ||
"method", | ||
"functional" | ||
], | ||
"author": { | ||
"name": "Blake Embrey", | ||
"email": "hello@blakeembrey.com", | ||
"url": "http://blakeembrey.me" | ||
}, | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/blakeembrey/invoke/issues" | ||
}, | ||
"homepage": "https://github.com/blakeembrey/invoke", | ||
"devDependencies": { | ||
"istanbul": "^0.3.0", | ||
"mocha": "^1.21.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* global describe, it */ | ||
var invoke = require('./'); | ||
var assert = require('assert'); | ||
|
||
describe('invoke', function () { | ||
it('should invoke the method', function () { | ||
var children = [1, 2, 3, true]; | ||
|
||
assert.deepEqual( | ||
children.map(invoke('toString', 10)), | ||
['1', '2', '3', 'true'] | ||
); | ||
}); | ||
}); |