node-fibers-synchronize-helper
Advanced tools
+1
-1
@@ -1,2 +0,2 @@ | ||
| var sync = require('synchronize'); | ||
| var sync = require('synchronize_f2'); | ||
@@ -3,0 +3,0 @@ var synchObj = function (that, returnParamsNameArr) { |
+20
-18
| { | ||
| "name": "node-fibers-synchronize-helper", | ||
| "version": "1.1.2", | ||
| "version": "2.0.0", | ||
| "description": "helper for synchronize promise and callback and manage variables on Fiber Thread as ThreadLocal", | ||
| "main": "index.js", | ||
| "scripts": { | ||
| "test": "echo \"Error: no test specified\" && exit 1" | ||
| "test": "node test.js" | ||
| }, | ||
| "dependencies": { | ||
| "synchronize": "2.0.0" | ||
| "synchronize_f2": "2.0.1" | ||
| }, | ||
| "devDependencies": { | ||
| "mongodb": "^2.2.33" | ||
| }, | ||
| "repository": { | ||
@@ -18,17 +21,16 @@ "type": "git", | ||
| "nodejs", | ||
| "node", | ||
| "fiber", | ||
| "synchronize", | ||
| "promise", | ||
| "callback", | ||
| "helper", | ||
| "sync", | ||
| "avoid callback", | ||
| "callback hell", | ||
| "fiber thread", | ||
| "ThreadLocal", | ||
| "Java ThreadLocal", | ||
| "Underlying Fiber Thread Objects" | ||
| ], | ||
| "node", | ||
| "fiber", | ||
| "synchronize", | ||
| "promise", | ||
| "callback", | ||
| "helper", | ||
| "sync", | ||
| "avoid callback", | ||
| "callback hell", | ||
| "fiber thread", | ||
| "ThreadLocal", | ||
| "Java ThreadLocal", | ||
| "Underlying Fiber Thread Objects" | ||
| ], | ||
| "author": "davide.zaccheo@gmail.com", | ||
@@ -35,0 +37,0 @@ "license": "ISC", |
+2
-0
| # node-fibers-synchronize-helper | ||
| This helper uses synchronize module (https://www.npmjs.com/package/synchronize) and helps to manage promises and callbacks, and manage variables on underlying Fiber Thread like Java ThreadLocal, **you will be able to synchronize callback and promises** and **develop syncronously as your did in Java** returning Objects and catch exceptions, and set-get Objects on your Fiber Thread as you did with Java **ThreadLocal**. | ||
| Note version 2.0.x: | ||
| updated Fibers version to 2.0.0 by synchronize_f2 module (just a synchronize fork with pointing to Fibers 2.0.0) | ||
@@ -5,0 +7,0 @@ |
+24
-7
@@ -10,3 +10,3 @@ //TEST | ||
| var url = 'mongodb://localhost:27017/local'; | ||
| var url = 'mongodb://localhost:27017/test'; | ||
| console.log("CALLBACK") | ||
@@ -18,10 +18,27 @@ MongoClient.connect(url, function (err, db) { | ||
| console.log("PROMISE") | ||
| MongoClient.connect(url).then(function (res) { | ||
| var collection = res.collection('test_correctly_access_collections2'); | ||
| assert.notEqual(null, collection); | ||
| var insertDocuments = function(db, callback) { | ||
| // Get the documents collection | ||
| var collection = db.collection('documents'); | ||
| // Insert some documents | ||
| collection.insertMany([ | ||
| {a : 1}, {a : 2}, {a : 3} | ||
| ], function(err, result) { | ||
| assert.equal(err, null); | ||
| assert.equal(3, result.result.n); | ||
| assert.equal(3, result.ops.length); | ||
| console.log("Inserted 3 documents into the collection"); | ||
| callback(result); | ||
| }); | ||
| } | ||
| }).catch(function (err) { | ||
| // console.log("err:" + err); | ||
| }) | ||
| MongoClient.connect(url, function(err, db) { | ||
| assert.equal(null, err); | ||
| console.log("Connected successfully to server"); | ||
| insertDocuments(db, function() { | ||
| db.close(); | ||
| }); | ||
| }); | ||
| console.log("SYNCH") | ||
@@ -28,0 +45,0 @@ |
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
16900
3.79%307
5.14%0
-100%193
1.05%1
Infinity%+ Added
+ Added
+ Added
- Removed
- Removed
- Removed