Created
August 16, 2017 12:59
-
-
Save benjamingr/a7c7cd7ff2ee69d3a71f0058d286ff9a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/benchmark/doxbee-sequential/callbacks-caolan-async-waterfall.js b/benchmark/doxbee-sequential/callbacks-caolan-async-waterfall.js | |
deleted file mode 100644 | |
index 439f9bba..00000000 | |
--- a/benchmark/doxbee-sequential/callbacks-caolan-async-waterfall.js | |
+++ /dev/null | |
@@ -1,71 +0,0 @@ | |
-require('../lib/fakes'); | |
-var async = require('async'); | |
- | |
-module.exports = function upload(stream, idOrPath, tag, done) { | |
- var blob = blobManager.create(account); | |
- var tx = db.begin(); | |
- var blobId, file, version, fileId; | |
- async.waterfall([ | |
- function writeBlob(callback) { | |
- blob.put(stream, callback); | |
- }, | |
- function afterBlobWritten(callback) { | |
- blobId = undefined // iBlobId; | |
- self.byUuidOrPath(idOrPath).get(callback); | |
- }, | |
- function afterFileFetched(callback) { | |
- file = undefined; //iFile; | |
- var previousId = file ? file.version : null; | |
- version = { | |
- userAccountId: userAccount.id, | |
- date: new Date(), | |
- blobId: blobId, | |
- creatorId: userAccount.id, | |
- previousId: previousId, | |
- mergedId: null, | |
- mergeType: 'mine', | |
- comment: '', | |
- tag: tag | |
- }; | |
- version.id = Version.createHash(version); | |
- Version.insert(version).execWithin(tx, callback); | |
- }, | |
- function afterVersionInserted(callback) { | |
- if (!file) { | |
- var splitPath = idOrPath.split('/'); | |
- var fileName = splitPath[splitPath.length - 1]; | |
- var newId = uuid.v1(); | |
- self.createQuery(idOrPath, { | |
- id: newId, | |
- userAccountId: userAccount.id, | |
- type: 'file', | |
- name: fileName, | |
- version: version.id | |
- }, function (err, q) { | |
- if (err) return backoff(err); | |
- q.execWithin(tx, function (err) { | |
- callback(err, newId); | |
- }); | |
- | |
- }) | |
- } | |
- else return callback(null, file.id); | |
- }, | |
- function afterFileExists(iFileId, callback) { | |
- fileId = iFileId; | |
- FileVersion.insert({fileId: fileId, versionId: version.id}) | |
- .execWithin(tx, callback); | |
- }, | |
- function afterFileVersionInserted(callback) { | |
- File.whereUpdate({id: fileId}, { version: version.id }) | |
- .execWithin(tx, callback); | |
- }, | |
- function afterFileUpdated(callback) { | |
- tx.commit(callback); | |
- } | |
- ], | |
- function (err) { | |
- if (err) tx.rollback(); | |
- done(err); | |
- }); | |
-} | |
diff --git a/benchmark/doxbee-sequential/callbacks-suguru03-neo-async-waterfall.js b/benchmark/doxbee-sequential/callbacks-suguru03-neo-async-waterfall.js | |
deleted file mode 100644 | |
index 2c734aeb..00000000 | |
--- a/benchmark/doxbee-sequential/callbacks-suguru03-neo-async-waterfall.js | |
+++ /dev/null | |
@@ -1,71 +0,0 @@ | |
-require('../lib/fakes'); | |
-var async = require('neo-async'); | |
- | |
-module.exports = function upload(stream, idOrPath, tag, done) { | |
- var blob = blobManager.create(account); | |
- var tx = db.begin(); | |
- var blobId, file, version, fileId; | |
- async.waterfall([ | |
- function writeBlob(callback) { | |
- blob.put(stream, callback); | |
- }, | |
- function afterBlobWritten(callback) { | |
- blobId = undefined // iBlobId; | |
- self.byUuidOrPath(idOrPath).get(callback); | |
- }, | |
- function afterFileFetched(callback) { | |
- file = undefined; //iFile; | |
- var previousId = file ? file.version : null; | |
- version = { | |
- userAccountId: userAccount.id, | |
- date: new Date(), | |
- blobId: blobId, | |
- creatorId: userAccount.id, | |
- previousId: previousId, | |
- mergedId: null, | |
- mergeType: 'mine', | |
- comment: '', | |
- tag: tag | |
- }; | |
- version.id = Version.createHash(version); | |
- Version.insert(version).execWithin(tx, callback); | |
- }, | |
- function afterVersionInserted(callback) { | |
- if (!file) { | |
- var splitPath = idOrPath.split('/'); | |
- var fileName = splitPath[splitPath.length - 1]; | |
- var newId = uuid.v1(); | |
- self.createQuery(idOrPath, { | |
- id: newId, | |
- userAccountId: userAccount.id, | |
- type: 'file', | |
- name: fileName, | |
- version: version.id | |
- }, function (err, q) { | |
- if (err) return backoff(err); | |
- q.execWithin(tx, function (err) { | |
- callback(err, newId); | |
- }); | |
- | |
- }) | |
- } | |
- else return callback(null, file.id); | |
- }, | |
- function afterFileExists(iFileId, callback) { | |
- fileId = iFileId; | |
- FileVersion.insert({fileId: fileId, versionId: version.id}) | |
- .execWithin(tx, callback); | |
- }, | |
- function afterFileVersionInserted(callback) { | |
- File.whereUpdate({id: fileId}, { version: version.id }) | |
- .execWithin(tx, callback); | |
- }, | |
- function afterFileUpdated(callback) { | |
- tx.commit(callback); | |
- } | |
- ], | |
- function (err) { | |
- if (err) tx.rollback(); | |
- done(err); | |
- }); | |
-} | |
diff --git a/benchmark/doxbee-sequential/generators-tj-co.js b/benchmark/doxbee-sequential/generators-tj-co.js | |
deleted file mode 100644 | |
index 4dd2290a..00000000 | |
--- a/benchmark/doxbee-sequential/generators-tj-co.js | |
+++ /dev/null | |
@@ -1,53 +0,0 @@ | |
-global.useNative = true; | |
- | |
-try { | |
- if (Promise.race.toString() !== 'function race() { [native code] }') | |
- throw 0; | |
-} catch (e) { | |
- throw new Error("No ES6 promises available"); | |
-} | |
-var co = require("co"); | |
-require('../lib/fakesP'); | |
- | |
-module.exports = function upload(stream, idOrPath, tag, done) { | |
- co(function* () { | |
- try { | |
- var blob = blobManager.create(account); | |
- var tx = db.begin(); | |
- var blobId = yield blob.put(stream); | |
- var file = yield self.byUuidOrPath(idOrPath).get(); | |
- | |
- var previousId = file ? file.version : null; | |
- version = { | |
- userAccountId: userAccount.id, | |
- date: new Date(), | |
- blobId: blobId, | |
- creatorId: userAccount.id, | |
- previousId: previousId, | |
- }; | |
- version.id = Version.createHash(version); | |
- yield Version.insert(version).execWithin(tx); | |
- if (!file) { | |
- var splitPath = idOrPath.split('/'); | |
- var fileName = splitPath[splitPath.length - 1]; | |
- file = { | |
- id: uuid.v1(), | |
- userAccountId: userAccount.id, | |
- name: fileName, | |
- version: version.id | |
- } | |
- var query = yield self.createQuery(idOrPath, file); | |
- yield query.execWithin(tx); | |
- } | |
- yield FileVersion.insert({fileId: file.id, versionId: version.id}) | |
- .execWithin(tx); | |
- yield File.whereUpdate({id: file.id}, {version: version.id}) | |
- .execWithin(tx); | |
- tx.commit(); | |
- done(); | |
- } catch (err) { | |
- tx.rollback(); | |
- done(err); | |
- } | |
- }); | |
-}; | |
diff --git a/benchmark/doxbee-sequential/observables-Reactive-Extensions-RxJS.js b/benchmark/doxbee-sequential/observables-Reactive-Extensions-RxJS.js | |
deleted file mode 100644 | |
index 85bc5eb9..00000000 | |
--- a/benchmark/doxbee-sequential/observables-Reactive-Extensions-RxJS.js | |
+++ /dev/null | |
@@ -1,62 +0,0 @@ | |
-global.useRx = true; | |
-var Rx = require('rx'); | |
-require('../lib/fakesObservable'); | |
- | |
-module.exports = function upload(stream, idOrPath, tag, done) { | |
- var blob = blobManager.create(account); | |
- var tx = db.begin(); | |
- var blobIdP = blob.put(stream); | |
- var fileP = self.byUuidOrPath(idOrPath).get(); | |
- var version, fileId, file; | |
- | |
- | |
- Rx.Observable.forkJoin(blobIdP, fileP).flatMap(function(v) { | |
- file = v[1]; | |
- var blobId = v[0]; | |
- var previousId = file ? file.version : null; | |
- version = { | |
- userAccountId: userAccount.id, | |
- date: new Date(), | |
- blobId: blobId, | |
- creatorId: userAccount.id, | |
- previousId: previousId, | |
- }; | |
- version.id = Version.createHash(version); | |
- return Version.insert(version).execWithin(tx); | |
- }).flatMap(function() { | |
- if (!file) { | |
- var splitPath = idOrPath.split('/'); | |
- var fileName = splitPath[splitPath.length - 1]; | |
- var newId = uuid.v1(); | |
- return self.createQuery(idOrPath, { | |
- id: newId, | |
- userAccountId: userAccount.id, | |
- name: fileName, | |
- version: version.id | |
- }).flatMap(function(q) { | |
- return q.execWithin(tx); | |
- }).map(function() { | |
- return newId; | |
- }); | |
- } else { | |
- return Rx.Observable.return(file.id); | |
- } | |
- }).flatMap(function(fileIdV) { | |
- fileId = fileIdV; | |
- return FileVersion.insert({ | |
- fileId: fileId, | |
- versionId: version.id | |
- }).execWithin(tx); | |
- }).flatMap(function() { | |
- return File.whereUpdate({id: fileId}, {version: version.id}) | |
- .execWithin(tx); | |
- }).subscribe(function() { | |
- | |
- }, function() { | |
- tx.rollback(); | |
- done(err); | |
- }, function() { | |
- tx.commit(); | |
- done(); | |
- }); | |
-} | |
diff --git a/benchmark/doxbee-sequential/observables-baconjs-bacon.js.js b/benchmark/doxbee-sequential/observables-baconjs-bacon.js.js | |
deleted file mode 100644 | |
index 822b38c7..00000000 | |
--- a/benchmark/doxbee-sequential/observables-baconjs-bacon.js.js | |
+++ /dev/null | |
@@ -1,62 +0,0 @@ | |
-global.useBacon = true; | |
-var Bacon = require('baconjs').Bacon; | |
-require('../lib/fakesObservable'); | |
- | |
-module.exports = function upload(stream, idOrPath, tag, done) { | |
- var blob = blobManager.create(account); | |
- var tx = db.begin(); | |
- var blobIdP = blob.put(stream); | |
- var fileP = self.byUuidOrPath(idOrPath).get(); | |
- var version, fileId, file; | |
- | |
- | |
- var stream = Bacon.combineAsArray(blobIdP, fileP).flatMap(function(v) { | |
- file = v[1]; | |
- var blobId = v[0]; | |
- var previousId = file ? file.version : null; | |
- version = { | |
- userAccountId: userAccount.id, | |
- date: new Date(), | |
- blobId: blobId, | |
- creatorId: userAccount.id, | |
- previousId: previousId, | |
- }; | |
- version.id = Version.createHash(version); | |
- return Version.insert(version).execWithin(tx); | |
- }).flatMap(function() { | |
- if (!file) { | |
- var splitPath = idOrPath.split('/'); | |
- var fileName = splitPath[splitPath.length - 1]; | |
- var newId = uuid.v1(); | |
- return self.createQuery(idOrPath, { | |
- id: newId, | |
- userAccountId: userAccount.id, | |
- name: fileName, | |
- version: version.id | |
- }).flatMap(function(q) { | |
- return q.execWithin(tx); | |
- }).map(function() { | |
- return newId; | |
- }); | |
- } else { | |
- return Bacon.constant(file.id); | |
- } | |
- }).flatMap(function(fileIdV) { | |
- fileId = fileIdV; | |
- return FileVersion.insert({ | |
- fileId: fileId, | |
- versionId: version.id | |
- }).execWithin(tx); | |
- }).flatMap(function() { | |
- return File.whereUpdate({id: fileId}, {version: version.id}) | |
- .execWithin(tx); | |
- }); | |
- stream.onError(function() { | |
- tx.rollback(); | |
- done(err); | |
- }); | |
- stream.onValue(function() { | |
- tx.commit(); | |
- done(); | |
- }); | |
-} | |
diff --git a/benchmark/doxbee-sequential/observables-caolan-highland.js b/benchmark/doxbee-sequential/observables-caolan-highland.js | |
deleted file mode 100644 | |
index e8272b13..00000000 | |
--- a/benchmark/doxbee-sequential/observables-caolan-highland.js | |
+++ /dev/null | |
@@ -1,57 +0,0 @@ | |
-global.useHighland = true; | |
-var _ = require("highland"); | |
-require('../lib/fakesObservable'); | |
- | |
-module.exports = function upload(stream, idOrPath, tag, done) { | |
- var blob = blobManager.create(account); | |
- var tx = db.begin(); | |
- var blobIdP = blob.put(stream); | |
- var fileP = self.byUuidOrPath(idOrPath).get(); | |
- var version, fileId, file; | |
- | |
- _([blobIdP, fileP]).merge().apply(function(blobId, file) { | |
- var previousId = file ? file.version : null; | |
- version = { | |
- userAccountId: userAccount.id, | |
- date: new Date(), | |
- blobId: blobId, | |
- creatorId: userAccount.id, | |
- previousId: previousId, | |
- }; | |
- version.id = Version.createHash(version); | |
- Version.insert(version).execWithin(tx).flatMap(function() { | |
- if (!file) { | |
- var splitPath = idOrPath.split('/'); | |
- var fileName = splitPath[splitPath.length - 1]; | |
- var newId = uuid.v1(); | |
- return self.createQuery(idOrPath, { | |
- id: newId, | |
- userAccountId: userAccount.id, | |
- name: fileName, | |
- version: version.id | |
- }).flatMap(function(q) { | |
- return q.execWithin(tx); | |
- }).map(function() { | |
- return newId; | |
- }); | |
- } else { | |
- return _([file.id]); | |
- } | |
- }).flatMap(function(fileIdV) { | |
- fileId = fileIdV; | |
- return FileVersion.insert({ | |
- fileId: fileId, | |
- versionId: version.id | |
- }).execWithin(tx); | |
- }).flatMap(function() { | |
- return File.whereUpdate({id: fileId}, {version: version.id}) | |
- .execWithin(tx); | |
- }).stopOnError(function(err) { | |
- tx.rollback(); | |
- done(err); | |
- }).apply(function(v) { | |
- tx.commit(); | |
- done(); | |
- }); | |
- }); | |
-} | |
diff --git a/benchmark/doxbee-sequential/observables-pozadi-kefir.js b/benchmark/doxbee-sequential/observables-pozadi-kefir.js | |
deleted file mode 100644 | |
index f0ea1579..00000000 | |
--- a/benchmark/doxbee-sequential/observables-pozadi-kefir.js | |
+++ /dev/null | |
@@ -1,62 +0,0 @@ | |
-global.useKefir = true; | |
-var Kefir = require('kefir').Kefir; | |
-require('../lib/fakesObservable'); | |
- | |
-module.exports = function upload(stream, idOrPath, tag, done) { | |
- var blob = blobManager.create(account); | |
- var tx = db.begin(); | |
- var blobIdP = blob.put(stream); | |
- var fileP = self.byUuidOrPath(idOrPath).get(); | |
- var version, fileId, file; | |
- | |
- | |
- var stream = Kefir.zip([blobIdP, fileP]).flatMap(function(v) { | |
- file = v[1]; | |
- var blobId = v[0]; | |
- var previousId = file ? file.version : null; | |
- version = { | |
- userAccountId: userAccount.id, | |
- date: new Date(), | |
- blobId: blobId, | |
- creatorId: userAccount.id, | |
- previousId: previousId, | |
- }; | |
- version.id = Version.createHash(version); | |
- return Version.insert(version).execWithin(tx); | |
- }).flatMap(function() { | |
- if (!file) { | |
- var splitPath = idOrPath.split('/'); | |
- var fileName = splitPath[splitPath.length - 1]; | |
- var newId = uuid.v1(); | |
- return self.createQuery(idOrPath, { | |
- id: newId, | |
- userAccountId: userAccount.id, | |
- name: fileName, | |
- version: version.id | |
- }).flatMap(function(q) { | |
- return q.execWithin(tx); | |
- }).map(function() { | |
- return newId; | |
- }); | |
- } else { | |
- return Kefir.constant(file.id); | |
- } | |
- }).flatMap(function(fileIdV) { | |
- fileId = fileIdV; | |
- return FileVersion.insert({ | |
- fileId: fileId, | |
- versionId: version.id | |
- }).execWithin(tx); | |
- }).flatMap(function() { | |
- return File.whereUpdate({id: fileId}, {version: version.id}) | |
- .execWithin(tx); | |
- }); | |
- stream.onError(function() { | |
- tx.rollback(); | |
- done(err); | |
- }); | |
- stream.onValue(function() { | |
- tx.commit(); | |
- done(); | |
- }); | |
-} | |
diff --git a/benchmark/doxbee-sequential/promises-calvinmetcalf-lie.js b/benchmark/doxbee-sequential/promises-calvinmetcalf-lie.js | |
deleted file mode 100644 | |
index f041e19f..00000000 | |
--- a/benchmark/doxbee-sequential/promises-calvinmetcalf-lie.js | |
+++ /dev/null | |
@@ -1,61 +0,0 @@ | |
-global.useLie = true; | |
- | |
-var promise = require("lie"); | |
- | |
-require('../lib/fakesP'); | |
- | |
- | |
-module.exports = function upload(stream, idOrPath, tag, done) { | |
- var blob = blobManager.create(account); | |
- var tx = db.begin(); | |
- var blobIdP = blob.put(stream); | |
- var fileP = self.byUuidOrPath(idOrPath).get(); | |
- var version, fileId, file; | |
- promise.all([blobIdP, fileP]).then(function(all) { | |
- var blobId = all[0], fileV = all[1]; | |
- file = fileV; | |
- var previousId = file ? file.version : null; | |
- version = { | |
- userAccountId: userAccount.id, | |
- date: new Date(), | |
- blobId: blobId, | |
- creatorId: userAccount.id, | |
- previousId: previousId, | |
- }; | |
- version.id = Version.createHash(version); | |
- return Version.insert(version).execWithin(tx); | |
- }).then(function() { | |
- if (!file) { | |
- var splitPath = idOrPath.split('/'); | |
- var fileName = splitPath[splitPath.length - 1]; | |
- var newId = uuid.v1(); | |
- return self.createQueryCtxless(idOrPath, { | |
- id: newId, | |
- userAccountId: userAccount.id, | |
- name: fileName, | |
- version: version.id | |
- }).then(function(q) { | |
- return q.execWithin(tx); | |
- }).then(function() { | |
- return newId; | |
- }); | |
- } else { | |
- return file.id; | |
- } | |
- }).then(function(fileIdV) { | |
- fileId = fileIdV; | |
- return FileVersion.insert({ | |
- fileId: fileId, | |
- versionId: version.id | |
- }).execWithin(tx); | |
- }).then(function() { | |
- return File.whereUpdate({id: fileId}, {version: version.id}) | |
- .execWithin(tx); | |
- }).then(function() { | |
- tx.commit(); | |
- return done(); | |
- }, function(err) { | |
- tx.rollback(); | |
- return done(err); | |
- }); | |
-} | |
diff --git a/benchmark/doxbee-sequential/promises-cujojs-when.js b/benchmark/doxbee-sequential/promises-cujojs-when.js | |
deleted file mode 100644 | |
index fffadd37..00000000 | |
--- a/benchmark/doxbee-sequential/promises-cujojs-when.js | |
+++ /dev/null | |
@@ -1,59 +0,0 @@ | |
-var when = require('when'), | |
- fn = require('when/function'), | |
- p = require('../lib/promiseSupport.js'); | |
- | |
-require('../lib/fakesP'); | |
- | |
-module.exports = function upload(stream, idOrPath, tag, done) { | |
- var blob = blobManager.create(account); | |
- var tx = db.begin(); | |
- var blobIdP = blob.put(stream); | |
- var fileP = self.byUuidOrPath(idOrPath).get(); | |
- var version, fileId, file; | |
- when([blobIdP, fileP]).spread(function(blobId, fileV) { | |
- file = fileV; | |
- var previousId = file ? file.version : null; | |
- version = { | |
- userAccountId: userAccount.id, | |
- date: new Date(), | |
- blobId: blobId, | |
- creatorId: userAccount.id, | |
- previousId: previousId, | |
- }; | |
- version.id = Version.createHash(version); | |
- return Version.insert(version).execWithin(tx); | |
- }).then(function() { | |
- if (!file) { | |
- var splitPath = idOrPath.split('/'); | |
- var fileName = splitPath[splitPath.length - 1]; | |
- var newId = uuid.v1(); | |
- return self.createQuery(idOrPath, { | |
- id: newId, | |
- userAccountId: userAccount.id, | |
- name: fileName, | |
- version: version.id | |
- }).then(function(q) { | |
- return q.execWithin(tx); | |
- }).then(function() { | |
- return newId; | |
- }); | |
- } else { | |
- return file.id; | |
- } | |
- }).then(function(fileIdV) { | |
- fileId = fileIdV; | |
- return FileVersion.insert({ | |
- fileId: fileId, | |
- versionId: version.id | |
- }).execWithin(tx); | |
- }).then(function() { | |
- return File.whereUpdate({id: fileId}, {version: version.id}) | |
- .execWithin(tx); | |
- }).then(function() { | |
- tx.commit(); | |
- return done(); | |
- }, function(err) { | |
- tx.rollback(); | |
- return done(err); | |
- }); | |
-} | |
diff --git a/benchmark/doxbee-sequential/promises-ecmascript6-asyncawait.js b/benchmark/doxbee-sequential/promises-ecmascript6-asyncawait.js | |
new file mode 100644 | |
index 00000000..5a9b7c7c | |
--- /dev/null | |
+++ b/benchmark/doxbee-sequential/promises-ecmascript6-asyncawait.js | |
@@ -0,0 +1,57 @@ | |
+global.useNativeNoPromisify = true; | |
+ | |
+try { | |
+ if (Promise.race.toString() !== 'function race() { [native code] }') | |
+ throw 0; | |
+} catch (e) { | |
+ throw new Error("No ES6 promises available"); | |
+} | |
+ | |
+require('../lib/fakesP'); | |
+ | |
+module.exports = async function upload(stream, idOrPath, tag, done) { | |
+ const blob = blobManager.create(account); | |
+ const tx = db.begin(); | |
+ var fileP = self.byUuidOrPath(idOrPath).get(); | |
+ try { | |
+ const [blobId, file] = await Promise.all([blob.put(stream), fileP]); | |
+ const previousId = file ? file.version : null; | |
+ const version = { | |
+ userAccountId: userAccount.id, | |
+ date: new Date(), | |
+ blobId: blobId, | |
+ creatorId: userAccount.id, | |
+ previousId: previousId, | |
+ }; | |
+ version.id = Version.createHash(version); | |
+ await Version.insert(version).execWithin(tx); | |
+ const fileId = getFileId(file, idOrPath, version, tx); | |
+ await FileVersion.insert({ | |
+ fileId: fileId, | |
+ versionId: version.id | |
+ }).execWithin(tx); | |
+ await File.whereUpdate({id: fileId}, {version: version.id}).execWithin(tx); | |
+ tx.commit(); | |
+ done(); | |
+ } catch (e) { | |
+ tx.rollback() | |
+ done(e); | |
+ } | |
+} | |
+ | |
+async function getFileId(file, idOrPath, version, tx) { | |
+ if (file) { | |
+ return file.id; | |
+ } | |
+ const splitPath = idOrPath.split('/'); | |
+ const fileName = splitPath[splitPath.length - 1]; | |
+ const newId = uuid.v1(); | |
+ const q = await self.createQuery(idOrPath, { | |
+ id: newId, | |
+ userAccountId: userAccount.id, | |
+ name: fileName, | |
+ version: version.id | |
+ }); | |
+ await q.execWithin(tx); | |
+ return newId; | |
+} | |
diff --git a/benchmark/doxbee-sequential/promises-dfilatov-vow.js b/benchmark/doxbee-sequential/promises-ecmascript6-native-base.js | |
similarity index 84% | |
rename from benchmark/doxbee-sequential/promises-dfilatov-vow.js | |
rename to benchmark/doxbee-sequential/promises-ecmascript6-native-base.js | |
index 812d8818..a4014edb 100644 | |
--- a/benchmark/doxbee-sequential/promises-dfilatov-vow.js | |
+++ b/benchmark/doxbee-sequential/promises-ecmascript6-native-base.js | |
@@ -1,5 +1,11 @@ | |
-var vow = require('vow'), | |
- p = require('../lib/promiseSupport.js'); | |
+global.useNativeNoPromisify = true; | |
+ | |
+try { | |
+ if (Promise.race.toString() !== 'function race() { [native code] }') | |
+ throw 0; | |
+} catch (e) { | |
+ throw new Error("No ES6 promises available"); | |
+} | |
require('../lib/fakesP'); | |
@@ -10,7 +16,9 @@ module.exports = function upload(stream, idOrPath, tag, done) { | |
var fileP = self.byUuidOrPath(idOrPath).get(); | |
var version, fileId, file; | |
- vow.all([blobIdP, fileP]).spread(function(blobId, fileV) { | |
+ Promise.all([blobIdP, fileP]).then(function(result) { | |
+ var blobId = result[0]; | |
+ var fileV = result[1]; | |
file = fileV; | |
var previousId = file ? file.version : null; | |
version = { | |
@@ -57,3 +65,4 @@ module.exports = function upload(stream, idOrPath, tag, done) { | |
return done(err); | |
}); | |
} | |
+ | |
diff --git a/benchmark/doxbee-sequential/promises-ecmascript6-native.js b/benchmark/doxbee-sequential/promises-ecmascript6-native-promisify.js | |
similarity index 98% | |
rename from benchmark/doxbee-sequential/promises-ecmascript6-native.js | |
rename to benchmark/doxbee-sequential/promises-ecmascript6-native-promisify.js | |
index 7bcd018c..a8e2c271 100644 | |
--- a/benchmark/doxbee-sequential/promises-ecmascript6-native.js | |
+++ b/benchmark/doxbee-sequential/promises-ecmascript6-native-promisify.js | |
@@ -1,4 +1,4 @@ | |
-global.useNative = true; | |
+global.useNativePromisify = true; | |
try { | |
if (Promise.race.toString() !== 'function race() { [native code] }') | |
diff --git a/benchmark/doxbee-sequential/promises-kriskowal-q.js b/benchmark/doxbee-sequential/promises-kriskowal-q.js | |
deleted file mode 100644 | |
index a1345c0e..00000000 | |
--- a/benchmark/doxbee-sequential/promises-kriskowal-q.js | |
+++ /dev/null | |
@@ -1,59 +0,0 @@ | |
-global.useQ = true; | |
- | |
-var q = require('q'); | |
- | |
-require('../lib/fakesP'); | |
- | |
-module.exports = function upload(stream, idOrPath, tag, done) { | |
- var blob = blobManager.create(account); | |
- var tx = db.begin(); | |
- var blobIdP = blob.put(stream); | |
- var fileP = self.byUuidOrPath(idOrPath).get(); | |
- var version, fileId, file; | |
- q.spread([blobIdP, fileP], function(blobId, fileV) { | |
- file = fileV; | |
- var previousId = file ? file.version : null; | |
- version = { | |
- userAccountId: userAccount.id, | |
- date: new Date(), | |
- blobId: blobId, | |
- creatorId: userAccount.id, | |
- previousId: previousId, | |
- }; | |
- version.id = Version.createHash(version); | |
- return Version.insert(version).execWithin(tx); | |
- }).then(function() { | |
- if (!file) { | |
- var splitPath = idOrPath.split('/'); | |
- var fileName = splitPath[splitPath.length - 1]; | |
- var newId = uuid.v1(); | |
- return self.createQuery(idOrPath, { | |
- id: newId, | |
- userAccountId: userAccount.id, | |
- name: fileName, | |
- version: version.id | |
- }).then(function(q) { | |
- return q.execWithin(tx); | |
- }).then(function() { | |
- return newId; | |
- }); | |
- } else { | |
- return file.id; | |
- } | |
- }).then(function(fileIdV) { | |
- fileId = fileIdV; | |
- return FileVersion.insert({ | |
- fileId: fileId, | |
- versionId: version.id | |
- }).execWithin(tx); | |
- }).then(function() { | |
- return File.whereUpdate({id: fileId}, {version: version.id}) | |
- .execWithin(tx); | |
- }).then(function() { | |
- tx.commit(); | |
- return done(); | |
- }, function(err) { | |
- tx.rollback(); | |
- return done(err); | |
- }); | |
-} | |
diff --git a/benchmark/doxbee-sequential/promises-lvivski-davy.js b/benchmark/doxbee-sequential/promises-lvivski-davy.js | |
deleted file mode 100755 | |
index 47fe5e81..00000000 | |
--- a/benchmark/doxbee-sequential/promises-lvivski-davy.js | |
+++ /dev/null | |
@@ -1,58 +0,0 @@ | |
-global.useDavy = true; | |
-var davy = require('davy'); | |
-require('../lib/fakesP'); | |
- | |
-module.exports = function upload(stream, idOrPath, tag, done) { | |
- var blob = blobManager.create(account); | |
- var tx = db.begin(); | |
- var blobIdP = blob.put(stream); | |
- var fileP = self.byUuidOrPath(idOrPath).get(); | |
- var version, fileId, file; | |
- | |
- davy.all([blobIdP, fileP]).spread(function(blobId, fileV) { | |
- file = fileV; | |
- var previousId = file ? file.version : null; | |
- version = { | |
- userAccountId: userAccount.id, | |
- date: new Date(), | |
- blobId: blobId, | |
- creatorId: userAccount.id, | |
- previousId: previousId, | |
- }; | |
- version.id = Version.createHash(version); | |
- return Version.insert(version).execWithin(tx); | |
- }).then(function() { | |
- if (!file) { | |
- var splitPath = idOrPath.split('/'); | |
- var fileName = splitPath[splitPath.length - 1]; | |
- var newId = uuid.v1(); | |
- return self.createQuery(idOrPath, { | |
- id: newId, | |
- userAccountId: userAccount.id, | |
- name: fileName, | |
- version: version.id | |
- }).then(function(q) { | |
- return q.execWithin(tx); | |
- }).then(function() { | |
- return newId; | |
- }); | |
- } else { | |
- return file.id; | |
- } | |
- }).then(function(fileIdV) { | |
- fileId = fileIdV; | |
- return FileVersion.insert({ | |
- fileId: fileId, | |
- versionId: version.id | |
- }).execWithin(tx); | |
- }).then(function() { | |
- return File.whereUpdate({id: fileId}, {version: version.id}) | |
- .execWithin(tx); | |
- }).then(function() { | |
- tx.commit(); | |
- return done(); | |
- }, function(err) { | |
- tx.rollback(); | |
- return done(err); | |
- }); | |
-} | |
diff --git a/benchmark/doxbee-sequential/promises-medikoo-deferred.js b/benchmark/doxbee-sequential/promises-medikoo-deferred.js | |
deleted file mode 100644 | |
index 908065e8..00000000 | |
--- a/benchmark/doxbee-sequential/promises-medikoo-deferred.js | |
+++ /dev/null | |
@@ -1,65 +0,0 @@ | |
-global.useDeferred = true; | |
- | |
-var deferred = require('deferred'); | |
- | |
-require('../lib/fakesP'); | |
- | |
-function identity(v) { | |
- return v; | |
-} | |
- | |
-module.exports = function upload(stream, idOrPath, tag, done) { | |
- var blob = blobManager.create(account); | |
- var tx = db.begin(); | |
- var blobIdP = blob.put(stream); | |
- var fileP = self.byUuidOrPath(idOrPath).get(); | |
- var version, fileId, file; | |
- //Couldn't find .all in docs, this seems closest | |
- deferred.map([blobIdP, fileP], identity)(function(all) { | |
- var blobId = all[0], fileV = all[1]; | |
- file = fileV; | |
- var previousId = file ? file.version : null; | |
- version = { | |
- userAccountId: userAccount.id, | |
- date: new Date(), | |
- blobId: blobId, | |
- creatorId: userAccount.id, | |
- previousId: previousId, | |
- }; | |
- version.id = Version.createHash(version); | |
- return Version.insert(version).execWithin(tx); | |
- })(function() { | |
- if (!file) { | |
- var splitPath = idOrPath.split('/'); | |
- var fileName = splitPath[splitPath.length - 1]; | |
- var newId = uuid.v1(); | |
- return self.createQueryCtxless(idOrPath, { | |
- id: newId, | |
- userAccountId: userAccount.id, | |
- name: fileName, | |
- version: version.id | |
- })(function(q) { | |
- return q.execWithin(tx); | |
- })(function() { | |
- return newId; | |
- }); | |
- } else { | |
- return file.id; | |
- } | |
- })(function(fileIdV) { | |
- fileId = fileIdV; | |
- return FileVersion.insert({ | |
- fileId: fileId, | |
- versionId: version.id | |
- }).execWithin(tx); | |
- })(function() { | |
- return File.whereUpdate({id: fileId}, {version: version.id}) | |
- .execWithin(tx); | |
- })(function() { | |
- tx.commit(); | |
- return done(); | |
- }, function(err) { | |
- tx.rollback(); | |
- return done(err); | |
- }); | |
-} | |
diff --git a/benchmark/doxbee-sequential/promises-obvious-kew.js b/benchmark/doxbee-sequential/promises-obvious-kew.js | |
deleted file mode 100644 | |
index 3d154b46..00000000 | |
--- a/benchmark/doxbee-sequential/promises-obvious-kew.js | |
+++ /dev/null | |
@@ -1,60 +0,0 @@ | |
-global.useKew = true; | |
- | |
-var q = require('kew'); | |
- | |
-require('../lib/fakesP'); | |
- | |
-module.exports = function upload(stream, idOrPath, tag, done) { | |
- var blob = blobManager.create(account); | |
- var tx = db.begin(); | |
- var blobIdP = blob.put(stream); | |
- var fileP = self.byUuidOrPath(idOrPath).get(); | |
- var version, fileId, file; | |
- q.all([blobIdP, fileP]).then(function(all) { | |
- var blobId = all[0], fileV = all[1]; | |
- file = fileV; | |
- var previousId = file ? file.version : null; | |
- version = { | |
- userAccountId: userAccount.id, | |
- date: new Date(), | |
- blobId: blobId, | |
- creatorId: userAccount.id, | |
- previousId: previousId, | |
- }; | |
- version.id = Version.createHash(version); | |
- return Version.insert(version).execWithin(tx); | |
- }).then(function() { | |
- if (!file) { | |
- var splitPath = idOrPath.split('/'); | |
- var fileName = splitPath[splitPath.length - 1]; | |
- var newId = uuid.v1(); | |
- return self.createQueryCtxless(idOrPath, { | |
- id: newId, | |
- userAccountId: userAccount.id, | |
- name: fileName, | |
- version: version.id | |
- }).then(function(q) { | |
- return q.execWithin(tx); | |
- }).then(function() { | |
- return newId; | |
- }); | |
- } else { | |
- return file.id; | |
- } | |
- }).then(function(fileIdV) { | |
- fileId = fileIdV; | |
- return FileVersion.insert({ | |
- fileId: fileId, | |
- versionId: version.id | |
- }).execWithin(tx); | |
- }).then(function() { | |
- return File.whereUpdate({id: fileId}, {version: version.id}) | |
- .execWithin(tx); | |
- }).then(function() { | |
- tx.commit(); | |
- return done(); | |
- }, function(err) { | |
- tx.rollback(); | |
- return done(err); | |
- }); | |
-} | |
diff --git a/benchmark/doxbee-sequential/promises-then-promise.js b/benchmark/doxbee-sequential/promises-then-promise.js | |
deleted file mode 100644 | |
index dfb56a6c..00000000 | |
--- a/benchmark/doxbee-sequential/promises-then-promise.js | |
+++ /dev/null | |
@@ -1,61 +0,0 @@ | |
-global.useThenPromise = true; | |
- | |
-var promise = require("promise"); | |
- | |
-require('../lib/fakesP'); | |
- | |
- | |
-module.exports = function upload(stream, idOrPath, tag, done) { | |
- var blob = blobManager.create(account); | |
- var tx = db.begin(); | |
- var blobIdP = blob.put(stream); | |
- var fileP = self.byUuidOrPath(idOrPath).get(); | |
- var version, fileId, file; | |
- promise.all([blobIdP, fileP]).then(function(all) { | |
- var blobId = all[0], fileV = all[1]; | |
- file = fileV; | |
- var previousId = file ? file.version : null; | |
- version = { | |
- userAccountId: userAccount.id, | |
- date: new Date(), | |
- blobId: blobId, | |
- creatorId: userAccount.id, | |
- previousId: previousId, | |
- }; | |
- version.id = Version.createHash(version); | |
- return Version.insert(version).execWithin(tx); | |
- }).then(function() { | |
- if (!file) { | |
- var splitPath = idOrPath.split('/'); | |
- var fileName = splitPath[splitPath.length - 1]; | |
- var newId = uuid.v1(); | |
- return self.createQueryCtxless(idOrPath, { | |
- id: newId, | |
- userAccountId: userAccount.id, | |
- name: fileName, | |
- version: version.id | |
- }).then(function(q) { | |
- return q.execWithin(tx); | |
- }).then(function() { | |
- return newId; | |
- }); | |
- } else { | |
- return file.id; | |
- } | |
- }).then(function(fileIdV) { | |
- fileId = fileIdV; | |
- return FileVersion.insert({ | |
- fileId: fileId, | |
- versionId: version.id | |
- }).execWithin(tx); | |
- }).then(function() { | |
- return File.whereUpdate({id: fileId}, {version: version.id}) | |
- .execWithin(tx); | |
- }).then(function() { | |
- tx.commit(); | |
- return done(); | |
- }, function(err) { | |
- tx.rollback(); | |
- return done(err); | |
- }); | |
-} | |
diff --git a/benchmark/doxbee-sequential/promises-tildeio-rsvp.js b/benchmark/doxbee-sequential/promises-tildeio-rsvp.js | |
deleted file mode 100644 | |
index 6802686c..00000000 | |
--- a/benchmark/doxbee-sequential/promises-tildeio-rsvp.js | |
+++ /dev/null | |
@@ -1,60 +0,0 @@ | |
-global.useRSVP = true; | |
- | |
-var rsvp = require('rsvp'); | |
- | |
-require('../lib/fakesP'); | |
- | |
-module.exports = function upload(stream, idOrPath, tag, done) { | |
- var blob = blobManager.create(account); | |
- var tx = db.begin(); | |
- var blobIdP = blob.put(stream); | |
- var fileP = self.byUuidOrPath(idOrPath).get(); | |
- var version, fileId, file; | |
- rsvp.all([blobIdP, fileP]).then(function(all) { | |
- var blobId = all[0], fileV = all[1]; | |
- file = fileV; | |
- var previousId = file ? file.version : null; | |
- version = { | |
- userAccountId: userAccount.id, | |
- date: new Date(), | |
- blobId: blobId, | |
- creatorId: userAccount.id, | |
- previousId: previousId, | |
- }; | |
- version.id = Version.createHash(version); | |
- return Version.insert(version).execWithin(tx); | |
- }).then(function() { | |
- if (!file) { | |
- var splitPath = idOrPath.split('/'); | |
- var fileName = splitPath[splitPath.length - 1]; | |
- var newId = uuid.v1(); | |
- return self.createQueryCtxless(idOrPath, { | |
- id: newId, | |
- userAccountId: userAccount.id, | |
- name: fileName, | |
- version: version.id | |
- }).then(function(q) { | |
- return q.execWithin(tx); | |
- }).then(function() { | |
- return newId; | |
- }); | |
- } else { | |
- return file.id; | |
- } | |
- }).then(function(fileIdV) { | |
- fileId = fileIdV; | |
- return FileVersion.insert({ | |
- fileId: fileId, | |
- versionId: version.id | |
- }).execWithin(tx); | |
- }).then(function() { | |
- return File.whereUpdate({id: fileId}, {version: version.id}) | |
- .execWithin(tx); | |
- }).then(function() { | |
- tx.commit(); | |
- return done(); | |
- }, function(err) { | |
- tx.rollback(); | |
- return done(err); | |
- }); | |
-} | |
diff --git a/benchmark/doxbee-sequential/streamline-callbacks.js b/benchmark/doxbee-sequential/streamline-callbacks.js | |
deleted file mode 100644 | |
index 02b0029c..00000000 | |
--- a/benchmark/doxbee-sequential/streamline-callbacks.js | |
+++ /dev/null | |
@@ -1,91 +0,0 @@ | |
-'use strict'; | |
- | |
-var regeneratorRuntime = typeof require === 'function' ? require('streamline-runtime/lib/callbacks/regenerator') : Streamline.require('streamline-runtime/lib/callbacks/regenerator'); | |
- | |
-var _streamline = typeof require === 'function' ? require('streamline-runtime/lib/callbacks/runtime') : Streamline.require('streamline-runtime/lib/callbacks/runtime'); | |
- | |
-var _filename = '/Users/bruno/dev/bluebird/benchmark/doxbee-sequential/streamline._js'; | |
-require('../lib/fakes'); | |
- | |
-module.exports = _streamline.async(regeneratorRuntime.mark(function _$$upload$$(stream, idOrPath, tag, _2) { | |
- var blob, tx, blobId, file, previousId, version, splitPath, fileName, query; | |
- return regeneratorRuntime.wrap(function _$$upload$$$(_context) { | |
- while (1) { | |
- switch (_context.prev = _context.next) { | |
- case 0: | |
- _context.prev = 0; | |
- blob = blobManager.create(account); | |
- tx = db.begin(); | |
- _context.next = 5; | |
- return _streamline.await(_filename, 7, blob, 'put', 1, null, false, [stream, true]); | |
- | |
- case 5: | |
- blobId = _context.sent; | |
- _context.next = 8; | |
- return _streamline.await(_filename, 8, self.byUuidOrPath(idOrPath), 'get', 0, null, false, [true]); | |
- | |
- case 8: | |
- file = _context.sent; | |
- previousId = file ? file.version : null; | |
- version = { | |
- userAccountId: userAccount.id, | |
- date: new Date(), | |
- blobId: blobId, | |
- creatorId: userAccount.id, | |
- previousId: previousId | |
- }; | |
- | |
- version.id = Version.createHash(version); | |
- _context.next = 14; | |
- return _streamline.await(_filename, 19, Version.insert(version), 'execWithin', 1, null, false, [tx, true]); | |
- | |
- case 14: | |
- if (file) { | |
- _context.next = 23; | |
- break; | |
- } | |
- | |
- splitPath = idOrPath.split('/'); | |
- fileName = splitPath[splitPath.length - 1]; | |
- | |
- file = { | |
- id: uuid.v1(), | |
- userAccountId: userAccount.id, | |
- name: fileName, | |
- version: version.id | |
- }; | |
- _context.next = 20; | |
- return _streamline.await(_filename, 29, self, 'createQuery', 2, null, false, [idOrPath, file, true]); | |
- | |
- case 20: | |
- query = _context.sent; | |
- _context.next = 23; | |
- return _streamline.await(_filename, 30, query, 'execWithin', 1, null, false, [tx, true]); | |
- | |
- case 23: | |
- _context.next = 25; | |
- return _streamline.await(_filename, 32, FileVersion.insert({ fileId: file.id, versionId: version.id }), 'execWithin', 1, null, false, [tx, true]); | |
- | |
- case 25: | |
- _context.next = 27; | |
- return _streamline.await(_filename, 34, File.whereUpdate({ id: file.id }, { version: version.id }), 'execWithin', 1, null, false, [tx, true]); | |
- | |
- case 27: | |
- tx.commit(); | |
- _context.next = 34; | |
- break; | |
- | |
- case 30: | |
- _context.prev = 30; | |
- _context.t0 = _context['catch'](0); | |
- | |
- tx.rollback(); | |
- throw _context.t0; | |
- | |
- case 34: | |
- case 'end': | |
- return _context.stop(); | |
- } | |
- } | |
- }, _$$upload$$, this, [[0, 30]]); | |
-}), 3, 4); | |
\ No newline at end of file | |
diff --git a/benchmark/doxbee-sequential/streamline-generators.js b/benchmark/doxbee-sequential/streamline-generators.js | |
deleted file mode 100644 | |
index 209fb37d..00000000 | |
--- a/benchmark/doxbee-sequential/streamline-generators.js | |
+++ /dev/null | |
@@ -1,46 +0,0 @@ | |
-'use strict'; | |
- | |
-var _streamline = typeof require === 'function' ? require('streamline-runtime/lib/generators/runtime') : Streamline.require('streamline-runtime/lib/generators/runtime'); | |
- | |
-var _filename = '/Users/bruno/dev/bluebird/benchmark/doxbee-sequential/streamline._js'; | |
-require('../lib/fakes'); | |
- | |
-module.exports = _streamline.async(function* _$$upload$$(stream, idOrPath, tag, _2) { | |
- { | |
- try { | |
- var blob = blobManager.create(account); | |
- var tx = db.begin(); | |
- var blobId = yield _streamline.await(_filename, 7, blob, 'put', 1, null, false, [stream, true]); | |
- var file = yield _streamline.await(_filename, 8, self.byUuidOrPath(idOrPath), 'get', 0, null, false, [true]); | |
- | |
- var previousId = file ? file.version : null; | |
- var version = { | |
- userAccountId: userAccount.id, | |
- date: new Date(), | |
- blobId: blobId, | |
- creatorId: userAccount.id, | |
- previousId: previousId | |
- }; | |
- version.id = Version.createHash(version); | |
- yield _streamline.await(_filename, 19, Version.insert(version), 'execWithin', 1, null, false, [tx, true]); | |
- if (!file) { | |
- var splitPath = idOrPath.split('/'); | |
- var fileName = splitPath[splitPath.length - 1]; | |
- file = { | |
- id: uuid.v1(), | |
- userAccountId: userAccount.id, | |
- name: fileName, | |
- version: version.id | |
- }; | |
- var query = yield _streamline.await(_filename, 29, self, 'createQuery', 2, null, false, [idOrPath, file, true]); | |
- yield _streamline.await(_filename, 30, query, 'execWithin', 1, null, false, [tx, true]); | |
- } | |
- yield _streamline.await(_filename, 32, FileVersion.insert({ fileId: file.id, versionId: version.id }), 'execWithin', 1, null, false, [tx, true]); | |
- yield _streamline.await(_filename, 34, File.whereUpdate({ id: file.id }, { version: version.id }), 'execWithin', 1, null, false, [tx, true]); | |
- tx.commit(); | |
- } catch (err) { | |
- tx.rollback(); | |
- throw err; | |
- } | |
- } | |
-}, 3, 4); | |
\ No newline at end of file | |
diff --git a/benchmark/doxbee-sequential/streamline._js b/benchmark/doxbee-sequential/streamline._js | |
deleted file mode 100644 | |
index b3088a3e..00000000 | |
--- a/benchmark/doxbee-sequential/streamline._js | |
+++ /dev/null | |
@@ -1,41 +0,0 @@ | |
-require('../lib/fakes'); | |
- | |
-module.exports = function upload(stream, idOrPath, tag, _) { | |
- try { | |
- var blob = blobManager.create(account); | |
- var tx = db.begin(); | |
- var blobId = blob.put(stream, _); | |
- var file = self.byUuidOrPath(idOrPath).get(_); | |
- | |
- var previousId = file ? file.version : null; | |
- var version = { | |
- userAccountId: userAccount.id, | |
- date: new Date(), | |
- blobId: blobId, | |
- creatorId: userAccount.id, | |
- previousId: previousId, | |
- }; | |
- version.id = Version.createHash(version); | |
- Version.insert(version).execWithin(tx, _); | |
- if (!file) { | |
- var splitPath = idOrPath.split('/'); | |
- var fileName = splitPath[splitPath.length - 1]; | |
- file = { | |
- id: uuid.v1(), | |
- userAccountId: userAccount.id, | |
- name: fileName, | |
- version: version.id | |
- } | |
- var query = self.createQuery(idOrPath, file, _); | |
- query.execWithin(tx, _); | |
- } | |
- FileVersion.insert({fileId: file.id, versionId: version.id}) | |
- .execWithin(tx, _); | |
- File.whereUpdate({id: file.id}, {version: version.id}) | |
- .execWithin(tx, _); | |
- tx.commit(); | |
- } catch (err) { | |
- tx.rollback(); | |
- throw err; | |
- } | |
-} | |
diff --git a/benchmark/lib/fakesP.js b/benchmark/lib/fakesP.js | |
index 1faaa61a..6e5d3169 100644 | |
--- a/benchmark/lib/fakesP.js | |
+++ b/benchmark/lib/fakesP.js | |
@@ -1,63 +1,7 @@ | |
- | |
- | |
-if (global.useQ) | |
- var lifter = require('q').denodeify; | |
-else if (global.useBluebird) | |
+if (global.useBluebird) { | |
//Currently promisifies only Node style callbacks | |
var lifter = require('../../js/release/bluebird.js').promisify; | |
-else if (global.useKew) { | |
- var q = require('kew'); | |
- var slicer = [].slice; | |
- var lifter = function lifter(nodefn) { | |
- return function() { | |
- var p = q.defer(); | |
- arguments[arguments.length++] = function(err, res) { | |
- if (err) p.reject(err); | |
- else p.resolve(res) | |
- }; | |
- try { | |
- nodefn.apply(this, arguments); | |
- } | |
- catch (e) { | |
- p.reject(e); | |
- } | |
- return p; | |
- } | |
- } | |
-} | |
-else if(global.useLie) { | |
- var Lie = require('lie'); | |
- var lifter = function(nodefn) { | |
- return function() { | |
- var self = this; | |
- var l = arguments.length; | |
- var args = new Array(l + 1); | |
- for (var i = 0; i < l; ++i) { | |
- args[i] = arguments[i]; | |
- } | |
- return new Lie(function(resolve, reject) { | |
- args[l] = function(err, val) { | |
- if (err) reject(err); | |
- else resolve(val); | |
- }; | |
- nodefn.apply(self, args); | |
- }); | |
- }; | |
- }; | |
-} | |
-else if(global.useThenPromise) { | |
- var lifter = require("promise").denodeify; | |
-} | |
-else if( global.useRSVP ) { | |
- var lifter = require("rsvp").denodeify; | |
-} | |
-else if( global.useDeferred) { | |
- var lifter = require("deferred").promisify; | |
-} | |
-else if( global.useDavy) { | |
- var lifter = require("davy").wrap; | |
-} | |
-else if (global.useNative) { | |
+} else if (global.useNativeNoPromisify) { | |
try { | |
if (Promise.race.toString() !== 'function race() { [native code] }') | |
throw 0; | |
@@ -81,9 +25,8 @@ else if (global.useNative) { | |
}); | |
}; | |
}; | |
-} | |
-else { | |
- var lifter = require('when/node').lift; | |
+} else if (global.useNativePromisify) { | |
+ var lifter = require("util").promisify; | |
} | |
var f = require('./dummy'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment