Browse Source

Initial commit

master
Sven Slootweg 4 months ago
commit
a148139303
  1. 3
      .eslintrc.js
  2. 1
      .gitignore
  3. 22
      example.js
  4. 24
      index.js
  5. 21
      package.json
  6. 1404
      yarn.lock

3
.eslintrc.js

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

1
.gitignore

@ -0,0 +1 @@
node_modules

22
example.js

@ -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 ]
});

24
index.js

@ -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");
}
});
};

21
package.json

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

1404
yarn.lock
File diff suppressed because it is too large
View File

Loading…
Cancel
Save