https://github.com/buren/pipe-ops
Pipe like transformations in JavaScript.
https://github.com/buren/pipe-ops
Last synced: 3 months ago
JSON representation
Pipe like transformations in JavaScript.
- Host: GitHub
- URL: https://github.com/buren/pipe-ops
- Owner: buren
- Created: 2016-11-14T00:55:25.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2021-12-01T02:22:19.000Z (over 3 years ago)
- Last Synced: 2025-02-19T22:04:18.537Z (3 months ago)
- Language: JavaScript
- Size: 3.91 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# pipe-ops
Pipe like transformations in JavaScript.
## Pipes
* __must__ implement: `value`, `inject` and `optional` functions.
## Examples
String transformation:
```js
new StringPipe('Hi %name%! Asdf %other_name% and this is').
optional().
format('%name%', 'Jacob').
format('%other_name%', 'Buren').
truncate(26).
concat('Read more..').
surround('', '
').
inject(function(value) { return '(:) ' + value }).
surround('', '').
value()
// "(:)Hi Jacob! Asdf Buren and..Read more..
"
```You can also move between different types:
```js
var echo = function(data) { return data + '... ' + data; };new StringPipe('Jacob,Buren').
split(',', ArrayPipe).map(function(el) { return '# ' + el + ' '; }).
join('', StringPipe).
inject(echo).
value()
// "# Jacob # Buren ... # Jacob # Buren"
```