Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

ogen

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ogen - npm Package Compare versions

Comparing version
1.1.0
to
1.2.0
+1
-1
package.json
{
"name": "ogen",
"version": "1.1.0",
"version": "1.2.0",
"description": "An observable Async/Await. Write async code that looks synchronous.",

@@ -5,0 +5,0 @@ "main": "source/ogen.js",

@@ -15,3 +15,11 @@ /* eslint-disable no-use-before-define */

} = callbacks;
const item = iter.next(prev);
let item;
try {
item = iter.next(prev);
} catch (err) {
return onError(err);
}
const value = item.value;

@@ -18,0 +26,0 @@

@@ -105,3 +105,3 @@ const test = require('tape');

assert.pass(msg);
setTimeout(() => assert.end(), 500);
setTimeout(() => assert.end(), 10);
},

@@ -112,1 +112,60 @@ () => {

});
test('promise throw', assert => {
const msg = 'should notify onError';
const halt = 'should not emit more data';
const noComplete = 'should not notify onComplete';
const fetchSomething = () => new Promise(() => {
throw new Error('Could not fetch data');
});
const generator = function* () {
const result = yield fetchSomething();
// should not emit this
yield result + ' 2';
};
const observable = ogen(generator)();
observable.subscribe(val => {
assert.fail(halt);
assert.fail(`emitted: ${ val }`);
},
() => {
assert.pass(msg);
setTimeout(() => assert.end(), 10);
},
() => {
assert.fail(noComplete);
});
});
test('generator throw', assert => {
const msg = 'should notify onError';
const halt = 'should not emit more data';
const noComplete = 'should not notify onComplete';
const generator = function* () {
throw new Error('faulty generator');
/* eslint-disable no-unreachable */
yield 'should not emit this';
};
const observable = ogen(generator)();
observable.subscribe(val => {
assert.fail(halt);
assert.fail(`emitted: ${ val }`);
},
() => {
assert.pass(msg);
setTimeout(() => assert.end(), 10);
},
() => {
assert.fail(noComplete);
});
});