Build on @promistream/from-lazy-value instead

master
Sven Slootweg 3 years ago
parent 32d0c49786
commit 5b9579954e

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

@ -13,8 +13,7 @@
"eslint": "^6.3.0" "eslint": "^6.3.0"
}, },
"dependencies": { "dependencies": {
"@promistream/end-of-stream": "^0.1.1", "@promistream/from-lazy-value": "^0.1.0",
"@promistream/simple-source": "^0.1.2",
"@validatem/core": "^0.3.13", "@validatem/core": "^0.3.13",
"@validatem/required": "^0.1.1" "@validatem/required": "^0.1.1"
} }

@ -56,6 +56,17 @@
default-value "^1.0.0" default-value "^1.0.0"
error-chain "^0.1.0" error-chain "^0.1.0"
"@promistream/from-lazy-value@^0.1.0":
version "0.1.0"
resolved "https://registry.yarnpkg.com/@promistream/from-lazy-value/-/from-lazy-value-0.1.0.tgz#6256fffced708cf46b47bf156ab3a9039db78334"
integrity sha512-LFLaOs4uS2BcMC8azaR2LN3bmQgjgyGtYA2Dv/uWhq7mksLz+xRAZ1vAnioMRRIatSIVOrbckI6xQfQ9TJxjNA==
dependencies:
"@promistream/end-of-stream" "^0.1.1"
"@promistream/simple-source" "^0.1.2"
"@validatem/core" "^0.3.13"
"@validatem/is-function" "^0.1.0"
"@validatem/required" "^0.1.1"
"@promistream/is-aborted@^0.1.1": "@promistream/is-aborted@^0.1.1":
version "0.1.1" version "0.1.1"
resolved "https://registry.yarnpkg.com/@promistream/is-aborted/-/is-aborted-0.1.1.tgz#58d714dbd5f20bf851c77339c2213128ac50f0bf" resolved "https://registry.yarnpkg.com/@promistream/is-aborted/-/is-aborted-0.1.1.tgz#58d714dbd5f20bf851c77339c2213128ac50f0bf"

Loading…
Cancel
Save