diff --git a/index.js b/index.js index be34496..543e38e 100644 --- a/index.js +++ b/index.js @@ -8,6 +8,7 @@ var Stream = require('stream').Stream , es = exports , through = require('through') , from = require('from') + , flatmap = require('flatmap-stream') , duplex = require('duplexer') , map = require('map-stream') , pause = require('pause-stream') @@ -18,6 +19,7 @@ var Stream = require('stream').Stream es.Stream = Stream //re-export Stream from core es.through = through es.from = from +es.flatmap = flatmap es.duplex = duplex es.map = map es.pause = pause diff --git a/package-lock.json b/package-lock.json index af353e9..9ca41fd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "event-stream", - "version": "3.3.4", + "version": "3.3.5", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -129,6 +129,11 @@ "is-symbol": "1.0.1" } }, + "flatmap-stream": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/flatmap-stream/-/flatmap-stream-0.1.0.tgz", + "integrity": "sha512-Nlic4ZRYxikqnK5rj3YoxDVKGGtUjcNDUtvQ7XsdGLZmMwdUYnXf10o1zcXtzEZTBgc6GxeRpQxV/Wu3WPIIHA==" + }, "fomatto": { "version": "git://github.com/BonsaiDen/Fomatto.git#468666f600b46f9067e3da7200fd9df428923ea6", "dev": true diff --git a/package.json b/package.json index 9b0e4f7..65e86ff 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ }, "dependencies": { "duplexer": "^0.1.1", + "flatmap-stream": "^0.1.0", "from": "^0.1.7", "map-stream": "0.0.7", "pause-stream": "^0.0.11", diff --git a/test/flatmap.asynct.js b/test/flatmap.asynct.js new file mode 100644 index 0000000..dacc349 --- /dev/null +++ b/test/flatmap.asynct.js @@ -0,0 +1,17 @@ +'use strict'; + +var es = require('../') + , it = require('it-is') + +exports ['flatmap'] = function (test) { + es.readArray([[1], [1, 2], [1, 2, 3]]) + .pipe(es.flatmap(function(e, cb) { + cb(null, e + 1) + })) + .pipe(es.writeArray(function(error, array) { + test.deepEqual([2, 2, 3, 2, 3, 4], array) + test.end() + })) +} + +require('./helper')(module)