[Pkg-javascript-commits] [node-bluebird] 06/11: Imported Upstream version 2.9.13+dfsg
Ross Gammon
ross-guest at moszumanska.debian.org
Mon Mar 2 23:21:31 UTC 2015
This is an automated email from the git hooks/post-receive script.
ross-guest pushed a commit to branch master
in repository node-bluebird.
commit d5fcdfeb4a2733dc4d03e2b9f3c578b23c8e2ea2
Author: Ross Gammon <rossgammon at mail.dk>
Date: Mon Mar 2 22:43:29 2015 +0100
Imported Upstream version 2.9.13+dfsg
---
benchmark/README.md | 72 ----
benchmark/analysis/promises-bluebird-parallel.js | 22 -
benchmark/analysis/promises-bluebird.js | 59 ---
.../doxbee-sequential-errors/callbacks-baseline.js | 68 ---
.../callbacks-caolan-async-waterfall.js | 71 ---
.../promises-bluebird-generator.js | 49 ---
.../doxbee-sequential-errors/promises-bluebird.js | 63 ---
.../promises-calvinmetcalf-liar.js | 65 ---
.../promises-cujojs-when.js | 63 ---
.../promises-dfilatov-vow.js | 63 ---
.../promises-kriskowal-q.js | 63 ---
.../promises-lvivski-davy.js | 63 ---
.../promises-medikoo-deferred.js | 69 ---
.../promises-obvious-kew.js | 64 ---
.../promises-then-promise.js | 65 ---
.../promises-tildeio-rsvp.js | 64 ---
benchmark/doxbee-sequential/callbacks-baseline.js | 59 ---
.../callbacks-caolan-async-waterfall.js | 71 ---
benchmark/doxbee-sequential/generators-tj-co.js | 53 ---
.../observables-Reactive-Extensions-RxJS.js | 62 ---
.../observables-baconjs-bacon.js.js | 62 ---
.../observables-caolan-highland.js | 57 ---
.../promises-bluebird-generator.js | 45 --
benchmark/doxbee-sequential/promises-bluebird.js | 59 ---
.../promises-calvinmetcalf-lie.js | 61 ---
.../doxbee-sequential/promises-cujojs-when.js | 59 ---
.../doxbee-sequential/promises-dfilatov-vow.js | 59 ---
.../promises-ecmascript6-native.js | 67 ---
.../doxbee-sequential/promises-kriskowal-q.js | 59 ---
.../doxbee-sequential/promises-lvivski-davy.js | 58 ---
.../doxbee-sequential/promises-medikoo-deferred.js | 65 ---
.../doxbee-sequential/promises-obvious-kew.js | 60 ---
.../doxbee-sequential/promises-then-promise.js | 61 ---
.../doxbee-sequential/promises-tildeio-rsvp.js | 60 ---
benchmark/lib/catcher.js | 48 ---
benchmark/lib/dummy.js | 30 --
benchmark/lib/fakemaker.js | 92 ----
benchmark/lib/fakes-ctx.js | 39 --
benchmark/lib/fakes.js | 8 -
benchmark/lib/fakesC.js | 18 -
benchmark/lib/fakesO.js | 29 --
benchmark/lib/fakesObservable.js | 35 --
benchmark/lib/fakesP-ctx.js | 79 ----
benchmark/lib/fakesP.js | 105 -----
benchmark/lib/fakesSJS-dst.js | 4 -
benchmark/lib/fakesSJS-src.sjs | 56 ---
benchmark/lib/promiseSupport.js | 51 ---
benchmark/lib/timers-ctx.js | 479 ---------------------
benchmark/madeup-parallel/callbacks-baseline.js | 25 --
.../callbacks-caolan-async-parallel.js | 29 --
.../madeup-parallel/promises-bluebird-generator.js | 23 -
benchmark/madeup-parallel/promises-bluebird.js | 21 -
.../madeup-parallel/promises-calvinmetcalf-lie.js | 22 -
benchmark/madeup-parallel/promises-cujojs-when.js | 22 -
benchmark/madeup-parallel/promises-dfilatov-vow.js | 21 -
.../madeup-parallel/promises-ecmascript6-native.js | 27 --
benchmark/madeup-parallel/promises-lvivski-davy.js | 22 -
.../madeup-parallel/promises-medikoo-deferred.js | 27 --
benchmark/madeup-parallel/promises-obvious-kew.js | 22 -
benchmark/madeup-parallel/promises-then-promise.js | 22 -
benchmark/madeup-parallel/promises-tildeio-rsvp.js | 22 -
benchmark/package.json | 35 --
benchmark/performance.js | 177 --------
63 files changed, 3650 deletions(-)
diff --git a/benchmark/README.md b/benchmark/README.md
deleted file mode 100644
index 640c690..0000000
--- a/benchmark/README.md
+++ /dev/null
@@ -1,72 +0,0 @@
-**2015-01-05** Latest results, using latest versions of modules:
-
- ├── async at 0.9.0
- ├── davy at 0.3.3
- ├── deferred at 0.7.1
- ├── kew at 0.5.0-alpha.1
- ├── lie at 2.8.0
- ├── optimist at 0.6.1
- ├── promise at 6.0.1
- ├── q at 1.1.2
- ├── rsvp at 3.0.16
- ├── vow at 0.4.7
- └── when at 3.6.4
- ├── rx at 2.3.25
- ├── co at 4.2.0
- ├── baconjs at 0.7.43
- ├── highland at 2.3.0
-
-bench doxbee-sequential
-
- results for 10000 parallel executions, 1 ms per I/O op
-
- file time(ms) memory(MB)
- callbacks-baseline.js 232 35.86
- promises-bluebird-generator.js 235 38.04
- promises-bluebird.js 335 52.08
- promises-cujojs-when.js 405 75.77
- promises-tildeio-rsvp.js 468 87.56
- promises-dfilatov-vow.js 578 125.98
- callbacks-caolan-async-waterfall.js 634 88.64
- promises-lvivski-davy.js 653 109.64
- promises-calvinmetcalf-lie.js 732 165.41
- promises-obvious-kew.js 1346 261.69
- promises-ecmascript6-native.js 1348 189.29
- generators-tj-co.js 1419 164.03
- promises-then-promise.js 1571 294.45
- promises-medikoo-deferred.js 2091 262.18
- observables-Reactive-Extensions-RxJS.js 3201 356.76
- observables-caolan-highland.js 7429 616.78
- promises-kriskowal-q.js 9952 694.23
- observables-baconjs-bacon.js.js 25805 885.55
-
- Platform info:
- Windows_NT 6.1.7601 x64
- Node.JS 1.1.0
- V8 4.1.0.14
- Intel(R) Core(TM) i5-2500K CPU @ 3.30GHz × 4
-
-bench parallel (`--p 25`)
-
-results for 10000 parallel executions, 1 ms per I/O op
-
- file time(ms) memory(MB)
- callbacks-baseline.js 211 25.57
- promises-bluebird.js 389 53.49
- promises-bluebird-generator.js 491 55.52
- promises-tildeio-rsvp.js 785 108.14
- promises-dfilatov-vow.js 798 102.08
- promises-cujojs-when.js 851 60.46
- promises-calvinmetcalf-lie.js 1065 187.69
- promises-lvivski-davy.js 1298 135.43
- callbacks-caolan-async-parallel.js 1780 101.11
- promises-then-promise.js 2438 338.91
- promises-ecmascript6-native.js 3532 301.96
- promises-medikoo-deferred.js 4207 357.60
- promises-obvious-kew.js 8311 559.24
-
- Platform info:
- Windows_NT 6.1.7601 ia32
- Node.JS 0.11.14
- V8 3.26.33
- Intel(R) Core(TM) i5-2500K CPU @ 3.30GHz × 4
diff --git a/benchmark/analysis/promises-bluebird-parallel.js b/benchmark/analysis/promises-bluebird-parallel.js
deleted file mode 100644
index 4b63367..0000000
--- a/benchmark/analysis/promises-bluebird-parallel.js
+++ /dev/null
@@ -1,22 +0,0 @@
-global.useBluebird = true;
-global.useQ = false;
-global.parallelQueries = 25;
-var Promise = require('../../js/main/bluebird.js');
-require('../lib/fakesP');
-
-module.exports = function upload(stream, idOrPath, tag, done) {
- var queries = new Array(global.parallelQueries);
- var tx = db.begin();
-
- for( var i = 0, len = queries.length; i < len; ++i ) {
- queries[i] = FileVersion.insert({index: i}).execWithin(tx);
- }
-
- Promise.all(queries).then().then(function() {
- tx.commit();
- done();
- }, function(err) {
- tx.rollback();
- done(err);
- });
-}
diff --git a/benchmark/analysis/promises-bluebird.js b/benchmark/analysis/promises-bluebird.js
deleted file mode 100644
index 758c7f6..0000000
--- a/benchmark/analysis/promises-bluebird.js
+++ /dev/null
@@ -1,59 +0,0 @@
-global.useBluebird = true;
-global.useQ = false;
-var bluebird = require('../../js/main/bluebird.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;
-
- bluebird.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-errors/callbacks-baseline.js b/benchmark/doxbee-sequential-errors/callbacks-baseline.js
deleted file mode 100644
index 4d152c5..0000000
--- a/benchmark/doxbee-sequential-errors/callbacks-baseline.js
+++ /dev/null
@@ -1,68 +0,0 @@
-require('../lib/fakes');
-
-module.exports = function upload(stream, idOrPath, tag, done) {
- var blob = blobManager.create(account);
- var tx = db.begin();
- function backoff(err) {
- tx.rollback();
- return done(err);
- }
- var intentionalErrorShouldBeTriggered = function(){
- return LIKELIHOOD_OF_REJECTION && Math.random() <= LIKELIHOOD_OF_REJECTION;
- }
-
- blob.put(stream, function (err, blobId) {
- if (err) return done(err);
- self.byUuidOrPath(idOrPath).get(function (err, file) {
- if (err) return done(err);
- 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, function (err) {
- if (err) return backoff(err);
- if(intentionalErrorShouldBeTriggered()) return done(new Error("intentional failure"));
- if (!file) {
- var splitPath = idOrPath.split('/');
- var fileName = splitPath[splitPath.length - 1];
- var newId = uuid.v1();
- self.createQuery(idOrPath, {
- id: newId,
- userAccountId: userAccount.id,
- name: fileName,
- version: version.id
- }, function (err, q) {
- if (err) return backoff(err);
- if(intentionalErrorShouldBeTriggered()) return done(new Error("intentional failure"));
- q.execWithin(tx, function (err) {
- afterFileExists(err, newId);
- });
-
- })
- }
- else return afterFileExists(null, file.id);
- });
- function afterFileExists(err, fileId) {
- if (err) return backoff(err);
- if(intentionalErrorShouldBeTriggered()) return done(new Error("intentional failure"));
- FileVersion.insert({fileId: fileId,versionId: version.id})
- .execWithin(tx, function (err) {
- if (err) return backoff(err);
- if(intentionalErrorShouldBeTriggered()) return done(new Error("intentional failure"));
- File.whereUpdate({id: fileId}, {
- version: version.id
- }).execWithin(tx, function (err) {
- if (err) return backoff(err);
- if(intentionalErrorShouldBeTriggered()) return done(new Error("intentional failure"));
- tx.commit(done);
- });
- })
- }
- });
- });
-}
diff --git a/benchmark/doxbee-sequential-errors/callbacks-caolan-async-waterfall.js b/benchmark/doxbee-sequential-errors/callbacks-caolan-async-waterfall.js
deleted file mode 100644
index 439f9bb..0000000
--- a/benchmark/doxbee-sequential-errors/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-errors/promises-bluebird-generator.js b/benchmark/doxbee-sequential-errors/promises-bluebird-generator.js
deleted file mode 100644
index e2a4c84..0000000
--- a/benchmark/doxbee-sequential-errors/promises-bluebird-generator.js
+++ /dev/null
@@ -1,49 +0,0 @@
-global.useBluebird = true;
-global.useQ = false;
-var bluebird = require('../../js/main/bluebird.js');
-require('../lib/fakesP');
-
-module.exports = bluebird.coroutine(function* upload(stream, idOrPath, tag, done) {
- 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);
- triggerIntentionalError();
- 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);
- triggerIntentionalError();
- }
- yield FileVersion.insert({fileId: file.id, versionId: version.id})
- .execWithin(tx);
- triggerIntentionalError();
- yield File.whereUpdate({id: file.id}, {version: version.id})
- .execWithin(tx);
- triggerIntentionalError();
- tx.commit();
- done();
- } catch (err) {
- tx.rollback();
- done(err);
- }
-});
\ No newline at end of file
diff --git a/benchmark/doxbee-sequential-errors/promises-bluebird.js b/benchmark/doxbee-sequential-errors/promises-bluebird.js
deleted file mode 100644
index 1c83103..0000000
--- a/benchmark/doxbee-sequential-errors/promises-bluebird.js
+++ /dev/null
@@ -1,63 +0,0 @@
-global.useBluebird = true;
-global.useQ = false;
-var bluebird = require('../../js/main/bluebird.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;
-
- bluebird.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() {
- triggerIntentionalError();
- 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) {
- triggerIntentionalError();
- fileId = fileIdV;
- return FileVersion.insert({
- fileId: fileId,
- versionId: version.id
- }).execWithin(tx);
- }).then(function() {
- triggerIntentionalError();
- return File.whereUpdate({id: fileId}, {version: version.id})
- .execWithin(tx);
- }).then(function() {
- triggerIntentionalError();
- tx.commit();
- return done();
- }).then(null, function(err) {
- tx.rollback();
- return done(err);
- });
-}
diff --git a/benchmark/doxbee-sequential-errors/promises-calvinmetcalf-liar.js b/benchmark/doxbee-sequential-errors/promises-calvinmetcalf-liar.js
deleted file mode 100644
index b449639..0000000
--- a/benchmark/doxbee-sequential-errors/promises-calvinmetcalf-liar.js
+++ /dev/null
@@ -1,65 +0,0 @@
-global.useLiar = true;
-
-var promise = require("liar");
-
-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() {
- triggerIntentionalError();
- 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) {
- triggerIntentionalError();
- fileId = fileIdV;
- return FileVersion.insert({
- fileId: fileId,
- versionId: version.id
- }).execWithin(tx);
- }).then(function() {
- triggerIntentionalError();
- return File.whereUpdate({id: fileId}, {version: version.id})
- .execWithin(tx);
- }).then(function() {
- triggerIntentionalError();
- tx.commit();
- return done();
- }).then(null, function(err) {
- tx.rollback();
- return done(err);
- });
-}
diff --git a/benchmark/doxbee-sequential-errors/promises-cujojs-when.js b/benchmark/doxbee-sequential-errors/promises-cujojs-when.js
deleted file mode 100644
index f0f677e..0000000
--- a/benchmark/doxbee-sequential-errors/promises-cujojs-when.js
+++ /dev/null
@@ -1,63 +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() {
- triggerIntentionalError();
- 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) {
- triggerIntentionalError();
- fileId = fileIdV;
- return FileVersion.insert({
- fileId: fileId,
- versionId: version.id
- }).execWithin(tx);
- }).then(function() {
- triggerIntentionalError();
- return File.whereUpdate({id: fileId}, {version: version.id})
- .execWithin(tx);
- }).then(function() {
- triggerIntentionalError();
- tx.commit();
- return done();
- }).then(null, function(err) {
- tx.rollback();
- return done(err);
- });
-}
diff --git a/benchmark/doxbee-sequential-errors/promises-dfilatov-vow.js b/benchmark/doxbee-sequential-errors/promises-dfilatov-vow.js
deleted file mode 100644
index e6e9bcb..0000000
--- a/benchmark/doxbee-sequential-errors/promises-dfilatov-vow.js
+++ /dev/null
@@ -1,63 +0,0 @@
-var vow = require('vow'),
- 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;
-
- vow.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() {
- triggerIntentionalError();
- 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) {
- triggerIntentionalError();
- fileId = fileIdV;
- return FileVersion.insert({
- fileId: fileId,
- versionId: version.id
- }).execWithin(tx);
- }).then(function() {
- triggerIntentionalError();
- return File.whereUpdate({id: fileId}, {version: version.id})
- .execWithin(tx);
- }).then(function() {
- triggerIntentionalError();
- tx.commit();
- return done();
- }).then(null, function(err) {
- tx.rollback();
- return done(err);
- });
-}
diff --git a/benchmark/doxbee-sequential-errors/promises-kriskowal-q.js b/benchmark/doxbee-sequential-errors/promises-kriskowal-q.js
deleted file mode 100644
index fd20c39..0000000
--- a/benchmark/doxbee-sequential-errors/promises-kriskowal-q.js
+++ /dev/null
@@ -1,63 +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() {
- triggerIntentionalError();
- 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) {
- triggerIntentionalError();
- fileId = fileIdV;
- return FileVersion.insert({
- fileId: fileId,
- versionId: version.id
- }).execWithin(tx);
- }).then(function() {
- triggerIntentionalError();
- return File.whereUpdate({id: fileId}, {version: version.id})
- .execWithin(tx);
- }).then(function() {
- triggerIntentionalError();
- tx.commit();
- return done();
- }).then(null, function(err) {
- tx.rollback();
- return done(err);
- });
-}
diff --git a/benchmark/doxbee-sequential-errors/promises-lvivski-davy.js b/benchmark/doxbee-sequential-errors/promises-lvivski-davy.js
deleted file mode 100755
index 5d8932c..0000000
--- a/benchmark/doxbee-sequential-errors/promises-lvivski-davy.js
+++ /dev/null
@@ -1,63 +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(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() {
- triggerIntentionalError();
- 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) {
- triggerIntentionalError();
- fileId = fileIdV;
- return FileVersion.insert({
- fileId: fileId,
- versionId: version.id
- }).execWithin(tx);
- }).then(function() {
- triggerIntentionalError();
- return File.whereUpdate({id: fileId}, {version: version.id})
- .execWithin(tx);
- }).then(function() {
- triggerIntentionalError();
- tx.commit();
- return done();
- }).then(null, function(err) {
- tx.rollback();
- return done(err);
- });
-}
diff --git a/benchmark/doxbee-sequential-errors/promises-medikoo-deferred.js b/benchmark/doxbee-sequential-errors/promises-medikoo-deferred.js
deleted file mode 100644
index 9ef5a74..0000000
--- a/benchmark/doxbee-sequential-errors/promises-medikoo-deferred.js
+++ /dev/null
@@ -1,69 +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() {
- triggerIntentionalError();
- 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) {
- triggerIntentionalError();
- fileId = fileIdV;
- return FileVersion.insert({
- fileId: fileId,
- versionId: version.id
- }).execWithin(tx);
- })(function() {
- triggerIntentionalError();
- return File.whereUpdate({id: fileId}, {version: version.id})
- .execWithin(tx);
- })(function() {
- triggerIntentionalError();
- tx.commit();
- return done();
- }, function(err) {
- tx.rollback();
- return done(err);
- });
-}
diff --git a/benchmark/doxbee-sequential-errors/promises-obvious-kew.js b/benchmark/doxbee-sequential-errors/promises-obvious-kew.js
deleted file mode 100644
index 7b6500c..0000000
--- a/benchmark/doxbee-sequential-errors/promises-obvious-kew.js
+++ /dev/null
@@ -1,64 +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() {
- triggerIntentionalError();
- 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) {
- triggerIntentionalError();
- fileId = fileIdV;
- return FileVersion.insert({
- fileId: fileId,
- versionId: version.id
- }).execWithin(tx);
- }).then(function() {
- triggerIntentionalError();
- return File.whereUpdate({id: fileId}, {version: version.id})
- .execWithin(tx);
- }).then(function() {
- triggerIntentionalError();
- tx.commit();
- return done();
- }).then(null, function(err) {
- tx.rollback();
- return done(err);
- });
-}
diff --git a/benchmark/doxbee-sequential-errors/promises-then-promise.js b/benchmark/doxbee-sequential-errors/promises-then-promise.js
deleted file mode 100644
index b26e91b..0000000
--- a/benchmark/doxbee-sequential-errors/promises-then-promise.js
+++ /dev/null
@@ -1,65 +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() {
- triggerIntentionalError();
- 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) {
- triggerIntentionalError();
- fileId = fileIdV;
- return FileVersion.insert({
- fileId: fileId,
- versionId: version.id
- }).execWithin(tx);
- }).then(function() {
- triggerIntentionalError();
- return File.whereUpdate({id: fileId}, {version: version.id})
- .execWithin(tx);
- }).then(function() {
- triggerIntentionalError();
- tx.commit();
- return done();
- }).then(null, function(err) {
- tx.rollback();
- return done(err);
- });
-}
diff --git a/benchmark/doxbee-sequential-errors/promises-tildeio-rsvp.js b/benchmark/doxbee-sequential-errors/promises-tildeio-rsvp.js
deleted file mode 100644
index ad89c19..0000000
--- a/benchmark/doxbee-sequential-errors/promises-tildeio-rsvp.js
+++ /dev/null
@@ -1,64 +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() {
- triggerIntentionalError();
- 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) {
- triggerIntentionalError();
- fileId = fileIdV;
- return FileVersion.insert({
- fileId: fileId,
- versionId: version.id
- }).execWithin(tx);
- }).then(function() {
- triggerIntentionalError();
- return File.whereUpdate({id: fileId}, {version: version.id})
- .execWithin(tx);
- }).then(function() {
- triggerIntentionalError();
- tx.commit();
- return done();
- }).then(null, function(err) {
- tx.rollback();
- return done(err);
- });
-}
diff --git a/benchmark/doxbee-sequential/callbacks-baseline.js b/benchmark/doxbee-sequential/callbacks-baseline.js
deleted file mode 100644
index 60abe40..0000000
--- a/benchmark/doxbee-sequential/callbacks-baseline.js
+++ /dev/null
@@ -1,59 +0,0 @@
-require('../lib/fakes');
-
-module.exports = function upload(stream, idOrPath, tag, done) {
- var blob = blobManager.create(account);
- var tx = db.begin();
- function backoff(err) {
- tx.rollback();
- return done(err);
- }
- blob.put(stream, function (err, blobId) {
- if (err) return done(err);
- self.byUuidOrPath(idOrPath).get(function (err, file) {
- if (err) return done(err);
- 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, function (err) {
- if (err) return backoff(err);
- if (!file) {
- var splitPath = idOrPath.split('/');
- var fileName = splitPath[splitPath.length - 1];
- var newId = uuid.v1();
- self.createQuery(idOrPath, {
- id: newId,
- userAccountId: userAccount.id,
- name: fileName,
- version: version.id
- }, function (err, q) {
- if (err) return backoff(err);
- q.execWithin(tx, function (err) {
- afterFileExists(err, newId);
- });
-
- })
- }
- else return afterFileExists(null, file.id);
- });
- function afterFileExists(err, fileId) {
- if (err) return backoff(err);
- FileVersion.insert({fileId: fileId,versionId: version.id})
- .execWithin(tx, function (err) {
- if (err) return backoff(err);
- File.whereUpdate({id: fileId}, {
- version: version.id
- }).execWithin(tx, function (err) {
- if (err) return backoff(err);
- tx.commit(done);
- });
- })
- }
- });
- });
-}
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 439f9bb..0000000
--- 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/generators-tj-co.js b/benchmark/doxbee-sequential/generators-tj-co.js
deleted file mode 100644
index 4dd2290..0000000
--- 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 85bc5eb..0000000
--- 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 822b38c..0000000
--- 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 e8272b1..0000000
--- 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/promises-bluebird-generator.js b/benchmark/doxbee-sequential/promises-bluebird-generator.js
deleted file mode 100644
index 7afd708..0000000
--- a/benchmark/doxbee-sequential/promises-bluebird-generator.js
+++ /dev/null
@@ -1,45 +0,0 @@
-global.useBluebird = true;
-global.useQ = false;
-var bluebird = require('../../js/main/bluebird.js');
-require('../lib/fakesP');
-
-module.exports = bluebird.coroutine(function* upload(stream, idOrPath, tag, done) {
- 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/promises-bluebird.js b/benchmark/doxbee-sequential/promises-bluebird.js
deleted file mode 100644
index 87447b9..0000000
--- a/benchmark/doxbee-sequential/promises-bluebird.js
+++ /dev/null
@@ -1,59 +0,0 @@
-global.useBluebird = true;
-global.useQ = false;
-var bluebird = require('../../js/main/bluebird.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;
-
- bluebird.join(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-calvinmetcalf-lie.js b/benchmark/doxbee-sequential/promises-calvinmetcalf-lie.js
deleted file mode 100644
index f041e19..0000000
--- 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 fffadd3..0000000
--- 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-dfilatov-vow.js b/benchmark/doxbee-sequential/promises-dfilatov-vow.js
deleted file mode 100644
index 812d881..0000000
--- a/benchmark/doxbee-sequential/promises-dfilatov-vow.js
+++ /dev/null
@@ -1,59 +0,0 @@
-var vow = require('vow'),
- 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;
-
- vow.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-ecmascript6-native.js b/benchmark/doxbee-sequential/promises-ecmascript6-native.js
deleted file mode 100644
index 7bcd018..0000000
--- a/benchmark/doxbee-sequential/promises-ecmascript6-native.js
+++ /dev/null
@@ -1,67 +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");
-}
-
-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(result) {
- var blobId = result[0];
- var fileV = result[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.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-kriskowal-q.js b/benchmark/doxbee-sequential/promises-kriskowal-q.js
deleted file mode 100644
index a1345c0..0000000
--- 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 47fe5e8..0000000
--- 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 908065e..0000000
--- 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 3d154b4..0000000
--- 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 dfb56a6..0000000
--- 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 6802686..0000000
--- 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/lib/catcher.js b/benchmark/lib/catcher.js
deleted file mode 100644
index bab536d..0000000
--- a/benchmark/lib/catcher.js
+++ /dev/null
@@ -1,48 +0,0 @@
-
-exports.longStackSupport = global.longStackSupport;
-
-
-function invoke(ctx, cb, value, myhandler) {
- try {
- cb.call(ctx, value); // no error
- } catch (e) {
- if (myhandler)
- myhandler.call(ctx, e);
- else
- console.error(e);
- }
-}
-
-module.exports = function() {
- var self = {};
- var notCaught = true, myhandler;
- self.try = function $try(cb) {
- if (exports.longStackSupport) {
- var ex = {};
- Error.captureStackTrace(ex);
- }
- return function wrapper(err, value) {
- if (err) {
- if (notCaught) {
- notCaught = false;
- if (err.stack && ex) {
- var asyncStackRaw =
- ex.stack.substr(ex.stack.indexOf('\n'));
- err.stack += '\nFrom previous event:'
- + asyncStackRaw;
- }
- if (myhandler) myhandler(err);
- else console.error(err);
- }
- }
- else if (myhandler)
- invoke(this, cb, value, myhandler);
- else cb(value);
- }
- }
- self.catch = function $catch(handler) {
- myhandler = handler
- };
- return self;
-};
-
diff --git a/benchmark/lib/dummy.js b/benchmark/lib/dummy.js
deleted file mode 100644
index 5b94d98..0000000
--- a/benchmark/lib/dummy.js
+++ /dev/null
@@ -1,30 +0,0 @@
-// A typical node callback function
-// with the callback at the Nth position
-exports.dummy = function dummy(n) {
- return function dummy_n() {
- var cb = arguments[n - 1];
- if (global.asyncTime)
- setTimeout(cb, global.asyncTime || 100);
- else
- process.nextTick(cb);
- }
-}
-
-// A throwing callback function
-exports.dummyt = function dummyt(n) {
- return function dummy_throwing_n() {
- var cb = arguments[n - 1];
- if (global.testThrow)
- throw(new Error("Exception happened"));
- setTimeout(function throwTimeout() {
- if (global.testThrowAsync) {
- throw(new Error("Exception happened"));
- } else if (global.testError) {
- return cb(new Error("Error happened"));
- }
- else cb();
- }, global.asyncTime || 100);
- }
-}
-
-
diff --git a/benchmark/lib/fakemaker.js b/benchmark/lib/fakemaker.js
deleted file mode 100644
index 716f40d..0000000
--- a/benchmark/lib/fakemaker.js
+++ /dev/null
@@ -1,92 +0,0 @@
-
-module.exports = function fakemaker(dummy, dummyt, wrap) {
-
- var dummy_2 = dummy(2),
- dummy_1 = dummy(1);
-
- var dummyt_2, dummyt_1;
-
- if (global.testError || global.testThrow
- || global.testThrowAsync) {
- dummyt_2 = dummyt(2);
- dummyt_1 = dummyt(1);
- } else {
- dummyt_2 = dummy_2;
- dummyt_1 = dummy_1;
- }
-
- // a queryish object with all
- // kinds of functions
- function queryish() {
- return {
- execWithin: dummy_2,
- exec: dummy_1,
- get: dummy_1,
- all: dummy_1,
- };
- }
-
- // a queryish object with functions
- // that throw
- function queryisht() {
- return {
- execWithin: dummyt_2,
- exec: dummyt_1,
- get: dummyt_1,
- all: dummyt_1,
- };
- }
-
- global.uuid = { v1: function v1() {} };
-
- global.userAccount = { };
-
- global.account = { };
-
- global.blobManager = {
- create: function create() {
- return {
- put: dummy_2,
- }
- }
- };
-
- var cqQueryish = queryish();
-
- global.self = {
- byUuidOrPath: queryish,
- createQuery: wrap(function createQuery(x, y, cb, ctx) {
- cb.call(ctx, null, cqQueryish);
- }),
- createQueryCtxless: wrap(function createQuery(x, y, cb) {
- cb.call(this, null, cqQueryish);
- })
- };
-
-
- global.File = {
- insert: queryish,
- whereUpdate: queryish
- };
-
- global.FileVersion = {
- insert: queryisht
- };
-
- global.Version = {
- createHash: function createHash(v) { return 1; },
- insert: queryish
- };
-
- global.db = {
- begin: function begin() {
- return {
- commit: dummy_1,
- rollback: dummy_1,
- };
- }
- };
-
-};
-
-
diff --git a/benchmark/lib/fakes-ctx.js b/benchmark/lib/fakes-ctx.js
deleted file mode 100644
index 197c92c..0000000
--- a/benchmark/lib/fakes-ctx.js
+++ /dev/null
@@ -1,39 +0,0 @@
-var timers = require('./timers-ctx');
-
-var fakemaker = require('./fakemaker');
-
-var f = {};
-f.dummy = function dummy(n) {
- return function dummy_n() {
- var cb = arguments[n - 1],
- ctx = arguments[n];
- //console.log(cb, ctx);
-
- timers.setTimeout(cb, ctx, global.asyncTime || 100);
- }
-}
-
-// A throwing callback function
-f.dummyt = function dummyt(n) {
- return function dummy_throwing_n() {
- var cb = arguments[n - 1],
- ctx = arguments[n];
- if (global.testThrow)
- throw(new Error("Exception happened"));
- setTimeout(function throwTimeout() {
- if (global.testThrowAsync) {
- throw(new Error("Exception happened"));
- } else if (global.testError) {
- return cb.call(ctx, new Error("Error happened"));
- }
- else cb.call(ctx);
- }, global.asyncTime || 100);
- }
-}
-
-
-
-
-fakemaker(f.dummy, f.dummyt, function wrap_identity(f) { return f; });
-
-
diff --git a/benchmark/lib/fakes.js b/benchmark/lib/fakes.js
deleted file mode 100644
index 9fb7d91..0000000
--- a/benchmark/lib/fakes.js
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-var fakemaker = require('./fakemaker'),
- f = require('./dummy');
-
-fakemaker(f.dummy, f.dummyt, function wrap_identity(f) { return f; });
-
-
diff --git a/benchmark/lib/fakesC.js b/benchmark/lib/fakesC.js
deleted file mode 100644
index 83b7c5e..0000000
--- a/benchmark/lib/fakesC.js
+++ /dev/null
@@ -1,18 +0,0 @@
-
-var co = require('co');
-
-var f = require('./dummy');
-
-var makefakes = require('./fakemaker');
-
-// Continuable versions made with co.wrap
-function dummyC(n) {
- return co.wrap(f.dummy(n));
-}
-function dummytC(n) {
- return co.wrap(f.dummyt(n));
-}
-
-makefakes(dummyC, dummytC, co.wrap);
-
-
diff --git a/benchmark/lib/fakesO.js b/benchmark/lib/fakesO.js
deleted file mode 100644
index fc1192e..0000000
--- a/benchmark/lib/fakesO.js
+++ /dev/null
@@ -1,29 +0,0 @@
-
-var Rx = require('rx');
-var f = require('./dummy');
-
-var dummy1 = f.dummy(1),
- dummyt1 = f.dummyt(1);
-
-// Observable wrapper
-function dummyObsWrap(fn) {
- return function() {
- return Rx.Observable.create(function(observer) {
- fn(function(err, res) {
- if(err)
- return observer.onError(err);
- observer.onNext(res);
- observer.onCompleted();
- });
- });
- }
-}
-function dummyO() {
- return dummyObsWrap(dummy(1));
-}
-function dummytO() {
- return dummyObsWrap(dummyt(1));
-}
-
-makefakes(dummyO, dummytO, dummyObsWrap);
-
diff --git a/benchmark/lib/fakesObservable.js b/benchmark/lib/fakesObservable.js
deleted file mode 100644
index aaf832b..0000000
--- a/benchmark/lib/fakesObservable.js
+++ /dev/null
@@ -1,35 +0,0 @@
-var lifter, fromNodeCallback;
-if (global.useRx) {
- lifter = require("rx").Observable.fromNodeCallback;
-} else if (global.useBacon) {
- fromNodeCallback = require("baconjs").fromNodeCallback;
-} else if (global.useHighland) {
- lifter = require("highland").wrapCallback;
-}
-
-if (!lifter) {
- lifter = function(nodeFn) {
- return function() {
- var args = [].slice.call(arguments);
- args.unshift(nodeFn);
- return fromNodeCallback.apply(undefined, args);
- };
- };
-}
-
-var f = require('./dummy');
-
-var makefakes = require('./fakemaker');
-
-// A function taking n values or promises and returning
-// a promise
-function dummyP(n) {
- return lifter(f.dummy(n));
-}
-
-// Throwing version of above
-function dummytP(n) {
- return lifter(f.dummyt(n));
-}
-
-makefakes(dummyP, dummytP, lifter);
diff --git a/benchmark/lib/fakesP-ctx.js b/benchmark/lib/fakesP-ctx.js
deleted file mode 100644
index 27d13f1..0000000
--- a/benchmark/lib/fakesP-ctx.js
+++ /dev/null
@@ -1,79 +0,0 @@
-var timers = require('./timers-ctx');
-
-var fakemaker = require('./fakemaker');
-
-var f = {};
-f.dummy = function dummy(n) {
- return function dummy_n() {
- var cb = arguments[n - 1],
- ctx = arguments[n];
- timers.setTimeout(cb, ctx, global.asyncTime || 100);
- }
-}
-
-// A throwing callback function
-f.dummyt = function dummyt(n) {
- return function dummy_throwing_n() {
- var cb = arguments[n - 1],
- ctx = arguments[n];
- if (global.testThrow)
- throw(new Error("Exception happened"));
- setTimeout(function throwTimeout() {
- if (global.testThrowAsync) {
- throw(new Error("Exception happened"));
- } else if (global.testError) {
- return cb.call(ctx, new Error("Error happened"));
- }
- else cb.call(ctx);
- }, global.asyncTime || 100);
- }
-}
-
-
-
-//Currently promisifies only Node style callbacks
-//var lifter = require('bluebird').promisify;
-
-var Promise = require('bluebird');
-
-function nodeback(err, result) {
- if (err == null) this.fulfill(result);
- else this.reject(err);
-}
-
-function lifter(f) {
- return function lifted(a1, a2, a3, a4, a5) {
- "use strict";
- var len = arguments.length;
- var deferred = Promise.pending();
- try {
- switch(len) {
- case 1: f(a1, nodeback, deferred); break;
- case 2: f(a1, a2, nodeback, deferred); break;
- case 0: f(nodeback, deferred); break;
- case 3: f(a1, a2, a3, nodeback, deferred); break;
- case 4: f(a1, a2, a3, a4, nodeback, deferred); break;
- case 5: f(a1, a2, a3, a4, a5, nodeback, deferred); break;
- }
- } catch (err) { deferred.reject(err); }
- return deferred.promise;
- }
-}
-
-// A function taking n values or promises and returning
-// a promise
-function dummyP(n) {
- return function lifted() {
- var deferred = Promise.pending();
- timers.setTimeout(nodeback, deferred, global.asyncTime || 100);
- return deferred.promise;
- }
-}
-
-// Throwing version of above
-function dummytP(n) {
- return lifter(f.dummyt(n));
-}
-
-fakemaker(dummyP, dummytP, lifter);
-
diff --git a/benchmark/lib/fakesP.js b/benchmark/lib/fakesP.js
deleted file mode 100644
index 87daf17..0000000
--- a/benchmark/lib/fakesP.js
+++ /dev/null
@@ -1,105 +0,0 @@
-
-
-if (global.useQ)
- var lifter = require('q').denodeify;
-else if (global.useBluebird)
- //Currently promisifies only Node style callbacks
- var lifter = require('../../js/main/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) {
- try {
- if (Promise.race.toString() !== 'function race() { [native code] }')
- throw 0;
- } catch (e) {
- throw new Error("No ES6 promises available");
- }
- 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 Promise(function(resolve, reject) {
- args[l] = function(err, val) {
- if (err) reject(err);
- else resolve(val);
- };
- nodefn.apply(self, args);
- });
- };
- };
-}
-else {
- var lifter = require('when/node').lift;
-}
-
-var f = require('./dummy');
-
-var makefakes = require('./fakemaker');
-
-// A function taking n values or promises and returning
-// a promise
-function dummyP(n) {
- return lifter(f.dummy(n));
-}
-
-// Throwing version of above
-function dummytP(n) {
- return lifter(f.dummyt(n));
-}
-
-makefakes(dummyP, dummytP, lifter);
-
diff --git a/benchmark/lib/fakesSJS-dst.js b/benchmark/lib/fakesSJS-dst.js
deleted file mode 100644
index 333d475..0000000
--- a/benchmark/lib/fakesSJS-dst.js
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-var f,makefakes;function wrap(f){return __oni_rt.exseq(arguments,this,'lib/fakesSJS-src.sjs',[1,__oni_rt.Nb(function(){return __oni_rt.Return(function (x,y){var err,val;return __oni_rt.exseq(arguments,this,'lib/fakesSJS-src.sjs',[1,__oni_rt.Suspend(function(__oni_env,resume){return __oni_rt.ex(__oni_rt.Nb(function(){return f(x,y,resume);},8),__oni_env)}, function() {err=arguments[0];val=arguments[1];}),__oni_rt.Nb(function(){if(err){throw err;}return __oni_rt.Return(val);},10)])});},12)] [...]
-
diff --git a/benchmark/lib/fakesSJS-src.sjs b/benchmark/lib/fakesSJS-src.sjs
deleted file mode 100644
index f07e7af..0000000
--- a/benchmark/lib/fakesSJS-src.sjs
+++ /dev/null
@@ -1,56 +0,0 @@
-var f = require('./dummy.js');
-
-var makefakes = require('./fakemaker.js');
-
-function wrap(f) {
- return function(x, y) {
- waitfor(var err, val) {
- f(x, y, resume);
- }
- if (err) throw err;
- return val;
- };
-}
-
-function dummySJS0() {
- var inner = f.dummy(1);
- return function() {
- waitfor (var err, val) {
- inner(resume);
- }
- if (err) throw err;
- return val;
- }
-}
-
-function dummySJS1() {
- var inner = f.dummy(2);
- return function(x) {
- waitfor (var err, val) {
- inner(x, resume);
- }
- if (err) throw err;
- return val;
- }
-}
-
-function dummySJS(n) {
- if (n === 1) return dummySJS0();
- if (n === 2) return dummySJS1();
-}
-
-function dummytSJS(n) {
- var inner = f.dummyt(n);
- return function() {
- waitfor(var err, val) {
- var args = Array.prototype.slice.apply(arguments);
- args.push(resume);
- inner.apply(this, args);
- }
-
- if (err) throw err;
- return val;
- }
-}
-
-makefakes(dummySJS, dummytSJS, wrap, global);
diff --git a/benchmark/lib/promiseSupport.js b/benchmark/lib/promiseSupport.js
deleted file mode 100644
index 4a0fba6..0000000
--- a/benchmark/lib/promiseSupport.js
+++ /dev/null
@@ -1,51 +0,0 @@
-var when = require('when');
-var fn = require('when/function');
-
-
-
-exports.ternary = fn.lift(function(truthy, iftrue, iffalse) {
- return truthy ? iftrue: iffalse;
-})
-
-exports.not = function not(truthyP) {
- return when(truthyP).then(function(truthyVal) {
- return !truthyVal;
- });
-}
-
-exports.allObject = function allObject(objWithPromises) {
- return when(objWithPromises).then(function(objWithPromises) {
- var keys = Object.keys(objWithPromises);
- return when.all(keys.map(function(key) {
- return objWithPromise;
- })).then(function(vals) {
- var init = {};
- for (var k = 0; k < keys.length; ++k) {
- init[keys[k]] = vals[k];
- }
- return init;
- });
- });
-}
-
-exports.set = fn.lift(function(obj, values) {
- for (var key in values)
- obj[key] = values[key];
- return obj;
-});
-
-exports.if = function ifP (truthyP, fnTrue, fnFalse) {
- return truthyP.then(function(truthy) {
- if (truthy) return fnTrue();
- else return fnFalse();
- });
-}
-
-exports.get = fn.lift(function (obj, key) {
- return obj[key];
-});
-
-exports.eventuallyCall = fn.lift(function(obj, fnkey) {
- var args = [].slice.call(arguments, 2);
- obj[fnkey].apply(obj, args);
-});
diff --git a/benchmark/lib/timers-ctx.js b/benchmark/lib/timers-ctx.js
deleted file mode 100644
index a52b74d..0000000
--- a/benchmark/lib/timers-ctx.js
+++ /dev/null
@@ -1,479 +0,0 @@
-// Copyright Joyent, Inc. and other Node contributors.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a
-// copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to permit
-// persons to whom the Software is furnished to do so, subject to the
-// following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
-// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
-// USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-var Timer = process.binding('timer_wrap').Timer;
-var L = require('_linklist');
-var assert = require('assert').ok;
-
-var kOnTimeout = Timer.kOnTimeout | 0;
-
-// Timeout values > TIMEOUT_MAX are set to 1.
-var TIMEOUT_MAX = 2147483647; // 2^31-1
-
-
-var debug = require('util').debuglog('timer');
-
-
-// IDLE TIMEOUTS
-//
-// Because often many sockets will have the same idle timeout we will not
-// use one timeout watcher per item. It is too much overhead. Instead
-// we'll use a single watcher for all sockets with the same timeout value
-// and a linked list. This technique is described in the libev manual:
-// http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod#Be_smart_about_timeouts
-
-// Object containing all lists, timers
-// key = time in milliseconds
-// value = list
-var lists = {};
-
-// the main function - creates lists on demand and the watchers associated
-// with them.
-function insert(item, msecs) {
- item._idleStart = Timer.now();
- item._idleTimeout = msecs;
-
- if (msecs < 0) return;
-
- var list;
-
- if (lists[msecs]) {
- list = lists[msecs];
- } else {
- list = new Timer();
- list.start(msecs, 0);
-
- L.init(list);
-
- lists[msecs] = list;
- list.msecs = msecs;
- list[kOnTimeout] = listOnTimeout;
- }
-
- L.append(list, item);
- assert(!L.isEmpty(list)); // list is not empty
-}
-
-function listOnTimeout() {
- var msecs = this.msecs;
- var list = this;
-
- debug('timeout callback %d', msecs);
-
- var now = Timer.now();
- debug('now: %s', now);
-
- var first;
- while (first = L.peek(list)) {
- var diff = now - first._idleStart;
- if (diff < msecs) {
- list.start(msecs - diff, 0);
- debug('%d list wait because diff is %d', msecs, diff);
- return;
- } else {
- L.remove(first);
- assert(first !== L.peek(list));
-
- if (!first._onTimeout) continue;
-
- // v0.4 compatibility: if the timer callback throws and the
- // domain or uncaughtException handler ignore the exception,
- // other timers that expire on this tick should still run.
- //
- // https://github.com/joyent/node/issues/2631
- var domain = first.domain;
- if (domain && domain._disposed) continue;
- try {
- if (domain)
- domain.enter();
- var threw = true;
- if (!first._ctx || first._ctx === first)
- first._onTimeout();
- else
- first._onTimeout.call(first._ctx);
-
- if (domain)
- domain.exit();
- threw = false;
- } finally {
- if (threw) {
- process.nextTick(function() {
- list[kOnTimeout]();
- });
- }
- }
- }
- }
-
- debug('%d list empty', msecs);
- assert(L.isEmpty(list));
- list.close();
- delete lists[msecs];
-}
-
-
-var unenroll = exports.unenroll = function(item) {
- L.remove(item);
-
- var list = lists[item._idleTimeout];
- // if empty then stop the watcher
- debug('unenroll');
- if (list && L.isEmpty(list)) {
- debug('unenroll: list empty');
- list.close();
- delete lists[item._idleTimeout];
- }
- // if active is called later, then we want to make sure not to insert again
- item._idleTimeout = -1;
-};
-
-
-// Does not start the time, just sets up the members needed.
-exports.enroll = function(item, msecs) {
- // if this item was already in a list somewhere
- // then we should unenroll it from that
- if (item._idleNext) unenroll(item);
-
- // Ensure that msecs fits into signed int32
- if (msecs > 0x7fffffff) {
- msecs = 0x7fffffff;
- }
-
- item._idleTimeout = msecs;
- L.init(item);
-};
-
-
-// call this whenever the item is active (not idle)
-// it will reset its timeout.
-exports.active = function(item) {
- var msecs = item._idleTimeout;
- if (msecs >= 0) {
-
- var list = lists[msecs];
- if (!list || L.isEmpty(list)) {
- insert(item, msecs);
- } else {
- item._idleStart = Timer.now();
- L.append(list, item);
- }
- }
-};
-
-
-/*
- * DOM-style timers
- */
-
-
-exports.setTimeout = function(callback, ctx, after) {
- var timer;
-
- after *= 1; // coalesce to number or NaN
-
- if (!(after >= 1 && after <= TIMEOUT_MAX)) {
- after = 1; // schedule on next tick, follows browser behaviour
- }
-
- timer = new Timeout(after);
- timer._ctx = ctx;
- timer._onTimeout = callback;
-
- if (process.domain) timer.domain = process.domain;
-
- exports.active(timer);
-
- return timer;
-};
-
-
-exports.clearTimeout = function(timer) {
- if (timer && (timer[kOnTimeout] || timer._onTimeout)) {
- timer[kOnTimeout] = timer._onTimeout = null;
- if (timer instanceof Timeout) {
- timer.close(); // for after === 0
- } else {
- exports.unenroll(timer);
- }
- }
-};
-
-
-exports.setInterval = function(callback, repeat) {
- repeat *= 1; // coalesce to number or NaN
-
- if (!(repeat >= 1 && repeat <= TIMEOUT_MAX)) {
- repeat = 1; // schedule on next tick, follows browser behaviour
- }
-
- var timer = new Timeout(repeat);
- var args = Array.prototype.slice.call(arguments, 2);
- timer._onTimeout = wrapper;
- timer._repeat = true;
-
- if (process.domain) timer.domain = process.domain;
- exports.active(timer);
-
- return timer;
-
- function wrapper() {
- callback.apply(this, args);
- // If callback called clearInterval().
- if (timer._repeat === false) return;
- // If timer is unref'd (or was - it's permanently removed from the list.)
- if (this._handle) {
- this._handle.start(repeat, 0);
- } else {
- timer._idleTimeout = repeat;
- exports.active(timer);
- }
- }
-};
-
-
-exports.clearInterval = function(timer) {
- if (timer && timer._repeat) {
- timer._repeat = false;
- clearTimeout(timer);
- }
-};
-
-
-var Timeout = function(after) {
- this._idleTimeout = after;
- this._idlePrev = this;
- this._idleNext = this;
- this._idleStart = null;
- this._onTimeout = null;
- this._repeat = false;
- this._ctx = this;
-};
-
-Timeout.prototype.unref = function() {
- if (!this._handle) {
- var now = Timer.now();
- if (!this._idleStart) this._idleStart = now;
- var delay = this._idleStart + this._idleTimeout - now;
- if (delay < 0) delay = 0;
- exports.unenroll(this);
- this._handle = new Timer();
- this._handle[kOnTimeout] = this._onTimeout;
- this._handle.start(delay, 0);
- this._handle.domain = this.domain;
- this._handle.unref();
- } else {
- this._handle.unref();
- }
-};
-
-Timeout.prototype.ref = function() {
- if (this._handle)
- this._handle.ref();
-};
-
-Timeout.prototype.close = function() {
- this._onTimeout = this._ctx = null;
- if (this._handle) {
- this._handle[kOnTimeout] = null;
- this._handle.close();
- } else {
- exports.unenroll(this);
- }
-};
-
-
-var immediateQueue = {};
-L.init(immediateQueue);
-
-
-function processImmediate() {
- var queue = immediateQueue;
-
- immediateQueue = {};
- L.init(immediateQueue);
-
- while (L.isEmpty(queue) === false) {
- var immediate = L.shift(queue);
- var domain = immediate.domain;
- if (domain) domain.enter();
- immediate._onImmediate();
- if (domain) domain.exit();
- }
-
- // Only round-trip to C++ land if we have to. Calling clearImmediate() on an
- // immediate that's in |queue| is okay. Worst case is we make a superfluous
- // call to NeedImmediateCallbackSetter().
- if (L.isEmpty(immediateQueue)) {
- process._needImmediateCallback = false;
- }
-}
-
-
-exports.setImmediate = function(callback) {
- var immediate = {}, args;
-
- L.init(immediate);
-
- immediate._onImmediate = callback;
-
- if (arguments.length > 1) {
- args = Array.prototype.slice.call(arguments, 1);
-
- immediate._onImmediate = function() {
- callback.apply(immediate, args);
- };
- }
-
- if (!process._needImmediateCallback) {
- process._needImmediateCallback = true;
- process._immediateCallback = processImmediate;
- }
-
- if (process.domain) immediate.domain = process.domain;
-
- L.append(immediateQueue, immediate);
-
- return immediate;
-};
-
-
-exports.clearImmediate = function(immediate) {
- if (!immediate) return;
-
- immediate._onImmediate = undefined;
-
- L.remove(immediate);
-
- if (L.isEmpty(immediateQueue)) {
- process._needImmediateCallback = false;
- }
-};
-
-
-// Internal APIs that need timeouts should use timers._unrefActive isntead of
-// timers.active as internal timeouts shouldn't hold the loop open
-
-var unrefList, unrefTimer;
-
-
-function unrefTimeout() {
- var now = Timer.now();
-
- debug('unrefTimer fired');
-
- var first;
- while (first = L.peek(unrefList)) {
- var diff = now - first._idleStart;
-
- if (diff < first._idleTimeout) {
- diff = first._idleTimeout - diff;
- unrefTimer.start(diff, 0);
- unrefTimer.when = now + diff;
- debug('unrefTimer rescheudling for later');
- return;
- }
-
- L.remove(first);
-
- var domain = first.domain;
-
- if (!first._onTimeout) continue;
- if (domain && domain._disposed) continue;
-
- try {
- if (domain) domain.enter();
- var threw = true;
- debug('unreftimer firing timeout');
- if (!first._ctx || first._ctx === first)
- first._onTimeout();
- else
- first._onTimeout.call(first._ctx);
- threw = false;
- if (domain) domain.exit();
- } finally {
- if (threw) process.nextTick(unrefTimeout);
- }
- }
-
- debug('unrefList is empty');
- unrefTimer.when = -1;
-}
-
-
-exports._unrefActive = function(item) {
- var msecs = item._idleTimeout;
- if (!msecs || msecs < 0) return;
- assert(msecs >= 0);
-
- L.remove(item);
-
- if (!unrefList) {
- debug('unrefList initialized');
- unrefList = {};
- L.init(unrefList);
-
- debug('unrefTimer initialized');
- unrefTimer = new Timer();
- unrefTimer.unref();
- unrefTimer.when = -1;
- unrefTimer[kOnTimeout] = unrefTimeout;
- }
-
- var now = Timer.now();
- item._idleStart = now;
-
- if (L.isEmpty(unrefList)) {
- debug('unrefList empty');
- L.append(unrefList, item);
-
- unrefTimer.start(msecs, 0);
- unrefTimer.when = now + msecs;
- debug('unrefTimer scheduled');
- return;
- }
-
- var when = now + msecs;
-
- debug('unrefList find where we can insert');
-
- var cur, them;
-
- for (cur = unrefList._idlePrev; cur != unrefList; cur = cur._idlePrev) {
- them = cur._idleStart + cur._idleTimeout;
-
- if (when < them) {
- debug('unrefList inserting into middle of list');
-
- L.append(cur, item);
-
- if (unrefTimer.when > when) {
- debug('unrefTimer is scheduled to fire too late, reschedule');
- unrefTimer.start(msecs, 0);
- unrefTimer.when = when;
- }
-
- return;
- }
- }
-
- debug('unrefList append to end');
- L.append(unrefList, item);
-};
diff --git a/benchmark/madeup-parallel/callbacks-baseline.js b/benchmark/madeup-parallel/callbacks-baseline.js
deleted file mode 100644
index 9d49dcd..0000000
--- a/benchmark/madeup-parallel/callbacks-baseline.js
+++ /dev/null
@@ -1,25 +0,0 @@
-require('../lib/fakes');
-
-module.exports = function upload(stream, idOrPath, tag, done) {
- var tx = db.begin();
- var current = 0;
- var total = global.parallelQueries;
-
- function callback(err) {
- if( err ) {
- tx.rollback();
- done(err);
- }
- else {
- current++;
- if( current === total ) {
- tx.commit();
- done();
- }
- }
- }
-
- for( var i = 0; i < total; ++i ) {
- FileVersion.insert({index: i}).execWithin(tx, callback);
- }
-}
diff --git a/benchmark/madeup-parallel/callbacks-caolan-async-parallel.js b/benchmark/madeup-parallel/callbacks-caolan-async-parallel.js
deleted file mode 100644
index 054cc01..0000000
--- a/benchmark/madeup-parallel/callbacks-caolan-async-parallel.js
+++ /dev/null
@@ -1,29 +0,0 @@
-require('../lib/fakes');
-var async = require('async');
-
-function fileInsertFor(i, tx) {
- return function(callback) {
- FileVersion.insert({index: i})
- .execWithin(tx, callback);
- };
-}
-
-module.exports = function upload(stream, idOrPath, tag, done) {
- var queries = new Array(global.parallelQueries);
- var tx = db.begin();
-
- for( var i = 0, len = queries.length; i < len; ++i ) {
- queries[i] = fileInsertFor(i, tx);
- }
-
- async.parallel(queries, function(err, callback) {
- if (err) {
- tx.rollback();
- done(err);
- }
- else {
- tx.commit();
- done();
- }
- });
-}
diff --git a/benchmark/madeup-parallel/promises-bluebird-generator.js b/benchmark/madeup-parallel/promises-bluebird-generator.js
deleted file mode 100644
index 11071e7..0000000
--- a/benchmark/madeup-parallel/promises-bluebird-generator.js
+++ /dev/null
@@ -1,23 +0,0 @@
-global.useBluebird = true;
-global.useQ = false;
-var bluebird = require('../../js/main/bluebird.js');
-require('../lib/fakesP');
-
-module.exports = bluebird.coroutine(function* upload(stream, idOrPath, tag, done) {
- var queries = new Array(global.parallelQueries);
- var tx = db.begin();
-
- for( var i = 0, len = queries.length; i < len; ++i ) {
- queries[i] = FileVersion.insert({index: i}).execWithin(tx);
- }
-
- try {
- yield bluebird.all(queries);
- tx.commit();
- done();
- }
- catch(e) {
- tx.rollback();
- done(e);
- }
-});
diff --git a/benchmark/madeup-parallel/promises-bluebird.js b/benchmark/madeup-parallel/promises-bluebird.js
deleted file mode 100644
index 97d6663..0000000
--- a/benchmark/madeup-parallel/promises-bluebird.js
+++ /dev/null
@@ -1,21 +0,0 @@
-global.useBluebird = true;
-global.useQ = false;
-var Promise = require('../../js/main/bluebird.js');
-require('../lib/fakesP');
-
-module.exports = function upload(stream, idOrPath, tag, done) {
- var queries = new Array(global.parallelQueries);
- var tx = db.begin();
-
- for( var i = 0, len = queries.length; i < len; ++i ) {
- queries[i] = FileVersion.insert({index: i}).execWithin(tx);
- }
-
- Promise.all(queries).then().then(function() {
- tx.commit();
- done();
- }, function(err) {
- tx.rollback();
- done(err);
- });
-}
diff --git a/benchmark/madeup-parallel/promises-calvinmetcalf-lie.js b/benchmark/madeup-parallel/promises-calvinmetcalf-lie.js
deleted file mode 100644
index a26f329..0000000
--- a/benchmark/madeup-parallel/promises-calvinmetcalf-lie.js
+++ /dev/null
@@ -1,22 +0,0 @@
-global.useLie = true;
-
-var Promise = require("lie");
-
-require('../lib/fakesP');
-
-module.exports = function upload(stream, idOrPath, tag, done) {
- var queries = new Array(global.parallelQueries);
- var tx = db.begin();
-
- for( var i = 0, len = queries.length; i < len; ++i ) {
- queries[i] = FileVersion.insert({index: i}).execWithin(tx);
- }
-
- Promise.all(queries).then().then(function() {
- tx.commit();
- done();
- }, function(err) {
- tx.rollback();
- done(err);
- });
-}
diff --git a/benchmark/madeup-parallel/promises-cujojs-when.js b/benchmark/madeup-parallel/promises-cujojs-when.js
deleted file mode 100644
index 732c270..0000000
--- a/benchmark/madeup-parallel/promises-cujojs-when.js
+++ /dev/null
@@ -1,22 +0,0 @@
-global.useWhen = true;
-
-var when = require('when');
-
-require('../lib/fakesP');
-
-module.exports = function upload(stream, idOrPath, tag, done) {
- var queries = new Array(global.parallelQueries);
- var tx = db.begin();
-
- for( var i = 0, len = queries.length; i < len; ++i ) {
- queries[i] = FileVersion.insert({index: i}).execWithin(tx);
- }
-
- when.all(queries).then(function() {
- tx.commit();
- done();
- }, function(err) {
- tx.rollback();
- done(err);
- });
-};
diff --git a/benchmark/madeup-parallel/promises-dfilatov-vow.js b/benchmark/madeup-parallel/promises-dfilatov-vow.js
deleted file mode 100644
index 488ab41..0000000
--- a/benchmark/madeup-parallel/promises-dfilatov-vow.js
+++ /dev/null
@@ -1,21 +0,0 @@
-var vow = require('vow'),
- p = require('../lib/promiseSupport.js');
-
-require('../lib/fakesP');
-
-module.exports = function upload(stream, idOrPath, tag, done) {
- var queries = new Array(global.parallelQueries);
- var tx = db.begin();
-
- for( var i = 0, len = queries.length; i < len; ++i ) {
- queries[i] = FileVersion.insert({index: i}).execWithin(tx);
- }
-
- vow.all(queries).then(function() {
- tx.commit();
- done();
- }, function(err) {
- tx.rollback();
- done(err);
- });
-}
diff --git a/benchmark/madeup-parallel/promises-ecmascript6-native.js b/benchmark/madeup-parallel/promises-ecmascript6-native.js
deleted file mode 100644
index 219c087..0000000
--- a/benchmark/madeup-parallel/promises-ecmascript6-native.js
+++ /dev/null
@@ -1,27 +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");
-}
-
-require('../lib/fakesP');
-
-module.exports = function upload(stream, idOrPath, tag, done) {
- var queries = new Array(global.parallelQueries);
- var tx = db.begin();
-
- for( var i = 0, len = queries.length; i < len; ++i ) {
- queries[i] = FileVersion.insert({index: i}).execWithin(tx);
- }
-
- Promise.all(queries).then().then(function() {
- tx.commit();
- done();
- }, function(err) {
- tx.rollback();
- done(err);
- });
-}
diff --git a/benchmark/madeup-parallel/promises-lvivski-davy.js b/benchmark/madeup-parallel/promises-lvivski-davy.js
deleted file mode 100755
index b075fd4..0000000
--- a/benchmark/madeup-parallel/promises-lvivski-davy.js
+++ /dev/null
@@ -1,22 +0,0 @@
-global.useDavy = true;
-
-var davy = require('davy');
-
-require('../lib/fakesP');
-
-module.exports = function upload(stream, idOrPath, tag, done) {
- var queries = new Array(global.parallelQueries);
- var tx = db.begin();
-
- for( var i = 0, len = queries.length; i < len; ++i ) {
- queries[i] = FileVersion.insert({index: i}).execWithin(tx);
- }
-
- davy.all(queries).then(function() {
- tx.commit();
- done();
- }, function(err) {
- tx.rollback();
- done(err);
- });
-}
diff --git a/benchmark/madeup-parallel/promises-medikoo-deferred.js b/benchmark/madeup-parallel/promises-medikoo-deferred.js
deleted file mode 100644
index 2cc25dc..0000000
--- a/benchmark/madeup-parallel/promises-medikoo-deferred.js
+++ /dev/null
@@ -1,27 +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 queries = new Array(global.parallelQueries);
- var tx = db.begin();
-
- for( var i = 0, len = queries.length; i < len; ++i ) {
- queries[i] = FileVersion.insert({index: i}).execWithin(tx);
- }
-
- //Couldn't find .all in docs, this seems closest
- deferred.map(queries, identity)(function() {
- tx.commit();
- done();
- }, function(err) {
- tx.rollback();
- done(err);
- });
-}
diff --git a/benchmark/madeup-parallel/promises-obvious-kew.js b/benchmark/madeup-parallel/promises-obvious-kew.js
deleted file mode 100644
index a51f199..0000000
--- a/benchmark/madeup-parallel/promises-obvious-kew.js
+++ /dev/null
@@ -1,22 +0,0 @@
-global.useKew = true;
-
-var q = require('kew');
-
-require('../lib/fakesP');
-
-module.exports = function upload(stream, idOrPath, tag, done) {
- var queries = new Array(global.parallelQueries);
- var tx = db.begin();
-
- for( var i = 0, len = queries.length; i < len; ++i ) {
- queries[i] = FileVersion.insert({index: i}).execWithin(tx);
- }
-
- q.all(queries).then(function() {
- tx.commit();
- done();
- }, function(err) {
- tx.rollback();
- done(err);
- });
-}
diff --git a/benchmark/madeup-parallel/promises-then-promise.js b/benchmark/madeup-parallel/promises-then-promise.js
deleted file mode 100644
index da978cf..0000000
--- a/benchmark/madeup-parallel/promises-then-promise.js
+++ /dev/null
@@ -1,22 +0,0 @@
-global.useThenPromise = true;
-
-var Promise = require("promise");
-
-require('../lib/fakesP');
-
-module.exports = function upload(stream, idOrPath, tag, done) {
- var queries = new Array(global.parallelQueries);
- var tx = db.begin();
-
- for( var i = 0, len = queries.length; i < len; ++i ) {
- queries[i] = FileVersion.insert({index: i}).execWithin(tx);
- }
-
- Promise.all(queries).then().then(function() {
- tx.commit();
- done();
- }, function(err) {
- tx.rollback();
- done(err);
- });
-}
diff --git a/benchmark/madeup-parallel/promises-tildeio-rsvp.js b/benchmark/madeup-parallel/promises-tildeio-rsvp.js
deleted file mode 100644
index ae16a14..0000000
--- a/benchmark/madeup-parallel/promises-tildeio-rsvp.js
+++ /dev/null
@@ -1,22 +0,0 @@
-global.useRSVP = true;
-
-var RSVP = require('rsvp');
-
-require('../lib/fakesP');
-
-module.exports = function upload(stream, idOrPath, tag, done) {
- var queries = new Array(global.parallelQueries);
- var tx = db.begin();
-
- for( var i = 0, len = queries.length; i < len; ++i ) {
- queries[i] = FileVersion.insert({index: i}).execWithin(tx);
- }
-
- RSVP.all(queries).then(function() {
- tx.commit();
- done();
- }, function(err) {
- tx.rollback();
- done(err);
- });
-};
diff --git a/benchmark/package.json b/benchmark/package.json
deleted file mode 100644
index 611fb1a..0000000
--- a/benchmark/package.json
+++ /dev/null
@@ -1,35 +0,0 @@
-{
- "name": "async-compare",
- "version": "0.1.1",
- "description": "Compare the performance and code of multiple async patterns",
- "main": "perf.js",
- "dependencies": {
- "async": "^0.9.0",
- "davy": "^0.3.3",
- "deferred": "~0.7.0",
- "kew": "^0.5.0-alpha.1",
- "lie": "^2.7.2",
- "optimist": "~0.6.0",
- "promise": "^6.0.1",
- "q": "^1.1.2",
- "rsvp": "^3.0.16",
- "text-table": "~0.2.0",
- "vow": "~0.4.1",
- "when": "^3.6.4"
- },
- "devDependencies": {},
- "scripts": {
- "test": "echo \"Error: no test specified\" && exit 1"
- },
- "keywords": [
- "generators",
- "fibers",
- "promises",
- "callbacks",
- "comparison",
- "compare",
- "async"
- ],
- "author": "spion",
- "license": "MIT"
-}
diff --git a/benchmark/performance.js b/benchmark/performance.js
deleted file mode 100644
index 0517154..0000000
--- a/benchmark/performance.js
+++ /dev/null
@@ -1,177 +0,0 @@
-
-var args = require('optimist').argv;
-
-var util = require('util');
-
-var path = require('path');
-
-global.LIKELIHOOD_OF_REJECTION = args.e || 0.1;
-global.triggerIntentionalError = function(){
- if(LIKELIHOOD_OF_REJECTION && Math.random() <= LIKELIHOOD_OF_REJECTION) throw new Error("intentional failure");
-}
-
-function printPlatform() {
- console.log("\nPlatform info:");
- var os = require("os");
- var v8 = process.versions.v8;
- var node = process.versions.node;
- var plat = os.type() + " " + os.release() + " " + os.arch() + "\nNode.JS " + node + "\nV8 " + v8;
- var cpus = os.cpus().map(function(cpu){
- return cpu.model;
- }).reduce(function(o, model){
- if( !o[model] ) o[model] = 0;
- o[model]++;
- return o;
- }, {});
- cpus = Object.keys(cpus).map(function( key ){
- return key + " \u00d7 " + cpus[key];
- }).join("\n");
- console.log(plat + "\n" + cpus + "\n");
-}
-
-var perf = module.exports = function(args, done) {
-
- var errs = 0;
- var lastErr;
- var times = args.n;
-
- global.asyncTime = args.t;
- global.parallelQueries = args.p || 10;
-
- if (args.longStackSupport) {
- global.longStackSupport = require('q').longStackSupport
- = args.longStackSupport;
- require('bluebird').longStackTraces();
- }
-
- var fn = require(args.file);
-
- var start = Date.now();
-
-
- var warmedUp = 0;
- var tot = Math.min( 350, times );
- for (var k = 0, kn = tot; k < kn; ++k)
- fn(k,'b','c', warmup);
-
- var memMax; var memStart; var start;
- function warmup() {
- warmedUp++
- if( warmedUp === tot ) {
- start = Date.now();
-
- memStart = process.memoryUsage().rss;
- for (var k = 0, kn = args.n; k < kn; ++k)
- fn(k, 'b', 'c', cb);
- memMax = process.memoryUsage().rss;
- }
- }
-
- function cb (err) {
- if (err && err.message !== "intentional failure") {
- ++errs;
- lastErr = err;
- }
- memMax = Math.max(memMax, process.memoryUsage().rss);
- if (!--times) {
- fn.end && fn.end();
- done(null, {
- time: Date.now() - start,
- mem: (memMax - memStart)/1024/1024,
- errors: errs,
- lastErr: lastErr ? lastErr.stack : null
- });
- }
- }
-}
-
-
-function report(err, res) {
- console.log(JSON.stringify(res));
-}
-
-if (args.file) {
- perf(args, function(err, res) {
- report(err, res);
- if (res.lastErr)
- console.error(res.lastErr);
- });
-} else {
- var cp = require('child_process')
- var async = require('async');
- var fs = require('fs');
- var dir = __dirname + '/examples';
-
- var table = require('text-table');
-
-
- var files = args._.filter(function(f) {
- return !/^src-/.test(path.basename(f));
- });
-
- measure(files, args.n, args.t, args.p, function(err, res) {
- console.log("");
- console.log("results for", args.n, "parallel executions,",
- args.t, "ms per I/O op");
- if(args.e) console.log("Likelihood of rejection:", args.e);
-
- res.sort(function(r1, r2) {
- return parseFloat(r1.data.time) - parseFloat(r2.data.time)
- });
- console.log("");
- res = res.map(function(r) {
- var failText = 'OOM';
- if (r.data.timeout) failText = 'T/O';
- return [path.basename(r.file),
- r.data.mem != null ? r.data.time: failText,
- r.data.mem != null ? r.data.mem.toFixed(2) : failText]
- });
-
- res = [['file', 'time(ms)', 'memory(MB)']].concat(res)
-
- console.log(table(res, {align: ['l', 'r', 'r']}));
- printPlatform();
-
- });
-}
-
-
-function measure(files, requests, time, parg, callback) {
- async.mapSeries(files, function(f, done) {
- console.log("benchmarking", f);
- var logFile = path.basename(f) + ".log";
- var profileFlags = ["--prof", "--logfile=C:/etc/v8/" + logFile];
-
- var argsFork = [__filename,
- '--n', requests,
- '--t', time,
- '--p', parg,
- '--file', f];
- if (args.profile) argsFork = profileFlags.concat(argsFork);
- if (args.harmony) argsFork.unshift('--harmony');
- if (args.longStackSupport) argsFork.push('--longStackSupport');
- var p = cp.spawn(process.execPath, argsFork);
-
- var complete = false, timedout = false;
- if (args.timeout) setTimeout(function() {
- if (complete) return;
- timedout = true;
- p.kill();
- }, args.timeout);
-
- var r = { file: f, data: [] };
- p.stdout.on('data', function(d) { r.data.push(d.toString()); });
- p.stdout.pipe(process.stdout);
- p.stderr.pipe(process.stderr);
- p.stdout.on('end', function(code) {
- complete = true;
- try {
- r.data = JSON.parse(r.data.join(''));
- } catch(e) {
- r.data = {time: Number.POSITIVE_INFINITY, mem: null,
- missing: true, timeout: timedout};
- }
- done(null, r);
- });
- }, callback);
-}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-bluebird.git
More information about the Pkg-javascript-commits
mailing list