Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/segment-boneyard/to-transform
Create a transform stream constructor from a function
https://github.com/segment-boneyard/to-transform
Last synced: about 5 hours ago
JSON representation
Create a transform stream constructor from a function
- Host: GitHub
- URL: https://github.com/segment-boneyard/to-transform
- Owner: segment-boneyard
- Created: 2014-05-16T00:42:42.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-05-16T00:43:55.000Z (over 10 years ago)
- Last Synced: 2024-04-24T16:47:20.353Z (7 months ago)
- Language: JavaScript
- Size: 121 KB
- Stars: 10
- Watchers: 40
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- Changelog: History.md
Awesome Lists containing this project
README
# to-transform
Simple wrapper to create a transform stream
## API
### to-transform(fn)
Returns a Transform stream constructor which uses `fn` as the transform. Checks the number of arguments to decide whether to use a sync or async function.
```js
var transform = require('to-transform');
var Stream = transform(function(x){ return x + 1; });var stream = new Stream({ objectMode: true });
stream.write(1);process.nextTick(function(){
console.log(stream.read()); // 2;
});
```## License
(The MIT License)
Copyright (c) 2014 Segment.io <[email protected]>
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.