@options {Object} Optional Options to consume by prompt
-
-
Starts the prompt by listening to the appropriate events on options.stdin
-and options.stdout. If no streams are supplied, then process.stdin
-and process.stdout are used, respectively.
\ No newline at end of file
diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/pkginfo/examples/all-properties.js b/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/pkginfo/examples/all-properties.js
deleted file mode 100644
index fd1d831..0000000
--- a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/pkginfo/examples/all-properties.js
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * all-properties.js: Sample of including all properties from a package.json file
- *
- * (C) 2011, Charlie Robbins
- *
- */
-
-var util = require('util'),
- pkginfo = require('../lib/pkginfo')(module);
-
-exports.someFunction = function () {
- console.log('some of your custom logic here');
-};
-
-console.log('Inspecting module:');
-console.dir(module.exports);
-
-console.log('\nAll exports exposed:');
-console.error(Object.keys(module.exports));
\ No newline at end of file
diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/pkginfo/examples/array-argument.js b/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/pkginfo/examples/array-argument.js
deleted file mode 100644
index b1b6848..0000000
--- a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/pkginfo/examples/array-argument.js
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * array-argument.js: Sample of including specific properties from a package.json file
- * using Array argument syntax.
- *
- * (C) 2011, Charlie Robbins
- *
- */
-
-var util = require('util'),
- pkginfo = require('../lib/pkginfo')(module, ['version', 'author']);
-
-exports.someFunction = function () {
- console.log('some of your custom logic here');
-};
-
-console.log('Inspecting module:');
-console.dir(module.exports);
-
-console.log('\nAll exports exposed:');
-console.error(Object.keys(module.exports));
\ No newline at end of file
diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/pkginfo/examples/multiple-properties.js b/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/pkginfo/examples/multiple-properties.js
deleted file mode 100644
index b4b5fd6..0000000
--- a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/pkginfo/examples/multiple-properties.js
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * multiple-properties.js: Sample of including multiple properties from a package.json file
- *
- * (C) 2011, Charlie Robbins
- *
- */
-
-var util = require('util'),
- pkginfo = require('../lib/pkginfo')(module, 'version', 'author');
-
-exports.someFunction = function () {
- console.log('some of your custom logic here');
-};
-
-console.log('Inspecting module:');
-console.dir(module.exports);
-
-console.log('\nAll exports exposed:');
-console.error(Object.keys(module.exports));
\ No newline at end of file
diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/pkginfo/examples/object-argument.js b/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/pkginfo/examples/object-argument.js
deleted file mode 100644
index 28420c8..0000000
--- a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/pkginfo/examples/object-argument.js
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * object-argument.js: Sample of including specific properties from a package.json file
- * using Object argument syntax.
- *
- * (C) 2011, Charlie Robbins
- *
- */
-
-var util = require('util'),
- pkginfo = require('../lib/pkginfo')(module, {
- include: ['version', 'author']
- });
-
-exports.someFunction = function () {
- console.log('some of your custom logic here');
-};
-
-console.log('Inspecting module:');
-console.dir(module.exports);
-
-console.log('\nAll exports exposed:');
-console.error(Object.keys(module.exports));
\ No newline at end of file
diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/pkginfo/examples/package.json b/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/pkginfo/examples/package.json
deleted file mode 100644
index 1f2f01c..0000000
--- a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/pkginfo/examples/package.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "name": "simple-app",
- "description": "A test fixture for pkginfo",
- "version": "0.1.0",
- "author": "Charlie Robbins ",
- "keywords": ["test", "fixture"],
- "main": "./index.js",
- "scripts": { "test": "vows test/*-test.js --spec" },
- "engines": { "node": ">= 0.4.0" }
-}
diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/pkginfo/examples/single-property.js b/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/pkginfo/examples/single-property.js
deleted file mode 100644
index 4f44561..0000000
--- a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/pkginfo/examples/single-property.js
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * single-property.js: Sample of including a single specific properties from a package.json file
- *
- * (C) 2011, Charlie Robbins
- *
- */
-
-var util = require('util'),
- pkginfo = require('../lib/pkginfo')(module, 'version');
-
-exports.someFunction = function () {
- console.log('some of your custom logic here');
-};
-
-console.log('Inspecting module:');
-console.dir(module.exports);
-
-console.log('\nAll exports exposed:');
-console.error(Object.keys(module.exports));
\ No newline at end of file
diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/pkginfo/examples/subdir/package.json b/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/pkginfo/examples/subdir/package.json
deleted file mode 100644
index aa85410..0000000
--- a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/pkginfo/examples/subdir/package.json
+++ /dev/null
@@ -1,11 +0,0 @@
-{
- "name": "simple-app-subdir",
- "description": "A test fixture for pkginfo",
- "version": "0.1.0",
- "author": "Charlie Robbins ",
- "keywords": ["test", "fixture"],
- "main": "./index.js",
- "scripts": { "test": "vows test/*-test.js --spec" },
- "engines": { "node": ">= 0.4.0" },
- "subdironly": "true"
-}
diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/pkginfo/examples/target-dir.js b/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/pkginfo/examples/target-dir.js
deleted file mode 100644
index 88770e6..0000000
--- a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/pkginfo/examples/target-dir.js
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * multiple-properties.js: Sample of including multiple properties from a package.json file
- *
- * (C) 2011, Charlie Robbins
- *
- */
-
-var util = require('util'),
- path = require('path'),
- pkginfo = require('../lib/pkginfo')(module, { dir: path.resolve(__dirname, 'subdir' )});
-
-exports.someFunction = function () {
- console.log('some of your custom logic here');
-};
-
-console.log('Inspecting module:');
-console.dir(module.exports);
-
-console.log('\nAll exports exposed:');
-console.error(Object.keys(module.exports));
\ No newline at end of file
diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/pkginfo/lib/pkginfo.js b/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/pkginfo/lib/pkginfo.js
deleted file mode 100644
index c5dc020..0000000
--- a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/pkginfo/lib/pkginfo.js
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * pkginfo.js: Top-level include for the pkginfo module
- *
- * (C) 2011, Charlie Robbins
- *
- */
-
-var fs = require('fs'),
- path = require('path');
-
-//
-// ### function pkginfo ([options, 'property', 'property' ..])
-// #### @pmodule {Module} Parent module to read from.
-// #### @options {Object|Array|string} **Optional** Options used when exposing properties.
-// #### @arguments {string...} **Optional** Specified properties to expose.
-// Exposes properties from the package.json file for the parent module on
-// it's exports. Valid usage:
-//
-// `require('pkginfo')()`
-//
-// `require('pkginfo')('version', 'author');`
-//
-// `require('pkginfo')(['version', 'author']);`
-//
-// `require('pkginfo')({ include: ['version', 'author'] });`
-//
-var pkginfo = module.exports = function (pmodule, options) {
- var args = [].slice.call(arguments, 2).filter(function (arg) {
- return typeof arg === 'string';
- });
-
- //
- // **Parse variable arguments**
- //
- if (Array.isArray(options)) {
- //
- // If the options passed in is an Array assume that
- // it is the Array of properties to expose from the
- // on the package.json file on the parent module.
- //
- options = { include: options };
- }
- else if (typeof options === 'string') {
- //
- // Otherwise if the first argument is a string, then
- // assume that it is the first property to expose from
- // the package.json file on the parent module.
- //
- options = { include: [options] };
- }
-
- //
- // **Setup default options**
- //
- options = options || {};
-
- // ensure that includes have been defined
- options.include = options.include || [];
-
- if (args.length > 0) {
- //
- // If additional string arguments have been passed in
- // then add them to the properties to expose on the
- // parent module.
- //
- options.include = options.include.concat(args);
- }
-
- var pkg = pkginfo.read(pmodule, options.dir).package;
- Object.keys(pkg).forEach(function (key) {
- if (options.include.length > 0 && !~options.include.indexOf(key)) {
- return;
- }
-
- if (!pmodule.exports[key]) {
- pmodule.exports[key] = pkg[key];
- }
- });
-
- return pkginfo;
-};
-
-//
-// ### function find (dir)
-// #### @pmodule {Module} Parent module to read from.
-// #### @dir {string} **Optional** Directory to start search from.
-// Searches up the directory tree from `dir` until it finds a directory
-// which contains a `package.json` file.
-//
-pkginfo.find = function (pmodule, dir) {
- if (! dir) {
- dir = path.dirname(pmodule.filename);
- }
-
- var files = fs.readdirSync(dir);
-
- if (~files.indexOf('package.json')) {
- return path.join(dir, 'package.json');
- }
-
- if (dir === '/') {
- throw new Error('Could not find package.json up from: ' + dir);
- }
- else if (!dir || dir === '.') {
- throw new Error('Cannot find package.json from unspecified directory');
- }
-
- return pkginfo.find(pmodule, path.dirname(dir));
-};
-
-//
-// ### function read (pmodule, dir)
-// #### @pmodule {Module} Parent module to read from.
-// #### @dir {string} **Optional** Directory to start search from.
-// Searches up the directory tree from `dir` until it finds a directory
-// which contains a `package.json` file and returns the package information.
-//
-pkginfo.read = function (pmodule, dir) {
- dir = pkginfo.find(pmodule, dir);
-
- var data = fs.readFileSync(dir).toString();
-
- return {
- dir: dir,
- package: JSON.parse(data)
- };
-};
-
-//
-// Call `pkginfo` on this module and expose version.
-//
-pkginfo(module, {
- dir: __dirname,
- include: ['version'],
- target: pkginfo
-});
\ No newline at end of file
diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/pkginfo/package.json b/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/pkginfo/package.json
deleted file mode 100644
index 968bcc1..0000000
--- a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/pkginfo/package.json
+++ /dev/null
@@ -1,54 +0,0 @@
-{
- "name": "pkginfo",
- "version": "0.3.0",
- "description": "An easy way to expose properties on a module from a package.json",
- "author": {
- "name": "Charlie Robbins",
- "email": "charlie.robbins@gmail.com"
- },
- "repository": {
- "type": "git",
- "url": "http://github.com/indexzero/node-pkginfo.git"
- },
- "keywords": [
- "info",
- "tools",
- "package.json"
- ],
- "devDependencies": {
- "vows": "0.7.x"
- },
- "main": "./lib/pkginfo",
- "scripts": {
- "test": "vows test/*-test.js --spec"
- },
- "engines": {
- "node": ">= 0.4.0"
- },
- "readme": "# node-pkginfo\n\nAn easy way to expose properties on a module from a package.json\n\n## Installation\n\n### Installing npm (node package manager)\n```\n curl http://npmjs.org/install.sh | sh\n```\n\n### Installing pkginfo\n```\n [sudo] npm install pkginfo\n```\n\n## Motivation\nHow often when writing node.js modules have you written the following line(s) of code? \n\n* Hard code your version string into your code\n\n``` js\n exports.version = '0.1.0';\n```\n\n* Programmatically expose the version from the package.json\n\n``` js\n exports.version = JSON.parse(fs.readFileSync('/path/to/package.json', 'utf8')).version;\n```\n\nIn other words, how often have you wanted to expose basic information from your package.json onto your module programmatically? **WELL NOW YOU CAN!**\n\n## Usage\n\nUsing `pkginfo` is idiot-proof, just require and invoke it. \n\n``` js\n var pkginfo = require('pkginfo')(module);\n \n console.dir(module.exports);\n```\n\nBy invoking the `pkginfo` module all of the properties in your `package.json` file will be automatically exposed on the callee module (i.e. the parent module of `pkginfo`). \n\nHere's a sample of the output:\n\n```\n { name: 'simple-app',\n description: 'A test fixture for pkginfo',\n version: '0.1.0',\n author: 'Charlie Robbins ',\n keywords: [ 'test', 'fixture' ],\n main: './index.js',\n scripts: { test: 'vows test/*-test.js --spec' },\n engines: { node: '>= 0.4.0' } }\n```\n\n### Expose specific properties\nIf you don't want to expose **all** properties on from your `package.json` on your module then simple pass those properties to the `pkginfo` function:\n\n``` js\n var pkginfo = require('pkginfo')(module, 'version', 'author');\n \n console.dir(module.exports);\n```\n\n```\n { version: '0.1.0',\n author: 'Charlie Robbins ' }\n```\n\nIf you're looking for further usage see the [examples][0] included in this repository. \n\n## Run Tests\nTests are written in [vows][1] and give complete coverage of all APIs.\n\n```\n vows test/*-test.js --spec\n```\n\n[0]: https://github.com/indexzero/node-pkginfo/tree/master/examples\n[1]: http://vowsjs.org\n\n#### Author: [Charlie Robbins](http://nodejitsu.com)\n#### License: MIT",
- "readmeFilename": "README.md",
- "_id": "pkginfo@0.3.0",
- "dist": {
- "shasum": "726411401039fe9b009eea86614295d5f3a54276",
- "tarball": "http://registry.npmjs.org/pkginfo/-/pkginfo-0.3.0.tgz"
- },
- "_npmVersion": "1.1.66",
- "_npmUser": {
- "name": "indexzero",
- "email": "charlie.robbins@gmail.com"
- },
- "maintainers": [
- {
- "name": "indexzero",
- "email": "charlie.robbins@gmail.com"
- }
- ],
- "directories": {},
- "_shasum": "726411401039fe9b009eea86614295d5f3a54276",
- "_from": "pkginfo@0.x.x",
- "_resolved": "https://registry.npmjs.org/pkginfo/-/pkginfo-0.3.0.tgz",
- "bugs": {
- "url": "https://github.com/indexzero/node-pkginfo/issues"
- },
- "homepage": "https://github.com/indexzero/node-pkginfo"
-}
diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/pkginfo/test/pkginfo-test.js b/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/pkginfo/test/pkginfo-test.js
deleted file mode 100644
index a59f077..0000000
--- a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/pkginfo/test/pkginfo-test.js
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * pkginfo-test.js: Tests for the pkginfo module.
- *
- * (C) 2011, Charlie Robbins
- *
- */
-
-var assert = require('assert'),
- exec = require('child_process').exec,
- fs = require('fs'),
- path = require('path'),
- vows = require('vows'),
- pkginfo = require('../lib/pkginfo');
-
-function assertProperties (source, target) {
- assert.lengthOf(source, target.length + 1);
- target.forEach(function (prop) {
- assert.isTrue(!!~source.indexOf(prop));
- });
-}
-
-function compareWithExample(targetPath) {
- var examplePaths = ['package.json'];
-
- if (targetPath) {
- examplePaths.unshift(targetPath);
- }
-
- return function(exposed) {
- var pkg = fs.readFileSync(path.join.apply(null, [__dirname, '..', 'examples'].concat(examplePaths))).toString(),
- keys = Object.keys(JSON.parse(pkg));
-
- assertProperties(exposed, keys);
- };
-}
-
-function testExposes (options) {
- return {
- topic: function () {
- exec('node ' + path.join(__dirname, '..', 'examples', options.script), this.callback);
- },
- "should expose that property correctly": function (err, stdout, stderr) {
- assert.isNull(err);
-
- var exposed = stderr.match(/'(\w+)'/ig).map(function (p) {
- return p.substring(1, p.length - 1);
- });
-
- return !options.assert
- ? assertProperties(exposed, options.properties)
- : options.assert(exposed);
- }
- }
-}
-
-vows.describe('pkginfo').addBatch({
- "When using the pkginfo module": {
- "and passed a single `string` argument": testExposes({
- script: 'single-property.js',
- properties: ['version']
- }),
- "and passed multiple `string` arguments": testExposes({
- script: 'multiple-properties.js',
- properties: ['version', 'author']
- }),
- "and passed an `object` argument": testExposes({
- script: 'object-argument.js',
- properties: ['version', 'author']
- }),
- "and passed an `array` argument": testExposes({
- script: 'array-argument.js',
- properties: ['version', 'author']
- }),
- "and read from a specified directory": testExposes({
- script: 'target-dir.js',
- assert: compareWithExample('subdir')
- }),
- "and passed no arguments": testExposes({
- script: 'all-properties.js',
- assert: compareWithExample()
- })
- }
-}).export(module);
diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/read/.npmignore b/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/read/.npmignore
deleted file mode 100644
index 0db216b..0000000
--- a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/read/.npmignore
+++ /dev/null
@@ -1,2 +0,0 @@
-npm-debug.log
-node_modules
diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/read/LICENCE b/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/read/LICENCE
deleted file mode 100644
index 74489e2..0000000
--- a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/read/LICENCE
+++ /dev/null
@@ -1,25 +0,0 @@
-Copyright (c) Isaac Z. Schlueter
-All rights reserved.
-
-The BSD License
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
-``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
-BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/read/LICENSE b/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/read/LICENSE
deleted file mode 100644
index 19129e3..0000000
--- a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/read/LICENSE
+++ /dev/null
@@ -1,15 +0,0 @@
-The ISC License
-
-Copyright (c) Isaac Z. Schlueter and Contributors
-
-Permission to use, copy, modify, and/or distribute this software for any
-purpose with or without fee is hereby granted, provided that the above
-copyright notice and this permission notice appear in all copies.
-
-THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
-IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/read/README.md b/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/read/README.md
deleted file mode 100644
index 5967fad..0000000
--- a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/read/README.md
+++ /dev/null
@@ -1,53 +0,0 @@
-## read
-
-For reading user input from stdin.
-
-Similar to the `readline` builtin's `question()` method, but with a
-few more features.
-
-## USAGE
-
-```javascript
-var read = require("read")
-read(options, callback)
-```
-
-The callback gets called with either the user input, or the default
-specified, or an error, as `callback(error, result, isDefault)`
-node style.
-
-## OPTIONS
-
-Every option is optional.
-
-* `prompt` What to write to stdout before reading input.
-* `silent` Don't echo the output as the user types it.
-* `replace` Replace silenced characters with the supplied character value.
-* `timeout` Number of ms to wait for user input before giving up.
-* `default` The default value if the user enters nothing.
-* `edit` Allow the user to edit the default value.
-* `terminal` Treat the output as a TTY, whether it is or not.
-* `input` Readable stream to get input data from. (default `process.stdin`)
-* `output` Writeable stream to write prompts to. (default: `process.stdout`)
-
-If silent is true, and the input is a TTY, then read will set raw
-mode, and read character by character.
-
-## COMPATIBILITY
-
-This module works sort of with node 0.6. It does not work with node
-versions less than 0.6. It is best on node 0.8.
-
-On node version 0.6, it will remove all listeners on the input
-stream's `data` and `keypress` events, because the readline module did
-not fully clean up after itself in that version of node, and did not
-make it possible to clean up after it in a way that has no potential
-for side effects.
-
-Additionally, some of the readline options (like `terminal`) will not
-function in versions of node before 0.8, because they were not
-implemented in the builtin readline module.
-
-## CONTRIBUTING
-
-Patches welcome.
diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/read/example/example.js b/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/read/example/example.js
deleted file mode 100644
index cf213bf..0000000
--- a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/read/example/example.js
+++ /dev/null
@@ -1,13 +0,0 @@
-var read = require("../lib/read.js")
-
-read({prompt: "Username: ", default: "test-user" }, function (er, user) {
- read({prompt: "Password: ", default: "test-pass", silent: true }, function (er, pass) {
- read({prompt: "Password again: ", default: "test-pass", silent: true }, function (er, pass2) {
- console.error({user: user,
- pass: pass,
- verify: pass2,
- passMatch: (pass === pass2)})
- console.error("the program should exit now")
- })
- })
-})
diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/read/lib/read.js b/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/read/lib/read.js
deleted file mode 100644
index a93d1b3..0000000
--- a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/read/lib/read.js
+++ /dev/null
@@ -1,113 +0,0 @@
-
-module.exports = read
-
-var readline = require('readline')
-var Mute = require('mute-stream')
-
-function read (opts, cb) {
- if (opts.num) {
- throw new Error('read() no longer accepts a char number limit')
- }
-
- if (typeof opts.default !== 'undefined' &&
- typeof opts.default !== 'string' &&
- typeof opts.default !== 'number') {
- throw new Error('default value must be string or number')
- }
-
- var input = opts.input || process.stdin
- var output = opts.output || process.stdout
- var prompt = (opts.prompt || '').trim() + ' '
- var silent = opts.silent
- var editDef = false
- var timeout = opts.timeout
-
- var def = opts.default || ''
- if (def) {
- if (silent) {
- prompt += '() '
- } else if (opts.edit) {
- editDef = true
- } else {
- prompt += '(' + def + ') '
- }
- }
- var terminal = !!(opts.terminal || output.isTTY)
-
- var m = new Mute({ replace: opts.replace, prompt: prompt })
- m.pipe(output, {end: false})
- output = m
- var rlOpts = { input: input, output: output, terminal: terminal }
-
- if (process.version.match(/^v0\.6/)) {
- var rl = readline.createInterface(rlOpts.input, rlOpts.output)
- } else {
- var rl = readline.createInterface(rlOpts)
- }
-
-
- output.unmute()
- rl.setPrompt(prompt)
- rl.prompt()
- if (silent) {
- output.mute()
- } else if (editDef) {
- rl.line = def
- rl.cursor = def.length
- rl._refreshLine()
- }
-
- var called = false
- rl.on('line', onLine)
- rl.on('error', onError)
-
- rl.on('SIGINT', function () {
- rl.close()
- onError(new Error('canceled'))
- })
-
- var timer
- if (timeout) {
- timer = setTimeout(function () {
- onError(new Error('timed out'))
- }, timeout)
- }
-
- function done () {
- called = true
- rl.close()
-
- if (process.version.match(/^v0\.6/)) {
- rl.input.removeAllListeners('data')
- rl.input.removeAllListeners('keypress')
- rl.input.pause()
- }
-
- clearTimeout(timer)
- output.mute()
- output.end()
- }
-
- function onError (er) {
- if (called) return
- done()
- return cb(er)
- }
-
- function onLine (line) {
- if (called) return
- if (silent && terminal) {
- output.unmute()
- output.write('\r\n')
- }
- done()
- // truncate the \n at the end.
- line = line.replace(/\r?\n$/, '')
- var isDefault = !!(editDef && line === def)
- if (def && !line) {
- isDefault = true
- line = def
- }
- cb(null, line, isDefault)
- }
-}
diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/read/node_modules/mute-stream/LICENSE b/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/read/node_modules/mute-stream/LICENSE
deleted file mode 100644
index 19129e3..0000000
--- a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/read/node_modules/mute-stream/LICENSE
+++ /dev/null
@@ -1,15 +0,0 @@
-The ISC License
-
-Copyright (c) Isaac Z. Schlueter and Contributors
-
-Permission to use, copy, modify, and/or distribute this software for any
-purpose with or without fee is hereby granted, provided that the above
-copyright notice and this permission notice appear in all copies.
-
-THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
-IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/read/node_modules/mute-stream/README.md b/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/read/node_modules/mute-stream/README.md
deleted file mode 100644
index 8ab1238..0000000
--- a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/read/node_modules/mute-stream/README.md
+++ /dev/null
@@ -1,68 +0,0 @@
-# mute-stream
-
-Bytes go in, but they don't come out (when muted).
-
-This is a basic pass-through stream, but when muted, the bytes are
-silently dropped, rather than being passed through.
-
-## Usage
-
-```javascript
-var MuteStream = require('mute-stream')
-
-var ms = new MuteStream(options)
-
-ms.pipe(process.stdout)
-ms.write('foo') // writes 'foo' to stdout
-ms.mute()
-ms.write('bar') // does not write 'bar'
-ms.unmute()
-ms.write('baz') // writes 'baz' to stdout
-
-// can also be used to mute incoming data
-var ms = new MuteStream
-input.pipe(ms)
-
-ms.on('data', function (c) {
- console.log('data: ' + c)
-})
-
-input.emit('data', 'foo') // logs 'foo'
-ms.mute()
-input.emit('data', 'bar') // does not log 'bar'
-ms.unmute()
-input.emit('data', 'baz') // logs 'baz'
-```
-
-## Options
-
-All options are optional.
-
-* `replace` Set to a string to replace each character with the
- specified string when muted. (So you can show `****` instead of the
- password, for example.)
-
-* `prompt` If you are using a replacement char, and also using a
- prompt with a readline stream (as for a `Password: *****` input),
- then specify what the prompt is so that backspace will work
- properly. Otherwise, pressing backspace will overwrite the prompt
- with the replacement character, which is weird.
-
-## ms.mute()
-
-Set `muted` to `true`. Turns `.write()` into a no-op.
-
-## ms.unmute()
-
-Set `muted` to `false`
-
-## ms.isTTY
-
-True if the pipe destination is a TTY, or if the incoming pipe source is
-a TTY.
-
-## Other stream methods...
-
-The other standard readable and writable stream methods are all
-available. The MuteStream object acts as a facade to its pipe source
-and destination.
diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/read/node_modules/mute-stream/mute.js b/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/read/node_modules/mute-stream/mute.js
deleted file mode 100644
index 42eac31..0000000
--- a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/read/node_modules/mute-stream/mute.js
+++ /dev/null
@@ -1,140 +0,0 @@
-var Stream = require('stream')
-
-module.exports = MuteStream
-
-// var out = new MuteStream(process.stdout)
-// argument auto-pipes
-function MuteStream (opts) {
- Stream.apply(this)
- opts = opts || {}
- this.writable = this.readable = true
- this.muted = false
- this.on('pipe', this._onpipe)
- this.replace = opts.replace
-
- // For readline-type situations
- // This much at the start of a line being redrawn after a ctrl char
- // is seen (such as backspace) won't be redrawn as the replacement
- this._prompt = opts.prompt || null
- this._hadControl = false
-}
-
-MuteStream.prototype = Object.create(Stream.prototype)
-
-Object.defineProperty(MuteStream.prototype, 'constructor', {
- value: MuteStream,
- enumerable: false
-})
-
-MuteStream.prototype.mute = function () {
- this.muted = true
-}
-
-MuteStream.prototype.unmute = function () {
- this.muted = false
-}
-
-Object.defineProperty(MuteStream.prototype, '_onpipe', {
- value: onPipe,
- enumerable: false,
- writable: true,
- configurable: true
-})
-
-function onPipe (src) {
- this._src = src
-}
-
-Object.defineProperty(MuteStream.prototype, 'isTTY', {
- get: getIsTTY,
- set: setIsTTY,
- enumerable: true,
- configurable: true
-})
-
-function getIsTTY () {
- return( (this._dest) ? this._dest.isTTY
- : (this._src) ? this._src.isTTY
- : false
- )
-}
-
-// basically just get replace the getter/setter with a regular value
-function setIsTTY (isTTY) {
- Object.defineProperty(this, 'isTTY', {
- value: isTTY,
- enumerable: true,
- writable: true,
- configurable: true
- })
-}
-
-Object.defineProperty(MuteStream.prototype, 'rows', {
- get: function () {
- return( this._dest ? this._dest.rows
- : this._src ? this._src.rows
- : undefined )
- }, enumerable: true, configurable: true })
-
-Object.defineProperty(MuteStream.prototype, 'columns', {
- get: function () {
- return( this._dest ? this._dest.columns
- : this._src ? this._src.columns
- : undefined )
- }, enumerable: true, configurable: true })
-
-
-MuteStream.prototype.pipe = function (dest) {
- this._dest = dest
- return Stream.prototype.pipe.call(this, dest)
-}
-
-MuteStream.prototype.pause = function () {
- if (this._src) return this._src.pause()
-}
-
-MuteStream.prototype.resume = function () {
- if (this._src) return this._src.resume()
-}
-
-MuteStream.prototype.write = function (c) {
- if (this.muted) {
- if (!this.replace) return true
- if (c.match(/^\u001b/)) {
- this._hadControl = true
- return this.emit('data', c)
- } else {
- if (this._prompt && this._hadControl &&
- c.indexOf(this._prompt) === 0) {
- this._hadControl = false
- this.emit('data', this._prompt)
- c = c.substr(this._prompt.length)
- }
- c = c.toString().replace(/./g, this.replace)
- }
- }
- this.emit('data', c)
-}
-
-MuteStream.prototype.end = function (c) {
- if (this.muted) {
- if (c && this.replace) {
- c = c.toString().replace(/./g, this.replace)
- } else {
- c = null
- }
- }
- if (c) this.emit('data', c)
- this.emit('end')
-}
-
-function proxy (fn) { return function () {
- var d = this._dest
- var s = this._src
- if (d && d[fn]) d[fn].apply(d, arguments)
- if (s && s[fn]) s[fn].apply(s, arguments)
-}}
-
-MuteStream.prototype.destroy = proxy('destroy')
-MuteStream.prototype.destroySoon = proxy('destroySoon')
-MuteStream.prototype.close = proxy('close')
diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/read/node_modules/mute-stream/package.json b/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/read/node_modules/mute-stream/package.json
deleted file mode 100644
index 8fe251b..0000000
--- a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/read/node_modules/mute-stream/package.json
+++ /dev/null
@@ -1,56 +0,0 @@
-{
- "name": "mute-stream",
- "version": "0.0.5",
- "main": "mute.js",
- "directories": {
- "test": "test"
- },
- "devDependencies": {
- "tap": "~0.2.5"
- },
- "scripts": {
- "test": "tap test/*.js"
- },
- "repository": {
- "type": "git",
- "url": "git://github.com/isaacs/mute-stream.git"
- },
- "keywords": [
- "mute",
- "stream",
- "pipe"
- ],
- "author": {
- "name": "Isaac Z. Schlueter",
- "email": "i@izs.me",
- "url": "http://blog.izs.me/"
- },
- "license": "ISC",
- "description": "Bytes go in, but they don't come out (when muted).",
- "gitHead": "17d9854a315f56088d039534f87b740e470a9af0",
- "bugs": {
- "url": "https://github.com/isaacs/mute-stream/issues"
- },
- "homepage": "https://github.com/isaacs/mute-stream#readme",
- "_id": "mute-stream@0.0.5",
- "_shasum": "8fbfabb0a98a253d3184331f9e8deb7372fac6c0",
- "_from": "mute-stream@~0.0.4",
- "_npmVersion": "2.10.0",
- "_nodeVersion": "2.0.1",
- "_npmUser": {
- "name": "isaacs",
- "email": "isaacs@npmjs.com"
- },
- "dist": {
- "shasum": "8fbfabb0a98a253d3184331f9e8deb7372fac6c0",
- "tarball": "http://registry.npmjs.org/mute-stream/-/mute-stream-0.0.5.tgz"
- },
- "maintainers": [
- {
- "name": "isaacs",
- "email": "i@izs.me"
- }
- ],
- "_resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.5.tgz",
- "readme": "ERROR: No README data found!"
-}
diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/read/node_modules/mute-stream/test/basic.js b/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/read/node_modules/mute-stream/test/basic.js
deleted file mode 100644
index 41f9e10..0000000
--- a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/read/node_modules/mute-stream/test/basic.js
+++ /dev/null
@@ -1,207 +0,0 @@
-var Stream = require('stream')
-var tap = require('tap')
-var MS = require('../mute.js')
-
-// some marker objects
-var END = {}
-var PAUSE = {}
-var RESUME = {}
-
-function PassThrough () {
- Stream.call(this)
- this.readable = this.writable = true
-}
-
-PassThrough.prototype = Object.create(Stream.prototype, {
- constructor: {
- value: PassThrough
- },
- write: {
- value: function (c) {
- this.emit('data', c)
- return true
- }
- },
- end: {
- value: function (c) {
- if (c) this.write(c)
- this.emit('end')
- }
- },
- pause: {
- value: function () {
- this.emit('pause')
- }
- },
- resume: {
- value: function () {
- this.emit('resume')
- }
- }
-})
-
-tap.test('incoming', function (t) {
- var ms = new MS
- var str = new PassThrough
- str.pipe(ms)
-
- var expect = ['foo', 'boo', END]
- ms.on('data', function (c) {
- t.equal(c, expect.shift())
- })
- ms.on('end', function () {
- t.equal(END, expect.shift())
- t.end()
- })
- str.write('foo')
- ms.mute()
- str.write('bar')
- ms.unmute()
- str.write('boo')
- ms.mute()
- str.write('blaz')
- str.end('grelb')
-})
-
-tap.test('outgoing', function (t) {
- var ms = new MS
- var str = new PassThrough
- ms.pipe(str)
-
- var expect = ['foo', 'boo', END]
- str.on('data', function (c) {
- t.equal(c, expect.shift())
- })
- str.on('end', function () {
- t.equal(END, expect.shift())
- t.end()
- })
-
- ms.write('foo')
- ms.mute()
- ms.write('bar')
- ms.unmute()
- ms.write('boo')
- ms.mute()
- ms.write('blaz')
- ms.end('grelb')
-})
-
-tap.test('isTTY', function (t) {
- var str = new PassThrough
- str.isTTY = true
- str.columns=80
- str.rows=24
-
- var ms = new MS
- t.equal(ms.isTTY, false)
- t.equal(ms.columns, undefined)
- t.equal(ms.rows, undefined)
- ms.pipe(str)
- t.equal(ms.isTTY, true)
- t.equal(ms.columns, 80)
- t.equal(ms.rows, 24)
- str.isTTY = false
- t.equal(ms.isTTY, false)
- t.equal(ms.columns, 80)
- t.equal(ms.rows, 24)
- str.isTTY = true
- t.equal(ms.isTTY, true)
- t.equal(ms.columns, 80)
- t.equal(ms.rows, 24)
- ms.isTTY = false
- t.equal(ms.isTTY, false)
- t.equal(ms.columns, 80)
- t.equal(ms.rows, 24)
-
- ms = new MS
- t.equal(ms.isTTY, false)
- str.pipe(ms)
- t.equal(ms.isTTY, true)
- str.isTTY = false
- t.equal(ms.isTTY, false)
- str.isTTY = true
- t.equal(ms.isTTY, true)
- ms.isTTY = false
- t.equal(ms.isTTY, false)
-
- t.end()
-})
-
-tap.test('pause/resume incoming', function (t) {
- var str = new PassThrough
- var ms = new MS
- str.on('pause', function () {
- t.equal(PAUSE, expect.shift())
- })
- str.on('resume', function () {
- t.equal(RESUME, expect.shift())
- })
- var expect = [PAUSE, RESUME, PAUSE, RESUME]
- str.pipe(ms)
- ms.pause()
- ms.resume()
- ms.pause()
- ms.resume()
- t.equal(expect.length, 0, 'saw all events')
- t.end()
-})
-
-tap.test('replace with *', function (t) {
- var str = new PassThrough
- var ms = new MS({replace: '*'})
- str.pipe(ms)
- var expect = ['foo', '*****', 'bar', '***', 'baz', 'boo', '**', '****']
-
- ms.on('data', function (c) {
- t.equal(c, expect.shift())
- })
-
- str.write('foo')
- ms.mute()
- str.write('12345')
- ms.unmute()
- str.write('bar')
- ms.mute()
- str.write('baz')
- ms.unmute()
- str.write('baz')
- str.write('boo')
- ms.mute()
- str.write('xy')
- str.write('xyzΩ')
-
- t.equal(expect.length, 0)
- t.end()
-})
-
-tap.test('replace with ~YARG~', function (t) {
- var str = new PassThrough
- var ms = new MS({replace: '~YARG~'})
- str.pipe(ms)
- var expect = ['foo', '~YARG~~YARG~~YARG~~YARG~~YARG~', 'bar',
- '~YARG~~YARG~~YARG~', 'baz', 'boo', '~YARG~~YARG~',
- '~YARG~~YARG~~YARG~~YARG~']
-
- ms.on('data', function (c) {
- t.equal(c, expect.shift())
- })
-
- // also throw some unicode in there, just for good measure.
- str.write('foo')
- ms.mute()
- str.write('ΩΩ')
- ms.unmute()
- str.write('bar')
- ms.mute()
- str.write('Ω')
- ms.unmute()
- str.write('baz')
- str.write('boo')
- ms.mute()
- str.write('Ω')
- str.write('ΩΩ')
-
- t.equal(expect.length, 0)
- t.end()
-})
diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/read/package.json b/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/read/package.json
deleted file mode 100644
index 1a7078b..0000000
--- a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/read/package.json
+++ /dev/null
@@ -1,55 +0,0 @@
-{
- "name": "read",
- "version": "1.0.6",
- "main": "lib/read.js",
- "dependencies": {
- "mute-stream": "~0.0.4"
- },
- "devDependencies": {
- "tap": "*"
- },
- "engines": {
- "node": ">=0.8"
- },
- "author": {
- "name": "Isaac Z. Schlueter",
- "email": "i@izs.me",
- "url": "http://blog.izs.me/"
- },
- "description": "read(1) for node programs",
- "repository": {
- "type": "git",
- "url": "git://github.com/isaacs/read.git"
- },
- "license": "ISC",
- "scripts": {
- "test": "tap test/*.js"
- },
- "gitHead": "2f5101c8e41332a033e5aa4e27e33fd6e09598e2",
- "bugs": {
- "url": "https://github.com/isaacs/read/issues"
- },
- "homepage": "https://github.com/isaacs/read#readme",
- "_id": "read@1.0.6",
- "_shasum": "09873c14ecc114d063fad43b8ca5a33d304721c8",
- "_from": "read@1.0.x",
- "_npmVersion": "2.10.0",
- "_nodeVersion": "2.0.1",
- "_npmUser": {
- "name": "isaacs",
- "email": "isaacs@npmjs.com"
- },
- "dist": {
- "shasum": "09873c14ecc114d063fad43b8ca5a33d304721c8",
- "tarball": "http://registry.npmjs.org/read/-/read-1.0.6.tgz"
- },
- "maintainers": [
- {
- "name": "isaacs",
- "email": "i@izs.me"
- }
- ],
- "directories": {},
- "_resolved": "https://registry.npmjs.org/read/-/read-1.0.6.tgz",
- "readme": "ERROR: No README data found!"
-}
diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/read/rs.js b/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/read/rs.js
deleted file mode 100644
index d9f7f48..0000000
--- a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/read/rs.js
+++ /dev/null
@@ -1,4 +0,0 @@
-var read = require('read');
-read({ silent: true, prompt: 'stars: ' }, function(er, data) {
- console.log(er, data)
-})
diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/read/test/basic.js b/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/read/test/basic.js
deleted file mode 100644
index f0926f3..0000000
--- a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/read/test/basic.js
+++ /dev/null
@@ -1,60 +0,0 @@
-var tap = require('tap')
-var read = require('../lib/read.js')
-
-if (process.argv[2] === 'child') {
- return child()
-}
-
-var CLOSE = 'close'
-if (process.version.match(/^v0\.6/)) {
- CLOSE = 'exit'
-}
-
-var spawn = require('child_process').spawn
-
-tap.test('basic', function (t) {
- var child = spawn(process.execPath, [__filename, 'child'])
- var output = ''
- var write = child.stdin.write.bind(child.stdin)
- child.stdout.on('data', function (c) {
- console.error('data %s', c)
- output += c
- if (output.match(/Username: \(test-user\) $/)) {
- process.nextTick(write.bind(null, 'a user\n'))
- } else if (output.match(/Password: \(\) $/)) {
- process.nextTick(write.bind(null, 'a password\n'))
- } else if (output.match(/Password again: \(\) $/)) {
- process.nextTick(write.bind(null, 'a password\n'))
- } else {
- console.error('prompts done, output=%j', output)
- }
- })
-
- var result = ''
- child.stderr.on('data', function (c) {
- result += c
- console.error('result %j', c.toString())
- })
-
- child.on(CLOSE, function () {
- result = JSON.parse(result)
- t.same(result, {"user":"a user","pass":"a password","verify":"a password","passMatch":true})
- t.equal(output, 'Username: (test-user) Password: () Password again: () ')
- t.end()
- })
-})
-
-function child () {
- read({prompt: "Username: ", default: "test-user" }, function (er, user) {
- read({prompt: "Password: ", default: "test-pass", silent: true }, function (er, pass) {
- read({prompt: "Password again: ", default: "test-pass", silent: true }, function (er, pass2) {
- console.error(JSON.stringify({user: user,
- pass: pass,
- verify: pass2,
- passMatch: (pass === pass2)}))
- if (process.stdin.unref)
- process.stdin.unref()
- })
- })
- })
-}
diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/read/test/defaults.js b/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/read/test/defaults.js
deleted file mode 100644
index e3d2ac7..0000000
--- a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/read/test/defaults.js
+++ /dev/null
@@ -1,60 +0,0 @@
-var tap = require('tap')
-var read = require('../lib/read.js')
-
-if (process.argv[2] === 'child') {
- return child()
-}
-
-var CLOSE = 'close'
-if (process.version.match(/^v0\.6/)) {
- CLOSE = 'exit'
-}
-
-var spawn = require('child_process').spawn
-
-tap.test('defaults', function (t) {
- var child = spawn(process.execPath, [__filename, 'child'])
- var output = ''
- var write = child.stdin.write.bind(child.stdin)
- child.stdout.on('data', function (c) {
- console.error('data %s', c)
- output += c
- if (output.match(/Username: \(test-user\) $/)) {
- process.nextTick(write.bind(null, '\n'))
- } else if (output.match(/Password: \(\) $/)) {
- process.nextTick(write.bind(null, '\n'))
- } else if (output.match(/Password again: \(\) $/)) {
- process.nextTick(write.bind(null, '\n'))
- } else {
- console.error('prompts done, output=%j', output)
- }
- })
-
- var result = ''
- child.stderr.on('data', function (c) {
- result += c
- console.error('result %j', c.toString())
- })
-
- child.on(CLOSE, function () {
- result = JSON.parse(result)
- t.same(result, {"user":"test-user","pass":"test-pass","verify":"test-pass","passMatch":true})
- t.equal(output, 'Username: (test-user) Password: () Password again: () ')
- t.end()
- })
-})
-
-function child () {
- read({prompt: "Username: ", default: "test-user" }, function (er, user) {
- read({prompt: "Password: ", default: "test-pass", silent: true }, function (er, pass) {
- read({prompt: "Password again: ", default: "test-pass", silent: true }, function (er, pass2) {
- console.error(JSON.stringify({user: user,
- pass: pass,
- verify: pass2,
- passMatch: (pass === pass2)}))
- if (process.stdin.unref)
- process.stdin.unref()
- })
- })
- })
-}
diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/read/test/many.js b/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/read/test/many.js
deleted file mode 100644
index 6a2f87b..0000000
--- a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/read/test/many.js
+++ /dev/null
@@ -1,83 +0,0 @@
-var tap = require('tap')
-var read = require('../lib/read.js')
-
-var CLOSE = 'close'
-if (process.version.match(/^v0\.6/)) {
- CLOSE = 'exit'
-}
-
-if (process.argv[2] === 'child') {
- return child()
-}
-
-var spawn = require('child_process').spawn
-function child () {
- read({prompt:'1'}, function (er, r1) {if (er) throw er
- read({prompt:'2'}, function (er, r2) {if (er) throw er
- read({prompt:'3'}, function (er, r3) {if (er) throw er
- read({prompt:'4'}, function (er, r4) {if (er) throw er
- read({prompt:'5'}, function (er, r5) {if (er) throw er
- read({prompt:'6'}, function (er, r6) {if (er) throw er
- read({prompt:'7'}, function (er, r7) {if (er) throw er
- read({prompt:'8'}, function (er, r8) {if (er) throw er
- read({prompt:'9'}, function (er, r9) {if (er) throw er
- read({prompt:'10'}, function (er, r10) {if (er) throw er
- read({prompt:'11'}, function (er, r11) {if (er) throw er
- read({prompt:'12'}, function (er, r12) {if (er) throw er
- read({prompt:'13'}, function (er, r13) {if (er) throw er
- read({prompt:'14'}, function (er, r14) {if (er) throw er
- read({prompt:'15'}, function (er, r15) {if (er) throw er
- read({prompt:'16'}, function (er, r16) {if (er) throw er
- read({prompt:'17'}, function (er, r17) {if (er) throw er
- read({prompt:'18'}, function (er, r18) {if (er) throw er
- console.log(r1, r2, r3, r4, r5, r6, r7, r8, r9, r10,
- r11, r12, r13, r14, r15, r16, r17, r18)
- if (process.stdin.unref)
- process.stdin.unref()
- })})})})})})})})})})})})})})})})})})
-}
-
-tap.test('many reads', function (t) {
- var child = spawn(process.execPath, [__filename, 'child'])
- var n = 0
- var output = ''
- var expect = '1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ' +
- '16 17 18 1 2 3 4 5 6 7 8 9 10 11 12 ' +
- '13 14 15 16 17 18\n'
- var write = child.stdin.write.bind(child.stdin)
- var answers =
- [ '1\n',
- '2\n',
- '3\n',
- '4\n',
- '5\n',
- '6\n',
- '7\n',
- '8\n',
- '9\n',
- '10\n',
- '11\n',
- '12\n',
- '13\n',
- '14\n',
- '15\n',
- '16\n',
- '17\n',
- '18\n' ]
- child.stdout.on('data', function (c) {
- n++;
- output += c
- if (answers.length) {
- write(answers.shift())
- }
- })
- child.stderr.on('data', function (c) {
- output += c
- console.error('' + c)
- })
- child.on(CLOSE, function (c) {
- t.equal(output, expect)
- t.equal(n, 19)
- t.end()
- })
-})
diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/revalidator/.npmignore b/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/revalidator/.npmignore
deleted file mode 100644
index 5171c54..0000000
--- a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/revalidator/.npmignore
+++ /dev/null
@@ -1,2 +0,0 @@
-node_modules
-npm-debug.log
\ No newline at end of file
diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/revalidator/.travis.yml b/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/revalidator/.travis.yml
deleted file mode 100644
index 04d6dd9..0000000
--- a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/revalidator/.travis.yml
+++ /dev/null
@@ -1,11 +0,0 @@
-language: node_js
-node_js:
- - "0.8"
- - "0.10"
- - "0.11"
-
-notifications:
- email:
- - travis@nodejitsu.com
- irc: "irc.freenode.org#nodejitsu"
-
diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/revalidator/CHANGELOG.md b/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/revalidator/CHANGELOG.md
deleted file mode 100644
index 8befb22..0000000
--- a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/revalidator/CHANGELOG.md
+++ /dev/null
@@ -1,25 +0,0 @@
-
-0.1.3 / 2012-10-17
-==================
-
- * Fixed case problem with types
-
-0.1.2 / 2012-06-27
-==================
-
- * Added host-name String format
- * Added support for additionalProperties
- * Added few default validation messages for formats
-
-0.1.1 / 2012-04-16
-==================
-
- * Added default and custom error message support
- * Added suport for conform function
- * Updated date-time format
-
-0.1.0 / 2011-11-09
-=================
-
- * Initial release
-
diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/revalidator/LICENSE b/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/revalidator/LICENSE
deleted file mode 100644
index a83d179..0000000
--- a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/revalidator/LICENSE
+++ /dev/null
@@ -1,179 +0,0 @@
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
-TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
-2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
-3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
-4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
-5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
-6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
-7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
-8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
-9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
-END OF TERMS AND CONDITIONS
-
-Copyright (c) 2009-2010 Alexis Sellier, Charlie Robbins, Nodejitsu Inc.
diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/revalidator/README.md b/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/revalidator/README.md
deleted file mode 100644
index be6601b..0000000
--- a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/revalidator/README.md
+++ /dev/null
@@ -1,301 +0,0 @@
-# revalidator [](http://travis-ci.org/flatiron/revalidator)
-
-A cross-browser / node.js validator used by resourceful and flatiron. Revalidator has [JSONSchema](http://tools.ietf.org/html/draft-zyp-json-schema-04) compatibility as primary goal.
-
-## Example
-The core of `revalidator` is simple and succinct: `revalidator.validate(obj, schema)`:
-
-``` js
- var revalidator = require('revalidator');
-
- console.dir(revalidator.validate(someObject, {
- properties: {
- url: {
- description: 'the url the object should be stored at',
- type: 'string',
- pattern: '^/[^#%&*{}\\:<>?\/+]+$',
- required: true
- },
- challenge: {
- description: 'a means of protecting data (insufficient for production, used as example)',
- type: 'string',
- minLength: 5
- },
- body: {
- description: 'what to store at the url',
- type: 'any',
- default: null
- }
- }
- }));
-```
-
-This will return with a value indicating if the `obj` conforms to the `schema`. If it does not, a descriptive object will be returned containing the errors encountered with validation.
-
-``` js
- {
- valid: true // or false
- errors: [/* Array of errors if valid is false */]
- }
-```
-
-In the browser, the validation function is exposed on `window.validate` by simply including `revalidator.js`.
-
-## Installation
-
-### Installing npm (node package manager)
-``` bash
- $ curl http://npmjs.org/install.sh | sh
-```
-
-### Installing revalidator
-``` bash
- $ [sudo] npm install revalidator
-```
-
-## Usage
-
-`revalidator` takes json-schema as input to validate objects.
-
-### revalidator.validate (obj, schema, options)
-
-This will return with a value indicating if the `obj` conforms to the `schema`. If it does not, a descriptive object will be returned containing the errors encountered with validation.
-
-``` js
-{
- valid: true // or false
- errors: [/* Array of errors if valid is false */]
-}
-```
-
-#### Available Options
-
-* __validateFormats__: Enforce format constraints (_default true_)
-* __validateFormatsStrict__: When `validateFormats` is _true_ treat unrecognized formats as validation errors (_default false_)
-* __validateFormatExtensions__: When `validateFormats` is _true_ also validate formats defined in `validate.formatExtensions` (_default true_)
-* __cast__: Enforce casting of some types (for integers/numbers are only supported) when it's possible, e.g. `"42" => 42`, but `"forty2" => "forty2"` for the `integer` type.
-
-### Schema
-For a property an `value` is that which is given as input for validation where as an `expected value` is the value of the below fields
-
-#### required
-If true, the value should not be undefined
-
-```js
-{ required: true }
-```
-
-#### allowEmpty
-If false, the value must not be an empty string
-
-```js
-{ allowEmpty: false }
-```
-
-#### type
-The `type of value` should be equal to the expected value
-
-```js
-{ type: 'string' }
-{ type: 'number' }
-{ type: 'integer' }
-{ type: 'array' }
-{ type: 'boolean' }
-{ type: 'object' }
-{ type: 'null' }
-{ type: 'any' }
-{ type: ['boolean', 'string'] }
-```
-
-#### pattern
-The expected value regex needs to be satisfied by the value
-
-```js
-{ pattern: /^[a-z]+$/ }
-```
-
-#### maxLength
-The length of value must be greater than or equal to expected value
-
-```js
-{ maxLength: 8 }
-```
-
-#### minLength
-The length of value must be lesser than or equal to expected value
-
-```js
-{ minLength: 8 }
-```
-
-#### minimum
-Value must be greater than or equal to the expected value
-
-```js
-{ minimum: 10 }
-```
-
-#### maximum
-Value must be lesser than or equal to the expected value
-
-```js
-{ maximum: 10 }
-```
-
-#### allowEmpty
-Value may not be empty
-
-```js
-{ allowEmpty: false }
-```
-
-#### exclusiveMinimum
-Value must be greater than expected value
-
-```js
-{ exclusiveMinimum: 9 }
-```
-
-### exclusiveMaximum
-Value must be lesser than expected value
-
-```js
-{ exclusiveMaximum: 11 }
-```
-
-#### divisibleBy
-Value must be divisible by expected value
-
-```js
-{ divisibleBy: 5 }
-{ divisibleBy: 0.5 }
-```
-
-#### minItems
-Value must contain more then expected value number of items
-
-```js
-{ minItems: 2 }
-```
-
-#### maxItems
-Value must contains less then expected value number of items
-
-```js
-{ maxItems: 5 }
-```
-
-#### uniqueItems
-Value must hold a unique set of values
-
-```js
-{ uniqueItems: true }
-```
-
-#### enum
-Value must be present in the array of expected value
-
-```js
-{ enum: ['month', 'year'] }
-```
-
-#### format
-Value must be a valid format
-
-```js
-{ format: 'url' }
-{ format: 'email' }
-{ format: 'ip-address' }
-{ format: 'ipv6' }
-{ format: 'date-time' }
-{ format: 'date' }
-{ format: 'time' }
-{ format: 'color' }
-{ format: 'host-name' }
-{ format: 'utc-millisec' }
-{ format: 'regex' }
-```
-
-#### conform
-Value must conform to constraint denoted by expected value
-
-```js
-{ conform: function (v) {
- if (v%3==1) return true;
- return false;
- }
-}
-```
-
-#### dependencies
-Value is valid only if the dependent value is valid
-
-```js
-{
- town: { required: true, dependencies: 'country' },
- country: { maxLength: 3, required: true }
-}
-```
-
-### Nested Schema
-We also allow nested schema
-
-```js
-{
- properties: {
- title: {
- type: 'string',
- maxLength: 140,
- required: true
- },
- author: {
- type: 'object',
- required: true,
- properties: {
- name: {
- type: 'string',
- required: true
- },
- email: {
- type: 'string',
- format: 'email'
- }
- }
- }
- }
-}
-```
-
-### Custom Messages
-We also allow custom message for different constraints
-
-```js
-{
- type: 'string',
- format: 'url'
- messages: {
- type: 'Not a string type',
- format: 'Expected format is a url'
- }
-```
-
-```js
-{
- conform: function () { ... },
- message: 'This can be used as a global message'
-}
-```
-
-## Tests
-All tests are written with [vows][0] and should be run with [npm][1]:
-
-``` bash
- $ npm test
-```
-
-#### Author: [Charlie Robbins](http://nodejitsu.com), [Alexis Sellier](http://cloudhead.io)
-#### Contributors: [Fedor Indutny](http://github.com/indutny), [Bradley Meck](http://github.com/bmeck), [Laurie Harper](http://laurie.holoweb.net/)
-#### License: Apache 2.0
-
-[0]: http://vowsjs.org
-[1]: http://npmjs.org
diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/revalidator/example/webservice.js b/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/revalidator/example/webservice.js
deleted file mode 100644
index 33d5f0e..0000000
--- a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/revalidator/example/webservice.js
+++ /dev/null
@@ -1,204 +0,0 @@
-//
-// (C) 2011, Nodejitsu Inc.
-// MIT License
-//
-// A simple web service for storing JSON data via REST
-//
-// GET - View Object
-// POST - Create Object
-// PUT - Update Object
-// DELETE - Delete Object
-//
-
-var revalidator = require('../'),
- http = require('http'),
-//
-// Keep our objects in a simple memory store
-//
- memoryStore = {},
-//
-// Set up our request schema
-//
- schema = {
- properties: {
- url: {
- description: 'the url the object should be stored at',
- type: 'string',
- pattern: '^/[^#%&*{}\\:<>?\/+]+$',
- required: true
- },
- challenge: {
- description: 'a means of protecting data (insufficient for production, used as example)',
- type: 'string',
- minLength: 5
- },
- body: {
- description: 'what to store at the url',
- type: 'any',
- default: null
- }
- }
- }
-
-var server = http.createServer(function validateRestRequest (req, res) {
- req.method = req.method.toUpperCase();
-
- //
- // Log the requests
- //
- console.log(req.method, req.url);
-
- //
- // Buffer the request so it can be parsed as JSON
- //
- var requestBody = [];
- req.on('data', function addDataToBody (data) {
- requestBody.push(data);
- });
-
- //
- // Once the request has ended work with the body
- //
- req.on('end', function dealWithRest () {
-
- //
- // Parse the JSON
- //
- requestBody = requestBody.join('');
- if ({POST: 1, PUT: 1}[req.method]) {
- try {
- requestBody = JSON.parse(requestBody);
- }
- catch (e) {
- res.writeHead(400);
- res.end(e);
- return;
- }
- }
- else {
- requestBody = {};
- }
-
- //
- // If this was sent to a url but the body url was not declared
- // Make sure the body get the requested url so that our schema
- // validates before we work on it
- //
- if (!requestBody.url) {
- requestBody.url = req.url;
- }
-
- //
- // Don't let users override the main API endpoint
- //
- if (requestBody.url === '/') {
- res.writeHead(400);
- res.end('Cannot override the API endpoint "/"');
- return;
- }
-
- //
- // See if our request and target are out of sync
- // This lets us double check the url we are about to take up
- // if we choose to send the request to the url directly
- //
- if (req.url !== '/' && requestBody.url !== req.url) {
- res.writeHead(400);
- res.end('Requested url and actual url do not match');
- return;
- }
-
- //
- // Validate the schema
- //
- var validation = revalidator.validate(requestBody, schema);
- if (!validation.valid) {
- res.writeHead(400);
- res.end(validation.errors.join('\n'));
- return;
- }
-
- //
- // Grab the current value from storage and
- // check if it is a valid state for REST
- //
- var storedValue = memoryStore[requestBody.url];
- if (req.method === 'POST') {
- if (storedValue) {
- res.writeHead(400);
- res.end('ALREADY EXISTS');
- return;
- }
- }
- else if (!storedValue) {
- res.writeHead(404);
- res.end('DOES NOT EXIST');
- return;
- }
-
- //
- // Check our challenge
- //
- if (storedValue && requestBody.challenge != storedValue.challenge) {
- res.writeHead(403);
- res.end('NOT AUTHORIZED');
- return;
- }
-
- //
- // Since revalidator only checks and does not manipulate
- // our object we need to set up the defaults our selves
- // For an easier solution to this please look at Flatiron's
- // `Resourceful` project
- //
- if (requestBody.body === undefined) {
- requestBody.body = schema.properties.body.default;
- }
-
- //
- // Use REST to determine how to manipulate the stored
- // values
- //
- switch (req.method) {
-
- case "GET":
- res.writeHead(200);
- var result = storedValue.body;
- res.end(JSON.stringify(result));
- return;
-
- case "POST":
- res.writeHead(201);
- res.end();
- memoryStore[requestBody.url] = requestBody;
- return;
-
- case "DELETE":
- delete memoryStore[requestBody.url];
- res.writeHead(200);
- res.end();
- return;
-
- case "PUT":
- memoryStore[requestBody.url] = requestBody;
- res.writeHead(200);
- res.end();
- return;
-
- default:
- res.writeHead(400);
- res.end('Invalid Http Verb');
- return;
- }
- });
-})
-//
-// Listen to various ports depending on environment we are being run on
-//
-server.listen(process.env.PORT || process.env.C9_PORT || 1337, function reportListening () {
-
- console.log('JSON REST Service listening on port', this.address().port);
- console.log('Requests can be sent via REST to "/" if they conform to the following schema:');
- console.log(JSON.stringify(schema, null, ' '));
-
-});
\ No newline at end of file
diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/revalidator/lib/revalidator.js b/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/revalidator/lib/revalidator.js
deleted file mode 100644
index ad65814..0000000
--- a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/revalidator/lib/revalidator.js
+++ /dev/null
@@ -1,427 +0,0 @@
-(function (exports) {
- exports.validate = validate;
- exports.mixin = mixin;
-
- //
- // ### function validate (object, schema, options)
- // #### {Object} object the object to validate.
- // #### {Object} schema (optional) the JSON Schema to validate against.
- // #### {Object} options (optional) options controlling the validation
- // process. See {@link #validate.defaults) for details.
- // Validate object against a JSON Schema.
- // If object is self-describing (i.e. has a
- // $schema property), it will also be validated
- // against the referenced schema. [TODO]: This behaviour bay be
- // suppressed by setting the {@link #validate.options.???}
- // option to ???.[/TODO]
- //
- // If schema is not specified, and object
- // is not self-describing, validation always passes.
- //
- // Note: in order to pass options but no schema,
- // schemamust be specified in the call to
- // validate(); otherwise, options will
- // be interpreted as the schema. schema may be passed
- // as null, undefinded, or the empty object
- // ({}) in this case.
- //
- function validate(object, schema, options) {
- options = mixin({}, options, validate.defaults);
- var errors = [];
-
- validateObject(object, schema, options, errors);
-
- //
- // TODO: self-described validation
- // if (! options.selfDescribing) { ... }
- //
-
- return {
- valid: !(errors.length),
- errors: errors
- };
- };
-
- /**
- * Default validation options. Defaults can be overridden by
- * passing an 'options' hash to {@link #validate}. They can
- * also be set globally be changing the values in
- * validate.defaults directly.
- */
- validate.defaults = {
- /**
- *
- * Enforce 'format' constraints.
- *
- * Default: true
- *
- */
- validateFormats: true,
- /**
- *
- * When {@link #validateFormats} is true,
- * treat unrecognized formats as validation errors.
- *
- * When {@link #validateFormats} is true,
- * also validate formats defined in {@link #validate.formatExtensions}.
- *
- * Default: true
- *
- */
- validateFormatExtensions: true
- };
-
- /**
- * Default messages to include with validation errors.
- */
- validate.messages = {
- required: "is required",
- allowEmpty: "must not be empty",
- minLength: "is too short (minimum is %{expected} characters)",
- maxLength: "is too long (maximum is %{expected} characters)",
- pattern: "invalid input",
- minimum: "must be greater than or equal to %{expected}",
- maximum: "must be less than or equal to %{expected}",
- exclusiveMinimum: "must be greater than %{expected}",
- exclusiveMaximum: "must be less than %{expected}",
- divisibleBy: "must be divisible by %{expected}",
- minItems: "must contain more than %{expected} items",
- maxItems: "must contain less than %{expected} items",
- uniqueItems: "must hold a unique set of values",
- format: "is not a valid %{expected}",
- conform: "must conform to given constraint",
- type: "must be of %{expected} type"
- };
- validate.messages['enum'] = "must be present in given enumerator";
-
- /**
- *
- */
- validate.formats = {
- 'email': /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i,
- 'ip-address': /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/i,
- 'ipv6': /^([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4}$/,
- 'date-time': /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:.\d{1,3})?Z$/,
- 'date': /^\d{4}-\d{2}-\d{2}$/,
- 'time': /^\d{2}:\d{2}:\d{2}$/,
- 'color': /^#[a-z0-9]{6}|#[a-z0-9]{3}|(?:rgb\(\s*(?:[+-]?\d+%?)\s*,\s*(?:[+-]?\d+%?)\s*,\s*(?:[+-]?\d+%?)\s*\))aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow$/i,
- //'style': (not supported)
- //'phone': (not supported)
- //'uri': (not supported)
- 'host-name': /^(([a-zA-Z]|[a-zA-Z][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z]|[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9])/,
- 'utc-millisec': {
- test: function (value) {
- return typeof(value) === 'number' && value >= 0;
- }
- },
- 'regex': {
- test: function (value) {
- try { new RegExp(value) }
- catch (e) { return false }
-
- return true;
- }
- }
- };
-
- /**
- *
- */
- validate.formatExtensions = {
- 'url': /^(https?|ftp|git):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i
- };
-
- function mixin(obj) {
- var sources = Array.prototype.slice.call(arguments, 1);
- while (sources.length) {
- var source = sources.shift();
- if (!source) { continue }
-
- if (typeof(source) !== 'object') {
- throw new TypeError('mixin non-object');
- }
-
- for (var p in source) {
- if (source.hasOwnProperty(p)) {
- obj[p] = source[p];
- }
- }
- }
-
- return obj;
- };
-
- function validateObject(object, schema, options, errors) {
- var props, allProps = Object.keys(object),
- visitedProps = [];
-
- // see 5.2
- if (schema.properties) {
- props = schema.properties;
- for (var p in props) {
- if (props.hasOwnProperty(p)) {
- visitedProps.push(p);
- validateProperty(object, object[p], p, props[p], options, errors);
- }
- }
- }
-
- // see 5.3
- if (schema.patternProperties) {
- props = schema.patternProperties;
- for (var p in props) {
- if (props.hasOwnProperty(p)) {
- var re = new RegExp(p);
-
- // Find all object properties that are matching `re`
- for (var k in object) {
- if (object.hasOwnProperty(k)) {
- visitedProps.push(k);
- if (re.exec(k) !== null) {
- validateProperty(object, object[k], p, props[p], options, errors);
- }
- }
- }
- }
- }
- }
-
- // see 5.4
- if (undefined !== schema.additionalProperties) {
- var i, l;
-
- var unvisitedProps = allProps.filter(function(k){
- return -1 === visitedProps.indexOf(k);
- });
-
- // Prevent additional properties; each unvisited property is therefore an error
- if (schema.additionalProperties === false && unvisitedProps.length > 0) {
- for (i = 0, l = unvisitedProps.length; i < l; i++) {
- error("additionalProperties", unvisitedProps[i], object[unvisitedProps[i]], false, errors);
- }
- }
- // additionalProperties is a schema and validate unvisited properties against that schema
- else if (typeof schema.additionalProperties == "object" && unvisitedProps.length > 0) {
- for (i = 0, l = unvisitedProps.length; i < l; i++) {
- validateProperty(object, object[unvisitedProps[i]], unvisitedProps[i], schema.unvisitedProperties, options, errors);
- }
- }
- }
-
- };
-
- function validateProperty(object, value, property, schema, options, errors) {
- var format,
- valid,
- spec,
- type;
-
- function constrain(name, value, assert) {
- if (schema[name] !== undefined && !assert(value, schema[name])) {
- error(name, property, value, schema, errors);
- }
- }
-
- if (value === undefined) {
- if (schema.required && schema.type !== 'any') {
- return error('required', property, undefined, schema, errors);
- } else {
- return;
- }
- }
-
- if (options.cast) {
- if (('integer' === schema.type || 'number' === schema.type) && value == +value) {
- value = +value;
- object[property] = value;
- }
-
- if ('boolean' === schema.type) {
- if ('true' === value || '1' === value || 1 === value) {
- value = true;
- object[property] = value;
- }
-
- if ('false' === value || '0' === value || 0 === value) {
- value = false;
- object[property] = value;
- }
- }
- }
-
- if (schema.format && options.validateFormats) {
- format = schema.format;
-
- if (options.validateFormatExtensions) { spec = validate.formatExtensions[format] }
- if (!spec) { spec = validate.formats[format] }
- if (!spec) {
- if (options.validateFormatsStrict) {
- return error('format', property, value, schema, errors);
- }
- }
- else {
- if (!spec.test(value)) {
- return error('format', property, value, schema, errors);
- }
- }
- }
-
- if (schema['enum'] && schema['enum'].indexOf(value) === -1) {
- error('enum', property, value, schema, errors);
- }
-
- // Dependencies (see 5.8)
- if (typeof schema.dependencies === 'string' &&
- object[schema.dependencies] === undefined) {
- error('dependencies', property, null, schema, errors);
- }
-
- if (isArray(schema.dependencies)) {
- for (var i = 0, l = schema.dependencies.length; i < l; i++) {
- if (object[schema.dependencies[i]] === undefined) {
- error('dependencies', property, null, schema, errors);
- }
- }
- }
-
- if (typeof schema.dependencies === 'object') {
- validateObject(object, schema.dependencies, options, errors);
- }
-
- checkType(value, schema.type, function(err, type) {
- if (err) return error('type', property, typeof value, schema, errors);
-
- constrain('conform', value, function (a, e) { return e(a, object) });
-
- switch (type || (isArray(value) ? 'array' : typeof value)) {
- case 'string':
- constrain('allowEmpty', value, function (a, e) { return e ? e : a !== '' });
- constrain('minLength', value.length, function (a, e) { return a >= e });
- constrain('maxLength', value.length, function (a, e) { return a <= e });
- constrain('pattern', value, function (a, e) {
- e = typeof e === 'string'
- ? e = new RegExp(e)
- : e;
- return e.test(a)
- });
- break;
- case 'integer':
- case 'number':
- constrain('minimum', value, function (a, e) { return a >= e });
- constrain('maximum', value, function (a, e) { return a <= e });
- constrain('exclusiveMinimum', value, function (a, e) { return a > e });
- constrain('exclusiveMaximum', value, function (a, e) { return a < e });
- constrain('divisibleBy', value, function (a, e) {
- var multiplier = Math.max((a - Math.floor(a)).toString().length - 2, (e - Math.floor(e)).toString().length - 2);
- multiplier = multiplier > 0 ? Math.pow(10, multiplier) : 1;
- return (a * multiplier) % (e * multiplier) === 0
- });
- break;
- case 'array':
- constrain('items', value, function (a, e) {
- for (var i = 0, l = a.length; i < l; i++) {
- validateProperty(object, a[i], property, e, options, errors);
- }
- return true;
- });
- constrain('minItems', value, function (a, e) { return a.length >= e });
- constrain('maxItems', value, function (a, e) { return a.length <= e });
- constrain('uniqueItems', value, function (a) {
- var h = {};
-
- for (var i = 0, l = a.length; i < l; i++) {
- var key = JSON.stringify(a[i]);
- if (h[key]) return false;
- h[key] = true;
- }
-
- return true;
- });
- break;
- case 'object':
- // Recursive validation
- if (schema.properties || schema.patternProperties || schema.additionalProperties) {
- validateObject(value, schema, options, errors);
- }
- break;
- }
- });
- };
-
- function checkType(val, type, callback) {
- var result = false,
- types = isArray(type) ? type : [type];
-
- // No type - no check
- if (type === undefined) return callback(null, type);
-
- // Go through available types
- // And fine first matching
- for (var i = 0, l = types.length; i < l; i++) {
- type = types[i].toLowerCase().trim();
- if (type === 'string' ? typeof val === 'string' :
- type === 'array' ? isArray(val) :
- type === 'object' ? val && typeof val === 'object' &&
- !isArray(val) :
- type === 'number' ? typeof val === 'number' :
- type === 'integer' ? typeof val === 'number' && ~~val === val :
- type === 'null' ? val === null :
- type === 'boolean'? typeof val === 'boolean' :
- type === 'date' ? isDate(val) :
- type === 'any' ? typeof val !== 'undefined' : false) {
- return callback(null, type);
- }
- };
-
- callback(true);
- };
-
- function error(attribute, property, actual, schema, errors) {
- var lookup = { expected: schema[attribute], actual: actual, attribute: attribute, property: property };
- var message = schema.messages && schema.messages[attribute] || schema.message || validate.messages[attribute] || "no default message";
- message = message.replace(/%\{([a-z]+)\}/ig, function (_, match) { return lookup[match.toLowerCase()] || ''; });
- errors.push({
- attribute: attribute,
- property: property,
- expected: schema[attribute],
- actual: actual,
- message: message
- });
- };
-
- function isArray(value) {
- var s = typeof value;
- if (s === 'object') {
- if (value) {
- if (typeof value.length === 'number' &&
- !(value.propertyIsEnumerable('length')) &&
- typeof value.splice === 'function') {
- return true;
- }
- }
- }
- return false;
- }
-
- function isDate(value) {
- var s = typeof value;
- if (s === 'object') {
- if (value) {
- if (typeof value.getTime === 'function') {
- return true;
- }
- }
- }
-
- return false;
- }
-
-})(typeof module === 'object' && module && module.exports ? module.exports : window);
diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/revalidator/package.json b/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/revalidator/package.json
deleted file mode 100644
index b1585d3..0000000
--- a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/revalidator/package.json
+++ /dev/null
@@ -1,57 +0,0 @@
-{
- "name": "revalidator",
- "version": "0.1.8",
- "description": "A cross-browser / node.js validator used by resourceful",
- "license": "Apache 2.0",
- "author": {
- "name": "Nodejitsu Inc.",
- "email": "info@nodejitsu.com"
- },
- "maintainers": [
- {
- "name": "indexzero",
- "email": "charlie.robbins@gmail.com"
- },
- {
- "name": "fedor.indutny",
- "email": "fedor.indutny@gmail.com"
- },
- {
- "name": "julianduque",
- "email": "julianduquej@gmail.com"
- }
- ],
- "repository": {
- "type": "git",
- "url": "http://github.com/flatiron/revalidator.git"
- },
- "devDependencies": {
- "vows": "0.7.0"
- },
- "main": "./lib/revalidator",
- "scripts": {
- "test": "vows test/*-test.js --spec"
- },
- "engines": {
- "node": ">= 0.4.0"
- },
- "bugs": {
- "url": "https://github.com/flatiron/revalidator/issues"
- },
- "homepage": "https://github.com/flatiron/revalidator",
- "_id": "revalidator@0.1.8",
- "_shasum": "fece61bfa0c1b52a206bd6b18198184bdd523a3b",
- "_from": "revalidator@0.1.x",
- "_npmVersion": "1.4.10",
- "_npmUser": {
- "name": "julianduque",
- "email": "julianduquej@gmail.com"
- },
- "dist": {
- "shasum": "fece61bfa0c1b52a206bd6b18198184bdd523a3b",
- "tarball": "http://registry.npmjs.org/revalidator/-/revalidator-0.1.8.tgz"
- },
- "directories": {},
- "_resolved": "https://registry.npmjs.org/revalidator/-/revalidator-0.1.8.tgz",
- "readme": "ERROR: No README data found!"
-}
diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/revalidator/test/validator-test.js b/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/revalidator/test/validator-test.js
deleted file mode 100644
index 6d962c2..0000000
--- a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/revalidator/test/validator-test.js
+++ /dev/null
@@ -1,421 +0,0 @@
-var assert = require('assert'),
- vows = require('vows'),
- revalidator = require('../lib/revalidator');
-
-function clone(object) {
- return Object.keys(object).reduce(function (obj, k) {
- obj[k] = object[k];
- return obj;
- }, {});
-};
-
-
-function assertInvalid(res) {
- assert.isObject(res);
- assert.strictEqual(res.valid, false);
-}
-
-function assertValid(res) {
- assert.isObject(res);
- assert.strictEqual(res.valid, true);
-}
-
-function assertHasError(attr, field) {
- return function (res) {
- assert.notEqual(res.errors.length, 0);
- assert.ok(res.errors.some(function (e) {
- return e.attribute === attr && (field ? e.property === field : true);
- }));
- };
-}
-
-function assertHasErrorMsg(attr, msg) {
- return function (res) {
- assert.notEqual(res.errors.length, 0);
- assert.ok(res.errors.some(function (e) {
- return e.attribute === attr && e.message === msg;
- }));
- };
-}
-
-function assertValidates(passingValue, failingValue, attributes) {
- var schema = {
- name: 'Resource',
- properties: { field: {} }
- };
-
- var failing;
-
- if (!attributes) {
- attributes = failingValue;
- failing = false;
- } else {
- failing = true;
- }
-
- var attr = Object.keys(attributes)[0];
- revalidator.mixin(schema.properties.field, attributes);
-
- var result = {
- "when the object conforms": {
- topic: function () {
- return revalidator.validate({ field: passingValue }, schema);
- },
- "return an object with `valid` set to true": assertValid
- }
- };
-
- if (failing) {
- result["when the object does not conform"] ={
- topic: function () {
- return revalidator.validate({ field: failingValue }, schema);
- },
- "return an object with `valid` set to false": assertInvalid,
- "and an error concerning the attribute": assertHasError(Object.keys(attributes)[0], 'field')
- };
- };
-
- return result;
-}
-
-vows.describe('revalidator', {
- "Validating": {
- "with :'string'": assertValidates ('hello', 42, { type: "string" }),
- "with :'number'": assertValidates (42, 'hello', { type: "number" }),
- "with :'integer'": assertValidates (42, 42.5, { type: "integer" }),
- "with :'array'": assertValidates ([4, 2], 'hi', { type: "array" }),
- "with :'object'": assertValidates ({}, [], { type: "object" }),
- "with :'boolean'": assertValidates (false, 42, { type: "boolean" }),
- "with :bool,num": assertValidates (false, 'hello', { type: ["boolean", "number"] }),
- "with :bool,num": assertValidates (544, null, { type: ["boolean", "number"] }),
- "with :'null'": assertValidates (null, false, { type: "null" }),
- "with :'any'": assertValidates (9, { type: "any" }),
- "with :'date'": assertValidates (new Date(), 'hello', { type: "date" }),
- "with ": assertValidates ("kaboom", "42", { pattern: /^[a-z]+$/ }),
- "with ": assertValidates ("boom", "kaboom", { maxLength: 4 }),
- "with ": assertValidates ("kaboom", "boom", { minLength: 6 }),
- "with ": assertValidates ("hello", "", { allowEmpty: false }),
- "with ": assertValidates ( 512, 43, { minimum: 473 }),
- "with ": assertValidates ( 512, 1949, { maximum: 678 }),
- "with ": assertValidates ( 10, 9, { divisibleBy: 5 }),
- "with decimal": assertValidates ( 0.2, 0.009, { divisibleBy: 0.01 }),
- "with ": assertValidates ("orange", "cigar", { enum: ["orange", "apple", "pear"] }),
- "with :'url'": assertValidates ('http://test.com/', 'hello', { format: 'url' }),
- "with ": {
- topic: {
- properties: {
- town: { dependencies: "country" },
- country: { }
- }
- },
- "when the object conforms": {
- topic: function (schema) {
- return revalidator.validate({ town: "luna", country: "moon" }, schema);
- },
- "return an object with `valid` set to true": assertValid
- },
- "when the object does not conform": {
- topic: function (schema) {
- return revalidator.validate({ town: "luna" }, schema);
- },
- "return an object with `valid` set to false": assertInvalid,
- "and an error concerning the attribute": assertHasError('dependencies')
- }
- },
- "with as array": {
- topic: {
- properties: {
- town: { dependencies: ["country", "planet"] },
- country: { },
- planet: { }
- }
- },
- "when the object conforms": {
- topic: function (schema) {
- return revalidator.validate({ town: "luna", country: "moon", planet: "mars" }, schema);
- },
- "return an object with `valid` set to true": assertValid
- },
- "when the object does not conform": {
- topic: function (schema) {
- return revalidator.validate({ town: "luna", planet: "mars" }, schema);
- },
- "return an object with `valid` set to false": assertInvalid,
- "and an error concerning the attribute": assertHasError('dependencies')
- }
- },
- "with as schema": {
- topic: {
- properties: {
- town: {
- type: 'string',
- dependencies: {
- properties: { x: { type: "number" } }
- }
- },
- country: { }
- }
- },
- "when the object conforms": {
- topic: function (schema) {
- return revalidator.validate({ town: "luna", x: 1 }, schema);
- },
- "return an object with `valid` set to true": assertValid,
- },
- "when the object does not conform": {
- topic: function (schema) {
- return revalidator.validate({ town: "luna", x: 'no' }, schema);
- },
- "return an object with `valid` set to false": assertInvalid
- }
- },
- "with :'integer' and": {
- " constraints": assertValidates ( 512, 43, { minimum: 473, type: 'integer' }),
- " constraints": assertValidates ( 512, 1949, { maximum: 678, type: 'integer' }),
- " constraints": assertValidates ( 10, 9, { divisibleBy: 5, type: 'integer' })
- },
- "with :false": {
- topic: {
- properties: {
- town: { type: 'string' }
- },
- additionalProperties: false
- },
- "when the object conforms": {
- topic: function (schema) {
- return revalidator.validate({ town: "luna" }, schema);
- },
- "return an object with `valid` set to true": assertValid
- },
- "when the object does not conform": {
- topic: function (schema) {
- return revalidator.validate({ town: "luna", area: 'park' }, schema);
- },
- "return an object with `valid` set to false": assertInvalid
- }
- }
- }
-}).addBatch({
- "A schema": {
- topic: {
- name: 'Article',
- properties: {
- title: {
- type: 'string',
- maxLength: 140,
- conditions: {
- optional: function () {
- return !this.published;
- }
- }
- },
- date: { type: 'string', format: 'date', messages: { format: "must be a valid %{expected} and nothing else" } },
- body: { type: 'string' },
- tags: {
- type: 'array',
- uniqueItems: true,
- minItems: 2,
- items: {
- type: 'string',
- pattern: /[a-z ]+/
- }
- },
- tuple: {
- type: 'array',
- minItems: 2,
- maxItems: 2,
- items: {
- type: ['string', 'number']
- }
- },
- author: { type: 'string', pattern: /^[\w ]+$/i, required: true, messages: { required: "is essential for survival" } },
- published: { type: 'boolean', 'default': false },
- category: { type: 'string' },
- palindrome: {type: 'string', conform: function(val) {
- return val == val.split("").reverse().join(""); }
- },
- name: { type: 'string', default: '', conform: function(val, data) {
- return (val === data.author); }
- }
- },
- patternProperties: {
- '^_': {
- type: 'boolean', default: false
- }
- }
- },
- "and an object": {
- topic: {
- title: 'Gimme some Gurus',
- date: '2012-02-04',
- body: "And I will pwn your codex.",
- tags: ['energy drinks', 'code'],
- tuple: ['string0', 103],
- author: 'cloudhead',
- published: true,
- category: 'misc',
- palindrome: 'dennis sinned',
- name: 'cloudhead',
- _flag: true
- },
- "can be validated with `revalidator.validate`": {
- "and if it conforms": {
- topic: function (object, schema) {
- return revalidator.validate(object, schema);
- },
- "return an object with the `valid` property set to true": assertValid,
- "return an object with the `errors` property as an empty array": function (res) {
- assert.isArray(res.errors);
- assert.isEmpty(res.errors);
- }
- },
- "and if it has a missing required property": {
- topic: function (object, schema) {
- object = clone(object);
- delete object.author;
- return revalidator.validate(object, schema);
- },
- "return an object with `valid` set to false": assertInvalid,
- "and an error concerning the 'required' attribute": assertHasError('required'),
- "and the error message defined": assertHasErrorMsg('required', "is essential for survival")
- },
- "and if it has a missing non-required property": {
- topic: function (object, schema) {
- object = clone(object);
- delete object.category;
- return revalidator.validate(object, schema);
- },
- "return an object with `valid` set to false": assertValid
- },
- "and if it has a incorrect pattern property": {
- topic: function (object, schema) {
- object = clone(object);
- object._additionalFlag = 'text';
- return revalidator.validate(object, schema);
- },
- "return an object with `valid` set to false": assertInvalid
- },
- "and if it has a incorrect unique array property": {
- topic: function (object, schema) {
- object = clone(object);
- object.tags = ['a', 'a'];
- return revalidator.validate(object, schema);
- },
- "return an object with `valid` set to false": assertInvalid
- },
- "and if it has a incorrect array property (wrong values)": {
- topic: function (object, schema) {
- object = clone(object);
- object.tags = ['a', '____'];
- return revalidator.validate(object, schema);
- },
- "return an object with `valid` set to false": assertInvalid
- },
- "and if it has a incorrect array property (< minItems)": {
- topic: function (object, schema) {
- object = clone(object);
- object.tags = ['x'];
- return revalidator.validate(object, schema);
- },
- "return an object with `valid` set to false": assertInvalid
- },
- "and if it has a incorrect format (date)": {
- topic: function (object, schema) {
- object = clone(object);
- object.date = 'bad date';
- return revalidator.validate(object, schema);
- },
- "return an object with `valid` set to false": assertInvalid,
- "and the error message defined": assertHasErrorMsg('format', "must be a valid date and nothing else")
- },
- "and if it is not a palindrome (conform function)": {
- topic: function (object, schema) {
- object = clone(object);
- object.palindrome = 'bad palindrome';
- return revalidator.validate(object, schema);
- },
- "return an object with `valid` set to false": assertInvalid
- },
- "and if it didn't validate a pattern": {
- topic: function (object, schema) {
- object = clone(object);
- object.author = 'email@address.com';
- return revalidator.validate(object, schema);
- },
- "return an object with `valid` set to false": assertInvalid,
- "and an error concerning the 'pattern' attribute": assertHasError('pattern')
- },
- }
- },
- "with option": {
- topic: {
- properties: {
- answer: { type: "integer" },
- is_ready: { type: "boolean" }
- }
- },
- "and property": {
- "is castable string": {
- topic: function (schema) {
- return revalidator.validate({ answer: "42" }, schema, { cast: true });
- },
- "return an object with `valid` set to true": assertValid
- },
- "is uncastable string": {
- topic: function (schema) {
- return revalidator.validate({ answer: "forty2" }, schema, { cast: true });
- },
- "return an object with `valid` set to false": assertInvalid
- },
- "is casted to integer": {
- topic: function (schema) {
- var object = { answer: "42" };
- revalidator.validate(object, schema, { cast: true });
- return object;
- },
- "return an object with `answer` set to 42": function(res) { assert.strictEqual(res.answer, 42) }
- }
- },
- "and property": {
- "is castable 'true/false' string": {
- topic: function (schema) {
- return revalidator.validate({ is_ready: "true" }, schema, { cast: true });
- },
- "return an object with `valid` set to true": assertValid
- },
- "is castable '1/0' string": {
- topic: function (schema) {
- return revalidator.validate({ is_ready: "1" }, schema, { cast: true });
- },
- "return an object with `valid` set to true": assertValid
- },
- "is castable `1/0` integer": {
- topic: function (schema) {
- return revalidator.validate({ is_ready: 1 }, schema, { cast: true });
- },
- "return an object with `valid` set to true": assertValid
- },
- "is uncastable string": {
- topic: function (schema) {
- return revalidator.validate({ is_ready: "not yet" }, schema, { cast: true });
- },
- "return an object with `valid` set to false": assertInvalid
- },
- "is uncastable number": {
- topic: function (schema) {
- return revalidator.validate({ is_ready: 42 }, schema, { cast: true });
- },
- "return an object with `valid` set to false": assertInvalid
- },
- "is casted to boolean": {
- topic: function (schema) {
- var object = { is_ready: "true" };
- revalidator.validate(object, schema, { cast: true });
- return object;
- },
- "return an object with `is_ready` set to true": function(res) { assert.strictEqual(res.is_ready, true) }
- }
- }
- }
- }
-}).export(module);
diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/utile/.npmignore b/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/utile/.npmignore
deleted file mode 100644
index 8d8bfd5..0000000
--- a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/utile/.npmignore
+++ /dev/null
@@ -1,4 +0,0 @@
-node_modules
-npm-debug.log
-*.swp
-*.swo
diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/utile/.travis.yml b/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/utile/.travis.yml
deleted file mode 100644
index 88cf1f3..0000000
--- a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/utile/.travis.yml
+++ /dev/null
@@ -1,10 +0,0 @@
-language: node_js
-node_js:
- - 0.6
- - 0.8
-
-notifications:
- email:
- - travis@nodejitsu.com
- irc: "irc.freenode.org#nodejitsu"
-
diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/utile/CHANGELOG.md b/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/utile/CHANGELOG.md
deleted file mode 100644
index b4e427a..0000000
--- a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/utile/CHANGELOG.md
+++ /dev/null
@@ -1,16 +0,0 @@
-
-0.1.5 / 2012-09-18
-==================
-
- * Fixed problem with underscore values in camelToUnderscore
-
-0.1.4 / 2012-07-26
-==================
-
- * Made use of inflect for camel to underscore conversion
-
-0.1.3 / 2012-07-25
-==================
-
- * Added camel to underscore conversion and vice-versa
-
diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/utile/LICENSE b/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/utile/LICENSE
deleted file mode 100644
index 56217ca..0000000
--- a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/utile/LICENSE
+++ /dev/null
@@ -1,19 +0,0 @@
-Copyright (c) 2010 Nodejitsu Inc.
-
-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/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/utile/README.md b/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/utile/README.md
deleted file mode 100644
index 451b1fc..0000000
--- a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/utile/README.md
+++ /dev/null
@@ -1,87 +0,0 @@
-# utile [](http://travis-ci.org/flatiron/utile)
-
-A drop-in replacement for `util` with some additional advantageous functions
-
-## Motivation
-Javascript is definitely a "batteries not included language" when compared to languages like Ruby or Python. Node.js has a simple utility library which exposes some basic (but important) functionality:
-
-```
-$ node
-> var util = require('util');
-> util.
-(...)
-
-util.debug util.error util.exec util.inherits util.inspect
-util.log util.p util.print util.pump util.puts
-```
-
-When one considers their own utility library, why ever bother requiring `util` again? That is the approach taken by this module. To compare:
-
-```
-$ node
-> var utile = require('./lib')
-> utile.
-(...)
-
-utile.async utile.capitalize utile.clone utile.cpr utile.createPath utile.debug
-utile.each utile.error utile.exec utile.file utile.filter utile.find
-utile.inherits utile.log utile.mixin utile.mkdirp utile.p utile.path
-utile.print utile.pump utile.puts utile.randomString utile.requireDir uile.requireDirLazy
-utile.rimraf
-```
-
-As you can see all of the original methods from `util` are there, but there are several new methods specific to `utile`. A note about implementation: _no node.js native modules are modified by utile, it simply copies those methods._
-
-## Methods
-The `utile` modules exposes some simple utility methods:
-
-* `.each(obj, iterator)`: Iterate over the keys of an object.
-* `.mixin(target [source0, source1, ...])`: Copies enumerable properties from `source0 ... sourceN` onto `target` and returns the resulting object.
-* `.clone(obj)`: Shallow clones the specified object.
-* `.capitalize(str)`: Capitalizes the specified `str`.
-* `.randomString(length)`: randomString returns a pseudo-random ASCII string (subset) the return value is a string of length ⌈bits/6⌉ of characters from the base64 alphabet.
-* `.filter(obj, test)`: return an object with the properties that `test` returns true on.
-* `.args(arguments)`: Converts function arguments into actual array with special `callback`, `cb`, `array`, and `last` properties. Also supports *optional* argument contracts. See [the example](https://github.com/flatiron/utile/blob/master/examples/utile-args.js) for more details.
-* `.requireDir(directory)`: Requires all files and directories from `directory`, returning an object with keys being filenames (without trailing `.js`) and respective values being return values of `require(filename)`.
-* `.requireDirLazy(directory)`: Lazily requires all files and directories from `directory`, returning an object with keys being filenames (without trailing `.js`) and respective values (getters) being return values of `require(filename)`.
-* `.format([string] text, [array] formats, [array] replacements)`: Replace `formats` in `text` with `replacements`. This will fall back to the original `util.format` command if it is called improperly.
-
-## Packaged Dependencies
-In addition to the methods that are built-in, utile includes a number of commonly used dependencies to reduce the number of includes in your package.json. These modules _are not eagerly loaded to be respectful of startup time,_ but instead are lazy-loaded getters on the `utile` object
-
-* `.async`: [Async utilities for node and the browser][0]
-* `.inflect`: [Customizable inflections for node.js][6]
-* `.mkdirp`: [Recursively mkdir, like mkdir -p, but in node.js][1]
-* `.rimraf`: [A rm -rf util for nodejs][2]
-* `.cpr`: [Asynchronous recursive file copying with Node.js][3]
-
-## Installation
-
-### Installing npm (node package manager)
-```
- curl http://npmjs.org/install.sh | sh
-```
-
-### Installing utile
-```
- [sudo] npm install utile
-```
-
-## Tests
-All tests are written with [vows][4] and should be run with [npm][5]:
-
-``` bash
- $ npm test
-```
-
-#### Author: [Nodejitsu Inc.](http://www.nodejitsu.com)
-#### Contributors: [Charlie Robbins](http://github.com/indexzero), [Dominic Tarr](http://github.com/dominictarr)
-#### License: MIT
-
-[0]: https://github.com/caolan/async
-[1]: https://github.com/substack/node-mkdirp
-[2]: https://github.com/isaacs/rimraf
-[3]: https://github.com/avianflu/ncp
-[4]: https://vowsjs.org
-[5]: https://npmjs.org
-[6]: https://github.com/pksunkara/inflect
diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/utile/lib/args.js b/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/utile/lib/args.js
deleted file mode 100644
index 34f1c11..0000000
--- a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/utile/lib/args.js
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * args.js: function argument parsing helper utility
- *
- * (C) 2012, Nodejitsu Inc.
- * MIT LICENSE
- *
- */
-
-var utile = require('./index');
-
-//
-// ### function args(_args)
-// #### _args {Arguments} Original function arguments
-//
-// Top-level method will accept a javascript "arguments" object (the actual keyword
-// "arguments" inside any scope), and attempt to return back an intelligent object
-// representing the functions arguments
-//
-module.exports = function (_args) {
- var args = utile.rargs(_args),
- _cb;
-
- //
- // Find and define the first argument
- //
- Object.defineProperty(args, 'first', { value: args[0] });
-
- //
- // Find and define any callback
- //
- _cb = args[args.length - 1] || args[args.length];
- if (typeof _cb === "function") {
- Object.defineProperty(args, 'callback', { value: _cb });
- Object.defineProperty(args, 'cb', { value: _cb });
- args.pop();
- }
-
- //
- // Find and define the last argument
- //
- if (args.length) {
- Object.defineProperty(args, 'last', { value: args[args.length - 1] });
- }
-
- return args;
-};
diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/utile/lib/base64.js b/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/utile/lib/base64.js
deleted file mode 100644
index 1de7a76..0000000
--- a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/utile/lib/base64.js
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * base64.js: An extremely simple implementation of base64 encoding / decoding using node.js Buffers
- *
- * (C) 2010, Nodejitsu Inc.
- *
- */
-
-var base64 = exports;
-
-//
-// ### function encode (unencoded)
-// #### @unencoded {string} The string to base64 encode
-// Encodes the specified string to base64 using node.js Buffers.
-//
-base64.encode = function (unencoded) {
- var encoded;
-
- try {
- encoded = new Buffer(unencoded || '').toString('base64');
- }
- catch (ex) {
- return null;
- }
-
- return encoded;
-};
-
-//
-// ### function decode (encoded)
-// #### @encoded {string} The string to base64 decode
-// Decodes the specified string from base64 using node.js Buffers.
-//
-base64.decode = function (encoded) {
- var decoded;
-
- try {
- decoded = new Buffer(encoded || '', 'base64').toString('utf8');
- }
- catch (ex) {
- return null;
- }
-
- return decoded;
-};
\ No newline at end of file
diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/utile/lib/file.js b/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/utile/lib/file.js
deleted file mode 100644
index 4641878..0000000
--- a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/utile/lib/file.js
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * file.js: Simple utilities for working with the file system.
- *
- * (C) 2011, Nodejitsu Inc.
- * MIT LICENSE
- *
- */
-
-var fs = require('fs');
-
-exports.readJson = exports.readJSON = function (file, callback) {
- if (typeof callback !== 'function') {
- throw new Error('utile.file.readJson needs a callback');
- }
-
- fs.readFile(file, 'utf-8', function (err, data) {
- if (err) {
- return callback(err);
- }
-
- try {
- var json = JSON.parse(data);
- callback(null, json);
- }
- catch (err) {
- return callback(err);
- }
- });
-};
-
-exports.readJsonSync = exports.readJSONSync = function (file) {
- return JSON.parse(fs.readFileSync(file, 'utf-8'));
-};
diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/utile/lib/format.js b/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/utile/lib/format.js
deleted file mode 100644
index 3262dd5..0000000
--- a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/utile/lib/format.js
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * format.js: `util.format` enhancement to allow custom formatting parameters.
- *
- * (C) 2012, Nodejitsu Inc.
- * MIT LICENSE
- *
- */
-
-var util = require('util');
-
-exports = module.exports = function(str) {
- var formats = [].slice.call(arguments, 1, 3);
-
- if (!(formats[0] instanceof Array && formats[1] instanceof Array) || arguments.length > 3)
- return util.format.apply(null, arguments);
-
- var replacements = formats.pop(),
- formats = formats.shift();
-
- formats.forEach(function(format, id) {
- str = str.replace(new RegExp(format), replacements[id]);
- });
-
- return str;
-};
diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/utile/lib/index.js b/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/utile/lib/index.js
deleted file mode 100644
index ac9f925..0000000
--- a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/utile/lib/index.js
+++ /dev/null
@@ -1,467 +0,0 @@
-/*
- * index.js: Top-level include for the `utile` module.
- *
- * (C) 2011, Nodejitsu Inc.
- * MIT LICENSE
- *
- */
-
-var fs = require('fs'),
- path = require('path'),
- util = require('util');
-
-var utile = module.exports;
-
-//
-// Extend the `utile` object with all methods from the
-// core node `util` methods.
-//
-Object.keys(util).forEach(function (key) {
- utile[key] = util[key];
-});
-
-Object.defineProperties(utile, {
-
- //
- // ### function async
- // Simple wrapper to `require('async')`.
- //
- 'async': {
- get: function() {
- return utile.async = require('async');
- }
- },
-
- //
- // ### function inflect
- // Simple wrapper to `require('i')`.
- //
- 'inflect': {
- get: function() {
- return utile.inflect = require('i')();
- }
- },
-
- //
- // ### function mkdirp
- // Simple wrapper to `require('mkdirp')`
- //
- 'mkdirp': {
- get: function() {
- return utile.mkdirp = require('mkdirp');
- }
- },
-
- //
- // ### function deepEqual
- // Simple wrapper to `require('deep-equal')`
- // Remark: deepEqual is 4x faster then using assert.deepEqual
- // see: https://gist.github.com/2790507
- //
- 'deepEqual': {
- get: function() {
- return utile.deepEqual = require('deep-equal');
- }
- },
-
- //
- // ### function rimraf
- // Simple wrapper to `require('rimraf')`
- //
- 'rimraf': {
- get: function() {
- return utile.rimraf = require('rimraf');
- }
- },
-
- //
- // ### function cpr
- // Simple wrapper to `require('ncp').ncp`
- //
- 'cpr': {
- get: function() {
- return utile.cpr = require('ncp').ncp;
- }
- },
-
- //
- // ### @file {Object}
- // Lazy-loaded `file` module
- //
- 'file': {
- get: function() {
- return utile.file = require('./file');
- }
- },
-
- //
- // ### @args {Object}
- // Lazy-loaded `args` module
- //
- 'args': {
- get: function() {
- return utile.args = require('./args');
- }
- },
-
- //
- // ### @base64 {Object}
- // Lazy-loaded `base64` object
- //
- 'base64': {
- get: function() {
- return utile.base64 = require('./base64');
- }
- },
-
- //
- // ### @format {Object}
- // Lazy-loaded `format` object
- //
- 'format': {
- get: function() {
- return utile.format = require('./format');
- }
- }
-
-});
-
-
-//
-// ### function rargs(_args)
-// #### _args {Arguments} Original function arguments
-//
-// Top-level method will accept a javascript "arguments" object
-// (the actual keyword "arguments" inside any scope) and return
-// back an Array.
-//
-utile.rargs = function (_args, slice) {
- if (!slice) {
- slice = 0;
- }
-
- var len = (_args || []).length,
- args = new Array(len - slice),
- i;
-
- //
- // Convert the raw `_args` to a proper Array.
- //
- for (i = slice; i < len; i++) {
- args[i - slice] = _args[i];
- }
-
- return args;
-};
-
-//
-// ### function each (obj, iterator)
-// #### @obj {Object} Object to iterate over
-// #### @iterator {function} Continuation to use on each key. `function (value, key, object)`
-// Iterate over the keys of an object.
-//
-utile.each = function (obj, iterator) {
- Object.keys(obj).forEach(function (key) {
- iterator(obj[key], key, obj);
- });
-};
-
-//
-// ### function find (o)
-//
-//
-utile.find = function (obj, pred) {
- var value, key;
-
- for (key in obj) {
- value = obj[key];
- if (pred(value, key)) {
- return value;
- }
- }
-};
-
-//
-// ### function pad (str, len, chr)
-// ### @str {String} String to pad
-// ### @len {Number} Number of chars to pad str with
-// ### @chr {String} Optional replacement character, defaults to empty space
-// Appends chr to str until it reaches a length of len
-//
-utile.pad = function pad(str, len, chr) {
- var s;
- if (!chr) {
- chr = ' ';
- }
- str = str || '';
- s = str;
- if (str.length < len) {
- for (var i = 0; i < (len - str.length); i++) {
- s += chr;
- }
- }
- return s;
-}
-
-//
-// ### function path (obj, path, value)
-// ### @obj {Object} Object to insert value into
-// ### @path {Array} List of nested keys to insert value at
-// Retreives a value from given Object, `obj`, located at the
-// nested keys, `path`.
-//
-utile.path = function (obj, path) {
- var key, i;
-
- for (i in path) {
- if (typeof obj === 'undefined') {
- return undefined;
- }
-
- key = path[i];
- obj = obj[key];
- }
-
- return obj;
-};
-
-//
-// ### function createPath (obj, path, value)
-// ### @obj {Object} Object to insert value into
-// ### @path {Array} List of nested keys to insert value at
-// ### @value {*} Value to insert into the object.
-// Inserts the `value` into the given Object, `obj`, creating
-// any keys in `path` along the way if necessary.
-//
-utile.createPath = function (obj, path, value) {
- var key, i;
-
- for (i in path) {
- key = path[i];
- if (!obj[key]) {
- obj[key] = ((+i + 1 === path.length) ? value : {});
- }
-
- obj = obj[key];
- }
-};
-
-//
-// ### function mixin (target [source0, source1, ...])
-// Copies enumerable properties from `source0 ... sourceN`
-// onto `target` and returns the resulting object.
-//
-utile.mixin = function (target) {
- utile.rargs(arguments, 1).forEach(function (o) {
- Object.getOwnPropertyNames(o).forEach(function(attr) {
- var getter = Object.getOwnPropertyDescriptor(o, attr).get,
- setter = Object.getOwnPropertyDescriptor(o, attr).set;
-
- if (!getter && !setter) {
- target[attr] = o[attr];
- }
- else {
- Object.defineProperty(target, attr, {
- get: getter,
- set: setter
- });
- }
- });
- });
-
- return target;
-};
-
-
-//
-// ### function capitalize (str)
-// #### @str {string} String to capitalize
-// Capitalizes the specified `str`.
-//
-utile.capitalize = utile.inflect.camelize;
-
-//
-// ### function escapeRegExp (str)
-// #### @str {string} String to be escaped
-// Escape string for use in Javascript regex
-//
-utile.escapeRegExp = function (str) {
- return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
-};
-
-//
-// ### function randomString (length)
-// #### @length {integer} The number of bits for the random base64 string returned to contain
-// randomString returns a pseude-random ASCII string (subset)
-// the return value is a string of length ⌈bits/6⌉ of characters
-// from the base64 alphabet.
-//
-utile.randomString = function (length) {
- var chars, rand, i, ret, mod, bits;
-
- chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-';
- ret = '';
- // standard 4
- mod = 4;
- // default is 16
- bits = length * mod || 64;
-
- // in v8, Math.random() yields 32 pseudo-random bits (in spidermonkey it gives 53)
- while (bits > 0) {
- // 32-bit integer
- rand = Math.floor(Math.random() * 0x100000000);
- //we use the top bits
- for (i = 26; i > 0 && bits > 0; i -= mod, bits -= mod) {
- ret += chars[0x3F & rand >>> i];
- }
- }
-
- return ret;
-};
-
-//
-// ### function filter (object, test)
-// #### @obj {Object} Object to iterate over
-// #### @pred {function} Predicate applied to each property. `function (value, key, object)`
-// Returns an object with properties from `obj` which satisfy
-// the predicate `pred`
-//
-utile.filter = function (obj, pred) {
- var copy;
- if (Array.isArray(obj)) {
- copy = [];
- utile.each(obj, function (val, key) {
- if (pred(val, key, obj)) {
- copy.push(val);
- }
- });
- }
- else {
- copy = {};
- utile.each(obj, function (val, key) {
- if (pred(val, key, obj)) {
- copy[key] = val;
- }
- });
- }
- return copy;
-};
-
-//
-// ### function requireDir (directory)
-// #### @directory {string} Directory to require
-// Requires all files and directories from `directory`, returning an object
-// with keys being filenames (without trailing `.js`) and respective values
-// being return values of `require(filename)`.
-//
-utile.requireDir = function (directory) {
- var result = {},
- files = fs.readdirSync(directory);
-
- files.forEach(function (file) {
- if (file.substr(-3) === '.js') {
- file = file.substr(0, file.length - 3);
- }
- result[file] = require(path.resolve(directory, file));
- });
- return result;
-};
-
-//
-// ### function requireDirLazy (directory)
-// #### @directory {string} Directory to require
-// Lazily requires all files and directories from `directory`, returning an
-// object with keys being filenames (without trailing `.js`) and respective
-// values (getters) being return values of `require(filename)`.
-//
-utile.requireDirLazy = function (directory) {
- var result = {},
- files = fs.readdirSync(directory);
-
- files.forEach(function (file) {
- if (file.substr(-3) === '.js') {
- file = file.substr(0, file.length - 3);
- }
- Object.defineProperty(result, file, {
- get: function() {
- return result[file] = require(path.resolve(directory, file));
- }
- });
- });
-
- return result;
-};
-
-//
-// ### function clone (object, filter)
-// #### @object {Object} Object to clone
-// #### @filter {Function} Filter to be used
-// Shallow clones the specified object.
-//
-utile.clone = function (object, filter) {
- return Object.keys(object).reduce(filter ? function (obj, k) {
- if (filter(k)) obj[k] = object[k];
- return obj;
- } : function (obj, k) {
- obj[k] = object[k];
- return obj;
- }, {});
-};
-
-//
-// ### function camelToUnderscore (obj)
-// #### @obj {Object} Object to convert keys on.
-// Converts all keys of the type `keyName` to `key_name` on the
-// specified `obj`.
-//
-utile.camelToUnderscore = function (obj) {
- if (typeof obj !== 'object' || obj === null) {
- return obj;
- }
-
- if (Array.isArray(obj)) {
- obj.forEach(utile.camelToUnderscore);
- return obj;
- }
-
- Object.keys(obj).forEach(function (key) {
- var k = utile.inflect.underscore(key);
- if (k !== key) {
- obj[k] = obj[key];
- delete obj[key];
- key = k;
- }
- utile.camelToUnderscore(obj[key]);
- });
-
- return obj;
-};
-
-//
-// ### function underscoreToCamel (obj)
-// #### @obj {Object} Object to convert keys on.
-// Converts all keys of the type `key_name` to `keyName` on the
-// specified `obj`.
-//
-utile.underscoreToCamel = function (obj) {
- if (typeof obj !== 'object' || obj === null) {
- return obj;
- }
-
- if (Array.isArray(obj)) {
- obj.forEach(utile.underscoreToCamel);
- return obj;
- }
-
- Object.keys(obj).forEach(function (key) {
- var k = utile.inflect.camelize(key, false);
- if (k !== key) {
- obj[k] = obj[key];
- delete obj[key];
- key = k;
- }
- utile.underscoreToCamel(obj[key]);
- });
-
- return obj;
-};
diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/utile/node_modules/.bin/mkdirp b/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/utile/node_modules/.bin/mkdirp
deleted file mode 120000
index 017896c..0000000
--- a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/utile/node_modules/.bin/mkdirp
+++ /dev/null
@@ -1 +0,0 @@
-../mkdirp/bin/cmd.js
\ No newline at end of file
diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/utile/node_modules/.bin/ncp b/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/utile/node_modules/.bin/ncp
deleted file mode 120000
index 1c02648..0000000
--- a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/utile/node_modules/.bin/ncp
+++ /dev/null
@@ -1 +0,0 @@
-../ncp/bin/ncp
\ No newline at end of file
diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/utile/node_modules/.bin/rimraf b/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/utile/node_modules/.bin/rimraf
deleted file mode 120000
index 4cd49a4..0000000
--- a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/utile/node_modules/.bin/rimraf
+++ /dev/null
@@ -1 +0,0 @@
-../rimraf/bin.js
\ No newline at end of file
diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/utile/node_modules/async/LICENSE b/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/utile/node_modules/async/LICENSE
deleted file mode 100644
index b7f9d50..0000000
--- a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/utile/node_modules/async/LICENSE
+++ /dev/null
@@ -1,19 +0,0 @@
-Copyright (c) 2010 Caolan McMahon
-
-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.
diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/utile/node_modules/async/README.md b/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/utile/node_modules/async/README.md
deleted file mode 100644
index 951f76e..0000000
--- a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/utile/node_modules/async/README.md
+++ /dev/null
@@ -1,1425 +0,0 @@
-# Async.js
-
-Async is a utility module which provides straight-forward, powerful functions
-for working with asynchronous JavaScript. Although originally designed for
-use with [node.js](http://nodejs.org), it can also be used directly in the
-browser. Also supports [component](https://github.com/component/component).
-
-Async provides around 20 functions that include the usual 'functional'
-suspects (map, reduce, filter, each…) as well as some common patterns
-for asynchronous control flow (parallel, series, waterfall…). All these
-functions assume you follow the node.js convention of providing a single
-callback as the last argument of your async function.
-
-
-## Quick Examples
-
-```javascript
-async.map(['file1','file2','file3'], fs.stat, function(err, results){
- // results is now an array of stats for each file
-});
-
-async.filter(['file1','file2','file3'], fs.exists, function(results){
- // results now equals an array of the existing files
-});
-
-async.parallel([
- function(){ ... },
- function(){ ... }
-], callback);
-
-async.series([
- function(){ ... },
- function(){ ... }
-]);
-```
-
-There are many more functions available so take a look at the docs below for a
-full list. This module aims to be comprehensive, so if you feel anything is
-missing please create a GitHub issue for it.
-
-## Common Pitfalls
-
-### Binding a context to an iterator
-
-This section is really about bind, not about async. If you are wondering how to
-make async execute your iterators in a given context, or are confused as to why
-a method of another library isn't working as an iterator, study this example:
-
-```js
-// Here is a simple object with an (unnecessarily roundabout) squaring method
-var AsyncSquaringLibrary = {
- squareExponent: 2,
- square: function(number, callback){
- var result = Math.pow(number, this.squareExponent);
- setTimeout(function(){
- callback(null, result);
- }, 200);
- }
-};
-
-async.map([1, 2, 3], AsyncSquaringLibrary.square, function(err, result){
- // result is [NaN, NaN, NaN]
- // This fails because the `this.squareExponent` expression in the square
- // function is not evaluated in the context of AsyncSquaringLibrary, and is
- // therefore undefined.
-});
-
-async.map([1, 2, 3], AsyncSquaringLibrary.square.bind(AsyncSquaringLibrary), function(err, result){
- // result is [1, 4, 9]
- // With the help of bind we can attach a context to the iterator before
- // passing it to async. Now the square function will be executed in its
- // 'home' AsyncSquaringLibrary context and the value of `this.squareExponent`
- // will be as expected.
-});
-```
-
-## Download
-
-The source is available for download from
-[GitHub](http://github.com/caolan/async).
-Alternatively, you can install using Node Package Manager (npm):
-
- npm install async
-
-__Development:__ [async.js](https://github.com/caolan/async/raw/master/lib/async.js) - 29.6kb Uncompressed
-
-## In the Browser
-
-So far it's been tested in IE6, IE7, IE8, FF3.6 and Chrome 5. Usage:
-
-```html
-
-
-```
-
-## Documentation
-
-### Collections
-
-* [each](#each)
-* [eachSeries](#eachSeries)
-* [eachLimit](#eachLimit)
-* [map](#map)
-* [mapSeries](#mapSeries)
-* [mapLimit](#mapLimit)
-* [filter](#filter)
-* [filterSeries](#filterSeries)
-* [reject](#reject)
-* [rejectSeries](#rejectSeries)
-* [reduce](#reduce)
-* [reduceRight](#reduceRight)
-* [detect](#detect)
-* [detectSeries](#detectSeries)
-* [sortBy](#sortBy)
-* [some](#some)
-* [every](#every)
-* [concat](#concat)
-* [concatSeries](#concatSeries)
-
-### Control Flow
-
-* [series](#series)
-* [parallel](#parallel)
-* [parallelLimit](#parallellimittasks-limit-callback)
-* [whilst](#whilst)
-* [doWhilst](#doWhilst)
-* [until](#until)
-* [doUntil](#doUntil)
-* [forever](#forever)
-* [waterfall](#waterfall)
-* [compose](#compose)
-* [applyEach](#applyEach)
-* [applyEachSeries](#applyEachSeries)
-* [queue](#queue)
-* [cargo](#cargo)
-* [auto](#auto)
-* [iterator](#iterator)
-* [apply](#apply)
-* [nextTick](#nextTick)
-* [times](#times)
-* [timesSeries](#timesSeries)
-
-### Utils
-
-* [memoize](#memoize)
-* [unmemoize](#unmemoize)
-* [log](#log)
-* [dir](#dir)
-* [noConflict](#noConflict)
-
-
-## Collections
-
-
-
-### each(arr, iterator, callback)
-
-Applies an iterator function to each item in an array, in parallel.
-The iterator is called with an item from the list and a callback for when it
-has finished. If the iterator passes an error to this callback, the main
-callback for the each function is immediately called with the error.
-
-Note, that since this function applies the iterator to each item in parallel
-there is no guarantee that the iterator functions will complete in order.
-
-__Arguments__
-
-* arr - An array to iterate over.
-* iterator(item, callback) - A function to apply to each item in the array.
- The iterator is passed a callback(err) which must be called once it has
- completed. If no error has occured, the callback should be run without
- arguments or with an explicit null argument.
-* callback(err) - A callback which is called after all the iterator functions
- have finished, or an error has occurred.
-
-__Example__
-
-```js
-// assuming openFiles is an array of file names and saveFile is a function
-// to save the modified contents of that file:
-
-async.each(openFiles, saveFile, function(err){
- // if any of the saves produced an error, err would equal that error
-});
-```
-
----------------------------------------
-
-
-
-### eachSeries(arr, iterator, callback)
-
-The same as each only the iterator is applied to each item in the array in
-series. The next iterator is only called once the current one has completed
-processing. This means the iterator functions will complete in order.
-
-
----------------------------------------
-
-
-
-### eachLimit(arr, limit, iterator, callback)
-
-The same as each only no more than "limit" iterators will be simultaneously
-running at any time.
-
-Note that the items are not processed in batches, so there is no guarantee that
- the first "limit" iterator functions will complete before any others are
-started.
-
-__Arguments__
-
-* arr - An array to iterate over.
-* limit - The maximum number of iterators to run at any time.
-* iterator(item, callback) - A function to apply to each item in the array.
- The iterator is passed a callback(err) which must be called once it has
- completed. If no error has occured, the callback should be run without
- arguments or with an explicit null argument.
-* callback(err) - A callback which is called after all the iterator functions
- have finished, or an error has occurred.
-
-__Example__
-
-```js
-// Assume documents is an array of JSON objects and requestApi is a
-// function that interacts with a rate-limited REST api.
-
-async.eachLimit(documents, 20, requestApi, function(err){
- // if any of the saves produced an error, err would equal that error
-});
-```
-
----------------------------------------
-
-
-### map(arr, iterator, callback)
-
-Produces a new array of values by mapping each value in the given array through
-the iterator function. The iterator is called with an item from the array and a
-callback for when it has finished processing. The callback takes 2 arguments,
-an error and the transformed item from the array. If the iterator passes an
-error to this callback, the main callback for the map function is immediately
-called with the error.
-
-Note, that since this function applies the iterator to each item in parallel
-there is no guarantee that the iterator functions will complete in order, however
-the results array will be in the same order as the original array.
-
-__Arguments__
-
-* arr - An array to iterate over.
-* iterator(item, callback) - A function to apply to each item in the array.
- The iterator is passed a callback(err, transformed) which must be called once
- it has completed with an error (which can be null) and a transformed item.
-* callback(err, results) - A callback which is called after all the iterator
- functions have finished, or an error has occurred. Results is an array of the
- transformed items from the original array.
-
-__Example__
-
-```js
-async.map(['file1','file2','file3'], fs.stat, function(err, results){
- // results is now an array of stats for each file
-});
-```
-
----------------------------------------
-
-
-### mapSeries(arr, iterator, callback)
-
-The same as map only the iterator is applied to each item in the array in
-series. The next iterator is only called once the current one has completed
-processing. The results array will be in the same order as the original.
-
-
----------------------------------------
-
-
-### mapLimit(arr, limit, iterator, callback)
-
-The same as map only no more than "limit" iterators will be simultaneously
-running at any time.
-
-Note that the items are not processed in batches, so there is no guarantee that
- the first "limit" iterator functions will complete before any others are
-started.
-
-__Arguments__
-
-* arr - An array to iterate over.
-* limit - The maximum number of iterators to run at any time.
-* iterator(item, callback) - A function to apply to each item in the array.
- The iterator is passed a callback(err, transformed) which must be called once
- it has completed with an error (which can be null) and a transformed item.
-* callback(err, results) - A callback which is called after all the iterator
- functions have finished, or an error has occurred. Results is an array of the
- transformed items from the original array.
-
-__Example__
-
-```js
-async.mapLimit(['file1','file2','file3'], 1, fs.stat, function(err, results){
- // results is now an array of stats for each file
-});
-```
-
----------------------------------------
-
-
-### filter(arr, iterator, callback)
-
-__Alias:__ select
-
-Returns a new array of all the values which pass an async truth test.
-_The callback for each iterator call only accepts a single argument of true or
-false, it does not accept an error argument first!_ This is in-line with the
-way node libraries work with truth tests like fs.exists. This operation is
-performed in parallel, but the results array will be in the same order as the
-original.
-
-__Arguments__
-
-* arr - An array to iterate over.
-* iterator(item, callback) - A truth test to apply to each item in the array.
- The iterator is passed a callback(truthValue) which must be called with a
- boolean argument once it has completed.
-* callback(results) - A callback which is called after all the iterator
- functions have finished.
-
-__Example__
-
-```js
-async.filter(['file1','file2','file3'], fs.exists, function(results){
- // results now equals an array of the existing files
-});
-```
-
----------------------------------------
-
-
-### filterSeries(arr, iterator, callback)
-
-__alias:__ selectSeries
-
-The same as filter only the iterator is applied to each item in the array in
-series. The next iterator is only called once the current one has completed
-processing. The results array will be in the same order as the original.
-
----------------------------------------
-
-
-### reject(arr, iterator, callback)
-
-The opposite of filter. Removes values that pass an async truth test.
-
----------------------------------------
-
-
-### rejectSeries(arr, iterator, callback)
-
-The same as reject, only the iterator is applied to each item in the array
-in series.
-
-
----------------------------------------
-
-
-### reduce(arr, memo, iterator, callback)
-
-__aliases:__ inject, foldl
-
-Reduces a list of values into a single value using an async iterator to return
-each successive step. Memo is the initial state of the reduction. This
-function only operates in series. For performance reasons, it may make sense to
-split a call to this function into a parallel map, then use the normal
-Array.prototype.reduce on the results. This function is for situations where
-each step in the reduction needs to be async, if you can get the data before
-reducing it then it's probably a good idea to do so.
-
-__Arguments__
-
-* arr - An array to iterate over.
-* memo - The initial state of the reduction.
-* iterator(memo, item, callback) - A function applied to each item in the
- array to produce the next step in the reduction. The iterator is passed a
- callback(err, reduction) which accepts an optional error as its first
- argument, and the state of the reduction as the second. If an error is
- passed to the callback, the reduction is stopped and the main callback is
- immediately called with the error.
-* callback(err, result) - A callback which is called after all the iterator
- functions have finished. Result is the reduced value.
-
-__Example__
-
-```js
-async.reduce([1,2,3], 0, function(memo, item, callback){
- // pointless async:
- process.nextTick(function(){
- callback(null, memo + item)
- });
-}, function(err, result){
- // result is now equal to the last value of memo, which is 6
-});
-```
-
----------------------------------------
-
-
-### reduceRight(arr, memo, iterator, callback)
-
-__Alias:__ foldr
-
-Same as reduce, only operates on the items in the array in reverse order.
-
-
----------------------------------------
-
-
-### detect(arr, iterator, callback)
-
-Returns the first value in a list that passes an async truth test. The
-iterator is applied in parallel, meaning the first iterator to return true will
-fire the detect callback with that result. That means the result might not be
-the first item in the original array (in terms of order) that passes the test.
-
-If order within the original array is important then look at detectSeries.
-
-__Arguments__
-
-* arr - An array to iterate over.
-* iterator(item, callback) - A truth test to apply to each item in the array.
- The iterator is passed a callback(truthValue) which must be called with a
- boolean argument once it has completed.
-* callback(result) - A callback which is called as soon as any iterator returns
- true, or after all the iterator functions have finished. Result will be
- the first item in the array that passes the truth test (iterator) or the
- value undefined if none passed.
-
-__Example__
-
-```js
-async.detect(['file1','file2','file3'], fs.exists, function(result){
- // result now equals the first file in the list that exists
-});
-```
-
----------------------------------------
-
-
-### detectSeries(arr, iterator, callback)
-
-The same as detect, only the iterator is applied to each item in the array
-in series. This means the result is always the first in the original array (in
-terms of array order) that passes the truth test.
-
-
----------------------------------------
-
-
-### sortBy(arr, iterator, callback)
-
-Sorts a list by the results of running each value through an async iterator.
-
-__Arguments__
-
-* arr - An array to iterate over.
-* iterator(item, callback) - A function to apply to each item in the array.
- The iterator is passed a callback(err, sortValue) which must be called once it
- has completed with an error (which can be null) and a value to use as the sort
- criteria.
-* callback(err, results) - A callback which is called after all the iterator
- functions have finished, or an error has occurred. Results is the items from
- the original array sorted by the values returned by the iterator calls.
-
-__Example__
-
-```js
-async.sortBy(['file1','file2','file3'], function(file, callback){
- fs.stat(file, function(err, stats){
- callback(err, stats.mtime);
- });
-}, function(err, results){
- // results is now the original array of files sorted by
- // modified date
-});
-```
-
----------------------------------------
-
-
-### some(arr, iterator, callback)
-
-__Alias:__ any
-
-Returns true if at least one element in the array satisfies an async test.
-_The callback for each iterator call only accepts a single argument of true or
-false, it does not accept an error argument first!_ This is in-line with the
-way node libraries work with truth tests like fs.exists. Once any iterator
-call returns true, the main callback is immediately called.
-
-__Arguments__
-
-* arr - An array to iterate over.
-* iterator(item, callback) - A truth test to apply to each item in the array.
- The iterator is passed a callback(truthValue) which must be called with a
- boolean argument once it has completed.
-* callback(result) - A callback which is called as soon as any iterator returns
- true, or after all the iterator functions have finished. Result will be
- either true or false depending on the values of the async tests.
-
-__Example__
-
-```js
-async.some(['file1','file2','file3'], fs.exists, function(result){
- // if result is true then at least one of the files exists
-});
-```
-
----------------------------------------
-
-
-### every(arr, iterator, callback)
-
-__Alias:__ all
-
-Returns true if every element in the array satisfies an async test.
-_The callback for each iterator call only accepts a single argument of true or
-false, it does not accept an error argument first!_ This is in-line with the
-way node libraries work with truth tests like fs.exists.
-
-__Arguments__
-
-* arr - An array to iterate over.
-* iterator(item, callback) - A truth test to apply to each item in the array.
- The iterator is passed a callback(truthValue) which must be called with a
- boolean argument once it has completed.
-* callback(result) - A callback which is called after all the iterator
- functions have finished. Result will be either true or false depending on
- the values of the async tests.
-
-__Example__
-
-```js
-async.every(['file1','file2','file3'], fs.exists, function(result){
- // if result is true then every file exists
-});
-```
-
----------------------------------------
-
-
-### concat(arr, iterator, callback)
-
-Applies an iterator to each item in a list, concatenating the results. Returns the
-concatenated list. The iterators are called in parallel, and the results are
-concatenated as they return. There is no guarantee that the results array will
-be returned in the original order of the arguments passed to the iterator function.
-
-__Arguments__
-
-* arr - An array to iterate over
-* iterator(item, callback) - A function to apply to each item in the array.
- The iterator is passed a callback(err, results) which must be called once it
- has completed with an error (which can be null) and an array of results.
-* callback(err, results) - A callback which is called after all the iterator
- functions have finished, or an error has occurred. Results is an array containing
- the concatenated results of the iterator function.
-
-__Example__
-
-```js
-async.concat(['dir1','dir2','dir3'], fs.readdir, function(err, files){
- // files is now a list of filenames that exist in the 3 directories
-});
-```
-
----------------------------------------
-
-
-### concatSeries(arr, iterator, callback)
-
-Same as async.concat, but executes in series instead of parallel.
-
-
-## Control Flow
-
-
-### series(tasks, [callback])
-
-Run an array of functions in series, each one running once the previous
-function has completed. If any functions in the series pass an error to its
-callback, no more functions are run and the callback for the series is
-immediately called with the value of the error. Once the tasks have completed,
-the results are passed to the final callback as an array.
-
-It is also possible to use an object instead of an array. Each property will be
-run as a function and the results will be passed to the final callback as an object
-instead of an array. This can be a more readable way of handling results from
-async.series.
-
-
-__Arguments__
-
-* tasks - An array or object containing functions to run, each function is passed
- a callback(err, result) it must call on completion with an error (which can
- be null) and an optional result value.
-* callback(err, results) - An optional callback to run once all the functions
- have completed. This function gets a results array (or object) containing all
- the result arguments passed to the task callbacks.
-
-__Example__
-
-```js
-async.series([
- function(callback){
- // do some stuff ...
- callback(null, 'one');
- },
- function(callback){
- // do some more stuff ...
- callback(null, 'two');
- }
-],
-// optional callback
-function(err, results){
- // results is now equal to ['one', 'two']
-});
-
-
-// an example using an object instead of an array
-async.series({
- one: function(callback){
- setTimeout(function(){
- callback(null, 1);
- }, 200);
- },
- two: function(callback){
- setTimeout(function(){
- callback(null, 2);
- }, 100);
- }
-},
-function(err, results) {
- // results is now equal to: {one: 1, two: 2}
-});
-```
-
----------------------------------------
-
-
-### parallel(tasks, [callback])
-
-Run an array of functions in parallel, without waiting until the previous
-function has completed. If any of the functions pass an error to its
-callback, the main callback is immediately called with the value of the error.
-Once the tasks have completed, the results are passed to the final callback as an
-array.
-
-It is also possible to use an object instead of an array. Each property will be
-run as a function and the results will be passed to the final callback as an object
-instead of an array. This can be a more readable way of handling results from
-async.parallel.
-
-
-__Arguments__
-
-* tasks - An array or object containing functions to run, each function is passed
- a callback(err, result) it must call on completion with an error (which can
- be null) and an optional result value.
-* callback(err, results) - An optional callback to run once all the functions
- have completed. This function gets a results array (or object) containing all
- the result arguments passed to the task callbacks.
-
-__Example__
-
-```js
-async.parallel([
- function(callback){
- setTimeout(function(){
- callback(null, 'one');
- }, 200);
- },
- function(callback){
- setTimeout(function(){
- callback(null, 'two');
- }, 100);
- }
-],
-// optional callback
-function(err, results){
- // the results array will equal ['one','two'] even though
- // the second function had a shorter timeout.
-});
-
-
-// an example using an object instead of an array
-async.parallel({
- one: function(callback){
- setTimeout(function(){
- callback(null, 1);
- }, 200);
- },
- two: function(callback){
- setTimeout(function(){
- callback(null, 2);
- }, 100);
- }
-},
-function(err, results) {
- // results is now equals to: {one: 1, two: 2}
-});
-```
-
----------------------------------------
-
-
-### parallelLimit(tasks, limit, [callback])
-
-The same as parallel only the tasks are executed in parallel with a maximum of "limit"
-tasks executing at any time.
-
-Note that the tasks are not executed in batches, so there is no guarantee that
-the first "limit" tasks will complete before any others are started.
-
-__Arguments__
-
-* tasks - An array or object containing functions to run, each function is passed
- a callback(err, result) it must call on completion with an error (which can
- be null) and an optional result value.
-* limit - The maximum number of tasks to run at any time.
-* callback(err, results) - An optional callback to run once all the functions
- have completed. This function gets a results array (or object) containing all
- the result arguments passed to the task callbacks.
-
----------------------------------------
-
-
-### whilst(test, fn, callback)
-
-Repeatedly call fn, while test returns true. Calls the callback when stopped,
-or an error occurs.
-
-__Arguments__
-
-* test() - synchronous truth test to perform before each execution of fn.
-* fn(callback) - A function to call each time the test passes. The function is
- passed a callback(err) which must be called once it has completed with an
- optional error argument.
-* callback(err) - A callback which is called after the test fails and repeated
- execution of fn has stopped.
-
-__Example__
-
-```js
-var count = 0;
-
-async.whilst(
- function () { return count < 5; },
- function (callback) {
- count++;
- setTimeout(callback, 1000);
- },
- function (err) {
- // 5 seconds have passed
- }
-);
-```
-
----------------------------------------
-
-
-### doWhilst(fn, test, callback)
-
-The post check version of whilst. To reflect the difference in the order of operations `test` and `fn` arguments are switched. `doWhilst` is to `whilst` as `do while` is to `while` in plain JavaScript.
-
----------------------------------------
-
-
-### until(test, fn, callback)
-
-Repeatedly call fn, until test returns true. Calls the callback when stopped,
-or an error occurs.
-
-The inverse of async.whilst.
-
----------------------------------------
-
-
-### doUntil(fn, test, callback)
-
-Like doWhilst except the test is inverted. Note the argument ordering differs from `until`.
-
----------------------------------------
-
-
-### forever(fn, callback)
-
-Calls the asynchronous function 'fn' repeatedly, in series, indefinitely.
-If an error is passed to fn's callback then 'callback' is called with the
-error, otherwise it will never be called.
-
----------------------------------------
-
-
-### waterfall(tasks, [callback])
-
-Runs an array of functions in series, each passing their results to the next in
-the array. However, if any of the functions pass an error to the callback, the
-next function is not executed and the main callback is immediately called with
-the error.
-
-__Arguments__
-
-* tasks - An array of functions to run, each function is passed a
- callback(err, result1, result2, ...) it must call on completion. The first
- argument is an error (which can be null) and any further arguments will be
- passed as arguments in order to the next task.
-* callback(err, [results]) - An optional callback to run once all the functions
- have completed. This will be passed the results of the last task's callback.
-
-
-
-__Example__
-
-```js
-async.waterfall([
- function(callback){
- callback(null, 'one', 'two');
- },
- function(arg1, arg2, callback){
- callback(null, 'three');
- },
- function(arg1, callback){
- // arg1 now equals 'three'
- callback(null, 'done');
- }
-], function (err, result) {
- // result now equals 'done'
-});
-```
-
----------------------------------------
-
-### compose(fn1, fn2...)
-
-Creates a function which is a composition of the passed asynchronous
-functions. Each function consumes the return value of the function that
-follows. Composing functions f(), g() and h() would produce the result of
-f(g(h())), only this version uses callbacks to obtain the return values.
-
-Each function is executed with the `this` binding of the composed function.
-
-__Arguments__
-
-* functions... - the asynchronous functions to compose
-
-
-__Example__
-
-```js
-function add1(n, callback) {
- setTimeout(function () {
- callback(null, n + 1);
- }, 10);
-}
-
-function mul3(n, callback) {
- setTimeout(function () {
- callback(null, n * 3);
- }, 10);
-}
-
-var add1mul3 = async.compose(mul3, add1);
-
-add1mul3(4, function (err, result) {
- // result now equals 15
-});
-```
-
----------------------------------------
-
-### applyEach(fns, args..., callback)
-
-Applies the provided arguments to each function in the array, calling the
-callback after all functions have completed. If you only provide the first
-argument then it will return a function which lets you pass in the
-arguments as if it were a single function call.
-
-__Arguments__
-
-* fns - the asynchronous functions to all call with the same arguments
-* args... - any number of separate arguments to pass to the function
-* callback - the final argument should be the callback, called when all
- functions have completed processing
-
-
-__Example__
-
-```js
-async.applyEach([enableSearch, updateSchema], 'bucket', callback);
-
-// partial application example:
-async.each(
- buckets,
- async.applyEach([enableSearch, updateSchema]),
- callback
-);
-```
-
----------------------------------------
-
-
-### applyEachSeries(arr, iterator, callback)
-
-The same as applyEach only the functions are applied in series.
-
----------------------------------------
-
-
-### queue(worker, concurrency)
-
-Creates a queue object with the specified concurrency. Tasks added to the
-queue will be processed in parallel (up to the concurrency limit). If all
-workers are in progress, the task is queued until one is available. Once
-a worker has completed a task, the task's callback is called.
-
-__Arguments__
-
-* worker(task, callback) - An asynchronous function for processing a queued
- task, which must call its callback(err) argument when finished, with an
- optional error as an argument.
-* concurrency - An integer for determining how many worker functions should be
- run in parallel.
-
-__Queue objects__
-
-The queue object returned by this function has the following properties and
-methods:
-
-* length() - a function returning the number of items waiting to be processed.
-* concurrency - an integer for determining how many worker functions should be
- run in parallel. This property can be changed after a queue is created to
- alter the concurrency on-the-fly.
-* push(task, [callback]) - add a new task to the queue, the callback is called
- once the worker has finished processing the task.
- instead of a single task, an array of tasks can be submitted. the respective callback is used for every task in the list.
-* unshift(task, [callback]) - add a new task to the front of the queue.
-* saturated - a callback that is called when the queue length hits the concurrency and further tasks will be queued
-* empty - a callback that is called when the last item from the queue is given to a worker
-* drain - a callback that is called when the last item from the queue has returned from the worker
-
-__Example__
-
-```js
-// create a queue object with concurrency 2
-
-var q = async.queue(function (task, callback) {
- console.log('hello ' + task.name);
- callback();
-}, 2);
-
-
-// assign a callback
-q.drain = function() {
- console.log('all items have been processed');
-}
-
-// add some items to the queue
-
-q.push({name: 'foo'}, function (err) {
- console.log('finished processing foo');
-});
-q.push({name: 'bar'}, function (err) {
- console.log('finished processing bar');
-});
-
-// add some items to the queue (batch-wise)
-
-q.push([{name: 'baz'},{name: 'bay'},{name: 'bax'}], function (err) {
- console.log('finished processing bar');
-});
-
-// add some items to the front of the queue
-
-q.unshift({name: 'bar'}, function (err) {
- console.log('finished processing bar');
-});
-```
-
----------------------------------------
-
-
-### cargo(worker, [payload])
-
-Creates a cargo object with the specified payload. Tasks added to the
-cargo will be processed altogether (up to the payload limit). If the
-worker is in progress, the task is queued until it is available. Once
-the worker has completed some tasks, each callback of those tasks is called.
-
-__Arguments__
-
-* worker(tasks, callback) - An asynchronous function for processing an array of
- queued tasks, which must call its callback(err) argument when finished, with
- an optional error as an argument.
-* payload - An optional integer for determining how many tasks should be
- processed per round; if omitted, the default is unlimited.
-
-__Cargo objects__
-
-The cargo object returned by this function has the following properties and
-methods:
-
-* length() - a function returning the number of items waiting to be processed.
-* payload - an integer for determining how many tasks should be
- process per round. This property can be changed after a cargo is created to
- alter the payload on-the-fly.
-* push(task, [callback]) - add a new task to the queue, the callback is called
- once the worker has finished processing the task.
- instead of a single task, an array of tasks can be submitted. the respective callback is used for every task in the list.
-* saturated - a callback that is called when the queue length hits the concurrency and further tasks will be queued
-* empty - a callback that is called when the last item from the queue is given to a worker
-* drain - a callback that is called when the last item from the queue has returned from the worker
-
-__Example__
-
-```js
-// create a cargo object with payload 2
-
-var cargo = async.cargo(function (tasks, callback) {
- for(var i=0; i
-### auto(tasks, [callback])
-
-Determines the best order for running functions based on their requirements.
-Each function can optionally depend on other functions being completed first,
-and each function is run as soon as its requirements are satisfied. If any of
-the functions pass an error to their callback, that function will not complete
-(so any other functions depending on it will not run) and the main callback
-will be called immediately with the error. Functions also receive an object
-containing the results of functions which have completed so far.
-
-Note, all functions are called with a results object as a second argument,
-so it is unsafe to pass functions in the tasks object which cannot handle the
-extra argument. For example, this snippet of code:
-
-```js
-async.auto({
- readData: async.apply(fs.readFile, 'data.txt', 'utf-8')
-}, callback);
-```
-
-will have the effect of calling readFile with the results object as the last
-argument, which will fail:
-
-```js
-fs.readFile('data.txt', 'utf-8', cb, {});
-```
-
-Instead, wrap the call to readFile in a function which does not forward the
-results object:
-
-```js
-async.auto({
- readData: function(cb, results){
- fs.readFile('data.txt', 'utf-8', cb);
- }
-}, callback);
-```
-
-__Arguments__
-
-* tasks - An object literal containing named functions or an array of
- requirements, with the function itself the last item in the array. The key
- used for each function or array is used when specifying requirements. The
- function receives two arguments: (1) a callback(err, result) which must be
- called when finished, passing an error (which can be null) and the result of
- the function's execution, and (2) a results object, containing the results of
- the previously executed functions.
-* callback(err, results) - An optional callback which is called when all the
- tasks have been completed. The callback will receive an error as an argument
- if any tasks pass an error to their callback. Results will always be passed
- but if an error occurred, no other tasks will be performed, and the results
- object will only contain partial results.
-
-
-__Example__
-
-```js
-async.auto({
- get_data: function(callback){
- // async code to get some data
- },
- make_folder: function(callback){
- // async code to create a directory to store a file in
- // this is run at the same time as getting the data
- },
- write_file: ['get_data', 'make_folder', function(callback){
- // once there is some data and the directory exists,
- // write the data to a file in the directory
- callback(null, filename);
- }],
- email_link: ['write_file', function(callback, results){
- // once the file is written let's email a link to it...
- // results.write_file contains the filename returned by write_file.
- }]
-});
-```
-
-This is a fairly trivial example, but to do this using the basic parallel and
-series functions would look like this:
-
-```js
-async.parallel([
- function(callback){
- // async code to get some data
- },
- function(callback){
- // async code to create a directory to store a file in
- // this is run at the same time as getting the data
- }
-],
-function(err, results){
- async.series([
- function(callback){
- // once there is some data and the directory exists,
- // write the data to a file in the directory
- },
- function(callback){
- // once the file is written let's email a link to it...
- }
- ]);
-});
-```
-
-For a complicated series of async tasks using the auto function makes adding
-new tasks much easier and makes the code more readable.
-
-
----------------------------------------
-
-
-### iterator(tasks)
-
-Creates an iterator function which calls the next function in the array,
-returning a continuation to call the next one after that. It's also possible to
-'peek' the next iterator by doing iterator.next().
-
-This function is used internally by the async module but can be useful when
-you want to manually control the flow of functions in series.
-
-__Arguments__
-
-* tasks - An array of functions to run.
-
-__Example__
-
-```js
-var iterator = async.iterator([
- function(){ sys.p('one'); },
- function(){ sys.p('two'); },
- function(){ sys.p('three'); }
-]);
-
-node> var iterator2 = iterator();
-'one'
-node> var iterator3 = iterator2();
-'two'
-node> iterator3();
-'three'
-node> var nextfn = iterator2.next();
-node> nextfn();
-'three'
-```
-
----------------------------------------
-
-
-### apply(function, arguments..)
-
-Creates a continuation function with some arguments already applied, a useful
-shorthand when combined with other control flow functions. Any arguments
-passed to the returned function are added to the arguments originally passed
-to apply.
-
-__Arguments__
-
-* function - The function you want to eventually apply all arguments to.
-* arguments... - Any number of arguments to automatically apply when the
- continuation is called.
-
-__Example__
-
-```js
-// using apply
-
-async.parallel([
- async.apply(fs.writeFile, 'testfile1', 'test1'),
- async.apply(fs.writeFile, 'testfile2', 'test2'),
-]);
-
-
-// the same process without using apply
-
-async.parallel([
- function(callback){
- fs.writeFile('testfile1', 'test1', callback);
- },
- function(callback){
- fs.writeFile('testfile2', 'test2', callback);
- }
-]);
-```
-
-It's possible to pass any number of additional arguments when calling the
-continuation:
-
-```js
-node> var fn = async.apply(sys.puts, 'one');
-node> fn('two', 'three');
-one
-two
-three
-```
-
----------------------------------------
-
-
-### nextTick(callback)
-
-Calls the callback on a later loop around the event loop. In node.js this just
-calls process.nextTick, in the browser it falls back to setImmediate(callback)
-if available, otherwise setTimeout(callback, 0), which means other higher priority
-events may precede the execution of the callback.
-
-This is used internally for browser-compatibility purposes.
-
-__Arguments__
-
-* callback - The function to call on a later loop around the event loop.
-
-__Example__
-
-```js
-var call_order = [];
-async.nextTick(function(){
- call_order.push('two');
- // call_order now equals ['one','two']
-});
-call_order.push('one')
-```
-
-
-### times(n, callback)
-
-Calls the callback n times and accumulates results in the same manner
-you would use with async.map.
-
-__Arguments__
-
-* n - The number of times to run the function.
-* callback - The function to call n times.
-
-__Example__
-
-```js
-// Pretend this is some complicated async factory
-var createUser = function(id, callback) {
- callback(null, {
- id: 'user' + id
- })
-}
-// generate 5 users
-async.times(5, function(n, next){
- createUser(n, function(err, user) {
- next(err, user)
- })
-}, function(err, users) {
- // we should now have 5 users
-});
-```
-
-
-### timesSeries(n, callback)
-
-The same as times only the iterator is applied to each item in the array in
-series. The next iterator is only called once the current one has completed
-processing. The results array will be in the same order as the original.
-
-
-## Utils
-
-
-### memoize(fn, [hasher])
-
-Caches the results of an async function. When creating a hash to store function
-results against, the callback is omitted from the hash and an optional hash
-function can be used.
-
-The cache of results is exposed as the `memo` property of the function returned
-by `memoize`.
-
-__Arguments__
-
-* fn - the function you to proxy and cache results from.
-* hasher - an optional function for generating a custom hash for storing
- results, it has all the arguments applied to it apart from the callback, and
- must be synchronous.
-
-__Example__
-
-```js
-var slow_fn = function (name, callback) {
- // do something
- callback(null, result);
-};
-var fn = async.memoize(slow_fn);
-
-// fn can now be used as if it were slow_fn
-fn('some name', function () {
- // callback
-});
-```
-
-
-### unmemoize(fn)
-
-Undoes a memoized function, reverting it to the original, unmemoized
-form. Comes handy in tests.
-
-__Arguments__
-
-* fn - the memoized function
-
-
-### log(function, arguments)
-
-Logs the result of an async function to the console. Only works in node.js or
-in browsers that support console.log and console.error (such as FF and Chrome).
-If multiple arguments are returned from the async function, console.log is
-called on each argument in order.
-
-__Arguments__
-
-* function - The function you want to eventually apply all arguments to.
-* arguments... - Any number of arguments to apply to the function.
-
-__Example__
-
-```js
-var hello = function(name, callback){
- setTimeout(function(){
- callback(null, 'hello ' + name);
- }, 1000);
-};
-```
-```js
-node> async.log(hello, 'world');
-'hello world'
-```
-
----------------------------------------
-
-
-### dir(function, arguments)
-
-Logs the result of an async function to the console using console.dir to
-display the properties of the resulting object. Only works in node.js or
-in browsers that support console.dir and console.error (such as FF and Chrome).
-If multiple arguments are returned from the async function, console.dir is
-called on each argument in order.
-
-__Arguments__
-
-* function - The function you want to eventually apply all arguments to.
-* arguments... - Any number of arguments to apply to the function.
-
-__Example__
-
-```js
-var hello = function(name, callback){
- setTimeout(function(){
- callback(null, {hello: name});
- }, 1000);
-};
-```
-```js
-node> async.dir(hello, 'world');
-{hello: 'world'}
-```
-
----------------------------------------
-
-
-### noConflict()
-
-Changes the value of async back to its original value, returning a reference to the
-async object.
diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/utile/node_modules/async/component.json b/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/utile/node_modules/async/component.json
deleted file mode 100644
index bbb0115..0000000
--- a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/utile/node_modules/async/component.json
+++ /dev/null
@@ -1,11 +0,0 @@
-{
- "name": "async",
- "repo": "caolan/async",
- "description": "Higher-order functions and common patterns for asynchronous code",
- "version": "0.1.23",
- "keywords": [],
- "dependencies": {},
- "development": {},
- "main": "lib/async.js",
- "scripts": [ "lib/async.js" ]
-}
diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/utile/node_modules/async/lib/async.js b/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/utile/node_modules/async/lib/async.js
deleted file mode 100755
index 1eebb15..0000000
--- a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/utile/node_modules/async/lib/async.js
+++ /dev/null
@@ -1,958 +0,0 @@
-/*global setImmediate: false, setTimeout: false, console: false */
-(function () {
-
- var async = {};
-
- // global on the server, window in the browser
- var root, previous_async;
-
- root = this;
- if (root != null) {
- previous_async = root.async;
- }
-
- async.noConflict = function () {
- root.async = previous_async;
- return async;
- };
-
- function only_once(fn) {
- var called = false;
- return function() {
- if (called) throw new Error("Callback was already called.");
- called = true;
- fn.apply(root, arguments);
- }
- }
-
- //// cross-browser compatiblity functions ////
-
- var _each = function (arr, iterator) {
- if (arr.forEach) {
- return arr.forEach(iterator);
- }
- for (var i = 0; i < arr.length; i += 1) {
- iterator(arr[i], i, arr);
- }
- };
-
- var _map = function (arr, iterator) {
- if (arr.map) {
- return arr.map(iterator);
- }
- var results = [];
- _each(arr, function (x, i, a) {
- results.push(iterator(x, i, a));
- });
- return results;
- };
-
- var _reduce = function (arr, iterator, memo) {
- if (arr.reduce) {
- return arr.reduce(iterator, memo);
- }
- _each(arr, function (x, i, a) {
- memo = iterator(memo, x, i, a);
- });
- return memo;
- };
-
- var _keys = function (obj) {
- if (Object.keys) {
- return Object.keys(obj);
- }
- var keys = [];
- for (var k in obj) {
- if (obj.hasOwnProperty(k)) {
- keys.push(k);
- }
- }
- return keys;
- };
-
- //// exported async module functions ////
-
- //// nextTick implementation with browser-compatible fallback ////
- if (typeof process === 'undefined' || !(process.nextTick)) {
- if (typeof setImmediate === 'function') {
- async.nextTick = function (fn) {
- // not a direct alias for IE10 compatibility
- setImmediate(fn);
- };
- async.setImmediate = async.nextTick;
- }
- else {
- async.nextTick = function (fn) {
- setTimeout(fn, 0);
- };
- async.setImmediate = async.nextTick;
- }
- }
- else {
- async.nextTick = process.nextTick;
- if (typeof setImmediate !== 'undefined') {
- async.setImmediate = function (fn) {
- // not a direct alias for IE10 compatibility
- setImmediate(fn);
- };
- }
- else {
- async.setImmediate = async.nextTick;
- }
- }
-
- async.each = function (arr, iterator, callback) {
- callback = callback || function () {};
- if (!arr.length) {
- return callback();
- }
- var completed = 0;
- _each(arr, function (x) {
- iterator(x, only_once(function (err) {
- if (err) {
- callback(err);
- callback = function () {};
- }
- else {
- completed += 1;
- if (completed >= arr.length) {
- callback(null);
- }
- }
- }));
- });
- };
- async.forEach = async.each;
-
- async.eachSeries = function (arr, iterator, callback) {
- callback = callback || function () {};
- if (!arr.length) {
- return callback();
- }
- var completed = 0;
- var iterate = function () {
- iterator(arr[completed], function (err) {
- if (err) {
- callback(err);
- callback = function () {};
- }
- else {
- completed += 1;
- if (completed >= arr.length) {
- callback(null);
- }
- else {
- iterate();
- }
- }
- });
- };
- iterate();
- };
- async.forEachSeries = async.eachSeries;
-
- async.eachLimit = function (arr, limit, iterator, callback) {
- var fn = _eachLimit(limit);
- fn.apply(null, [arr, iterator, callback]);
- };
- async.forEachLimit = async.eachLimit;
-
- var _eachLimit = function (limit) {
-
- return function (arr, iterator, callback) {
- callback = callback || function () {};
- if (!arr.length || limit <= 0) {
- return callback();
- }
- var completed = 0;
- var started = 0;
- var running = 0;
-
- (function replenish () {
- if (completed >= arr.length) {
- return callback();
- }
-
- while (running < limit && started < arr.length) {
- started += 1;
- running += 1;
- iterator(arr[started - 1], function (err) {
- if (err) {
- callback(err);
- callback = function () {};
- }
- else {
- completed += 1;
- running -= 1;
- if (completed >= arr.length) {
- callback();
- }
- else {
- replenish();
- }
- }
- });
- }
- })();
- };
- };
-
-
- var doParallel = function (fn) {
- return function () {
- var args = Array.prototype.slice.call(arguments);
- return fn.apply(null, [async.each].concat(args));
- };
- };
- var doParallelLimit = function(limit, fn) {
- return function () {
- var args = Array.prototype.slice.call(arguments);
- return fn.apply(null, [_eachLimit(limit)].concat(args));
- };
- };
- var doSeries = function (fn) {
- return function () {
- var args = Array.prototype.slice.call(arguments);
- return fn.apply(null, [async.eachSeries].concat(args));
- };
- };
-
-
- var _asyncMap = function (eachfn, arr, iterator, callback) {
- var results = [];
- arr = _map(arr, function (x, i) {
- return {index: i, value: x};
- });
- eachfn(arr, function (x, callback) {
- iterator(x.value, function (err, v) {
- results[x.index] = v;
- callback(err);
- });
- }, function (err) {
- callback(err, results);
- });
- };
- async.map = doParallel(_asyncMap);
- async.mapSeries = doSeries(_asyncMap);
- async.mapLimit = function (arr, limit, iterator, callback) {
- return _mapLimit(limit)(arr, iterator, callback);
- };
-
- var _mapLimit = function(limit) {
- return doParallelLimit(limit, _asyncMap);
- };
-
- // reduce only has a series version, as doing reduce in parallel won't
- // work in many situations.
- async.reduce = function (arr, memo, iterator, callback) {
- async.eachSeries(arr, function (x, callback) {
- iterator(memo, x, function (err, v) {
- memo = v;
- callback(err);
- });
- }, function (err) {
- callback(err, memo);
- });
- };
- // inject alias
- async.inject = async.reduce;
- // foldl alias
- async.foldl = async.reduce;
-
- async.reduceRight = function (arr, memo, iterator, callback) {
- var reversed = _map(arr, function (x) {
- return x;
- }).reverse();
- async.reduce(reversed, memo, iterator, callback);
- };
- // foldr alias
- async.foldr = async.reduceRight;
-
- var _filter = function (eachfn, arr, iterator, callback) {
- var results = [];
- arr = _map(arr, function (x, i) {
- return {index: i, value: x};
- });
- eachfn(arr, function (x, callback) {
- iterator(x.value, function (v) {
- if (v) {
- results.push(x);
- }
- callback();
- });
- }, function (err) {
- callback(_map(results.sort(function (a, b) {
- return a.index - b.index;
- }), function (x) {
- return x.value;
- }));
- });
- };
- async.filter = doParallel(_filter);
- async.filterSeries = doSeries(_filter);
- // select alias
- async.select = async.filter;
- async.selectSeries = async.filterSeries;
-
- var _reject = function (eachfn, arr, iterator, callback) {
- var results = [];
- arr = _map(arr, function (x, i) {
- return {index: i, value: x};
- });
- eachfn(arr, function (x, callback) {
- iterator(x.value, function (v) {
- if (!v) {
- results.push(x);
- }
- callback();
- });
- }, function (err) {
- callback(_map(results.sort(function (a, b) {
- return a.index - b.index;
- }), function (x) {
- return x.value;
- }));
- });
- };
- async.reject = doParallel(_reject);
- async.rejectSeries = doSeries(_reject);
-
- var _detect = function (eachfn, arr, iterator, main_callback) {
- eachfn(arr, function (x, callback) {
- iterator(x, function (result) {
- if (result) {
- main_callback(x);
- main_callback = function () {};
- }
- else {
- callback();
- }
- });
- }, function (err) {
- main_callback();
- });
- };
- async.detect = doParallel(_detect);
- async.detectSeries = doSeries(_detect);
-
- async.some = function (arr, iterator, main_callback) {
- async.each(arr, function (x, callback) {
- iterator(x, function (v) {
- if (v) {
- main_callback(true);
- main_callback = function () {};
- }
- callback();
- });
- }, function (err) {
- main_callback(false);
- });
- };
- // any alias
- async.any = async.some;
-
- async.every = function (arr, iterator, main_callback) {
- async.each(arr, function (x, callback) {
- iterator(x, function (v) {
- if (!v) {
- main_callback(false);
- main_callback = function () {};
- }
- callback();
- });
- }, function (err) {
- main_callback(true);
- });
- };
- // all alias
- async.all = async.every;
-
- async.sortBy = function (arr, iterator, callback) {
- async.map(arr, function (x, callback) {
- iterator(x, function (err, criteria) {
- if (err) {
- callback(err);
- }
- else {
- callback(null, {value: x, criteria: criteria});
- }
- });
- }, function (err, results) {
- if (err) {
- return callback(err);
- }
- else {
- var fn = function (left, right) {
- var a = left.criteria, b = right.criteria;
- return a < b ? -1 : a > b ? 1 : 0;
- };
- callback(null, _map(results.sort(fn), function (x) {
- return x.value;
- }));
- }
- });
- };
-
- async.auto = function (tasks, callback) {
- callback = callback || function () {};
- var keys = _keys(tasks);
- if (!keys.length) {
- return callback(null);
- }
-
- var results = {};
-
- var listeners = [];
- var addListener = function (fn) {
- listeners.unshift(fn);
- };
- var removeListener = function (fn) {
- for (var i = 0; i < listeners.length; i += 1) {
- if (listeners[i] === fn) {
- listeners.splice(i, 1);
- return;
- }
- }
- };
- var taskComplete = function () {
- _each(listeners.slice(0), function (fn) {
- fn();
- });
- };
-
- addListener(function () {
- if (_keys(results).length === keys.length) {
- callback(null, results);
- callback = function () {};
- }
- });
-
- _each(keys, function (k) {
- var task = (tasks[k] instanceof Function) ? [tasks[k]]: tasks[k];
- var taskCallback = function (err) {
- var args = Array.prototype.slice.call(arguments, 1);
- if (args.length <= 1) {
- args = args[0];
- }
- if (err) {
- var safeResults = {};
- _each(_keys(results), function(rkey) {
- safeResults[rkey] = results[rkey];
- });
- safeResults[k] = args;
- callback(err, safeResults);
- // stop subsequent errors hitting callback multiple times
- callback = function () {};
- }
- else {
- results[k] = args;
- async.setImmediate(taskComplete);
- }
- };
- var requires = task.slice(0, Math.abs(task.length - 1)) || [];
- var ready = function () {
- return _reduce(requires, function (a, x) {
- return (a && results.hasOwnProperty(x));
- }, true) && !results.hasOwnProperty(k);
- };
- if (ready()) {
- task[task.length - 1](taskCallback, results);
- }
- else {
- var listener = function () {
- if (ready()) {
- removeListener(listener);
- task[task.length - 1](taskCallback, results);
- }
- };
- addListener(listener);
- }
- });
- };
-
- async.waterfall = function (tasks, callback) {
- callback = callback || function () {};
- if (tasks.constructor !== Array) {
- var err = new Error('First argument to waterfall must be an array of functions');
- return callback(err);
- }
- if (!tasks.length) {
- return callback();
- }
- var wrapIterator = function (iterator) {
- return function (err) {
- if (err) {
- callback.apply(null, arguments);
- callback = function () {};
- }
- else {
- var args = Array.prototype.slice.call(arguments, 1);
- var next = iterator.next();
- if (next) {
- args.push(wrapIterator(next));
- }
- else {
- args.push(callback);
- }
- async.setImmediate(function () {
- iterator.apply(null, args);
- });
- }
- };
- };
- wrapIterator(async.iterator(tasks))();
- };
-
- var _parallel = function(eachfn, tasks, callback) {
- callback = callback || function () {};
- if (tasks.constructor === Array) {
- eachfn.map(tasks, function (fn, callback) {
- if (fn) {
- fn(function (err) {
- var args = Array.prototype.slice.call(arguments, 1);
- if (args.length <= 1) {
- args = args[0];
- }
- callback.call(null, err, args);
- });
- }
- }, callback);
- }
- else {
- var results = {};
- eachfn.each(_keys(tasks), function (k, callback) {
- tasks[k](function (err) {
- var args = Array.prototype.slice.call(arguments, 1);
- if (args.length <= 1) {
- args = args[0];
- }
- results[k] = args;
- callback(err);
- });
- }, function (err) {
- callback(err, results);
- });
- }
- };
-
- async.parallel = function (tasks, callback) {
- _parallel({ map: async.map, each: async.each }, tasks, callback);
- };
-
- async.parallelLimit = function(tasks, limit, callback) {
- _parallel({ map: _mapLimit(limit), each: _eachLimit(limit) }, tasks, callback);
- };
-
- async.series = function (tasks, callback) {
- callback = callback || function () {};
- if (tasks.constructor === Array) {
- async.mapSeries(tasks, function (fn, callback) {
- if (fn) {
- fn(function (err) {
- var args = Array.prototype.slice.call(arguments, 1);
- if (args.length <= 1) {
- args = args[0];
- }
- callback.call(null, err, args);
- });
- }
- }, callback);
- }
- else {
- var results = {};
- async.eachSeries(_keys(tasks), function (k, callback) {
- tasks[k](function (err) {
- var args = Array.prototype.slice.call(arguments, 1);
- if (args.length <= 1) {
- args = args[0];
- }
- results[k] = args;
- callback(err);
- });
- }, function (err) {
- callback(err, results);
- });
- }
- };
-
- async.iterator = function (tasks) {
- var makeCallback = function (index) {
- var fn = function () {
- if (tasks.length) {
- tasks[index].apply(null, arguments);
- }
- return fn.next();
- };
- fn.next = function () {
- return (index < tasks.length - 1) ? makeCallback(index + 1): null;
- };
- return fn;
- };
- return makeCallback(0);
- };
-
- async.apply = function (fn) {
- var args = Array.prototype.slice.call(arguments, 1);
- return function () {
- return fn.apply(
- null, args.concat(Array.prototype.slice.call(arguments))
- );
- };
- };
-
- var _concat = function (eachfn, arr, fn, callback) {
- var r = [];
- eachfn(arr, function (x, cb) {
- fn(x, function (err, y) {
- r = r.concat(y || []);
- cb(err);
- });
- }, function (err) {
- callback(err, r);
- });
- };
- async.concat = doParallel(_concat);
- async.concatSeries = doSeries(_concat);
-
- async.whilst = function (test, iterator, callback) {
- if (test()) {
- iterator(function (err) {
- if (err) {
- return callback(err);
- }
- async.whilst(test, iterator, callback);
- });
- }
- else {
- callback();
- }
- };
-
- async.doWhilst = function (iterator, test, callback) {
- iterator(function (err) {
- if (err) {
- return callback(err);
- }
- if (test()) {
- async.doWhilst(iterator, test, callback);
- }
- else {
- callback();
- }
- });
- };
-
- async.until = function (test, iterator, callback) {
- if (!test()) {
- iterator(function (err) {
- if (err) {
- return callback(err);
- }
- async.until(test, iterator, callback);
- });
- }
- else {
- callback();
- }
- };
-
- async.doUntil = function (iterator, test, callback) {
- iterator(function (err) {
- if (err) {
- return callback(err);
- }
- if (!test()) {
- async.doUntil(iterator, test, callback);
- }
- else {
- callback();
- }
- });
- };
-
- async.queue = function (worker, concurrency) {
- if (concurrency === undefined) {
- concurrency = 1;
- }
- function _insert(q, data, pos, callback) {
- if(data.constructor !== Array) {
- data = [data];
- }
- _each(data, function(task) {
- var item = {
- data: task,
- callback: typeof callback === 'function' ? callback : null
- };
-
- if (pos) {
- q.tasks.unshift(item);
- } else {
- q.tasks.push(item);
- }
-
- if (q.saturated && q.tasks.length === concurrency) {
- q.saturated();
- }
- async.setImmediate(q.process);
- });
- }
-
- var workers = 0;
- var q = {
- tasks: [],
- concurrency: concurrency,
- saturated: null,
- empty: null,
- drain: null,
- push: function (data, callback) {
- _insert(q, data, false, callback);
- },
- unshift: function (data, callback) {
- _insert(q, data, true, callback);
- },
- process: function () {
- if (workers < q.concurrency && q.tasks.length) {
- var task = q.tasks.shift();
- if (q.empty && q.tasks.length === 0) {
- q.empty();
- }
- workers += 1;
- var next = function () {
- workers -= 1;
- if (task.callback) {
- task.callback.apply(task, arguments);
- }
- if (q.drain && q.tasks.length + workers === 0) {
- q.drain();
- }
- q.process();
- };
- var cb = only_once(next);
- worker(task.data, cb);
- }
- },
- length: function () {
- return q.tasks.length;
- },
- running: function () {
- return workers;
- }
- };
- return q;
- };
-
- async.cargo = function (worker, payload) {
- var working = false,
- tasks = [];
-
- var cargo = {
- tasks: tasks,
- payload: payload,
- saturated: null,
- empty: null,
- drain: null,
- push: function (data, callback) {
- if(data.constructor !== Array) {
- data = [data];
- }
- _each(data, function(task) {
- tasks.push({
- data: task,
- callback: typeof callback === 'function' ? callback : null
- });
- if (cargo.saturated && tasks.length === payload) {
- cargo.saturated();
- }
- });
- async.setImmediate(cargo.process);
- },
- process: function process() {
- if (working) return;
- if (tasks.length === 0) {
- if(cargo.drain) cargo.drain();
- return;
- }
-
- var ts = typeof payload === 'number'
- ? tasks.splice(0, payload)
- : tasks.splice(0);
-
- var ds = _map(ts, function (task) {
- return task.data;
- });
-
- if(cargo.empty) cargo.empty();
- working = true;
- worker(ds, function () {
- working = false;
-
- var args = arguments;
- _each(ts, function (data) {
- if (data.callback) {
- data.callback.apply(null, args);
- }
- });
-
- process();
- });
- },
- length: function () {
- return tasks.length;
- },
- running: function () {
- return working;
- }
- };
- return cargo;
- };
-
- var _console_fn = function (name) {
- return function (fn) {
- var args = Array.prototype.slice.call(arguments, 1);
- fn.apply(null, args.concat([function (err) {
- var args = Array.prototype.slice.call(arguments, 1);
- if (typeof console !== 'undefined') {
- if (err) {
- if (console.error) {
- console.error(err);
- }
- }
- else if (console[name]) {
- _each(args, function (x) {
- console[name](x);
- });
- }
- }
- }]));
- };
- };
- async.log = _console_fn('log');
- async.dir = _console_fn('dir');
- /*async.info = _console_fn('info');
- async.warn = _console_fn('warn');
- async.error = _console_fn('error');*/
-
- async.memoize = function (fn, hasher) {
- var memo = {};
- var queues = {};
- hasher = hasher || function (x) {
- return x;
- };
- var memoized = function () {
- var args = Array.prototype.slice.call(arguments);
- var callback = args.pop();
- var key = hasher.apply(null, args);
- if (key in memo) {
- callback.apply(null, memo[key]);
- }
- else if (key in queues) {
- queues[key].push(callback);
- }
- else {
- queues[key] = [callback];
- fn.apply(null, args.concat([function () {
- memo[key] = arguments;
- var q = queues[key];
- delete queues[key];
- for (var i = 0, l = q.length; i < l; i++) {
- q[i].apply(null, arguments);
- }
- }]));
- }
- };
- memoized.memo = memo;
- memoized.unmemoized = fn;
- return memoized;
- };
-
- async.unmemoize = function (fn) {
- return function () {
- return (fn.unmemoized || fn).apply(null, arguments);
- };
- };
-
- async.times = function (count, iterator, callback) {
- var counter = [];
- for (var i = 0; i < count; i++) {
- counter.push(i);
- }
- return async.map(counter, iterator, callback);
- };
-
- async.timesSeries = function (count, iterator, callback) {
- var counter = [];
- for (var i = 0; i < count; i++) {
- counter.push(i);
- }
- return async.mapSeries(counter, iterator, callback);
- };
-
- async.compose = function (/* functions... */) {
- var fns = Array.prototype.reverse.call(arguments);
- return function () {
- var that = this;
- var args = Array.prototype.slice.call(arguments);
- var callback = args.pop();
- async.reduce(fns, args, function (newargs, fn, cb) {
- fn.apply(that, newargs.concat([function () {
- var err = arguments[0];
- var nextargs = Array.prototype.slice.call(arguments, 1);
- cb(err, nextargs);
- }]))
- },
- function (err, results) {
- callback.apply(that, [err].concat(results));
- });
- };
- };
-
- var _applyEach = function (eachfn, fns /*args...*/) {
- var go = function () {
- var that = this;
- var args = Array.prototype.slice.call(arguments);
- var callback = args.pop();
- return eachfn(fns, function (fn, cb) {
- fn.apply(that, args.concat([cb]));
- },
- callback);
- };
- if (arguments.length > 2) {
- var args = Array.prototype.slice.call(arguments, 2);
- return go.apply(this, args);
- }
- else {
- return go;
- }
- };
- async.applyEach = doParallel(_applyEach);
- async.applyEachSeries = doSeries(_applyEach);
-
- async.forever = function (fn, callback) {
- function next(err) {
- if (err) {
- if (callback) {
- return callback(err);
- }
- throw err;
- }
- fn(next);
- }
- next();
- };
-
- // AMD / RequireJS
- if (typeof define !== 'undefined' && define.amd) {
- define([], function () {
- return async;
- });
- }
- // Node.js
- else if (typeof module !== 'undefined' && module.exports) {
- module.exports = async;
- }
- // included directly via
-
-```
-
-## Documentation
-
-### Collections
-
-* [each](#each)
-* [eachSeries](#eachSeries)
-* [eachLimit](#eachLimit)
-* [map](#map)
-* [mapSeries](#mapSeries)
-* [mapLimit](#mapLimit)
-* [filter](#filter)
-* [filterSeries](#filterSeries)
-* [reject](#reject)
-* [rejectSeries](#rejectSeries)
-* [reduce](#reduce)
-* [reduceRight](#reduceRight)
-* [detect](#detect)
-* [detectSeries](#detectSeries)
-* [sortBy](#sortBy)
-* [some](#some)
-* [every](#every)
-* [concat](#concat)
-* [concatSeries](#concatSeries)
-
-### Control Flow
-
-* [series](#series)
-* [parallel](#parallel)
-* [parallelLimit](#parallellimittasks-limit-callback)
-* [whilst](#whilst)
-* [doWhilst](#doWhilst)
-* [until](#until)
-* [doUntil](#doUntil)
-* [forever](#forever)
-* [waterfall](#waterfall)
-* [compose](#compose)
-* [applyEach](#applyEach)
-* [applyEachSeries](#applyEachSeries)
-* [queue](#queue)
-* [cargo](#cargo)
-* [auto](#auto)
-* [iterator](#iterator)
-* [apply](#apply)
-* [nextTick](#nextTick)
-* [times](#times)
-* [timesSeries](#timesSeries)
-
-### Utils
-
-* [memoize](#memoize)
-* [unmemoize](#unmemoize)
-* [log](#log)
-* [dir](#dir)
-* [noConflict](#noConflict)
-
-
-## Collections
-
-
-
-### each(arr, iterator, callback)
-
-Applies an iterator function to each item in an array, in parallel.
-The iterator is called with an item from the list and a callback for when it
-has finished. If the iterator passes an error to this callback, the main
-callback for the each function is immediately called with the error.
-
-Note, that since this function applies the iterator to each item in parallel
-there is no guarantee that the iterator functions will complete in order.
-
-__Arguments__
-
-* arr - An array to iterate over.
-* iterator(item, callback) - A function to apply to each item in the array.
- The iterator is passed a callback(err) which must be called once it has
- completed. If no error has occured, the callback should be run without
- arguments or with an explicit null argument.
-* callback(err) - A callback which is called after all the iterator functions
- have finished, or an error has occurred.
-
-__Example__
-
-```js
-// assuming openFiles is an array of file names and saveFile is a function
-// to save the modified contents of that file:
-
-async.each(openFiles, saveFile, function(err){
- // if any of the saves produced an error, err would equal that error
-});
-```
-
----------------------------------------
-
-
-
-### eachSeries(arr, iterator, callback)
-
-The same as each only the iterator is applied to each item in the array in
-series. The next iterator is only called once the current one has completed
-processing. This means the iterator functions will complete in order.
-
-
----------------------------------------
-
-
-
-### eachLimit(arr, limit, iterator, callback)
-
-The same as each only no more than "limit" iterators will be simultaneously
-running at any time.
-
-Note that the items are not processed in batches, so there is no guarantee that
- the first "limit" iterator functions will complete before any others are
-started.
-
-__Arguments__
-
-* arr - An array to iterate over.
-* limit - The maximum number of iterators to run at any time.
-* iterator(item, callback) - A function to apply to each item in the array.
- The iterator is passed a callback(err) which must be called once it has
- completed. If no error has occured, the callback should be run without
- arguments or with an explicit null argument.
-* callback(err) - A callback which is called after all the iterator functions
- have finished, or an error has occurred.
-
-__Example__
-
-```js
-// Assume documents is an array of JSON objects and requestApi is a
-// function that interacts with a rate-limited REST api.
-
-async.eachLimit(documents, 20, requestApi, function(err){
- // if any of the saves produced an error, err would equal that error
-});
-```
-
----------------------------------------
-
-
-### map(arr, iterator, callback)
-
-Produces a new array of values by mapping each value in the given array through
-the iterator function. The iterator is called with an item from the array and a
-callback for when it has finished processing. The callback takes 2 arguments,
-an error and the transformed item from the array. If the iterator passes an
-error to this callback, the main callback for the map function is immediately
-called with the error.
-
-Note, that since this function applies the iterator to each item in parallel
-there is no guarantee that the iterator functions will complete in order, however
-the results array will be in the same order as the original array.
-
-__Arguments__
-
-* arr - An array to iterate over.
-* iterator(item, callback) - A function to apply to each item in the array.
- The iterator is passed a callback(err, transformed) which must be called once
- it has completed with an error (which can be null) and a transformed item.
-* callback(err, results) - A callback which is called after all the iterator
- functions have finished, or an error has occurred. Results is an array of the
- transformed items from the original array.
-
-__Example__
-
-```js
-async.map(['file1','file2','file3'], fs.stat, function(err, results){
- // results is now an array of stats for each file
-});
-```
-
----------------------------------------
-
-
-### mapSeries(arr, iterator, callback)
-
-The same as map only the iterator is applied to each item in the array in
-series. The next iterator is only called once the current one has completed
-processing. The results array will be in the same order as the original.
-
-
----------------------------------------
-
-
-### mapLimit(arr, limit, iterator, callback)
-
-The same as map only no more than "limit" iterators will be simultaneously
-running at any time.
-
-Note that the items are not processed in batches, so there is no guarantee that
- the first "limit" iterator functions will complete before any others are
-started.
-
-__Arguments__
-
-* arr - An array to iterate over.
-* limit - The maximum number of iterators to run at any time.
-* iterator(item, callback) - A function to apply to each item in the array.
- The iterator is passed a callback(err, transformed) which must be called once
- it has completed with an error (which can be null) and a transformed item.
-* callback(err, results) - A callback which is called after all the iterator
- functions have finished, or an error has occurred. Results is an array of the
- transformed items from the original array.
-
-__Example__
-
-```js
-async.mapLimit(['file1','file2','file3'], 1, fs.stat, function(err, results){
- // results is now an array of stats for each file
-});
-```
-
----------------------------------------
-
-
-### filter(arr, iterator, callback)
-
-__Alias:__ select
-
-Returns a new array of all the values which pass an async truth test.
-_The callback for each iterator call only accepts a single argument of true or
-false, it does not accept an error argument first!_ This is in-line with the
-way node libraries work with truth tests like fs.exists. This operation is
-performed in parallel, but the results array will be in the same order as the
-original.
-
-__Arguments__
-
-* arr - An array to iterate over.
-* iterator(item, callback) - A truth test to apply to each item in the array.
- The iterator is passed a callback(truthValue) which must be called with a
- boolean argument once it has completed.
-* callback(results) - A callback which is called after all the iterator
- functions have finished.
-
-__Example__
-
-```js
-async.filter(['file1','file2','file3'], fs.exists, function(results){
- // results now equals an array of the existing files
-});
-```
-
----------------------------------------
-
-
-### filterSeries(arr, iterator, callback)
-
-__alias:__ selectSeries
-
-The same as filter only the iterator is applied to each item in the array in
-series. The next iterator is only called once the current one has completed
-processing. The results array will be in the same order as the original.
-
----------------------------------------
-
-
-### reject(arr, iterator, callback)
-
-The opposite of filter. Removes values that pass an async truth test.
-
----------------------------------------
-
-
-### rejectSeries(arr, iterator, callback)
-
-The same as reject, only the iterator is applied to each item in the array
-in series.
-
-
----------------------------------------
-
-
-### reduce(arr, memo, iterator, callback)
-
-__aliases:__ inject, foldl
-
-Reduces a list of values into a single value using an async iterator to return
-each successive step. Memo is the initial state of the reduction. This
-function only operates in series. For performance reasons, it may make sense to
-split a call to this function into a parallel map, then use the normal
-Array.prototype.reduce on the results. This function is for situations where
-each step in the reduction needs to be async, if you can get the data before
-reducing it then it's probably a good idea to do so.
-
-__Arguments__
-
-* arr - An array to iterate over.
-* memo - The initial state of the reduction.
-* iterator(memo, item, callback) - A function applied to each item in the
- array to produce the next step in the reduction. The iterator is passed a
- callback(err, reduction) which accepts an optional error as its first
- argument, and the state of the reduction as the second. If an error is
- passed to the callback, the reduction is stopped and the main callback is
- immediately called with the error.
-* callback(err, result) - A callback which is called after all the iterator
- functions have finished. Result is the reduced value.
-
-__Example__
-
-```js
-async.reduce([1,2,3], 0, function(memo, item, callback){
- // pointless async:
- process.nextTick(function(){
- callback(null, memo + item)
- });
-}, function(err, result){
- // result is now equal to the last value of memo, which is 6
-});
-```
-
----------------------------------------
-
-
-### reduceRight(arr, memo, iterator, callback)
-
-__Alias:__ foldr
-
-Same as reduce, only operates on the items in the array in reverse order.
-
-
----------------------------------------
-
-
-### detect(arr, iterator, callback)
-
-Returns the first value in a list that passes an async truth test. The
-iterator is applied in parallel, meaning the first iterator to return true will
-fire the detect callback with that result. That means the result might not be
-the first item in the original array (in terms of order) that passes the test.
-
-If order within the original array is important then look at detectSeries.
-
-__Arguments__
-
-* arr - An array to iterate over.
-* iterator(item, callback) - A truth test to apply to each item in the array.
- The iterator is passed a callback(truthValue) which must be called with a
- boolean argument once it has completed.
-* callback(result) - A callback which is called as soon as any iterator returns
- true, or after all the iterator functions have finished. Result will be
- the first item in the array that passes the truth test (iterator) or the
- value undefined if none passed.
-
-__Example__
-
-```js
-async.detect(['file1','file2','file3'], fs.exists, function(result){
- // result now equals the first file in the list that exists
-});
-```
-
----------------------------------------
-
-
-### detectSeries(arr, iterator, callback)
-
-The same as detect, only the iterator is applied to each item in the array
-in series. This means the result is always the first in the original array (in
-terms of array order) that passes the truth test.
-
-
----------------------------------------
-
-
-### sortBy(arr, iterator, callback)
-
-Sorts a list by the results of running each value through an async iterator.
-
-__Arguments__
-
-* arr - An array to iterate over.
-* iterator(item, callback) - A function to apply to each item in the array.
- The iterator is passed a callback(err, sortValue) which must be called once it
- has completed with an error (which can be null) and a value to use as the sort
- criteria.
-* callback(err, results) - A callback which is called after all the iterator
- functions have finished, or an error has occurred. Results is the items from
- the original array sorted by the values returned by the iterator calls.
-
-__Example__
-
-```js
-async.sortBy(['file1','file2','file3'], function(file, callback){
- fs.stat(file, function(err, stats){
- callback(err, stats.mtime);
- });
-}, function(err, results){
- // results is now the original array of files sorted by
- // modified date
-});
-```
-
----------------------------------------
-
-
-### some(arr, iterator, callback)
-
-__Alias:__ any
-
-Returns true if at least one element in the array satisfies an async test.
-_The callback for each iterator call only accepts a single argument of true or
-false, it does not accept an error argument first!_ This is in-line with the
-way node libraries work with truth tests like fs.exists. Once any iterator
-call returns true, the main callback is immediately called.
-
-__Arguments__
-
-* arr - An array to iterate over.
-* iterator(item, callback) - A truth test to apply to each item in the array.
- The iterator is passed a callback(truthValue) which must be called with a
- boolean argument once it has completed.
-* callback(result) - A callback which is called as soon as any iterator returns
- true, or after all the iterator functions have finished. Result will be
- either true or false depending on the values of the async tests.
-
-__Example__
-
-```js
-async.some(['file1','file2','file3'], fs.exists, function(result){
- // if result is true then at least one of the files exists
-});
-```
-
----------------------------------------
-
-
-### every(arr, iterator, callback)
-
-__Alias:__ all
-
-Returns true if every element in the array satisfies an async test.
-_The callback for each iterator call only accepts a single argument of true or
-false, it does not accept an error argument first!_ This is in-line with the
-way node libraries work with truth tests like fs.exists.
-
-__Arguments__
-
-* arr - An array to iterate over.
-* iterator(item, callback) - A truth test to apply to each item in the array.
- The iterator is passed a callback(truthValue) which must be called with a
- boolean argument once it has completed.
-* callback(result) - A callback which is called after all the iterator
- functions have finished. Result will be either true or false depending on
- the values of the async tests.
-
-__Example__
-
-```js
-async.every(['file1','file2','file3'], fs.exists, function(result){
- // if result is true then every file exists
-});
-```
-
----------------------------------------
-
-
-### concat(arr, iterator, callback)
-
-Applies an iterator to each item in a list, concatenating the results. Returns the
-concatenated list. The iterators are called in parallel, and the results are
-concatenated as they return. There is no guarantee that the results array will
-be returned in the original order of the arguments passed to the iterator function.
-
-__Arguments__
-
-* arr - An array to iterate over
-* iterator(item, callback) - A function to apply to each item in the array.
- The iterator is passed a callback(err, results) which must be called once it
- has completed with an error (which can be null) and an array of results.
-* callback(err, results) - A callback which is called after all the iterator
- functions have finished, or an error has occurred. Results is an array containing
- the concatenated results of the iterator function.
-
-__Example__
-
-```js
-async.concat(['dir1','dir2','dir3'], fs.readdir, function(err, files){
- // files is now a list of filenames that exist in the 3 directories
-});
-```
-
----------------------------------------
-
-
-### concatSeries(arr, iterator, callback)
-
-Same as async.concat, but executes in series instead of parallel.
-
-
-## Control Flow
-
-
-### series(tasks, [callback])
-
-Run an array of functions in series, each one running once the previous
-function has completed. If any functions in the series pass an error to its
-callback, no more functions are run and the callback for the series is
-immediately called with the value of the error. Once the tasks have completed,
-the results are passed to the final callback as an array.
-
-It is also possible to use an object instead of an array. Each property will be
-run as a function and the results will be passed to the final callback as an object
-instead of an array. This can be a more readable way of handling results from
-async.series.
-
-
-__Arguments__
-
-* tasks - An array or object containing functions to run, each function is passed
- a callback(err, result) it must call on completion with an error (which can
- be null) and an optional result value.
-* callback(err, results) - An optional callback to run once all the functions
- have completed. This function gets a results array (or object) containing all
- the result arguments passed to the task callbacks.
-
-__Example__
-
-```js
-async.series([
- function(callback){
- // do some stuff ...
- callback(null, 'one');
- },
- function(callback){
- // do some more stuff ...
- callback(null, 'two');
- }
-],
-// optional callback
-function(err, results){
- // results is now equal to ['one', 'two']
-});
-
-
-// an example using an object instead of an array
-async.series({
- one: function(callback){
- setTimeout(function(){
- callback(null, 1);
- }, 200);
- },
- two: function(callback){
- setTimeout(function(){
- callback(null, 2);
- }, 100);
- }
-},
-function(err, results) {
- // results is now equal to: {one: 1, two: 2}
-});
-```
-
----------------------------------------
-
-
-### parallel(tasks, [callback])
-
-Run an array of functions in parallel, without waiting until the previous
-function has completed. If any of the functions pass an error to its
-callback, the main callback is immediately called with the value of the error.
-Once the tasks have completed, the results are passed to the final callback as an
-array.
-
-It is also possible to use an object instead of an array. Each property will be
-run as a function and the results will be passed to the final callback as an object
-instead of an array. This can be a more readable way of handling results from
-async.parallel.
-
-
-__Arguments__
-
-* tasks - An array or object containing functions to run, each function is passed
- a callback(err, result) it must call on completion with an error (which can
- be null) and an optional result value.
-* callback(err, results) - An optional callback to run once all the functions
- have completed. This function gets a results array (or object) containing all
- the result arguments passed to the task callbacks.
-
-__Example__
-
-```js
-async.parallel([
- function(callback){
- setTimeout(function(){
- callback(null, 'one');
- }, 200);
- },
- function(callback){
- setTimeout(function(){
- callback(null, 'two');
- }, 100);
- }
-],
-// optional callback
-function(err, results){
- // the results array will equal ['one','two'] even though
- // the second function had a shorter timeout.
-});
-
-
-// an example using an object instead of an array
-async.parallel({
- one: function(callback){
- setTimeout(function(){
- callback(null, 1);
- }, 200);
- },
- two: function(callback){
- setTimeout(function(){
- callback(null, 2);
- }, 100);
- }
-},
-function(err, results) {
- // results is now equals to: {one: 1, two: 2}
-});
-```
-
----------------------------------------
-
-
-### parallelLimit(tasks, limit, [callback])
-
-The same as parallel only the tasks are executed in parallel with a maximum of "limit"
-tasks executing at any time.
-
-Note that the tasks are not executed in batches, so there is no guarantee that
-the first "limit" tasks will complete before any others are started.
-
-__Arguments__
-
-* tasks - An array or object containing functions to run, each function is passed
- a callback(err, result) it must call on completion with an error (which can
- be null) and an optional result value.
-* limit - The maximum number of tasks to run at any time.
-* callback(err, results) - An optional callback to run once all the functions
- have completed. This function gets a results array (or object) containing all
- the result arguments passed to the task callbacks.
-
----------------------------------------
-
-
-### whilst(test, fn, callback)
-
-Repeatedly call fn, while test returns true. Calls the callback when stopped,
-or an error occurs.
-
-__Arguments__
-
-* test() - synchronous truth test to perform before each execution of fn.
-* fn(callback) - A function to call each time the test passes. The function is
- passed a callback(err) which must be called once it has completed with an
- optional error argument.
-* callback(err) - A callback which is called after the test fails and repeated
- execution of fn has stopped.
-
-__Example__
-
-```js
-var count = 0;
-
-async.whilst(
- function () { return count < 5; },
- function (callback) {
- count++;
- setTimeout(callback, 1000);
- },
- function (err) {
- // 5 seconds have passed
- }
-);
-```
-
----------------------------------------
-
-
-### doWhilst(fn, test, callback)
-
-The post check version of whilst. To reflect the difference in the order of operations `test` and `fn` arguments are switched. `doWhilst` is to `whilst` as `do while` is to `while` in plain JavaScript.
-
----------------------------------------
-
-
-### until(test, fn, callback)
-
-Repeatedly call fn, until test returns true. Calls the callback when stopped,
-or an error occurs.
-
-The inverse of async.whilst.
-
----------------------------------------
-
-
-### doUntil(fn, test, callback)
-
-Like doWhilst except the test is inverted. Note the argument ordering differs from `until`.
-
----------------------------------------
-
-
-### forever(fn, callback)
-
-Calls the asynchronous function 'fn' repeatedly, in series, indefinitely.
-If an error is passed to fn's callback then 'callback' is called with the
-error, otherwise it will never be called.
-
----------------------------------------
-
-
-### waterfall(tasks, [callback])
-
-Runs an array of functions in series, each passing their results to the next in
-the array. However, if any of the functions pass an error to the callback, the
-next function is not executed and the main callback is immediately called with
-the error.
-
-__Arguments__
-
-* tasks - An array of functions to run, each function is passed a
- callback(err, result1, result2, ...) it must call on completion. The first
- argument is an error (which can be null) and any further arguments will be
- passed as arguments in order to the next task.
-* callback(err, [results]) - An optional callback to run once all the functions
- have completed. This will be passed the results of the last task's callback.
-
-
-
-__Example__
-
-```js
-async.waterfall([
- function(callback){
- callback(null, 'one', 'two');
- },
- function(arg1, arg2, callback){
- callback(null, 'three');
- },
- function(arg1, callback){
- // arg1 now equals 'three'
- callback(null, 'done');
- }
-], function (err, result) {
- // result now equals 'done'
-});
-```
-
----------------------------------------
-
-### compose(fn1, fn2...)
-
-Creates a function which is a composition of the passed asynchronous
-functions. Each function consumes the return value of the function that
-follows. Composing functions f(), g() and h() would produce the result of
-f(g(h())), only this version uses callbacks to obtain the return values.
-
-Each function is executed with the `this` binding of the composed function.
-
-__Arguments__
-
-* functions... - the asynchronous functions to compose
-
-
-__Example__
-
-```js
-function add1(n, callback) {
- setTimeout(function () {
- callback(null, n + 1);
- }, 10);
-}
-
-function mul3(n, callback) {
- setTimeout(function () {
- callback(null, n * 3);
- }, 10);
-}
-
-var add1mul3 = async.compose(mul3, add1);
-
-add1mul3(4, function (err, result) {
- // result now equals 15
-});
-```
-
----------------------------------------
-
-### applyEach(fns, args..., callback)
-
-Applies the provided arguments to each function in the array, calling the
-callback after all functions have completed. If you only provide the first
-argument then it will return a function which lets you pass in the
-arguments as if it were a single function call.
-
-__Arguments__
-
-* fns - the asynchronous functions to all call with the same arguments
-* args... - any number of separate arguments to pass to the function
-* callback - the final argument should be the callback, called when all
- functions have completed processing
-
-
-__Example__
-
-```js
-async.applyEach([enableSearch, updateSchema], 'bucket', callback);
-
-// partial application example:
-async.each(
- buckets,
- async.applyEach([enableSearch, updateSchema]),
- callback
-);
-```
-
----------------------------------------
-
-
-### applyEachSeries(arr, iterator, callback)
-
-The same as applyEach only the functions are applied in series.
-
----------------------------------------
-
-
-### queue(worker, concurrency)
-
-Creates a queue object with the specified concurrency. Tasks added to the
-queue will be processed in parallel (up to the concurrency limit). If all
-workers are in progress, the task is queued until one is available. Once
-a worker has completed a task, the task's callback is called.
-
-__Arguments__
-
-* worker(task, callback) - An asynchronous function for processing a queued
- task, which must call its callback(err) argument when finished, with an
- optional error as an argument.
-* concurrency - An integer for determining how many worker functions should be
- run in parallel.
-
-__Queue objects__
-
-The queue object returned by this function has the following properties and
-methods:
-
-* length() - a function returning the number of items waiting to be processed.
-* concurrency - an integer for determining how many worker functions should be
- run in parallel. This property can be changed after a queue is created to
- alter the concurrency on-the-fly.
-* push(task, [callback]) - add a new task to the queue, the callback is called
- once the worker has finished processing the task.
- instead of a single task, an array of tasks can be submitted. the respective callback is used for every task in the list.
-* unshift(task, [callback]) - add a new task to the front of the queue.
-* saturated - a callback that is called when the queue length hits the concurrency and further tasks will be queued
-* empty - a callback that is called when the last item from the queue is given to a worker
-* drain - a callback that is called when the last item from the queue has returned from the worker
-
-__Example__
-
-```js
-// create a queue object with concurrency 2
-
-var q = async.queue(function (task, callback) {
- console.log('hello ' + task.name);
- callback();
-}, 2);
-
-
-// assign a callback
-q.drain = function() {
- console.log('all items have been processed');
-}
-
-// add some items to the queue
-
-q.push({name: 'foo'}, function (err) {
- console.log('finished processing foo');
-});
-q.push({name: 'bar'}, function (err) {
- console.log('finished processing bar');
-});
-
-// add some items to the queue (batch-wise)
-
-q.push([{name: 'baz'},{name: 'bay'},{name: 'bax'}], function (err) {
- console.log('finished processing bar');
-});
-
-// add some items to the front of the queue
-
-q.unshift({name: 'bar'}, function (err) {
- console.log('finished processing bar');
-});
-```
-
----------------------------------------
-
-
-### cargo(worker, [payload])
-
-Creates a cargo object with the specified payload. Tasks added to the
-cargo will be processed altogether (up to the payload limit). If the
-worker is in progress, the task is queued until it is available. Once
-the worker has completed some tasks, each callback of those tasks is called.
-
-__Arguments__
-
-* worker(tasks, callback) - An asynchronous function for processing an array of
- queued tasks, which must call its callback(err) argument when finished, with
- an optional error as an argument.
-* payload - An optional integer for determining how many tasks should be
- processed per round; if omitted, the default is unlimited.
-
-__Cargo objects__
-
-The cargo object returned by this function has the following properties and
-methods:
-
-* length() - a function returning the number of items waiting to be processed.
-* payload - an integer for determining how many tasks should be
- process per round. This property can be changed after a cargo is created to
- alter the payload on-the-fly.
-* push(task, [callback]) - add a new task to the queue, the callback is called
- once the worker has finished processing the task.
- instead of a single task, an array of tasks can be submitted. the respective callback is used for every task in the list.
-* saturated - a callback that is called when the queue length hits the concurrency and further tasks will be queued
-* empty - a callback that is called when the last item from the queue is given to a worker
-* drain - a callback that is called when the last item from the queue has returned from the worker
-
-__Example__
-
-```js
-// create a cargo object with payload 2
-
-var cargo = async.cargo(function (tasks, callback) {
- for(var i=0; i
-### auto(tasks, [callback])
-
-Determines the best order for running functions based on their requirements.
-Each function can optionally depend on other functions being completed first,
-and each function is run as soon as its requirements are satisfied. If any of
-the functions pass an error to their callback, that function will not complete
-(so any other functions depending on it will not run) and the main callback
-will be called immediately with the error. Functions also receive an object
-containing the results of functions which have completed so far.
-
-Note, all functions are called with a results object as a second argument,
-so it is unsafe to pass functions in the tasks object which cannot handle the
-extra argument. For example, this snippet of code:
-
-```js
-async.auto({
- readData: async.apply(fs.readFile, 'data.txt', 'utf-8')
-}, callback);
-```
-
-will have the effect of calling readFile with the results object as the last
-argument, which will fail:
-
-```js
-fs.readFile('data.txt', 'utf-8', cb, {});
-```
-
-Instead, wrap the call to readFile in a function which does not forward the
-results object:
-
-```js
-async.auto({
- readData: function(cb, results){
- fs.readFile('data.txt', 'utf-8', cb);
- }
-}, callback);
-```
-
-__Arguments__
-
-* tasks - An object literal containing named functions or an array of
- requirements, with the function itself the last item in the array. The key
- used for each function or array is used when specifying requirements. The
- function receives two arguments: (1) a callback(err, result) which must be
- called when finished, passing an error (which can be null) and the result of
- the function's execution, and (2) a results object, containing the results of
- the previously executed functions.
-* callback(err, results) - An optional callback which is called when all the
- tasks have been completed. The callback will receive an error as an argument
- if any tasks pass an error to their callback. Results will always be passed
- but if an error occurred, no other tasks will be performed, and the results
- object will only contain partial results.
-
-
-__Example__
-
-```js
-async.auto({
- get_data: function(callback){
- // async code to get some data
- },
- make_folder: function(callback){
- // async code to create a directory to store a file in
- // this is run at the same time as getting the data
- },
- write_file: ['get_data', 'make_folder', function(callback){
- // once there is some data and the directory exists,
- // write the data to a file in the directory
- callback(null, filename);
- }],
- email_link: ['write_file', function(callback, results){
- // once the file is written let's email a link to it...
- // results.write_file contains the filename returned by write_file.
- }]
-});
-```
-
-This is a fairly trivial example, but to do this using the basic parallel and
-series functions would look like this:
-
-```js
-async.parallel([
- function(callback){
- // async code to get some data
- },
- function(callback){
- // async code to create a directory to store a file in
- // this is run at the same time as getting the data
- }
-],
-function(err, results){
- async.series([
- function(callback){
- // once there is some data and the directory exists,
- // write the data to a file in the directory
- },
- function(callback){
- // once the file is written let's email a link to it...
- }
- ]);
-});
-```
-
-For a complicated series of async tasks using the auto function makes adding
-new tasks much easier and makes the code more readable.
-
-
----------------------------------------
-
-
-### iterator(tasks)
-
-Creates an iterator function which calls the next function in the array,
-returning a continuation to call the next one after that. It's also possible to
-'peek' the next iterator by doing iterator.next().
-
-This function is used internally by the async module but can be useful when
-you want to manually control the flow of functions in series.
-
-__Arguments__
-
-* tasks - An array of functions to run.
-
-__Example__
-
-```js
-var iterator = async.iterator([
- function(){ sys.p('one'); },
- function(){ sys.p('two'); },
- function(){ sys.p('three'); }
-]);
-
-node> var iterator2 = iterator();
-'one'
-node> var iterator3 = iterator2();
-'two'
-node> iterator3();
-'three'
-node> var nextfn = iterator2.next();
-node> nextfn();
-'three'
-```
-
----------------------------------------
-
-
-### apply(function, arguments..)
-
-Creates a continuation function with some arguments already applied, a useful
-shorthand when combined with other control flow functions. Any arguments
-passed to the returned function are added to the arguments originally passed
-to apply.
-
-__Arguments__
-
-* function - The function you want to eventually apply all arguments to.
-* arguments... - Any number of arguments to automatically apply when the
- continuation is called.
-
-__Example__
-
-```js
-// using apply
-
-async.parallel([
- async.apply(fs.writeFile, 'testfile1', 'test1'),
- async.apply(fs.writeFile, 'testfile2', 'test2'),
-]);
-
-
-// the same process without using apply
-
-async.parallel([
- function(callback){
- fs.writeFile('testfile1', 'test1', callback);
- },
- function(callback){
- fs.writeFile('testfile2', 'test2', callback);
- }
-]);
-```
-
-It's possible to pass any number of additional arguments when calling the
-continuation:
-
-```js
-node> var fn = async.apply(sys.puts, 'one');
-node> fn('two', 'three');
-one
-two
-three
-```
-
----------------------------------------
-
-
-### nextTick(callback)
-
-Calls the callback on a later loop around the event loop. In node.js this just
-calls process.nextTick, in the browser it falls back to setImmediate(callback)
-if available, otherwise setTimeout(callback, 0), which means other higher priority
-events may precede the execution of the callback.
-
-This is used internally for browser-compatibility purposes.
-
-__Arguments__
-
-* callback - The function to call on a later loop around the event loop.
-
-__Example__
-
-```js
-var call_order = [];
-async.nextTick(function(){
- call_order.push('two');
- // call_order now equals ['one','two']
-});
-call_order.push('one')
-```
-
-
-### times(n, callback)
-
-Calls the callback n times and accumulates results in the same manner
-you would use with async.map.
-
-__Arguments__
-
-* n - The number of times to run the function.
-* callback - The function to call n times.
-
-__Example__
-
-```js
-// Pretend this is some complicated async factory
-var createUser = function(id, callback) {
- callback(null, {
- id: 'user' + id
- })
-}
-// generate 5 users
-async.times(5, function(n, next){
- createUser(n, function(err, user) {
- next(err, user)
- })
-}, function(err, users) {
- // we should now have 5 users
-});
-```
-
-
-### timesSeries(n, callback)
-
-The same as times only the iterator is applied to each item in the array in
-series. The next iterator is only called once the current one has completed
-processing. The results array will be in the same order as the original.
-
-
-## Utils
-
-
-### memoize(fn, [hasher])
-
-Caches the results of an async function. When creating a hash to store function
-results against, the callback is omitted from the hash and an optional hash
-function can be used.
-
-The cache of results is exposed as the `memo` property of the function returned
-by `memoize`.
-
-__Arguments__
-
-* fn - the function you to proxy and cache results from.
-* hasher - an optional function for generating a custom hash for storing
- results, it has all the arguments applied to it apart from the callback, and
- must be synchronous.
-
-__Example__
-
-```js
-var slow_fn = function (name, callback) {
- // do something
- callback(null, result);
-};
-var fn = async.memoize(slow_fn);
-
-// fn can now be used as if it were slow_fn
-fn('some name', function () {
- // callback
-});
-```
-
-
-### unmemoize(fn)
-
-Undoes a memoized function, reverting it to the original, unmemoized
-form. Comes handy in tests.
-
-__Arguments__
-
-* fn - the memoized function
-
-
-### log(function, arguments)
-
-Logs the result of an async function to the console. Only works in node.js or
-in browsers that support console.log and console.error (such as FF and Chrome).
-If multiple arguments are returned from the async function, console.log is
-called on each argument in order.
-
-__Arguments__
-
-* function - The function you want to eventually apply all arguments to.
-* arguments... - Any number of arguments to apply to the function.
-
-__Example__
-
-```js
-var hello = function(name, callback){
- setTimeout(function(){
- callback(null, 'hello ' + name);
- }, 1000);
-};
-```
-```js
-node> async.log(hello, 'world');
-'hello world'
-```
-
----------------------------------------
-
-
-### dir(function, arguments)
-
-Logs the result of an async function to the console using console.dir to
-display the properties of the resulting object. Only works in node.js or
-in browsers that support console.dir and console.error (such as FF and Chrome).
-If multiple arguments are returned from the async function, console.dir is
-called on each argument in order.
-
-__Arguments__
-
-* function - The function you want to eventually apply all arguments to.
-* arguments... - Any number of arguments to apply to the function.
-
-__Example__
-
-```js
-var hello = function(name, callback){
- setTimeout(function(){
- callback(null, {hello: name});
- }, 1000);
-};
-```
-```js
-node> async.dir(hello, 'world');
-{hello: 'world'}
-```
-
----------------------------------------
-
-
-### noConflict()
-
-Changes the value of async back to its original value, returning a reference to the
-async object.
diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/winston/node_modules/async/component.json b/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/winston/node_modules/async/component.json
deleted file mode 100644
index bbb0115..0000000
--- a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/winston/node_modules/async/component.json
+++ /dev/null
@@ -1,11 +0,0 @@
-{
- "name": "async",
- "repo": "caolan/async",
- "description": "Higher-order functions and common patterns for asynchronous code",
- "version": "0.1.23",
- "keywords": [],
- "dependencies": {},
- "development": {},
- "main": "lib/async.js",
- "scripts": [ "lib/async.js" ]
-}
diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/winston/node_modules/async/lib/async.js b/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/winston/node_modules/async/lib/async.js
deleted file mode 100755
index 1eebb15..0000000
--- a/computer-science/01-introduction-to-cs-and-programming-mit/src/node_modules/prompt/node_modules/winston/node_modules/async/lib/async.js
+++ /dev/null
@@ -1,958 +0,0 @@
-/*global setImmediate: false, setTimeout: false, console: false */
-(function () {
-
- var async = {};
-
- // global on the server, window in the browser
- var root, previous_async;
-
- root = this;
- if (root != null) {
- previous_async = root.async;
- }
-
- async.noConflict = function () {
- root.async = previous_async;
- return async;
- };
-
- function only_once(fn) {
- var called = false;
- return function() {
- if (called) throw new Error("Callback was already called.");
- called = true;
- fn.apply(root, arguments);
- }
- }
-
- //// cross-browser compatiblity functions ////
-
- var _each = function (arr, iterator) {
- if (arr.forEach) {
- return arr.forEach(iterator);
- }
- for (var i = 0; i < arr.length; i += 1) {
- iterator(arr[i], i, arr);
- }
- };
-
- var _map = function (arr, iterator) {
- if (arr.map) {
- return arr.map(iterator);
- }
- var results = [];
- _each(arr, function (x, i, a) {
- results.push(iterator(x, i, a));
- });
- return results;
- };
-
- var _reduce = function (arr, iterator, memo) {
- if (arr.reduce) {
- return arr.reduce(iterator, memo);
- }
- _each(arr, function (x, i, a) {
- memo = iterator(memo, x, i, a);
- });
- return memo;
- };
-
- var _keys = function (obj) {
- if (Object.keys) {
- return Object.keys(obj);
- }
- var keys = [];
- for (var k in obj) {
- if (obj.hasOwnProperty(k)) {
- keys.push(k);
- }
- }
- return keys;
- };
-
- //// exported async module functions ////
-
- //// nextTick implementation with browser-compatible fallback ////
- if (typeof process === 'undefined' || !(process.nextTick)) {
- if (typeof setImmediate === 'function') {
- async.nextTick = function (fn) {
- // not a direct alias for IE10 compatibility
- setImmediate(fn);
- };
- async.setImmediate = async.nextTick;
- }
- else {
- async.nextTick = function (fn) {
- setTimeout(fn, 0);
- };
- async.setImmediate = async.nextTick;
- }
- }
- else {
- async.nextTick = process.nextTick;
- if (typeof setImmediate !== 'undefined') {
- async.setImmediate = function (fn) {
- // not a direct alias for IE10 compatibility
- setImmediate(fn);
- };
- }
- else {
- async.setImmediate = async.nextTick;
- }
- }
-
- async.each = function (arr, iterator, callback) {
- callback = callback || function () {};
- if (!arr.length) {
- return callback();
- }
- var completed = 0;
- _each(arr, function (x) {
- iterator(x, only_once(function (err) {
- if (err) {
- callback(err);
- callback = function () {};
- }
- else {
- completed += 1;
- if (completed >= arr.length) {
- callback(null);
- }
- }
- }));
- });
- };
- async.forEach = async.each;
-
- async.eachSeries = function (arr, iterator, callback) {
- callback = callback || function () {};
- if (!arr.length) {
- return callback();
- }
- var completed = 0;
- var iterate = function () {
- iterator(arr[completed], function (err) {
- if (err) {
- callback(err);
- callback = function () {};
- }
- else {
- completed += 1;
- if (completed >= arr.length) {
- callback(null);
- }
- else {
- iterate();
- }
- }
- });
- };
- iterate();
- };
- async.forEachSeries = async.eachSeries;
-
- async.eachLimit = function (arr, limit, iterator, callback) {
- var fn = _eachLimit(limit);
- fn.apply(null, [arr, iterator, callback]);
- };
- async.forEachLimit = async.eachLimit;
-
- var _eachLimit = function (limit) {
-
- return function (arr, iterator, callback) {
- callback = callback || function () {};
- if (!arr.length || limit <= 0) {
- return callback();
- }
- var completed = 0;
- var started = 0;
- var running = 0;
-
- (function replenish () {
- if (completed >= arr.length) {
- return callback();
- }
-
- while (running < limit && started < arr.length) {
- started += 1;
- running += 1;
- iterator(arr[started - 1], function (err) {
- if (err) {
- callback(err);
- callback = function () {};
- }
- else {
- completed += 1;
- running -= 1;
- if (completed >= arr.length) {
- callback();
- }
- else {
- replenish();
- }
- }
- });
- }
- })();
- };
- };
-
-
- var doParallel = function (fn) {
- return function () {
- var args = Array.prototype.slice.call(arguments);
- return fn.apply(null, [async.each].concat(args));
- };
- };
- var doParallelLimit = function(limit, fn) {
- return function () {
- var args = Array.prototype.slice.call(arguments);
- return fn.apply(null, [_eachLimit(limit)].concat(args));
- };
- };
- var doSeries = function (fn) {
- return function () {
- var args = Array.prototype.slice.call(arguments);
- return fn.apply(null, [async.eachSeries].concat(args));
- };
- };
-
-
- var _asyncMap = function (eachfn, arr, iterator, callback) {
- var results = [];
- arr = _map(arr, function (x, i) {
- return {index: i, value: x};
- });
- eachfn(arr, function (x, callback) {
- iterator(x.value, function (err, v) {
- results[x.index] = v;
- callback(err);
- });
- }, function (err) {
- callback(err, results);
- });
- };
- async.map = doParallel(_asyncMap);
- async.mapSeries = doSeries(_asyncMap);
- async.mapLimit = function (arr, limit, iterator, callback) {
- return _mapLimit(limit)(arr, iterator, callback);
- };
-
- var _mapLimit = function(limit) {
- return doParallelLimit(limit, _asyncMap);
- };
-
- // reduce only has a series version, as doing reduce in parallel won't
- // work in many situations.
- async.reduce = function (arr, memo, iterator, callback) {
- async.eachSeries(arr, function (x, callback) {
- iterator(memo, x, function (err, v) {
- memo = v;
- callback(err);
- });
- }, function (err) {
- callback(err, memo);
- });
- };
- // inject alias
- async.inject = async.reduce;
- // foldl alias
- async.foldl = async.reduce;
-
- async.reduceRight = function (arr, memo, iterator, callback) {
- var reversed = _map(arr, function (x) {
- return x;
- }).reverse();
- async.reduce(reversed, memo, iterator, callback);
- };
- // foldr alias
- async.foldr = async.reduceRight;
-
- var _filter = function (eachfn, arr, iterator, callback) {
- var results = [];
- arr = _map(arr, function (x, i) {
- return {index: i, value: x};
- });
- eachfn(arr, function (x, callback) {
- iterator(x.value, function (v) {
- if (v) {
- results.push(x);
- }
- callback();
- });
- }, function (err) {
- callback(_map(results.sort(function (a, b) {
- return a.index - b.index;
- }), function (x) {
- return x.value;
- }));
- });
- };
- async.filter = doParallel(_filter);
- async.filterSeries = doSeries(_filter);
- // select alias
- async.select = async.filter;
- async.selectSeries = async.filterSeries;
-
- var _reject = function (eachfn, arr, iterator, callback) {
- var results = [];
- arr = _map(arr, function (x, i) {
- return {index: i, value: x};
- });
- eachfn(arr, function (x, callback) {
- iterator(x.value, function (v) {
- if (!v) {
- results.push(x);
- }
- callback();
- });
- }, function (err) {
- callback(_map(results.sort(function (a, b) {
- return a.index - b.index;
- }), function (x) {
- return x.value;
- }));
- });
- };
- async.reject = doParallel(_reject);
- async.rejectSeries = doSeries(_reject);
-
- var _detect = function (eachfn, arr, iterator, main_callback) {
- eachfn(arr, function (x, callback) {
- iterator(x, function (result) {
- if (result) {
- main_callback(x);
- main_callback = function () {};
- }
- else {
- callback();
- }
- });
- }, function (err) {
- main_callback();
- });
- };
- async.detect = doParallel(_detect);
- async.detectSeries = doSeries(_detect);
-
- async.some = function (arr, iterator, main_callback) {
- async.each(arr, function (x, callback) {
- iterator(x, function (v) {
- if (v) {
- main_callback(true);
- main_callback = function () {};
- }
- callback();
- });
- }, function (err) {
- main_callback(false);
- });
- };
- // any alias
- async.any = async.some;
-
- async.every = function (arr, iterator, main_callback) {
- async.each(arr, function (x, callback) {
- iterator(x, function (v) {
- if (!v) {
- main_callback(false);
- main_callback = function () {};
- }
- callback();
- });
- }, function (err) {
- main_callback(true);
- });
- };
- // all alias
- async.all = async.every;
-
- async.sortBy = function (arr, iterator, callback) {
- async.map(arr, function (x, callback) {
- iterator(x, function (err, criteria) {
- if (err) {
- callback(err);
- }
- else {
- callback(null, {value: x, criteria: criteria});
- }
- });
- }, function (err, results) {
- if (err) {
- return callback(err);
- }
- else {
- var fn = function (left, right) {
- var a = left.criteria, b = right.criteria;
- return a < b ? -1 : a > b ? 1 : 0;
- };
- callback(null, _map(results.sort(fn), function (x) {
- return x.value;
- }));
- }
- });
- };
-
- async.auto = function (tasks, callback) {
- callback = callback || function () {};
- var keys = _keys(tasks);
- if (!keys.length) {
- return callback(null);
- }
-
- var results = {};
-
- var listeners = [];
- var addListener = function (fn) {
- listeners.unshift(fn);
- };
- var removeListener = function (fn) {
- for (var i = 0; i < listeners.length; i += 1) {
- if (listeners[i] === fn) {
- listeners.splice(i, 1);
- return;
- }
- }
- };
- var taskComplete = function () {
- _each(listeners.slice(0), function (fn) {
- fn();
- });
- };
-
- addListener(function () {
- if (_keys(results).length === keys.length) {
- callback(null, results);
- callback = function () {};
- }
- });
-
- _each(keys, function (k) {
- var task = (tasks[k] instanceof Function) ? [tasks[k]]: tasks[k];
- var taskCallback = function (err) {
- var args = Array.prototype.slice.call(arguments, 1);
- if (args.length <= 1) {
- args = args[0];
- }
- if (err) {
- var safeResults = {};
- _each(_keys(results), function(rkey) {
- safeResults[rkey] = results[rkey];
- });
- safeResults[k] = args;
- callback(err, safeResults);
- // stop subsequent errors hitting callback multiple times
- callback = function () {};
- }
- else {
- results[k] = args;
- async.setImmediate(taskComplete);
- }
- };
- var requires = task.slice(0, Math.abs(task.length - 1)) || [];
- var ready = function () {
- return _reduce(requires, function (a, x) {
- return (a && results.hasOwnProperty(x));
- }, true) && !results.hasOwnProperty(k);
- };
- if (ready()) {
- task[task.length - 1](taskCallback, results);
- }
- else {
- var listener = function () {
- if (ready()) {
- removeListener(listener);
- task[task.length - 1](taskCallback, results);
- }
- };
- addListener(listener);
- }
- });
- };
-
- async.waterfall = function (tasks, callback) {
- callback = callback || function () {};
- if (tasks.constructor !== Array) {
- var err = new Error('First argument to waterfall must be an array of functions');
- return callback(err);
- }
- if (!tasks.length) {
- return callback();
- }
- var wrapIterator = function (iterator) {
- return function (err) {
- if (err) {
- callback.apply(null, arguments);
- callback = function () {};
- }
- else {
- var args = Array.prototype.slice.call(arguments, 1);
- var next = iterator.next();
- if (next) {
- args.push(wrapIterator(next));
- }
- else {
- args.push(callback);
- }
- async.setImmediate(function () {
- iterator.apply(null, args);
- });
- }
- };
- };
- wrapIterator(async.iterator(tasks))();
- };
-
- var _parallel = function(eachfn, tasks, callback) {
- callback = callback || function () {};
- if (tasks.constructor === Array) {
- eachfn.map(tasks, function (fn, callback) {
- if (fn) {
- fn(function (err) {
- var args = Array.prototype.slice.call(arguments, 1);
- if (args.length <= 1) {
- args = args[0];
- }
- callback.call(null, err, args);
- });
- }
- }, callback);
- }
- else {
- var results = {};
- eachfn.each(_keys(tasks), function (k, callback) {
- tasks[k](function (err) {
- var args = Array.prototype.slice.call(arguments, 1);
- if (args.length <= 1) {
- args = args[0];
- }
- results[k] = args;
- callback(err);
- });
- }, function (err) {
- callback(err, results);
- });
- }
- };
-
- async.parallel = function (tasks, callback) {
- _parallel({ map: async.map, each: async.each }, tasks, callback);
- };
-
- async.parallelLimit = function(tasks, limit, callback) {
- _parallel({ map: _mapLimit(limit), each: _eachLimit(limit) }, tasks, callback);
- };
-
- async.series = function (tasks, callback) {
- callback = callback || function () {};
- if (tasks.constructor === Array) {
- async.mapSeries(tasks, function (fn, callback) {
- if (fn) {
- fn(function (err) {
- var args = Array.prototype.slice.call(arguments, 1);
- if (args.length <= 1) {
- args = args[0];
- }
- callback.call(null, err, args);
- });
- }
- }, callback);
- }
- else {
- var results = {};
- async.eachSeries(_keys(tasks), function (k, callback) {
- tasks[k](function (err) {
- var args = Array.prototype.slice.call(arguments, 1);
- if (args.length <= 1) {
- args = args[0];
- }
- results[k] = args;
- callback(err);
- });
- }, function (err) {
- callback(err, results);
- });
- }
- };
-
- async.iterator = function (tasks) {
- var makeCallback = function (index) {
- var fn = function () {
- if (tasks.length) {
- tasks[index].apply(null, arguments);
- }
- return fn.next();
- };
- fn.next = function () {
- return (index < tasks.length - 1) ? makeCallback(index + 1): null;
- };
- return fn;
- };
- return makeCallback(0);
- };
-
- async.apply = function (fn) {
- var args = Array.prototype.slice.call(arguments, 1);
- return function () {
- return fn.apply(
- null, args.concat(Array.prototype.slice.call(arguments))
- );
- };
- };
-
- var _concat = function (eachfn, arr, fn, callback) {
- var r = [];
- eachfn(arr, function (x, cb) {
- fn(x, function (err, y) {
- r = r.concat(y || []);
- cb(err);
- });
- }, function (err) {
- callback(err, r);
- });
- };
- async.concat = doParallel(_concat);
- async.concatSeries = doSeries(_concat);
-
- async.whilst = function (test, iterator, callback) {
- if (test()) {
- iterator(function (err) {
- if (err) {
- return callback(err);
- }
- async.whilst(test, iterator, callback);
- });
- }
- else {
- callback();
- }
- };
-
- async.doWhilst = function (iterator, test, callback) {
- iterator(function (err) {
- if (err) {
- return callback(err);
- }
- if (test()) {
- async.doWhilst(iterator, test, callback);
- }
- else {
- callback();
- }
- });
- };
-
- async.until = function (test, iterator, callback) {
- if (!test()) {
- iterator(function (err) {
- if (err) {
- return callback(err);
- }
- async.until(test, iterator, callback);
- });
- }
- else {
- callback();
- }
- };
-
- async.doUntil = function (iterator, test, callback) {
- iterator(function (err) {
- if (err) {
- return callback(err);
- }
- if (!test()) {
- async.doUntil(iterator, test, callback);
- }
- else {
- callback();
- }
- });
- };
-
- async.queue = function (worker, concurrency) {
- if (concurrency === undefined) {
- concurrency = 1;
- }
- function _insert(q, data, pos, callback) {
- if(data.constructor !== Array) {
- data = [data];
- }
- _each(data, function(task) {
- var item = {
- data: task,
- callback: typeof callback === 'function' ? callback : null
- };
-
- if (pos) {
- q.tasks.unshift(item);
- } else {
- q.tasks.push(item);
- }
-
- if (q.saturated && q.tasks.length === concurrency) {
- q.saturated();
- }
- async.setImmediate(q.process);
- });
- }
-
- var workers = 0;
- var q = {
- tasks: [],
- concurrency: concurrency,
- saturated: null,
- empty: null,
- drain: null,
- push: function (data, callback) {
- _insert(q, data, false, callback);
- },
- unshift: function (data, callback) {
- _insert(q, data, true, callback);
- },
- process: function () {
- if (workers < q.concurrency && q.tasks.length) {
- var task = q.tasks.shift();
- if (q.empty && q.tasks.length === 0) {
- q.empty();
- }
- workers += 1;
- var next = function () {
- workers -= 1;
- if (task.callback) {
- task.callback.apply(task, arguments);
- }
- if (q.drain && q.tasks.length + workers === 0) {
- q.drain();
- }
- q.process();
- };
- var cb = only_once(next);
- worker(task.data, cb);
- }
- },
- length: function () {
- return q.tasks.length;
- },
- running: function () {
- return workers;
- }
- };
- return q;
- };
-
- async.cargo = function (worker, payload) {
- var working = false,
- tasks = [];
-
- var cargo = {
- tasks: tasks,
- payload: payload,
- saturated: null,
- empty: null,
- drain: null,
- push: function (data, callback) {
- if(data.constructor !== Array) {
- data = [data];
- }
- _each(data, function(task) {
- tasks.push({
- data: task,
- callback: typeof callback === 'function' ? callback : null
- });
- if (cargo.saturated && tasks.length === payload) {
- cargo.saturated();
- }
- });
- async.setImmediate(cargo.process);
- },
- process: function process() {
- if (working) return;
- if (tasks.length === 0) {
- if(cargo.drain) cargo.drain();
- return;
- }
-
- var ts = typeof payload === 'number'
- ? tasks.splice(0, payload)
- : tasks.splice(0);
-
- var ds = _map(ts, function (task) {
- return task.data;
- });
-
- if(cargo.empty) cargo.empty();
- working = true;
- worker(ds, function () {
- working = false;
-
- var args = arguments;
- _each(ts, function (data) {
- if (data.callback) {
- data.callback.apply(null, args);
- }
- });
-
- process();
- });
- },
- length: function () {
- return tasks.length;
- },
- running: function () {
- return working;
- }
- };
- return cargo;
- };
-
- var _console_fn = function (name) {
- return function (fn) {
- var args = Array.prototype.slice.call(arguments, 1);
- fn.apply(null, args.concat([function (err) {
- var args = Array.prototype.slice.call(arguments, 1);
- if (typeof console !== 'undefined') {
- if (err) {
- if (console.error) {
- console.error(err);
- }
- }
- else if (console[name]) {
- _each(args, function (x) {
- console[name](x);
- });
- }
- }
- }]));
- };
- };
- async.log = _console_fn('log');
- async.dir = _console_fn('dir');
- /*async.info = _console_fn('info');
- async.warn = _console_fn('warn');
- async.error = _console_fn('error');*/
-
- async.memoize = function (fn, hasher) {
- var memo = {};
- var queues = {};
- hasher = hasher || function (x) {
- return x;
- };
- var memoized = function () {
- var args = Array.prototype.slice.call(arguments);
- var callback = args.pop();
- var key = hasher.apply(null, args);
- if (key in memo) {
- callback.apply(null, memo[key]);
- }
- else if (key in queues) {
- queues[key].push(callback);
- }
- else {
- queues[key] = [callback];
- fn.apply(null, args.concat([function () {
- memo[key] = arguments;
- var q = queues[key];
- delete queues[key];
- for (var i = 0, l = q.length; i < l; i++) {
- q[i].apply(null, arguments);
- }
- }]));
- }
- };
- memoized.memo = memo;
- memoized.unmemoized = fn;
- return memoized;
- };
-
- async.unmemoize = function (fn) {
- return function () {
- return (fn.unmemoized || fn).apply(null, arguments);
- };
- };
-
- async.times = function (count, iterator, callback) {
- var counter = [];
- for (var i = 0; i < count; i++) {
- counter.push(i);
- }
- return async.map(counter, iterator, callback);
- };
-
- async.timesSeries = function (count, iterator, callback) {
- var counter = [];
- for (var i = 0; i < count; i++) {
- counter.push(i);
- }
- return async.mapSeries(counter, iterator, callback);
- };
-
- async.compose = function (/* functions... */) {
- var fns = Array.prototype.reverse.call(arguments);
- return function () {
- var that = this;
- var args = Array.prototype.slice.call(arguments);
- var callback = args.pop();
- async.reduce(fns, args, function (newargs, fn, cb) {
- fn.apply(that, newargs.concat([function () {
- var err = arguments[0];
- var nextargs = Array.prototype.slice.call(arguments, 1);
- cb(err, nextargs);
- }]))
- },
- function (err, results) {
- callback.apply(that, [err].concat(results));
- });
- };
- };
-
- var _applyEach = function (eachfn, fns /*args...*/) {
- var go = function () {
- var that = this;
- var args = Array.prototype.slice.call(arguments);
- var callback = args.pop();
- return eachfn(fns, function (fn, cb) {
- fn.apply(that, args.concat([cb]));
- },
- callback);
- };
- if (arguments.length > 2) {
- var args = Array.prototype.slice.call(arguments, 2);
- return go.apply(this, args);
- }
- else {
- return go;
- }
- };
- async.applyEach = doParallel(_applyEach);
- async.applyEachSeries = doSeries(_applyEach);
-
- async.forever = function (fn, callback) {
- function next(err) {
- if (err) {
- if (callback) {
- return callback(err);
- }
- throw err;
- }
- fn(next);
- }
- next();
- };
-
- // AMD / RequireJS
- if (typeof define !== 'undefined' && define.amd) {
- define([], function () {
- return async;
- });
- }
- // Node.js
- else if (typeof module !== 'undefined' && module.exports) {
- module.exports = async;
- }
- // included directly via
-
-
-
-
-