diff --git a/index.js b/index.js index 5f2a547..bf3a48d 100644 --- a/index.js +++ b/index.js @@ -3,22 +3,12 @@ const { validateArguments } = require("@validatem/core"); const required = require("@validatem/required"); -const EndOfStream = require("@promistream/end-of-stream"); -const simpleSource = require("@promistream/simple-source"); +const fromLazyValue = require("@promistream/from-lazy-value"); 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"); - } - }); + return fromLazyValue(() => value); }; diff --git a/package.json b/package.json index 73e098c..421574f 100644 --- a/package.json +++ b/package.json @@ -13,8 +13,7 @@ "eslint": "^6.3.0" }, "dependencies": { - "@promistream/end-of-stream": "^0.1.1", - "@promistream/simple-source": "^0.1.2", + "@promistream/from-lazy-value": "^0.1.0", "@validatem/core": "^0.3.13", "@validatem/required": "^0.1.1" } diff --git a/yarn.lock b/yarn.lock index 618c19d..cf95f7f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -56,6 +56,17 @@ default-value "^1.0.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": version "0.1.1" resolved "https://registry.yarnpkg.com/@promistream/is-aborted/-/is-aborted-0.1.1.tgz#58d714dbd5f20bf851c77339c2213128ac50f0bf"