Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

callbag-concat

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

callbag-concat - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

.travis.yml

11

package.json
{
"name": "callbag-concat",
"version": "1.0.1",
"version": "1.1.0",
"description": "Callbag factory that concatenates data from multiple callbag sources",

@@ -9,5 +9,9 @@ "repository": {

},
"main": "readme.js",
"main": "readme.cjs.js",
"module": "readme.js",
"scripts": {
"test": "tape test.js"
"build": "rollup $npm_package_module -o $npm_package_main --f cjs",
"pretest": "npm run build",
"test": "tape test.js",
"prepare": "npm test"
},

@@ -20,4 +24,5 @@ "author": "staltz.com",

"devDependencies": {
"rollup": "^0.63.2",
"tape": "^4.8.0"
}
}

@@ -38,5 +38,3 @@ /**

const talkback = (t, d) => {
if (t === 1 || t === 2) {
sourceTalkback(t, d);
}
sourceTalkback(t, d);
};

@@ -53,7 +51,9 @@ (function next() {

else sourceTalkback(1);
} else if (t === 1) {
sink(1, d);
} else if (t === 2 && d) {
sink(2, d);
} else if (t === 2) {
i++;
next();
} else {
sink(t, d);
}

@@ -64,2 +64,2 @@ });

module.exports = concat;
export default concat;
const test = require('tape');
const concat = require('./readme');
const concat = require('.');

@@ -280,1 +280,103 @@ test('it concats 1 async finite listenable source', t => {

});
test('it passes unknown types up & down', t => {
t.plan(14);
const upwardsExpected = [
[0, 'function'],
[1, 'number'],
[11, 'string'],
[2, 'undefined'],
];
const downwardsExpected = [
[0, 'function'],
[1, 'number'],
[11, 'string'],
];
function makeSource() {
const source = (type, data) => {
const e = upwardsExpected.shift();
t.equals(type, e[0], 'upwards type is expected: ' + e[0]);
t.equals(typeof data, e[1], 'upwards data is expected: ' + e[1]);
if (type === 0) {
const sink = data;
sink(0, source);
sink(1, 42)
sink(11, 'unknown')
}
};
return source;
}
function makeSink(type, data) {
let talkback;
return (type, data) => {
const et = downwardsExpected.shift();
t.equals(type, et[0], 'downwards type is expected: ' + et[0]);
t.equals(typeof data, et[1], 'downwards data type is expected: ' + et[1]);
if (type === 0) {
talkback = data;
talkback(1, 57);
talkback(11, 'unknown');
talkback(2);
}
};
}
const source = concat(makeSource());
const sink = makeSink();
source(0, sink);
t.end();
});
test('it propagates source error to sink & doesn\'t subscribe to next source', t => {
t.plan(9);
const downwardsExpected = [
[0, 'function'],
[1, 'number'],
[1, 'number'],
[2, 'string'],
];
function makeSource() {
let limit = 2;
let value = 42;
const source = (type, data) => {
if (type !== 0) return;
const sink = data;
const id = setInterval(() => {
sink(1, value++);
if (--limit === 0) {
clearInterval(id);
sink(2, 'err');
}
}, 100);
sink(0, source);
};
return source;
}
function makeSink(type, data) {
let talkback;
return (type, data) => {
const et = downwardsExpected.shift();
t.equals(type, et[0], 'downwards type is expected: ' + et[0]);
t.equals(typeof data, et[1], 'downwards data type is expected: ' + et[1]);
};
}
const source = concat(makeSource(), makeSource());
const sink = makeSink();
source(0, sink);
setTimeout(() => {
t.pass('nothing else happens');
t.end();
}, 700);
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc