Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/team-griffin/partial-application-tree
https://github.com/team-griffin/partial-application-tree
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/team-griffin/partial-application-tree
- Owner: team-griffin
- License: mit
- Created: 2017-06-12T11:37:31.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-12-06T21:52:53.000Z (about 2 years ago)
- Last Synced: 2024-10-14T14:48:19.912Z (2 months ago)
- Language: JavaScript
- Size: 369 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# partial-application-tree
This module is designed to simplify making your library's codebase functional via partial application.
By using partial applicatio on your functions you are able to keep them pure when they would have otherwise been impure.
```js
const doAjaxRequest = (url) => {
// some ajax
};const myFunc = (doAjaxRequest) => {
return doAjaxRequest('url').then((response) => {
return 'something';
});
};```
As you can see in this code example `myFunc` is a pure function (when given a pure function). This allows it to be easily tested if you pass in a pure stub.
## Usage
```js
// Codebase
export const leaf = () => 'leaf';export const node = (leaf) => leaf();
// Your wiring up code (usually in index.js or module.js)
import pat from 'partial-application-tree';
import { leaf, node } from './code';const tree = [
['node', ['leaf']]
];const codebase = pat(tree, {
leaf,
node,
});```
There is added support for nested nodes. The paths are automatically resolved.
```js
const tree = [
['nested.node', ['deep.leaf']]
];
```