An open API service indexing awesome lists of open source software.

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.

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"
```