Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cheton/chained-function
Chained function calls
https://github.com/cheton/chained-function
chained function
Last synced: 10 days ago
JSON representation
Chained function calls
- Host: GitHub
- URL: https://github.com/cheton/chained-function
- Owner: cheton
- License: mit
- Created: 2017-02-16T08:19:12.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2019-08-27T11:52:04.000Z (about 5 years ago)
- Last Synced: 2024-10-30T00:00:11.735Z (20 days ago)
- Topics: chained, function
- Language: JavaScript
- Size: 4.88 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# chained-function [![build status](https://travis-ci.org/cheton/chained-function.svg?branch=master)](https://travis-ci.org/cheton/chained-function) [![Coverage Status](https://coveralls.io/repos/github/cheton/chained-function/badge.svg?branch=master)](https://coveralls.io/github/cheton/chained-function?branch=master)
[![NPM](https://nodei.co/npm/chained-function.png?downloads=true&stars=true)](https://www.npmjs.com/package/chained-function)
## Installation
```bash
npm install --save chained-function
```## Usage
```js
let sum = 0;
const func = chainedFunction(
function(val) {
sum += val;
console.log(sum); // 2
},
function(val) {
sum += val;
console.log(sum); // 4
},
function(val) {
sum += val;
console.log(sum); // 6
}
);func(2);
```### React
```js
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import chainedFunction from 'chained-function';class extends Component {
static propTypes = {
onClick: PropTypes.func
};
static contextTypes = {
$parent: PropTypes.shape({
onClick: PropTypes.func
})
};actions = {
handleClick: (event) => {
}
}render() {
const { onClick, ...props } = this.props;
const parent = this.context.$parent;## License
MIT