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

callbag-from-iter

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

callbag-from-iter - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

7

index.js

@@ -9,6 +9,7 @@ const fromIter = iter => (start, sink) => {

let got1 = false;
let completed = false;
let res;
function loop() {
inloop = true;
while (got1) {
while (got1 && !completed) {
got1 = false;

@@ -22,5 +23,9 @@ res = iterator.next();

sink(0, t => {
if (completed) return
if (t === 1) {
got1 = true;
if (!inloop && !(res && res.done)) loop();
} else if (t === 2) {
completed = true;
}

@@ -27,0 +32,0 @@ });

6

package.json
{
"name": "callbag-from-iter",
"version": "1.0.0",
"version": "1.1.0",
"description": "Convert an iterable or iterator to a callbag pullable source",

@@ -15,3 +15,5 @@ "repository": {

"license": "MIT",
"keywords": ["callbag"],
"keywords": [
"callbag"
],
"devDependencies": {

@@ -18,0 +20,0 @@ "tape": "^4.8.0"

@@ -98,1 +98,33 @@ const test = require('tape');

});
test('it stops sending after source completion', t => {
t.plan(5);
const source = fromIter([10, 20, 30]);
const actual = [];
const downwardsExpectedTypes = [
[0, 'function'],
[1, 'number'],
];
let talkback;
source(0, (type, data) => {
const et = downwardsExpectedTypes.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);
return;
}
if (type === 1) {
actual.push(data);
talkback(2);
talkback(1);
talkback(1);
}
});
t.deepEquals(actual, [10]);
});
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