Initial commit

master
Sven Slootweg 4 years ago
commit 9d1014c49d

@ -0,0 +1,3 @@
{
"extends": "@joepie91/eslint-config"
}

1
.gitignore vendored

@ -0,0 +1 @@
node_modules

@ -0,0 +1,43 @@
"use strict";
const Promise = require("bluebird");
const { validateArguments } = require("@validatem/core");
const required = require("@validatem/required");
const isFunction = require("@validatem/is-function");
const propagateAbort = require("@promistream/propagate-abort");
const propagatePeek = require("@promistream/propagate-peek");
module.exports = function mapFilter(_predicate) {
let [ predicate ] = validateArguments(arguments, {
predicate: [ required, isFunction ]
});
return {
_promistreamVersion: 0,
description: `map-filter stream`,
abort: propagateAbort,
peek: propagatePeek,
read: function produceValue_mapFilterStream(source) {
function attemptRead() {
return Promise.try(() => {
return source.read();
}).then((result) => {
return Promise.try(() => {
return predicate(result);
}).then((mappedItem) => {
if (mappedItem === module.exports.NoValue) {
return attemptRead();
} else {
return mappedItem;
}
});
});
}
return attemptRead();
}
};
};
module.exports.NoValue = Symbol("NoValue");

@ -0,0 +1,24 @@
{
"name": "@promistream/map-filter",
"description": "A Promistream that's optimized for the 'map some items and throw away the rest' usecase",
"version": "0.1.0",
"main": "index.js",
"keywords": [
"promistream"
],
"repository": "http://git.cryto.net/joepie91/map-filter.git",
"author": "Sven Slootweg <admin@cryto.net>",
"license": "WTFPL OR CC0-1.0",
"devDependencies": {
"@joepie91/eslint-config": "^1.1.0",
"eslint": "^6.8.0"
},
"dependencies": {
"@promistream/propagate-abort": "^0.1.6",
"@promistream/propagate-peek": "^0.1.1",
"@validatem/core": "^0.3.15",
"@validatem/is-function": "^0.1.0",
"@validatem/required": "^0.1.1",
"bluebird": "^3.7.2"
}
}

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save