$
This commit is contained in:
21
node_modules/cumpa/LICENSE
generated
vendored
Normal file
21
node_modules/cumpa/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Gianluca Guarini
|
||||
|
||||
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.
|
75
node_modules/cumpa/README.md
generated
vendored
Normal file
75
node_modules/cumpa/README.md
generated
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
# cumpa
|
||||
|
||||
Minimal function composition implementation
|
||||
|
||||
<img alt="cumpa" src="./cumpa.gif" width="50%"/>
|
||||
|
||||
> `cumpá` in some Italian :it: dialects means `fellow`
|
||||
|
||||
[![Build Status][travis-image]][travis-url]
|
||||
|
||||
[![NPM version][npm-version-image]][npm-url]
|
||||
[![NPM downloads][npm-downloads-image]][npm-url]
|
||||
[![MIT License][license-image]][license-url]
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import compose from 'cumpa'
|
||||
|
||||
const add2 = x => x + 2
|
||||
const multiplyBy3 = x => x * 3
|
||||
|
||||
const add2AndMultiplyBy3 = compose(multiplyBy3, add2)
|
||||
|
||||
console.log(add2AndMultiplyBy3(1)) // ((1 + 2) * 3) = 9
|
||||
```
|
||||
|
||||
[travis-image]: https://img.shields.io/travis/GianlucaGuarini/cumpa.svg?style=flat-square
|
||||
|
||||
[travis-url]: https://travis-ci.org/GianlucaGuarini/cumpa
|
||||
|
||||
[license-image]: http://img.shields.io/badge/license-MIT-000000.svg?style=flat-square
|
||||
|
||||
[license-url]: LICENSE
|
||||
|
||||
[npm-version-image]: http://img.shields.io/npm/v/cumpa.svg?style=flat-square
|
||||
|
||||
[npm-downloads-image]: http://img.shields.io/npm/dm/cumpa.svg?style=flat-square
|
||||
|
||||
[npm-url]: https://npmjs.org/package/cumpa
|
||||
|
||||
## API
|
||||
|
||||
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
|
||||
|
||||
#### Table of Contents
|
||||
|
||||
- [composeRight](#composeright)
|
||||
- [Parameters](#parameters)
|
||||
- [compose](#compose)
|
||||
- [Parameters](#parameters-1)
|
||||
|
||||
### composeRight
|
||||
|
||||
Similar to compose but performs from left-to-right function composition.<br/>
|
||||
[see also](https://30secondsofcode.org/function#composeright)
|
||||
|
||||
#### Parameters
|
||||
|
||||
- `fns` **...\[[function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)]** ) - list of unary fynctions
|
||||
|
||||
Returns **any** result of the computation
|
||||
|
||||
### compose
|
||||
|
||||
Performs right-to-left function composition.
|
||||
Use Array.prototype.reduce() to perform right-to-left function composition.
|
||||
The last (rightmost) function can accept one or more arguments; the remaining functions must be unary.<br/>
|
||||
[source code](https://30secondsofcode.org/function#compose)
|
||||
|
||||
#### Parameters
|
||||
|
||||
- `fns` **...\[[function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)]** ) - list of unary fynctions
|
||||
|
||||
Returns **any** result of the computation
|
32
node_modules/cumpa/cumpa.js
generated
vendored
Normal file
32
node_modules/cumpa/cumpa.js
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
||||
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
||||
(global = global || self, factory(global.cumpa = {}));
|
||||
}(this, function (exports) { 'use strict';
|
||||
|
||||
/**
|
||||
* Similar to compose but performs from left-to-right function composition.<br/>
|
||||
* {@link https://30secondsofcode.org/function#composeright see also}
|
||||
* @param {...[function]} fns) - list of unary function
|
||||
* @returns {*} result of the computation
|
||||
*/
|
||||
const composeRight = (...fns) => compose(...fns.reverse());
|
||||
|
||||
/**
|
||||
* Performs right-to-left function composition.<br/>
|
||||
* Use Array.prototype.reduce() to perform right-to-left function composition.<br/>
|
||||
* The last (rightmost) function can accept one or more arguments; the remaining functions must be unary.<br/>
|
||||
* {@link https://30secondsofcode.org/function#compose original source code}
|
||||
* @param {...[function]} fns) - list of unary function
|
||||
* @returns {*} result of the computation
|
||||
*/
|
||||
function compose(...fns) {
|
||||
return fns.reduce((f, g) => (...args) => f(g(...args)))
|
||||
}
|
||||
|
||||
exports.composeRight = composeRight;
|
||||
exports.default = compose;
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
}));
|
19
node_modules/cumpa/index.next.js
generated
vendored
Normal file
19
node_modules/cumpa/index.next.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* Similar to compose but performs from left-to-right function composition.<br/>
|
||||
* {@link https://30secondsofcode.org/function#composeright see also}
|
||||
* @param {...[function]} fns) - list of unary function
|
||||
* @returns {*} result of the computation
|
||||
*/
|
||||
export const composeRight = (...fns) => compose(...fns.reverse())
|
||||
|
||||
/**
|
||||
* Performs right-to-left function composition.<br/>
|
||||
* Use Array.prototype.reduce() to perform right-to-left function composition.<br/>
|
||||
* The last (rightmost) function can accept one or more arguments; the remaining functions must be unary.<br/>
|
||||
* {@link https://30secondsofcode.org/function#compose original source code}
|
||||
* @param {...[function]} fns) - list of unary function
|
||||
* @returns {*} result of the computation
|
||||
*/
|
||||
export default function compose(...fns) {
|
||||
return fns.reduce((f, g) => (...args) => f(g(...args)))
|
||||
}
|
42
node_modules/cumpa/package.json
generated
vendored
Normal file
42
node_modules/cumpa/package.json
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"name": "cumpa",
|
||||
"version": "1.0.1",
|
||||
"description": "Minimal function composition implementation",
|
||||
"main": "cumpa.js",
|
||||
"jsnext:main": "index.next.js",
|
||||
"module": "index.next.js",
|
||||
"scripts": {
|
||||
"prepare": "npm run build && npm test",
|
||||
"lint": "eslint index.next.js test.js rollup.config.js",
|
||||
"build": "rollup -c",
|
||||
"doc": "documentation readme index.next.js -s API",
|
||||
"pretest": "npm run build",
|
||||
"test": "npm run lint && mocha test.js"
|
||||
},
|
||||
"files": [
|
||||
"index.next.js"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/GianlucaGuarini/cumpa.git"
|
||||
},
|
||||
"keywords": [
|
||||
"flowRight",
|
||||
"functional",
|
||||
"compose",
|
||||
"compose-right"
|
||||
],
|
||||
"author": "Gianluca Guarini <gianluca.guarini@gmail.com> (http://gianlucaguarini.com)",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/GianlucaGuarini/cumpa/issues"
|
||||
},
|
||||
"homepage": "https://github.com/GianlucaGuarini/cumpa#readme",
|
||||
"devDependencies": {
|
||||
"@gianlucaguarini/eslint-config": "^2.0.0",
|
||||
"eslint": "^5.16.0",
|
||||
"mocha": "^6.0.2",
|
||||
"rollup": "^1.7.4",
|
||||
"rollup-plugin-node-resolve": "^4.0.1"
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user