update
This commit is contained in:
+8
-1
@@ -33,6 +33,11 @@ module.exports = Object.assign(
|
||||
async: function(args, resolve, reject) {
|
||||
const items = Array.from(args[0]);
|
||||
|
||||
if (items.length === 0) {
|
||||
Promise.resolve().then(() => resolve([]));
|
||||
return;
|
||||
}
|
||||
|
||||
let count = 0;
|
||||
const results = items.map(() => undefined);
|
||||
items.forEach((item, i) => {
|
||||
@@ -201,7 +206,9 @@ function buildOperation({ name, arity, sync, async }) {
|
||||
return setFunctionMetadata(name, arity, function*(...args) {
|
||||
const resume = yield GENSYNC_START;
|
||||
if (!resume) {
|
||||
return sync.call(this, args);
|
||||
// Break the tail call to avoid a bug in V8 v6.X with --harmony enabled.
|
||||
const res = sync.call(this, args);
|
||||
return res;
|
||||
}
|
||||
|
||||
let result;
|
||||
|
||||
+20
-12
@@ -1,36 +1,39 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"gensync@1.0.0-beta.1",
|
||||
"/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series"
|
||||
"gensync@1.0.0-beta.2",
|
||||
"/home/node/nuxt"
|
||||
]
|
||||
],
|
||||
"_from": "gensync@1.0.0-beta.1",
|
||||
"_id": "gensync@1.0.0-beta.1",
|
||||
"_from": "gensync@1.0.0-beta.2",
|
||||
"_id": "gensync@1.0.0-beta.2",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-r8EC6NO1sngH/zdD9fiRDLdcgnbayXah+mLgManTaIZJqEC1MZstmnox8KpnI2/fxQwrp5OpCOYWLp4rBl4Jcg==",
|
||||
"_integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==",
|
||||
"_location": "/gensync",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "gensync@1.0.0-beta.1",
|
||||
"raw": "gensync@1.0.0-beta.2",
|
||||
"name": "gensync",
|
||||
"escapedName": "gensync",
|
||||
"rawSpec": "1.0.0-beta.1",
|
||||
"rawSpec": "1.0.0-beta.2",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "1.0.0-beta.1"
|
||||
"fetchSpec": "1.0.0-beta.2"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/@babel/core"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.1.tgz",
|
||||
"_spec": "1.0.0-beta.1",
|
||||
"_where": "/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series",
|
||||
"_resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz",
|
||||
"_spec": "1.0.0-beta.2",
|
||||
"_where": "/home/node/nuxt",
|
||||
"author": {
|
||||
"name": "Logan Smyth",
|
||||
"email": "loganfsmyth@gmail.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/loganfsmyth/gensync/issues"
|
||||
},
|
||||
"description": "Allows users to use generators in order to write common functions that can be both sync or async.",
|
||||
"devDependencies": {
|
||||
"babel-core": "^6.26.3",
|
||||
@@ -46,6 +49,7 @@
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
},
|
||||
"homepage": "https://github.com/loganfsmyth/gensync",
|
||||
"keywords": [
|
||||
"async",
|
||||
"sync",
|
||||
@@ -56,8 +60,12 @@
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "gensync",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/loganfsmyth/gensync.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "jest"
|
||||
},
|
||||
"version": "1.0.0-beta.1"
|
||||
"version": "1.0.0-beta.2"
|
||||
}
|
||||
|
||||
+15
-1
@@ -181,7 +181,9 @@ describe("gensync({})", () => {
|
||||
test("default arity", () => {
|
||||
expect(
|
||||
gensync({
|
||||
sync: function(a, b, c, d, e, f, g){ throwTestError(); },
|
||||
sync: function(a, b, c, d, e, f, g) {
|
||||
throwTestError();
|
||||
},
|
||||
async: throwTestError,
|
||||
}).length
|
||||
).toBe(7);
|
||||
@@ -444,6 +446,18 @@ describe("gensync.all()", () => {
|
||||
syncErrback: false,
|
||||
});
|
||||
});
|
||||
|
||||
test("empty list", async () => {
|
||||
const fn = gensync(function*() {
|
||||
yield* gensync.all([]);
|
||||
});
|
||||
|
||||
await expectResult(fn, undefined, {
|
||||
value: undefined,
|
||||
expectSync: true,
|
||||
syncErrback: false,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("gensync.race()", () => {
|
||||
|
||||
Reference in New Issue
Block a user