Browse Source

Build on @promistream/from-lazy-value instead

master
Sven Slootweg 4 months ago
parent
commit
5b9579954e
  1. 14
      index.js
  2. 3
      package.json
  3. 11
      yarn.lock

14
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);
};

3
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"
}

11
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"

Loading…
Cancel
Save