aboutsummaryrefslogtreecommitdiffhomepage
path: root/node_modules/after
diff options
context:
space:
mode:
authorYaroslav De La Peña Smirnov <yaros.rus_89@live.com.mx>2017-11-29 11:44:34 +0300
committerYaroslav De La Peña Smirnov <yaros.rus_89@live.com.mx>2017-11-29 11:44:34 +0300
commit67fdec20726e48ba3a934cb25bb30d47ec4a4f29 (patch)
tree37fd9f4f0b0c20103e1646fc83021e4765de3680 /node_modules/after
downloadspanish-checkers-67fdec20726e48ba3a934cb25bb30d47ec4a4f29.tar.gz
spanish-checkers-67fdec20726e48ba3a934cb25bb30d47ec4a4f29.zip
Initial commit, version 0.5.3
Diffstat (limited to 'node_modules/after')
-rw-r--r--node_modules/after/.npmignore2
-rw-r--r--node_modules/after/.travis.yml12
-rw-r--r--node_modules/after/LICENCE19
-rw-r--r--node_modules/after/README.md115
-rw-r--r--node_modules/after/index.js28
-rw-r--r--node_modules/after/package.json103
-rw-r--r--node_modules/after/test/after-test.js120
7 files changed, 399 insertions, 0 deletions
diff --git a/node_modules/after/.npmignore b/node_modules/after/.npmignore
new file mode 100644
index 0000000..6c78602
--- /dev/null
+++ b/node_modules/after/.npmignore
@@ -0,0 +1,2 @@
+node_modules
+.monitor
diff --git a/node_modules/after/.travis.yml b/node_modules/after/.travis.yml
new file mode 100644
index 0000000..afd72d0
--- /dev/null
+++ b/node_modules/after/.travis.yml
@@ -0,0 +1,12 @@
+language: node_js
+node_js:
+ - 0.6
+ - 0.8
+ - 0.9
+ - 0.10
+ - 0.12
+ - 4.2.4
+ - 5.4.1
+ - iojs-1
+ - iojs-2
+ - iojs-3
diff --git a/node_modules/after/LICENCE b/node_modules/after/LICENCE
new file mode 100644
index 0000000..7c35130
--- /dev/null
+++ b/node_modules/after/LICENCE
@@ -0,0 +1,19 @@
+Copyright (c) 2011 Raynos.
+
+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. \ No newline at end of file
diff --git a/node_modules/after/README.md b/node_modules/after/README.md
new file mode 100644
index 0000000..fc69096
--- /dev/null
+++ b/node_modules/after/README.md
@@ -0,0 +1,115 @@
+# After [![Build Status][1]][2]
+
+Invoke callback after n calls
+
+## Status: production ready
+
+## Example
+
+```js
+var after = require("after")
+var db = require("./db") // some db.
+
+var updateUser = function (req, res) {
+ // use after to run two tasks in parallel,
+ // namely get request body and get session
+ // then run updateUser with the results
+ var next = after(2, updateUser)
+ var results = {}
+
+ getJSONBody(req, res, function (err, body) {
+ if (err) return next(err)
+
+ results.body = body
+ next(null, results)
+ })
+
+ getSessionUser(req, res, function (err, user) {
+ if (err) return next(err)
+
+ results.user = user
+ next(null, results)
+ })
+
+ // now do the thing!
+ function updateUser(err, result) {
+ if (err) {
+ res.statusCode = 500
+ return res.end("Unexpected Error")
+ }
+
+ if (!result.user || result.user.role !== "admin") {
+ res.statusCode = 403
+ return res.end("Permission Denied")
+ }
+
+ db.put("users:" + req.params.userId, result.body, function (err) {
+ if (err) {
+ res.statusCode = 500
+ return res.end("Unexpected Error")
+ }
+
+ res.statusCode = 200
+ res.end("Ok")
+ })
+ }
+}
+```
+
+## Naive Example
+
+```js
+var after = require("after")
+ , next = after(3, logItWorks)
+
+next()
+next()
+next() // it works
+
+function logItWorks() {
+ console.log("it works!")
+}
+```
+
+## Example with error handling
+
+```js
+var after = require("after")
+ , next = after(3, logError)
+
+next()
+next(new Error("oops")) // logs oops
+next() // does nothing
+
+// This callback is only called once.
+// If there is an error the callback gets called immediately
+// this avoids the situation where errors get lost.
+function logError(err) {
+ console.log(err)
+}
+```
+
+## Installation
+
+`npm install after`
+
+## Tests
+
+`npm test`
+
+## Contributors
+
+ - Raynos
+ - defunctzombie
+
+## MIT Licenced
+
+ [1]: https://secure.travis-ci.org/Raynos/after.png
+ [2]: http://travis-ci.org/Raynos/after
+ [3]: http://raynos.org/blog/2/Flow-control-in-node.js
+ [4]: http://stackoverflow.com/questions/6852059/determining-the-end-of-asynchronous-operations-javascript/6852307#6852307
+ [5]: http://stackoverflow.com/questions/6869872/in-javascript-what-are-best-practices-for-executing-multiple-asynchronous-functi/6870031#6870031
+ [6]: http://stackoverflow.com/questions/6864397/javascript-performance-long-running-tasks/6889419#6889419
+ [7]: http://stackoverflow.com/questions/6597493/synchronous-database-queries-with-node-js/6620091#6620091
+ [8]: http://github.com/Raynos/iterators
+ [9]: http://github.com/Raynos/composite
diff --git a/node_modules/after/index.js b/node_modules/after/index.js
new file mode 100644
index 0000000..ec24879
--- /dev/null
+++ b/node_modules/after/index.js
@@ -0,0 +1,28 @@
+module.exports = after
+
+function after(count, callback, err_cb) {
+ var bail = false
+ err_cb = err_cb || noop
+ proxy.count = count
+
+ return (count === 0) ? callback() : proxy
+
+ function proxy(err, result) {
+ if (proxy.count <= 0) {
+ throw new Error('after called too many times')
+ }
+ --proxy.count
+
+ // after first error, rest are passed to err_cb
+ if (err) {
+ bail = true
+ callback(err)
+ // future error callbacks will go to error handler
+ callback = err_cb
+ } else if (proxy.count === 0 && !bail) {
+ callback(null, result)
+ }
+ }
+}
+
+function noop() {}
diff --git a/node_modules/after/package.json b/node_modules/after/package.json
new file mode 100644
index 0000000..76304d2
--- /dev/null
+++ b/node_modules/after/package.json
@@ -0,0 +1,103 @@
+{
+ "_args": [
+ [
+ {
+ "raw": "after@0.8.2",
+ "scope": null,
+ "escapedName": "after",
+ "name": "after",
+ "rawSpec": "0.8.2",
+ "spec": "0.8.2",
+ "type": "version"
+ },
+ "/mnt/e/Yaroslav/Documents/Webs/nodejs/checkers/node_modules/engine.io-parser"
+ ]
+ ],
+ "_from": "after@0.8.2",
+ "_id": "after@0.8.2",
+ "_inCache": true,
+ "_location": "/after",
+ "_nodeVersion": "0.10.32",
+ "_npmOperationalInternal": {
+ "host": "packages-12-west.internal.npmjs.com",
+ "tmp": "tmp/after-0.8.2.tgz_1471308639186_0.9132961586583406"
+ },
+ "_npmUser": {
+ "name": "raynos",
+ "email": "raynos2@gmail.com"
+ },
+ "_npmVersion": "2.15.9",
+ "_phantomChildren": {},
+ "_requested": {
+ "raw": "after@0.8.2",
+ "scope": null,
+ "escapedName": "after",
+ "name": "after",
+ "rawSpec": "0.8.2",
+ "spec": "0.8.2",
+ "type": "version"
+ },
+ "_requiredBy": [
+ "/engine.io-parser"
+ ],
+ "_resolved": "https://registry.npmjs.org/after/-/after-0.8.2.tgz",
+ "_shasum": "fedb394f9f0e02aa9768e702bda23b505fae7e1f",
+ "_shrinkwrap": null,
+ "_spec": "after@0.8.2",
+ "_where": "/mnt/e/Yaroslav/Documents/Webs/nodejs/checkers/node_modules/engine.io-parser",
+ "author": {
+ "name": "Raynos",
+ "email": "raynos2@gmail.com"
+ },
+ "bugs": {
+ "url": "https://github.com/Raynos/after/issues"
+ },
+ "contributors": [
+ {
+ "name": "Raynos",
+ "email": "raynos2@gmail.com",
+ "url": "http://raynos.org"
+ }
+ ],
+ "dependencies": {},
+ "description": "after - tiny flow control",
+ "devDependencies": {
+ "mocha": "~1.8.1"
+ },
+ "directories": {},
+ "dist": {
+ "shasum": "fedb394f9f0e02aa9768e702bda23b505fae7e1f",
+ "tarball": "https://registry.npmjs.org/after/-/after-0.8.2.tgz"
+ },
+ "gitHead": "e8c26046f36962b90e68dc5df33a9672a54b25f5",
+ "homepage": "https://github.com/Raynos/after#readme",
+ "keywords": [
+ "flowcontrol",
+ "after",
+ "flow",
+ "control",
+ "arch"
+ ],
+ "license": "MIT",
+ "maintainers": [
+ {
+ "name": "raynos",
+ "email": "raynos2@gmail.com"
+ },
+ {
+ "name": "defunctzombie",
+ "email": "shtylman@gmail.com"
+ }
+ ],
+ "name": "after",
+ "optionalDependencies": {},
+ "readme": "ERROR: No README data found!",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/Raynos/after.git"
+ },
+ "scripts": {
+ "test": "mocha --ui tdd --reporter spec test/*.js"
+ },
+ "version": "0.8.2"
+}
diff --git a/node_modules/after/test/after-test.js b/node_modules/after/test/after-test.js
new file mode 100644
index 0000000..0d63f4c
--- /dev/null
+++ b/node_modules/after/test/after-test.js
@@ -0,0 +1,120 @@
+/*global suite, test*/
+
+var assert = require("assert")
+ , after = require("../")
+
+test("exists", function () {
+ assert(typeof after === "function", "after is not a function")
+})
+
+test("after when called with 0 invokes", function (done) {
+ after(0, done)
+});
+
+test("after 1", function (done) {
+ var next = after(1, done)
+ next()
+})
+
+test("after 5", function (done) {
+ var next = after(5, done)
+ , i = 5
+
+ while (i--) {
+ next()
+ }
+})
+
+test("manipulate count", function (done) {
+ var next = after(1, done)
+ , i = 5
+
+ next.count = i
+ while (i--) {
+ next()
+ }
+})
+
+test("after terminates on error", function (done) {
+ var next = after(2, function(err) {
+ assert.equal(err.message, 'test');
+ done();
+ })
+ next(new Error('test'))
+ next(new Error('test2'))
+})
+
+test('gee', function(done) {
+ done = after(2, done)
+
+ function cb(err) {
+ assert.equal(err.message, 1);
+ done()
+ }
+
+ var next = after(3, cb, function(err) {
+ assert.equal(err.message, 2)
+ done()
+ });
+
+ next()
+ next(new Error(1))
+ next(new Error(2))
+})
+
+test('eee', function(done) {
+ done = after(3, done)
+
+ function cb(err) {
+ assert.equal(err.message, 1);
+ done()
+ }
+
+ var next = after(3, cb, function(err) {
+ assert.equal(err.message, 2)
+ done()
+ });
+
+ next(new Error(1))
+ next(new Error(2))
+ next(new Error(2))
+})
+
+test('gge', function(done) {
+ function cb(err) {
+ assert.equal(err.message, 1);
+ done()
+ }
+
+ var next = after(3, cb, function(err) {
+ // should not happen
+ assert.ok(false);
+ });
+
+ next()
+ next()
+ next(new Error(1))
+})
+
+test('egg', function(done) {
+ function cb(err) {
+ assert.equal(err.message, 1);
+ done()
+ }
+
+ var next = after(3, cb, function(err) {
+ // should not happen
+ assert.ok(false);
+ });
+
+ next(new Error(1))
+ next()
+ next()
+})
+
+test('throws on too many calls', function(done) {
+ var next = after(1, done);
+ next()
+ assert.throws(next, /after called too many times/);
+});
+