Initial commit

master
Sven Slootweg 3 years ago
commit a148139303

@ -0,0 +1,3 @@
module.exports = {
extends: "@joepie91/eslint-config"
};

1
.gitignore vendored

@ -0,0 +1 @@
node_modules

@ -0,0 +1,22 @@
"use strict";
const Promise = require("bluebird");
const fromValue = require("./");
const pipe = require("@promistream/pipe");
const collect = require("@promistream/collect");
return Promise.try(() => {
return pipe([
fromValue(42),
collect()
]).read();
}).then((result) => {
console.log(result); // [ 42 ]
return pipe([
fromValue(Promise.resolve(9001)),
collect()
]).read();
}).then((result) => {
console.log(result); // [ 9001 ]
});

@ -0,0 +1,24 @@
"use strict";
const { validateArguments } = require("@validatem/core");
const required = require("@validatem/required");
const EndOfStream = require("@promistream/end-of-stream");
const simpleSource = require("@promistream/simple-source");
module.exports = function createStreamFromValue(_value) {
let [ value ] = validateArguments(arguments, {
value: required
});
let wasValueRead = false;
return simpleSource(() => {
if (wasValueRead === false) {
wasValueRead = true;
return value;
} else {
throw new EndOfStream("Value was read");
}
});
};

@ -0,0 +1,21 @@
{
"name": "@ppstreams/from-value",
"version": "0.1.0",
"main": "index.js",
"repository": "http://git.cryto.net/ppstreams/from-value.git",
"author": "Sven Slootweg <admin@cryto.net>",
"license": "WTFPL OR CC0-1.0",
"devDependencies": {
"@joepie91/eslint-config": "^1.1.0",
"@promistream/collect": "^0.1.1",
"@promistream/pipe": "^0.1.5",
"bluebird": "^3.7.2",
"eslint": "^6.3.0"
},
"dependencies": {
"@promistream/end-of-stream": "^0.1.1",
"@promistream/simple-source": "^0.1.2",
"@validatem/core": "^0.3.13",
"@validatem/required": "^0.1.1"
}
}

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