Browse Source

Initial commit

master
Sven Slootweg 1 year ago
commit
b8d2cc27ae
  1. 3
      .eslintrc
  2. 1
      .gitignore
  3. 17
      example.js
  4. 21
      index.js
  5. 20
      package.json
  6. 1174
      yarn.lock

3
.eslintrc

@ -0,0 +1,3 @@
{
"extends": "@joepie91/eslint-config"
}

1
.gitignore

@ -0,0 +1 @@
node_modules

17
example.js

@ -0,0 +1,17 @@
"use strict";
const Promise = require("bluebird");
const pipe = require("@ppstreams/pipe");
const collect = require("@ppstreams/collect");
const fromIterable = require("@ppstreams/from-iterable");
const join = require("./");
Promise.try(() => {
return pipe([
fromIterable([ 1, 2, 3, 4, 5 ]),
join(0),
collect()
]).read();
}).then((values) => {
console.log(values); // [ 1, 0, 2, 0, 3, 0, 4, 0, 5 ]
});

21
index.js

@ -0,0 +1,21 @@
"use strict";
const pipe = require("@ppstreams/pipe");
const map = require("@ppstreams/map");
const buffer = require("@ppstreams/buffer");
module.exports = function join(joinValue) {
let firstValueProcessed = false;
return pipe([
map((value) => {
if (firstValueProcessed === false) {
firstValueProcessed = true;
return [ value ];
} else {
return [ joinValue, value ];
}
}),
buffer()
]);
};

20
package.json

@ -0,0 +1,20 @@
{
"name": "@ppstreams/join",
"version": "0.1.0",
"main": "index.js",
"keywords": [
"ppstreams"
],
"repository": "http://git.cryto.net/joepie91/join.git",
"author": "Sven Slootweg <admin@cryto.net>",
"license": "WTFPL OR CC0-1.0",
"devDependencies": {
"@joepie91/eslint-config": "^1.1.0",
"@ppstreams/collect": "^0.1.0",
"bluebird": "^3.7.2",
"eslint": "^6.8.0"
},
"dependencies": {
"@ppstreams/pipe": "^0.1.1"
}
}

1174
yarn.lock

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