Commit 4b475fc7 authored by Leo Iannacone's avatar Leo Iannacone

update internals libraries

parent e7709a3c
## How to contribute to CoffeeScript
* Before you open a ticket or send a pull request, [search](https://github.com/jashkenas/coffee-script/issues) for previous discussions about the same feature or issue. Add to the earlier ticket if you find one.
* Before you open a ticket or send a pull request, [search](https://github.com/jashkenas/coffeescript/issues) for previous discussions about the same feature or issue. Add to the earlier ticket if you find one.
* Before sending a pull request for a feature, be sure to have [tests](https://github.com/jashkenas/coffee-script/tree/master/test).
* Before sending a pull request for a feature, be sure to have [tests](https://github.com/jashkenas/coffeescript/tree/master/test).
* Use the same coding style as the rest of the [codebase](https://github.com/jashkenas/coffee-script/tree/master/src). If you're just getting started with CoffeeScript, there's a nice [style guide](https://github.com/polarmobile/coffeescript-style-guide).
* Use the same coding style as the rest of the [codebase](https://github.com/jashkenas/coffeescript/tree/master/src). If you're just getting started with CoffeeScript, there's a nice [style guide](https://github.com/polarmobile/coffeescript-style-guide).
* In your pull request, do not add documentation to `index.html` or re-build the minified `coffee-script.js` file. We'll do those things before cutting a new release.
\ No newline at end of file
......@@ -38,13 +38,13 @@
http://coffeescript.org/
To suggest a feature, report a bug, or general discussion:
http://github.com/jashkenas/coffee-script/issues/
http://github.com/jashkenas/coffeescript/issues/
If you'd like to chat, drop by #coffeescript on Freenode IRC,
or on webchat.freenode.net.
The source repository:
git://github.com/jashkenas/coffee-script.git
git://github.com/jashkenas/coffeescript.git
Top 100 contributors are listed here:
http://github.com/jashkenas/coffee-script/contributors
http://github.com/jashkenas/coffeescript/contributors
{
} } {
{ { } }
} }{ {
{ }{ } } _____ __ __
{ }{ }{ { } / ____| / _|/ _|
.- { { } { }} -. | | ___ | |_| |_ ___ ___
( { } { } { } } ) | | / _ \| _| _/ _ \/ _ \
|`-..________ ..-'| | |___| (_) | | | || __/ __/
| | \_____\___/|_| |_| \___|\___|
| ;--.
| (__ \ _____ _ _
| | ) ) / ____| (_) | |
| |/ / | (___ ___ _ __ _ _ __ | |_
| ( / \___ \ / __| '__| | '_ \| __|
| |/ ____) | (__| | | | |_) | |_
| | |_____/ \___|_| |_| .__/ \__|
`-.._________..-' | |
|_|
CoffeeScript is a little language that compiles into JavaScript.
## Installation
If you have the node package manager, npm, installed:
```shell
npm install -g coffee-script
```
Leave off the `-g` if you don't wish to install globally. If you don't wish to use npm:
```shell
git clone https://github.com/jashkenas/coffeescript.git
sudo coffeescript/bin/cake install
```
## Getting Started
Execute a script:
```shell
coffee /path/to/script.coffee
```
Compile a script:
```shell
coffee -c /path/to/script.coffee
```
For documentation, usage, and examples, see: http://coffeescript.org/
To suggest a feature or report a bug: http://github.com/jashkenas/coffeescript/issues
If you'd like to chat, drop by #coffeescript on Freenode IRC.
The source repository: https://github.com/jashkenas/coffeescript.git
Our lovely and talented contributors are listed here: http://github.com/jashkenas/coffeescript/contributors
// Generated by CoffeeScript 1.7.1
// Generated by CoffeeScript 1.8.0
(function() {
var CoffeeScript, compile, runScripts,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
......
// Generated by CoffeeScript 1.7.1
// Generated by CoffeeScript 1.8.0
(function() {
var CoffeeScript, cakefileDirectory, fatalError, fs, helpers, missingTask, oparse, options, optparse, path, printTasks, switches, tasks;
......@@ -12,6 +12,8 @@
CoffeeScript = require('./coffee-script');
CoffeeScript.register();
tasks = {};
options = {};
......
// Generated by CoffeeScript 1.7.1
// Generated by CoffeeScript 1.8.0
(function() {
var Lexer, SourceMap, compile, formatSourcePosition, fs, getSourceMap, helpers, lexer, parser, path, sourceMaps, vm, withPrettyErrors,
var Lexer, SourceMap, compile, ext, formatSourcePosition, fs, getSourceMap, helpers, lexer, parser, path, sourceMaps, vm, withPrettyErrors, _base, _i, _len, _ref,
__hasProp = {}.hasOwnProperty,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
......@@ -18,7 +18,7 @@
SourceMap = require('./sourcemap');
exports.VERSION = '1.7.1';
exports.VERSION = '1.8.0';
exports.FILE_EXTENSIONS = ['.coffee', '.litcoffee', '.coffee.md'];
......@@ -186,6 +186,18 @@
return require('./register');
};
if (require.extensions) {
_ref = this.FILE_EXTENSIONS;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
ext = _ref[_i];
if ((_base = require.extensions)[ext] == null) {
_base[ext] = function() {
throw new Error("Use CoffeeScript.register() or require the coffee-script/register module to require " + ext + " files.");
};
}
}
}
exports._compileFile = function(filename, sourceMap) {
var answer, err, raw, stripped;
if (sourceMap == null) {
......@@ -233,9 +245,9 @@
parser.yy = require('./nodes');
parser.yy.parseError = function(message, _arg) {
var errorLoc, errorTag, errorText, errorToken, token, tokens, _ref;
var errorLoc, errorTag, errorText, errorToken, token, tokens, _ref1;
token = _arg.token;
_ref = parser.lexer, errorToken = _ref.errorToken, tokens = _ref.tokens;
_ref1 = parser.lexer, errorToken = _ref1.errorToken, tokens = _ref1.tokens;
errorTag = errorToken[0], errorText = errorToken[1], errorLoc = errorToken[2];
errorText = errorToken === tokens[tokens.length - 1] ? 'end of input' : errorTag === 'INDENT' || errorTag === 'OUTDENT' ? 'indentation' : helpers.nameWhitespaceCharacter(errorText);
return helpers.throwSyntaxError("unexpected " + errorText, errorLoc);
......@@ -292,11 +304,11 @@
sourceMaps = {};
getSourceMap = function(filename) {
var answer, _ref;
var answer, _ref1;
if (sourceMaps[filename]) {
return sourceMaps[filename];
}
if (_ref = path != null ? path.extname(filename) : void 0, __indexOf.call(exports.FILE_EXTENSIONS, _ref) < 0) {
if (_ref1 = path != null ? path.extname(filename) : void 0, __indexOf.call(exports.FILE_EXTENSIONS, _ref1) < 0) {
return;
}
answer = exports._compileFile(filename, true);
......@@ -304,7 +316,7 @@
};
Error.prepareStackTrace = function(err, stack) {
var frame, frames, getSourceMapping, _ref;
var frame, frames, getSourceMapping;
getSourceMapping = function(filename, line, column) {
var answer, sourceMap;
sourceMap = getSourceMap(filename);
......@@ -318,10 +330,10 @@
}
};
frames = (function() {
var _i, _len, _results;
var _j, _len1, _results;
_results = [];
for (_i = 0, _len = stack.length; _i < _len; _i++) {
frame = stack[_i];
for (_j = 0, _len1 = stack.length; _j < _len1; _j++) {
frame = stack[_j];
if (frame.getFunction() === exports.run) {
break;
}
......@@ -329,7 +341,7 @@
}
return _results;
})();
return "" + err.name + ": " + ((_ref = err.message) != null ? _ref : '') + "\n" + (frames.join('\n')) + "\n";
return "" + (err.toString()) + "\n" + (frames.join('\n')) + "\n";
};
}).call(this);
// Generated by CoffeeScript 1.7.1
// Generated by CoffeeScript 1.8.0
(function() {
var BANNER, CoffeeScript, EventEmitter, SWITCHES, compileJoin, compileOptions, compilePath, compileScript, compileStdio, exec, findDirectoryIndex, forkNode, fs, helpers, hidden, joinTimeout, mkdirp, notSources, optionParser, optparse, opts, outputPath, parseOptions, path, printLine, printTokens, printWarn, removeSource, removeSourceDir, silentUnlink, sourceCode, sources, spawn, timeLog, usage, useWinPathSep, version, wait, watch, watchDir, watchedDirs, writeJs, _ref,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
......@@ -37,7 +37,7 @@
BANNER = 'Usage: coffee [options] path/to/script.coffee -- [args]\n\nIf called without options, `coffee` will run your script.';
SWITCHES = [['-b', '--bare', 'compile without a top-level function wrapper'], ['-c', '--compile', 'compile to JavaScript and save as .js files'], ['-e', '--eval', 'pass a string from the command line as input'], ['-h', '--help', 'display this help message'], ['-i', '--interactive', 'run an interactive CoffeeScript REPL'], ['-j', '--join [FILE]', 'concatenate the source CoffeeScript before compiling'], ['-m', '--map', 'generate source map and save as .map files'], ['-n', '--nodes', 'print out the parse tree that the parser produces'], ['--nodejs [ARGS]', 'pass options directly to the "node" binary'], ['--no-header', 'suppress the "Generated by" header'], ['-o', '--output [DIR]', 'set the output directory for compiled JavaScript'], ['-p', '--print', 'print out the compiled JavaScript'], ['-s', '--stdio', 'listen for and compile scripts over stdio'], ['-l', '--literate', 'treat stdio as literate style coffee-script'], ['-t', '--tokens', 'print out the tokens that the lexer/rewriter produce'], ['-v', '--version', 'display the version number'], ['-w', '--watch', 'watch scripts for changes and rerun commands']];
SWITCHES = [['-b', '--bare', 'compile without a top-level function wrapper'], ['-c', '--compile', 'compile to JavaScript and save as .js files'], ['-e', '--eval', 'pass a string from the command line as input'], ['-h', '--help', 'display this help message'], ['-i', '--interactive', 'run an interactive CoffeeScript REPL'], ['-j', '--join [FILE]', 'concatenate the source CoffeeScript before compiling'], ['-m', '--map', 'generate source map and save as .js.map files'], ['-n', '--nodes', 'print out the parse tree that the parser produces'], ['--nodejs [ARGS]', 'pass options directly to the "node" binary'], ['--no-header', 'suppress the "Generated by" header'], ['-o', '--output [DIR]', 'set the output directory for compiled JavaScript'], ['-p', '--print', 'print out the compiled JavaScript'], ['-s', '--stdio', 'listen for and compile scripts over stdio'], ['-l', '--literate', 'treat stdio as literate style coffee-script'], ['-t', '--tokens', 'print out the tokens that the lexer/rewriter produce'], ['-v', '--version', 'display the version number'], ['-w', '--watch', 'watch scripts for changes and rerun commands']];
opts = {};
......@@ -86,6 +86,7 @@
}
if (opts.join) {
opts.join = path.resolve(opts.join);
console.error('\nThe --join option is deprecated and will be removed in a future version.\n\nIf for some reason it\'s necessary to share local variables between files,\nreplace...\n\n $ coffee --compile --join bundle.js -- a.coffee b.coffee c.coffee\n\nwith...\n\n $ cat a.coffee b.coffee c.coffee | coffee --compile --stdio > bundle.js\n');
}
_ref1 = opts["arguments"];
_results = [];
......@@ -405,7 +406,7 @@
sourceCode.splice(index, 1);
if (!opts.join) {
silentUnlink(outputPath(source, base));
silentUnlink(outputPath(source, base, '.map'));
silentUnlink(outputPath(source, base, '.js.map'));
return timeLog("removed " + source);
}
};
......@@ -444,7 +445,7 @@
if (generatedSourceMap == null) {
generatedSourceMap = null;
}
sourceMapPath = outputPath(sourcePath, base, ".map");
sourceMapPath = outputPath(sourcePath, base, ".js.map");
jsDir = path.dirname(jsPath);
compile = function() {
if (opts.compile) {
......@@ -456,7 +457,8 @@
}
fs.writeFile(jsPath, js, function(err) {
if (err) {
return printLine(err.message);
printLine(err.message);
return process.exit(1);
} else if (opts.compile && opts.watch) {
return timeLog("compiled " + sourcePath);
}
......@@ -465,7 +467,8 @@
if (generatedSourceMap) {
return fs.writeFile(sourceMapPath, generatedSourceMap, function(err) {
if (err) {
return printLine("Could not write source map: " + err.message);
printLine("Could not write source map: " + err.message);
return process.exit(1);
}
});
}
......
// Generated by CoffeeScript 1.7.1
// Generated by CoffeeScript 1.8.0
(function() {
var Parser, alt, alternatives, grammar, name, o, operators, token, tokens, unwrap;
......
// Generated by CoffeeScript 1.7.1
// Generated by CoffeeScript 1.8.0
(function() {
var buildLocationData, extend, flatten, last, repeat, syntaxErrorToString, _ref;
......@@ -220,7 +220,7 @@
codeLine = this.code.split('\n')[first_line];
start = first_column;
end = first_line === last_line ? last_column + 1 : codeLine.length;
marker = repeat(' ', start) + repeat('^', end - start);
marker = codeLine.slice(0, start).replace(/[^\s]/g, ' ') + repeat('^', end - start);
if (typeof process !== "undefined" && process !== null) {
colorsEnabled = process.stdout.isTTY && !process.env.NODE_DISABLE_COLORS;
}
......
// Generated by CoffeeScript 1.7.1
// Generated by CoffeeScript 1.8.0
(function() {
var key, val, _ref;
......
// Generated by CoffeeScript 1.7.1
// Generated by CoffeeScript 1.8.0
(function() {
var BOM, BOOL, CALLABLE, CODE, COFFEE_ALIASES, COFFEE_ALIAS_MAP, COFFEE_KEYWORDS, COMMENT, COMPARE, COMPOUND_ASSIGN, HEREDOC, HEREDOC_ILLEGAL, HEREDOC_INDENT, HEREGEX, HEREGEX_OMIT, IDENTIFIER, INDENTABLE_CLOSERS, INDEXABLE, INVERSES, JSTOKEN, JS_FORBIDDEN, JS_KEYWORDS, LINE_BREAK, LINE_CONTINUER, LOGIC, Lexer, MATH, MULTILINER, MULTI_DENT, NOT_REGEX, NOT_SPACED_REGEX, NUMBER, OPERATOR, REGEX, RELATION, RESERVED, Rewriter, SHIFT, SIMPLESTR, STRICT_PROSCRIBED, TRAILING_SPACES, UNARY, UNARY_MATH, WHITESPACE, compact, count, invertLiterate, key, last, locationDataToString, repeat, starts, throwSyntaxError, _ref, _ref1,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
......@@ -166,10 +166,10 @@
};
Lexer.prototype.stringToken = function() {
var octalEsc, quote, string, trimmed;
var inner, innerLen, numBreak, octalEsc, pos, quote, string, trimmed;
switch (quote = this.chunk.charAt(0)) {
case "'":
string = SIMPLESTR.exec(this.chunk)[0];
string = (SIMPLESTR.exec(this.chunk) || [])[0];
break;
case '"':
string = this.balancedString(this.chunk, '"');
......@@ -177,10 +177,16 @@
if (!string) {
return 0;
}
trimmed = this.removeNewlines(string.slice(1, -1));
inner = string.slice(1, -1);
trimmed = this.removeNewlines(inner);
if (quote === '"' && 0 < string.indexOf('#{', 1)) {
numBreak = pos = 0;
innerLen = inner.length;
while (inner.charAt(pos++) === '\n' && pos < innerLen) {
numBreak++;
}
this.interpolateString(trimmed, {
strOffset: 1,
strOffset: 1 + numBreak,
lexedLength: string.length
});
} else {
......@@ -193,7 +199,7 @@
};
Lexer.prototype.heredocToken = function() {
var doc, heredoc, match, quote;
var doc, heredoc, match, quote, strOffset;
if (!(match = HEREDOC.exec(this.chunk))) {
return 0;
}
......@@ -204,9 +210,10 @@
indent: null
});
if (quote === '"' && 0 <= doc.indexOf('#{')) {
strOffset = match[2].charAt(0) === '\n' ? 4 : 3;
this.interpolateString(doc, {
heredoc: true,
strOffset: 3,
strOffset: strOffset,
lexedLength: heredoc.length
});
} else {
......@@ -283,7 +290,8 @@
this.token('CALL_START', '(', 0, 0);
tokens = [];
_ref2 = this.interpolateString(body, {
regex: true
regex: true,
strOffset: 3
});
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
token = _ref2[_i];
......@@ -625,7 +633,7 @@
}
inner = expr.slice(1, -1);
if (inner.length) {
_ref2 = this.getLineAndColumnFromChunk(strOffset + i + 1), line = _ref2[0], column = _ref2[1];
_ref2 = this.getLineAndColumnFromChunk(strOffset + i + 2), line = _ref2[0], column = _ref2[1];
nested = new Lexer().tokenize(inner, {
line: line,
column: column,
......
// Generated by CoffeeScript 1.7.1
// Generated by CoffeeScript 1.8.0
(function() {
var Access, Arr, Assign, Base, Block, Call, Class, Code, CodeFragment, Comment, Existence, Expansion, Extends, For, HEXNUM, IDENTIFIER, IDENTIFIER_STR, IS_REGEX, IS_STRING, If, In, Index, LEVEL_ACCESS, LEVEL_COND, LEVEL_LIST, LEVEL_OP, LEVEL_PAREN, LEVEL_TOP, Literal, METHOD_DEF, NEGATE, NO, NUMBER, Obj, Op, Param, Parens, RESERVED, Range, Return, SIMPLENUM, STRICT_PROSCRIBED, Scope, Slice, Splat, Switch, TAB, THIS, Throw, Try, UTILITIES, Value, While, YES, addLocationDataFn, compact, del, ends, extend, flatten, fragmentsToText, isLiteralArguments, isLiteralThis, last, locationDataToString, merge, multident, parseNum, some, starts, throwSyntaxError, unfoldSoak, utility, _ref, _ref1,
__hasProp = {}.hasOwnProperty,
......@@ -623,10 +623,8 @@
exports.Return = Return = (function(_super) {
__extends(Return, _super);
function Return(expr) {
if (expr && !expr.unwrap().isUndefined) {
this.expression = expr;
}
function Return(expression) {
this.expression = expression;
}
Return.prototype.children = ['expression'];
......@@ -3075,7 +3073,7 @@
return "[].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }";
},
modulo: function() {
return "function(a, b) { return (a % b + +b) % b; }";
return "function(a, b) { return (+a % (b = +b) + b) % b; }";
},
hasProp: function() {
return '{}.hasOwnProperty';
......
// Generated by CoffeeScript 1.7.1
// Generated by CoffeeScript 1.8.0
(function() {
var LONG_FLAG, MULTI_FLAG, OPTIONAL, OptionParser, SHORT_FLAG, buildRule, buildRules, normalizeArguments, repeat;
......
// Generated by CoffeeScript 1.7.1
// Generated by CoffeeScript 1.8.0
(function() {
var CoffeeScript, Module, binary, child_process, ext, findExtension, fork, helpers, loadFile, path, _i, _len, _ref;
......
// Generated by CoffeeScript 1.7.1
// Generated by CoffeeScript 1.8.0
(function() {
var CoffeeScript, addHistory, addMultilineHandler, fs, merge, nodeREPL, path, replDefaults, updateSyntaxError, vm, _ref;
var CoffeeScript, addHistory, addMultilineHandler, fs, getCommandId, merge, nodeREPL, path, replDefaults, updateSyntaxError, vm, _ref;
fs = require('fs');
......@@ -41,14 +41,15 @@
};
addMultilineHandler = function(repl) {
var inputStream, multiline, nodeLineListener, outputStream, rli;
var inputStream, multiline, nodeLineListener, origPrompt, outputStream, rli, _ref1;
rli = repl.rli, inputStream = repl.inputStream, outputStream = repl.outputStream;
origPrompt = (_ref1 = repl._prompt) != null ? _ref1 : repl.prompt;
multiline = {
enabled: false,
initialPrompt: repl.prompt.replace(/^[^> ]*/, function(x) {
initialPrompt: origPrompt.replace(/^[^> ]*/, function(x) {
return x.replace(/./g, '-');
}),
prompt: repl.prompt.replace(/^[^> ]*>?/, function(x) {
prompt: origPrompt.replace(/^[^> ]*>?/, function(x) {
return x.replace(/./g, '.');
}),
buffer: ''
......@@ -61,6 +62,7 @@
rli.setPrompt(multiline.prompt);
rli.prompt(true);
} else {
rli.setPrompt(origPrompt);
nodeLineListener(cmd);
}
});
......@@ -71,7 +73,7 @@
if (multiline.enabled) {
if (!multiline.buffer.match(/\n/)) {
multiline.enabled = !multiline.enabled;
rli.setPrompt(repl.prompt);
rli.setPrompt(origPrompt);
rli.prompt(true);
return;
}
......@@ -123,7 +125,7 @@
repl.rli.on('exit', function() {
return fs.close(fd);
});
return repl.commands['.history'] = {
return repl.commands[getCommandId(repl, 'history')] = {
help: 'Show command history',
action: function() {
repl.outputStream.write("" + (repl.rli.history.slice(0).reverse().join('\n')) + "\n");
......@@ -132,6 +134,16 @@
};
};
getCommandId = function(repl, commandName) {
var commandsHaveLeadingDot;
commandsHaveLeadingDot = repl.commands['.help'] != null;
if (commandsHaveLeadingDot) {
return "." + commandName;
} else {
return commandName;
}
};
module.exports = {
start: function(opts) {
var build, major, minor, repl, _ref1;
......@@ -156,6 +168,7 @@
if (opts.historyFile) {
addHistory(repl, opts.historyFile, opts.historyMaxInputSize);
}
repl.commands[getCommandId(repl, 'load')].help = 'Load code from a file into this REPL session';
return repl;
}
};
......
// Generated by CoffeeScript 1.7.1
// Generated by CoffeeScript 1.8.0
(function() {
var BALANCED_PAIRS, CALL_CLOSERS, EXPRESSION_CLOSE, EXPRESSION_END, EXPRESSION_START, IMPLICIT_CALL, IMPLICIT_END, IMPLICIT_FUNC, IMPLICIT_UNSPACED_CALL, INVERSES, LINEBREAKS, SINGLE_CLOSERS, SINGLE_LINERS, generate, left, rite, _i, _len, _ref,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },
......
// Generated by CoffeeScript 1.7.1
// Generated by CoffeeScript 1.8.0
(function() {
var Scope, extend, last, _ref;
......
// Generated by CoffeeScript 1.7.1
// Generated by CoffeeScript 1.8.0
(function() {
var LineMap, SourceMap;
......
......@@ -10,7 +10,7 @@
"author": {
"name": "Jeremy Ashkenas"
},
"version": "1.7.1",
"version": "1.8.0",
"license": "MIT",
"engines": {
"node": ">=0.8.0"
......@@ -23,28 +23,34 @@
"coffee": "./bin/coffee",
"cake": "./bin/cake"
},
"preferGlobal": true,
"scripts": {
"test": "node ./bin/cake test"
},
"homepage": "http://coffeescript.org",
"bugs": {
"url": "https://github.com/jashkenas/coffee-script/issues"
"url": "https://github.com/jashkenas/coffeescript/issues"
},
"repository": {
"type": "git",
"url": "git://github.com/jashkenas/coffee-script.git"
"url": "git://github.com/jashkenas/coffeescript.git"
},
"devDependencies": {
"uglify-js": "~2.2",
"jison": ">=0.2.0",
"highlight.js": "~8.0.0",
"underscore": "~1.5.2"
"underscore": "~1.5.2",
"docco": "~0.6.2"
},
"dependencies": {
"mkdirp": "~0.3.5"
},
"readme": " {\n } } {\n { { } }\n } }{ {\n { }{ } } _____ __ __\n { }{ }{ { } / ____| / _|/ _|\n .- { { } { }} -. | | ___ | |_| |_ ___ ___\n ( { } { } { } } ) | | / _ \\| _| _/ _ \\/ _ \\\n |`-..________ ..-'| | |___| (_) | | | || __/ __/\n | | \\_____\\___/|_| |_| \\___|\\___|\n | ;--.\n | (__ \\ _____ _ _\n | | ) ) / ____| (_) | |\n | |/ / | (___ ___ _ __ _ _ __ | |_\n | ( / \\___ \\ / __| '__| | '_ \\| __|\n | |/ ____) | (__| | | | |_) | |_\n | | |_____/ \\___|_| |_| .__/ \\__|\n `-.._________..-' | |\n |_|\n\n\n CoffeeScript is a little language that compiles into JavaScript.\n\n If you have the Node Package Manager installed:\n npm install -g coffee-script\n (Leave off the -g if you don't wish to install globally.)\n\n Or, if you don't wish to use npm:\n sudo bin/cake install\n\n Execute a script:\n coffee /path/to/script.coffee\n\n Compile a script:\n coffee -c /path/to/script.coffee\n\n For documentation, usage, and examples, see:\n http://coffeescript.org/\n\n To suggest a feature, report a bug, or general discussion:\n http://github.com/jashkenas/coffee-script/issues/\n\n If you'd like to chat, drop by #coffeescript on Freenode IRC,\n or on webchat.freenode.net.\n\n The source repository:\n git://github.com/jashkenas/coffee-script.git\n\n Top 100 contributors are listed here:\n http://github.com/jashkenas/coffee-script/contributors\n",
"readme": " {\n } } {\n { { } }\n } }{ {\n { }{ } } _____ __ __\n { }{ }{ { } / ____| / _|/ _|\n .- { { } { }} -. | | ___ | |_| |_ ___ ___\n ( { } { } { } } ) | | / _ \\| _| _/ _ \\/ _ \\\n |`-..________ ..-'| | |___| (_) | | | || __/ __/\n | | \\_____\\___/|_| |_| \\___|\\___|\n | ;--.\n | (__ \\ _____ _ _\n | | ) ) / ____| (_) | |\n | |/ / | (___ ___ _ __ _ _ __ | |_\n | ( / \\___ \\ / __| '__| | '_ \\| __|\n | |/ ____) | (__| | | | |_) | |_\n | | |_____/ \\___|_| |_| .__/ \\__|\n `-.._________..-' | |\n |_|\n\n\n CoffeeScript is a little language that compiles into JavaScript.\n\n If you have the Node Package Manager installed:\n npm install -g coffee-script\n (Leave off the -g if you don't wish to install globally.)\n\n Or, if you don't wish to use npm:\n sudo bin/cake install\n\n Execute a script:\n coffee /path/to/script.coffee\n\n Compile a script:\n coffee -c /path/to/script.coffee\n\n For documentation, usage, and examples, see:\n http://coffeescript.org/\n\n To suggest a feature, report a bug, or general discussion:\n http://github.com/jashkenas/coffeescript/issues/\n\n If you'd like to chat, drop by #coffeescript on Freenode IRC,\n or on webchat.freenode.net.\n\n The source repository:\n git://github.com/jashkenas/coffeescript.git\n\n Top 100 contributors are listed here:\n http://github.com/jashkenas/coffeescript/contributors\n",
"readmeFilename": "README",
"_id": "coffee-script@1.7.1",
"_from": "coffee-script@"
"_id": "coffee-script@1.8.0",
"dist": {
"shasum": "cb094abbaba89f95fb2bc75cb972c3d1f93cb262"
},
"_from": "coffee-script@",
"_resolved": "https://registry.npmjs.org/coffee-script/-/coffee-script-1.8.0.tgz"
}
module.exports = require('./lib/coffee-script/repl');
......@@ -38,5 +38,5 @@
"url": "https://github.com/expressjs/mime-types/issues"
},
"_id": "mime-types@1.0.2",
"_from": "mime-types@~1.0.0"
"_from": "mime-types@~1.0.1"
}
4.8.6 / 2014-08-27
==================
* deps: qs@2.2.0
- Array parsing fix
- Performance improvements
4.8.5 / 2014-08-18
==================
......@@ -407,6 +414,14 @@
- `app.route()` - Proxy to the app's `Router#route()` method to create a new route
- Router & Route - public API
3.16.8 / 2014-08-27
===================
* deps: connect@2.25.8
- deps: body-parser@~1.6.6
- deps: csurf@~1.4.1
- deps: qs@2.2.0
3.16.7 / 2014-08-18
===================
......
[![Express Logo](https://i.cloudup.com/zfY6lL7eFa-3000x3000.png)](https://expressjs.com/)
[![Express Logo](https://i.cloudup.com/zfY6lL7eFa-3000x3000.png)](http://expressjs.com/)
Fast, unopinionated, minimalist web framework for [node](http://nodejs.org).
......
......@@ -23,5 +23,6 @@
"url": "https://github.com/guille/ms.js/issues"
},
"_id": "ms@0.6.2",
"_from": "ms@0.6.2"
"_from": "ms@0.6.2",
"scripts": {}
}
......@@ -43,5 +43,6 @@
"url": "https://github.com/visionmedia/debug/issues"
},
"_id": "debug@1.0.4",
"_from": "debug@1.0.4"
"_from": "debug@1.0.4",
"scripts": {}
}
......@@ -20,7 +20,7 @@ var str = Qs.stringify(obj); // 'a=c'
### Parsing Objects
```javascript
Qs.parse(string, [depth], [delimiter]);
Qs.parse(string, [options]);
```
**qs** allows you to create nested objects within your query strings, by surrounding the name of sub-keys with square brackets `[]`.
......@@ -74,22 +74,36 @@ By default, when nesting objects **qs** will only parse up to 5 children deep. T
}
```
This depth can be overridden by passing a `depth` option to `Qs.parse(string, depth)`:
This depth can be overridden by passing a `depth` option to `Qs.parse(string, [options])`:
```javascript
Qs.parse('a[b][c][d][e][f][g][h][i]=j', 1);
Qs.parse('a[b][c][d][e][f][g][h][i]=j', { depth: 1 });
// { a: { b: { '[c][d][e][f][g][h][i]': 'j' } } }
```
The depth limit mitigate abuse when **qs** is used to parse user input, and it is recommended to keep it a reasonably small number.
The depth limit helps mitigate abuse when **qs** is used to parse user input, and it is recommended to keep it a reasonably small number.
For similar reasons, by default **qs** will only parse up to 1000 parameters. This can be overridden by passing a `parameterLimit` option:
```javascript
Qs.parse('a=b&c=d', { parameterLimit: 1 });
// { a: 'b' }
```
An optional delimiter can also be passed:
```javascript
Qs.parse('a=b;c=d', ';');
Qs.parse('a=b;c=d', { delimiter: ';' });
// { a: 'b', c: 'd' }
```
Delimiters can be a regular expression too:
```javascript
Qs.parse('a=b;c=d,e=f', { delimiter: /[;,]/ });
// { a: 'b', c: 'd', e: 'f' }
```
### Parsing Arrays
**qs** can also parse arrays using a similar `[]` notation:
......@@ -132,6 +146,13 @@ Qs.parse('a[100]=b');
// { a: { '100': 'b' } }
```
This limit can be overridden by passing an `arrayLimit` option:
```javascript
Qs.parse('a[1]=b', { arrayLimit: 0 });
// { a: { '1': 'b' } }
```
If you mix notations, **qs** will merge the two items into an object:
```javascript
......@@ -149,7 +170,7 @@ Qs.parse('a[][b]=c');
### Stringifying
```javascript
Qs.stringify(object, [delimiter]);
Qs.stringify(object, [options]);
```
When stringifying, **qs** always URI encodes output. Objects are stringified as you would expect:
......@@ -187,6 +208,6 @@ Qs.stringify({ a: null, b: undefined });
The delimiter may be overridden with stringify as well:
```javascript
Qs.stringify({ a: 'b', c: 'd' }, ';');
Qs.stringify({ a: 'b', c: 'd' }, { delimiter: ';' });
// 'a=b;c=d'
```
......@@ -9,16 +9,14 @@ var internals = {
delimiter: '&',
depth: 5,
arrayLimit: 20,
parametersLimit: 1000
parameterLimit: 1000
};
internals.parseValues = function (str, delimiter) {
delimiter = typeof delimiter === 'string' ? delimiter : internals.delimiter;
internals.parseValues = function (str, options) {
var obj = {};
var parts = str.split(delimiter, internals.parametersLimit);
var parts = str.split(options.delimiter, options.parameterLimit === Infinity ? undefined : options.parameterLimit);
for (var i = 0, il = parts.length; i < il; ++i) {
var part = parts[i];
......@@ -44,7 +42,7 @@ internals.parseValues = function (str, delimiter) {
};
internals.parseObject = function (chain, val) {
internals.parseObject = function (chain, val, options) {
if (!chain.length) {
return val;
......@@ -55,20 +53,20 @@ internals.parseObject = function (chain, val) {
var obj = {};
if (root === '[]') {
obj = [];
obj = obj.concat(internals.parseObject(chain, val));
obj = obj.concat(internals.parseObject(chain, val, options));
}
else {
var cleanRoot = root[0] === '[' && root[root.length - 1] === ']' ? root.slice(1, root.length - 1) : root;
var index = parseInt(cleanRoot, 10);
if (!isNaN(index) &&
root !== cleanRoot &&
index <= internals.arrayLimit) {
index <= options.arrayLimit) {
obj = [];
obj[index] = internals.parseObject(chain, val);
obj[index] = internals.parseObject(chain, val, options);
}
else {
obj[cleanRoot] = internals.parseObject(chain, val);
obj[cleanRoot] = internals.parseObject(chain, val, options);
}
}
......@@ -76,7 +74,7 @@ internals.parseObject = function (chain, val) {
};
internals.parseKeys = function (key, val, depth) {
internals.parseKeys = function (key, val, options) {
if (!key) {
return;
......@@ -107,7 +105,7 @@ internals.parseKeys = function (key, val, depth) {
// Loop through children appending to the array until we hit depth
var i = 0;
while ((segment = child.exec(key)) !== null && i < depth) {
while ((segment = child.exec(key)) !== null && i < options.depth) {
++i;
if (!Object.prototype.hasOwnProperty(segment[1].replace(/\[|\]/g, ''))) {
......@@ -121,11 +119,11 @@ internals.parseKeys = function (key, val, depth) {
keys.push('[' + key.slice(segment.index) + ']');
}
return internals.parseObject(keys, val);
return internals.parseObject(keys, val, options);
};
module.exports = function (str, depth, delimiter) {
module.exports = function (str, options) {
if (str === '' ||
str === null ||
......@@ -134,19 +132,20 @@ module.exports = function (str, depth, delimiter) {
return {};
}
if (typeof depth !== 'number') {
delimiter = depth;
depth = internals.depth;
}
options = options || {};
options.delimiter = typeof options.delimiter === 'string' || Utils.isRegExp(options.delimiter) ? options.delimiter : internals.delimiter;
options.depth = typeof options.depth === 'number' ? options.depth : internals.depth;
options.arrayLimit = typeof options.arrayLimit === 'number' ? options.arrayLimit : internals.arrayLimit;
options.parameterLimit = typeof options.parameterLimit === 'number' ? options.parameterLimit : internals.parameterLimit;
var tempObj = typeof str === 'string' ? internals.parseValues(str, delimiter) : Utils.clone(str);
var tempObj = typeof str === 'string' ? internals.parseValues(str, options) : Utils.clone(str);
var obj = {};
// Iterate over the keys and setup the new object
//
for (var key in tempObj) {
if (tempObj.hasOwnProperty(key)) {
var newObj = internals.parseKeys(key, tempObj[key], depth);
var newObj = internals.parseKeys(key, tempObj[key], options);
obj = Utils.merge(obj, newObj);
}
}
......
// Load modules
var Utils = require('./utils');
// Declare internals
......@@ -10,7 +12,7 @@ var internals = {
internals.stringify = function (obj, prefix) {
if (Buffer.isBuffer(obj)) {
if (Utils.isBuffer(obj)) {
obj = obj.toString();
}
else if (obj instanceof Date) {
......@@ -39,9 +41,10 @@ internals.stringify = function (obj, prefix) {
};
module.exports = function (obj, delimiter) {
module.exports = function (obj, options) {
delimiter = typeof delimiter === 'undefined' ? internals.delimiter : delimiter;
options = options || {};
var delimiter = typeof options.delimiter === 'undefined' ? internals.delimiter : options.delimiter;
var keys = [];
......
......@@ -28,7 +28,7 @@ exports.clone = function (source) {
return source;
}
if (Buffer.isBuffer(source)) {
if (exports.isBuffer(source)) {
return source.toString();
}
......@@ -49,25 +49,29 @@ exports.merge = function (target, source) {
return target;
}
var obj = exports.clone(target);
if (Array.isArray(source)) {
for (var i = 0, il = source.length; i < il; ++i) {
if (typeof source[i] !== 'undefined') {
if (typeof obj[i] === 'object') {
obj[i] = exports.merge(obj[i], source[i]);
if (typeof target[i] === 'object') {
target[i] = exports.merge(target[i], source[i]);
}
else {
obj[i] = source[i];
target[i] = source[i];
}
}
}
return obj;
return target;
}
if (Array.isArray(obj)) {
obj = exports.arrayToObject(obj);
if (Array.isArray(target)) {
if (typeof source !== 'object') {
target.push(source);
return target;
}
else {
target = exports.arrayToObject(target);
}
}
var keys = Object.keys(source);
......@@ -78,19 +82,19 @@ exports.merge = function (target, source) {
if (value &&
typeof value === 'object') {
if (!obj[key]) {
obj[key] = exports.clone(value);
if (!target[key]) {
target[key] = exports.clone(value);
}
else {
obj[key] = exports.merge(obj[key], value);
target[key] = exports.merge(target[key], value);
}
}
else {
obj[key] = value;
target[key] = value;
}
}
return obj;
return target;
};
......@@ -131,3 +135,19 @@ exports.compact = function (obj) {
return compacted;
};
exports.isRegExp = function (obj) {
return Object.prototype.toString.call(obj) === '[object RegExp]';
};
exports.isBuffer = function (obj) {
if (typeof Buffer !== 'undefined') {
return Buffer.isBuffer(obj);
}
else {
return false;
}
};
{
"name": "qs",
"version": "1.2.2",
"version": "2.2.0",
"description": "A querystring parser that supports nesting and arrays, with a depth limit",
"homepage": "https://github.com/hapijs/qs",
"main": "index.js",
......@@ -29,11 +29,11 @@
"url": "http://github.com/hapijs/qs/raw/master/LICENSE"
}
],
"readme": "# qs\n\nA querystring parsing and stringifying library with some added security.\n\n[![Build Status](https://secure.travis-ci.org/hapijs/qs.svg)](http://travis-ci.org/hapijs/qs)\n\nLead Maintainer: [Nathan LaFreniere](https://github.com/nlf)\n\nThe **qs** module was originally created and maintained by [TJ Holowaychuk](https://github.com/visionmedia/node-querystring).\n\n## Usage\n\n```javascript\nvar Qs = require('qs');\n\nvar obj = Qs.parse('a=c'); // { a: 'c' }\nvar str = Qs.stringify(obj); // 'a=c'\n```\n\n### Parsing Objects\n\n```javascript\nQs.parse(string, [depth], [delimiter]);\n```\n\n**qs** allows you to create nested objects within your query strings, by surrounding the name of sub-keys with square brackets `[]`.\nFor example, the string `'foo[bar]=baz'` converts to:\n\n```javascript\n{\n foo: {\n bar: 'baz'\n }\n}\n```\n\nURI encoded strings work too:\n\n```javascript\nQs.parse('a%5Bb%5D=c');\n// { a: { b: 'c' } }\n```\n\nYou can also nest your objects, like `'foo[bar][baz]=foobarbaz'`:\n\n```javascript\n{\n foo: {\n bar: {\n baz: 'foobarbaz'\n }\n }\n}\n```\n\nBy default, when nesting objects **qs** will only parse up to 5 children deep. This means if you attempt to parse a string like\n`'a[b][c][d][e][f][g][h][i]=j'` your resulting object will be:\n\n```javascript\n{\n a: {\n b: {\n c: {\n d: {\n e: {\n f: {\n '[g][h][i]': 'j'\n }\n }\n }\n }\n }\n }\n}\n```\n\nThis depth can be overridden by passing a `depth` option to `Qs.parse(string, depth)`:\n\n```javascript\nQs.parse('a[b][c][d][e][f][g][h][i]=j', 1);\n// { a: { b: { '[c][d][e][f][g][h][i]': 'j' } } }\n```\n\nThe depth limit mitigate abuse when **qs** is used to parse user input, and it is recommended to keep it a reasonably small number.\n\nAn optional delimiter can also be passed:\n\n```javascript\nQs.parse('a=b;c=d', ';');\n// { a: 'b', c: 'd' }\n```\n\n### Parsing Arrays\n\n**qs** can also parse arrays using a similar `[]` notation:\n\n```javascript\nQs.parse('a[]=b&a[]=c');\n// { a: ['b', 'c'] }\n```\n\nYou may specify an index as well:\n\n```javascript\nQs.parse('a[1]=c&a[0]=b');\n// { a: ['b', 'c'] }\n```\n\nNote that the only difference between an index in an array and a key in an object is that the value between the brackets must be a number\nto create an array. When creating arrays with specific indices, **qs** will compact a sparse array to only the existing values preserving\ntheir order:\n\n```javascript\nQs.parse('a[1]=b&a[15]=c');\n// { a: ['b', 'c'] }\n```\n\nNote that an empty string is also a value, and will be preserved:\n\n```javascript\nQs.parse('a[]=&a[]=b');\n// { a: ['', 'b'] }\nQs.parse('a[0]=b&a[1]=&a[2]=c');\n// { a: ['b', '', 'c'] }\n```\n\n**qs** will also limit specifying indices in an array to a maximum index of `20`. Any array members with an index of greater than `20` will\ninstead be converted to an object with the index as the key:\n\n```javascript\nQs.parse('a[100]=b');\n// { a: { '100': 'b' } }\n```\n\nIf you mix notations, **qs** will merge the two items into an object:\n\n```javascript\nQs.parse('a[0]=b&a[b]=c');\n// { a: { '0': 'b', b: 'c' } }\n```\n\nYou can also create arrays of objects:\n\n```javascript\nQs.parse('a[][b]=c');\n// { a: [{ b: 'c' }] }\n```\n\n### Stringifying\n\n```javascript\nQs.stringify(object, [delimiter]);\n```\n\nWhen stringifying, **qs** always URI encodes output. Objects are stringified as you would expect:\n\n```javascript\nQs.stringify({ a: 'b' });\n// 'a=b'\nQs.stringify({ a: { b: 'c' } });\n// 'a%5Bb%5D=c'\n```\n\nExamples beyond this point will be shown as though the output is not URI encoded for clarity. Please note that the return values in these cases *will* be URI encoded during real usage.\n\nWhen arrays are stringified, they are always given explicit indices:\n\n```javascript\nQs.stringify({ a: ['b', 'c', 'd'] });\n// 'a[0]=b&a[1]=c&a[2]=d'\n```\n\nEmpty strings and null values will omit the value, but the equals sign (=) remains in place:\n\n```javascript\nQs.stringify({ a: '' });\n// 'a='\n```\n\nProperties that are set to `undefined` will be omitted entirely:\n\n```javascript\nQs.stringify({ a: null, b: undefined });\n// 'a='\n```\n\nThe delimiter may be overridden with stringify as well:\n\n```javascript\nQs.stringify({ a: 'b', c: 'd' }, ';');\n// 'a=b;c=d'\n```\n",
"readme": "# qs\n\nA querystring parsing and stringifying library with some added security.\n\n[![Build Status](https://secure.travis-ci.org/hapijs/qs.svg)](http://travis-ci.org/hapijs/qs)\n\nLead Maintainer: [Nathan LaFreniere](https://github.com/nlf)\n\nThe **qs** module was originally created and maintained by [TJ Holowaychuk](https://github.com/visionmedia/node-querystring).\n\n## Usage\n\n```javascript\nvar Qs = require('qs');\n\nvar obj = Qs.parse('a=c'); // { a: 'c' }\nvar str = Qs.stringify(obj); // 'a=c'\n```\n\n### Parsing Objects\n\n```javascript\nQs.parse(string, [options]);\n```\n\n**qs** allows you to create nested objects within your query strings, by surrounding the name of sub-keys with square brackets `[]`.\nFor example, the string `'foo[bar]=baz'` converts to:\n\n```javascript\n{\n foo: {\n bar: 'baz'\n }\n}\n```\n\nURI encoded strings work too:\n\n```javascript\nQs.parse('a%5Bb%5D=c');\n// { a: { b: 'c' } }\n```\n\nYou can also nest your objects, like `'foo[bar][baz]=foobarbaz'`:\n\n```javascript\n{\n foo: {\n bar: {\n baz: 'foobarbaz'\n }\n }\n}\n```\n\nBy default, when nesting objects **qs** will only parse up to 5 children deep. This means if you attempt to parse a string like\n`'a[b][c][d][e][f][g][h][i]=j'` your resulting object will be:\n\n```javascript\n{\n a: {\n b: {\n c: {\n d: {\n e: {\n f: {\n '[g][h][i]': 'j'\n }\n }\n }\n }\n }\n }\n}\n```\n\nThis depth can be overridden by passing a `depth` option to `Qs.parse(string, [options])`:\n\n```javascript\nQs.parse('a[b][c][d][e][f][g][h][i]=j', { depth: 1 });\n// { a: { b: { '[c][d][e][f][g][h][i]': 'j' } } }\n```\n\nThe depth limit helps mitigate abuse when **qs** is used to parse user input, and it is recommended to keep it a reasonably small number.\n\nFor similar reasons, by default **qs** will only parse up to 1000 parameters. This can be overridden by passing a `parameterLimit` option:\n\n```javascript\nQs.parse('a=b&c=d', { parameterLimit: 1 });\n// { a: 'b' }\n```\n\nAn optional delimiter can also be passed:\n\n```javascript\nQs.parse('a=b;c=d', { delimiter: ';' });\n// { a: 'b', c: 'd' }\n```\n\nDelimiters can be a regular expression too:\n\n```javascript\nQs.parse('a=b;c=d,e=f', { delimiter: /[;,]/ });\n// { a: 'b', c: 'd', e: 'f' }\n```\n\n### Parsing Arrays\n\n**qs** can also parse arrays using a similar `[]` notation:\n\n```javascript\nQs.parse('a[]=b&a[]=c');\n// { a: ['b', 'c'] }\n```\n\nYou may specify an index as well:\n\n```javascript\nQs.parse('a[1]=c&a[0]=b');\n// { a: ['b', 'c'] }\n```\n\nNote that the only difference between an index in an array and a key in an object is that the value between the brackets must be a number\nto create an array. When creating arrays with specific indices, **qs** will compact a sparse array to only the existing values preserving\ntheir order:\n\n```javascript\nQs.parse('a[1]=b&a[15]=c');\n// { a: ['b', 'c'] }\n```\n\nNote that an empty string is also a value, and will be preserved:\n\n```javascript\nQs.parse('a[]=&a[]=b');\n// { a: ['', 'b'] }\nQs.parse('a[0]=b&a[1]=&a[2]=c');\n// { a: ['b', '', 'c'] }\n```\n\n**qs** will also limit specifying indices in an array to a maximum index of `20`. Any array members with an index of greater than `20` will\ninstead be converted to an object with the index as the key:\n\n```javascript\nQs.parse('a[100]=b');\n// { a: { '100': 'b' } }\n```\n\nThis limit can be overridden by passing an `arrayLimit` option:\n\n```javascript\nQs.parse('a[1]=b', { arrayLimit: 0 });\n// { a: { '1': 'b' } }\n```\n\nIf you mix notations, **qs** will merge the two items into an object:\n\n```javascript\nQs.parse('a[0]=b&a[b]=c');\n// { a: { '0': 'b', b: 'c' } }\n```\n\nYou can also create arrays of objects:\n\n```javascript\nQs.parse('a[][b]=c');\n// { a: [{ b: 'c' }] }\n```\n\n### Stringifying\n\n```javascript\nQs.stringify(object, [options]);\n```\n\nWhen stringifying, **qs** always URI encodes output. Objects are stringified as you would expect:\n\n```javascript\nQs.stringify({ a: 'b' });\n// 'a=b'\nQs.stringify({ a: { b: 'c' } });\n// 'a%5Bb%5D=c'\n```\n\nExamples beyond this point will be shown as though the output is not URI encoded for clarity. Please note that the return values in these cases *will* be URI encoded during real usage.\n\nWhen arrays are stringified, they are always given explicit indices:\n\n```javascript\nQs.stringify({ a: ['b', 'c', 'd'] });\n// 'a[0]=b&a[1]=c&a[2]=d'\n```\n\nEmpty strings and null values will omit the value, but the equals sign (=) remains in place:\n\n```javascript\nQs.stringify({ a: '' });\n// 'a='\n```\n\nProperties that are set to `undefined` will be omitted entirely:\n\n```javascript\nQs.stringify({ a: null, b: undefined });\n// 'a='\n```\n\nThe delimiter may be overridden with stringify as well:\n\n```javascript\nQs.stringify({ a: 'b', c: 'd' }, { delimiter: ';' });\n// 'a=b;c=d'\n```\n",
"readmeFilename": "README.md",
"bugs": {
"url": "https://github.com/hapijs/qs/issues"
},
"_id": "qs@1.2.2",
"_from": "qs@1.2.2"
"_id": "qs@2.2.0",
"_from": "qs@2.2.0"
}
......@@ -62,8 +62,8 @@ describe('#parse', function () {
it('only parses one level when depth = 1', function (done) {
expect(Qs.parse('a[b][c]=d', 1)).to.deep.equal({ a: { b: { '[c]': 'd' } } });
expect(Qs.parse('a[b][c][d]=e', 1)).to.deep.equal({ a: { b: { '[c][d]': 'e' } } });
expect(Qs.parse('a[b][c]=d', { depth: 1 })).to.deep.equal({ a: { b: { '[c]': 'd' } } });
expect(Qs.parse('a[b][c][d]=e', { depth: 1 })).to.deep.equal({ a: { b: { '[c][d]': 'e' } } });
done();
});
......@@ -247,15 +247,39 @@ describe('#parse', function () {
done();
});
it('parses a string with an alternative delimiter', function (done) {
it('parses a string with an alternative string delimiter', function (done) {
expect(Qs.parse('a=b;c=d', ';')).to.deep.equal({ a: 'b', c: 'd' });
expect(Qs.parse('a=b;c=d', { delimiter: ';' })).to.deep.equal({ a: 'b', c: 'd' });
done();
});
it('does not use non-string objects as delimiters', function (done) {
it('parses a string with an alternative RegExp delimiter', function (done) {
expect(Qs.parse('a=b&c=d', {})).to.deep.equal({ a: 'b', c: 'd' });
expect(Qs.parse('a=b; c=d', { delimiter: /[;,] */ })).to.deep.equal({ a: 'b', c: 'd' });
done();
});
it('does not use non-splittable objects as delimiters', function (done) {
expect(Qs.parse('a=b&c=d', { delimiter: true })).to.deep.equal({ a: 'b', c: 'd' });
done();
});
it('allows overriding parameter limit', function (done) {
expect(Qs.parse('a=b&c=d', { parameterLimit: 1 })).to.deep.equal({ a: 'b' });
done();
});
it('allows setting the parameter limit to Infinity', function (done) {
expect(Qs.parse('a=b&c=d', { parameterLimit: Infinity })).to.deep.equal({ a: 'b', c: 'd' });
done();
});
it('allows overriding array limit', function (done) {
expect(Qs.parse('a[0]=b&a[1]=c', { arrayLimit: 0 })).to.deep.equal({ a: { '0': 'b', '1': 'c' } });
done();
});
......@@ -298,4 +322,19 @@ describe('#parse', function () {
expect(result).to.deep.equal(expected);
done();
});
it('does not blow up when Buffer global is missing', function (done) {
var tempBuffer = global.Buffer;
delete global.Buffer;
expect(Qs.parse('a=b&c=d')).to.deep.equal({ a: 'b', c: 'd' });
global.Buffer = tempBuffer;
done();
});
it('does not crash when using invalid dot notation', function (done) {
expect(Qs.parse('roomInfoList[0].childrenAges[0]=15&roomInfoList[0].numberOfAdults=2')).to.deep.equal({ roomInfoList: [['15', '2']] });
done();
});
});
......@@ -123,7 +123,16 @@ describe('#stringify', function () {
it('stringifies an object using an alternative delimiter', function (done) {
expect(Qs.stringify({ a: 'b', c: 'd' }, ';')).to.equal('a=b;c=d');
expect(Qs.stringify({ a: 'b', c: 'd' }, { delimiter: ';' })).to.equal('a=b;c=d');
done();
});
it('doesn\'t blow up when Buffer global is missing', function (done) {
var tempBuffer = global.Buffer;
delete global.Buffer;
expect(Qs.stringify({ a: 'b', c: 'd' })).to.equal('a=b&c=d');
global.Buffer = tempBuffer;
done();
});
});
......@@ -29,5 +29,5 @@
"url": "https://github.com/visionmedia/node-range-parser/issues"
},
"_id": "range-parser@1.0.0",
"_from": "range-parser@1.0.0"
"_from": "range-parser@~1.0.0"
}
......@@ -23,5 +23,6 @@
"url": "https://github.com/guille/ms.js/issues"
},
"_id": "ms@0.6.2",
"_from": "ms@0.6.2"
"_from": "ms@0.6.2",
"scripts": {}
}
{
"name": "express",
"description": "Fast, unopinionated, minimalist web framework",
"version": "4.8.5",
"version": "4.8.6",
"author": {
"name": "TJ Holowaychuk",
"email": "tj@vision-media.ca"
......@@ -65,7 +65,7 @@
"parseurl": "~1.3.0",
"path-to-regexp": "0.1.3",
"proxy-addr": "1.0.1",
"qs": "1.2.2",
"qs": "2.2.0",
"range-parser": "1.0.0",
"send": "0.8.3",
"serve-static": "~1.5.3",
......@@ -87,8 +87,8 @@
"ejs": "~1.0.0",
"marked": "0.3.2",
"hjs": "~0.0.6",
"body-parser": "~1.6.5",
"cookie-parser": "~1.3.1",
"body-parser": "~1.6.6",
"cookie-parser": "~1.3.2",
"express-session": "~1.7.6",
"jade": "~1.5.0",
"method-override": "~2.1.3",
......@@ -105,11 +105,11 @@
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --require test/support/env --reporter dot --check-leaks test/ test/acceptance/",
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --require test/support/env --reporter spec --check-leaks test/ test/acceptance/"
},
"readme": "[![Express Logo](https://i.cloudup.com/zfY6lL7eFa-3000x3000.png)](https://expressjs.com/)\n\n Fast, unopinionated, minimalist web framework for [node](http://nodejs.org).\n\n [![NPM Version](https://img.shields.io/npm/v/express.svg?style=flat)](https://www.npmjs.org/package/express)\n [![Build Status](https://img.shields.io/travis/strongloop/express.svg?style=flat)](https://travis-ci.org/strongloop/express)\n [![Coverage Status](https://img.shields.io/coveralls/strongloop/express.svg?style=flat)](https://coveralls.io/r/strongloop/express)\n [![Gittip](https://img.shields.io/gittip/dougwilson.svg?style=flat)](https://www.gittip.com/dougwilson/)\n\n```js\nvar express = require('express')\nvar app = express()\n\napp.get('/', function (req, res) {\n res.send('Hello World')\n})\n\napp.listen(3000)\n```\n\n **PROTIP** Be sure to read [Migrating from 3.x to 4.x](https://github.com/strongloop/express/wiki/Migrating-from-3.x-to-4.x) as well as [New features in 4.x](https://github.com/strongloop/express/wiki/New-features-in-4.x).\n\n### Installation\n\n```bash\n$ npm install express\n```\n\n## Quick Start\n\n The quickest way to get started with express is to utilize the executable [`express(1)`](https://github.com/expressjs/generator) to generate an application as shown below:\n\n Install the executable. The executable's major version will match Express's:\n\n```bash\n$ npm install -g express-generator@4\n```\n\n Create the app:\n\n```bash\n$ express /tmp/foo && cd /tmp/foo\n```\n\n Install dependencies:\n\n```bash\n$ npm install\n```\n\n Start the server:\n\n```bash\n$ npm start\n```\n\n## Features\n\n * Robust routing\n * HTTP helpers (redirection, caching, etc)\n * View system supporting 14+ template engines\n * Content negotiation\n * Focus on high performance\n * Executable for generating applications quickly\n * High test coverage\n\n## Philosophy\n\n The Express philosophy is to provide small, robust tooling for HTTP servers, making\n it a great solution for single page applications, web sites, hybrids, or public\n HTTP APIs.\n\n Express does not force you to use any specific ORM or template engine. With support for over\n 14 template engines via [Consolidate.js](https://github.com/visionmedia/consolidate.js),\n you can quickly craft your perfect framework.\n\n## More Information\n\n * [Website and Documentation](http://expressjs.com/) - [[website repo](https://github.com/strongloop/expressjs.com)]\n * [Github Organization](https://github.com/expressjs) for Official Middleware & Modules\n * [#express](https://webchat.freenode.net/?channels=express) on freenode IRC\n * Visit the [Wiki](https://github.com/strongloop/express/wiki)\n * [Google Group](https://groups.google.com/group/express-js) for discussion\n * [Русскоязычная документация](http://jsman.ru/express/)\n * [한국어 문서](http://expressjs.kr) - [[website repo](https://github.com/Hanul/expressjs.kr)]\n * Run express examples [online](https://runnable.com/express)\n\n## Viewing Examples\n\n Clone the Express repo, then install the dev dependencies to install all the example / test suite dependencies:\n\n```bash\n$ git clone git://github.com/strongloop/express.git --depth 1\n$ cd express\n$ npm install\n```\n\n Then run whichever example you want:\n\n $ node examples/content-negotiation\n\n You can also view live examples here:\n\n <a href=\"https://runnable.com/express\" target=\"_blank\"><img src=\"https://runnable.com/external/styles/assets/runnablebtn.png\" style=\"width:67px;height:25px;\"></a>\n\n## Running Tests\n\n To run the test suite, first invoke the following command within the repo, installing the development dependencies:\n\n```bash\n$ npm install\n```\n\n Then run the tests:\n\n```bash\n$ npm test\n```\n\n### Contributors\n\n * Author: [TJ Holowaychuk](https://github.com/visionmedia)\n * Lead Maintainer: [Douglas Christopher Wilson](https://github.com/dougwilson)\n * [All Contributors](https://github.com/strongloop/express/graphs/contributors)\n\n### License\n\n [MIT](LICENSE)\n",
"readme": "[![Express Logo](https://i.cloudup.com/zfY6lL7eFa-3000x3000.png)](http://expressjs.com/)\n\n Fast, unopinionated, minimalist web framework for [node](http://nodejs.org).\n\n [![NPM Version](https://img.shields.io/npm/v/express.svg?style=flat)](https://www.npmjs.org/package/express)\n [![Build Status](https://img.shields.io/travis/strongloop/express.svg?style=flat)](https://travis-ci.org/strongloop/express)\n [![Coverage Status](https://img.shields.io/coveralls/strongloop/express.svg?style=flat)](https://coveralls.io/r/strongloop/express)\n [![Gittip](https://img.shields.io/gittip/dougwilson.svg?style=flat)](https://www.gittip.com/dougwilson/)\n\n```js\nvar express = require('express')\nvar app = express()\n\napp.get('/', function (req, res) {\n res.send('Hello World')\n})\n\napp.listen(3000)\n```\n\n **PROTIP** Be sure to read [Migrating from 3.x to 4.x](https://github.com/strongloop/express/wiki/Migrating-from-3.x-to-4.x) as well as [New features in 4.x](https://github.com/strongloop/express/wiki/New-features-in-4.x).\n\n### Installation\n\n```bash\n$ npm install express\n```\n\n## Quick Start\n\n The quickest way to get started with express is to utilize the executable [`express(1)`](https://github.com/expressjs/generator) to generate an application as shown below:\n\n Install the executable. The executable's major version will match Express's:\n\n```bash\n$ npm install -g express-generator@4\n```\n\n Create the app:\n\n```bash\n$ express /tmp/foo && cd /tmp/foo\n```\n\n Install dependencies:\n\n```bash\n$ npm install\n```\n\n Start the server:\n\n```bash\n$ npm start\n```\n\n## Features\n\n * Robust routing\n * HTTP helpers (redirection, caching, etc)\n * View system supporting 14+ template engines\n * Content negotiation\n * Focus on high performance\n * Executable for generating applications quickly\n * High test coverage\n\n## Philosophy\n\n The Express philosophy is to provide small, robust tooling for HTTP servers, making\n it a great solution for single page applications, web sites, hybrids, or public\n HTTP APIs.\n\n Express does not force you to use any specific ORM or template engine. With support for over\n 14 template engines via [Consolidate.js](https://github.com/visionmedia/consolidate.js),\n you can quickly craft your perfect framework.\n\n## More Information\n\n * [Website and Documentation](http://expressjs.com/) - [[website repo](https://github.com/strongloop/expressjs.com)]\n * [Github Organization](https://github.com/expressjs) for Official Middleware & Modules\n * [#express](https://webchat.freenode.net/?channels=express) on freenode IRC\n * Visit the [Wiki](https://github.com/strongloop/express/wiki)\n * [Google Group](https://groups.google.com/group/express-js) for discussion\n * [Русскоязычная документация](http://jsman.ru/express/)\n * [한국어 문서](http://expressjs.kr) - [[website repo](https://github.com/Hanul/expressjs.kr)]\n * Run express examples [online](https://runnable.com/express)\n\n## Viewing Examples\n\n Clone the Express repo, then install the dev dependencies to install all the example / test suite dependencies:\n\n```bash\n$ git clone git://github.com/strongloop/express.git --depth 1\n$ cd express\n$ npm install\n```\n\n Then run whichever example you want:\n\n $ node examples/content-negotiation\n\n You can also view live examples here:\n\n <a href=\"https://runnable.com/express\" target=\"_blank\"><img src=\"https://runnable.com/external/styles/assets/runnablebtn.png\" style=\"width:67px;height:25px;\"></a>\n\n## Running Tests\n\n To run the test suite, first invoke the following command within the repo, installing the development dependencies:\n\n```bash\n$ npm install\n```\n\n Then run the tests:\n\n```bash\n$ npm test\n```\n\n### Contributors\n\n * Author: [TJ Holowaychuk](https://github.com/visionmedia)\n * Lead Maintainer: [Douglas Christopher Wilson](https://github.com/dougwilson)\n * [All Contributors](https://github.com/strongloop/express/graphs/contributors)\n\n### License\n\n [MIT](LICENSE)\n",
"readmeFilename": "Readme.md",
"bugs": {
"url": "https://github.com/strongloop/express/issues"
},
"_id": "express@4.8.5",
"_id": "express@4.8.6",
"_from": "express@4.x"
}
......@@ -38,5 +38,5 @@
"url": "https://github.com/expressjs/mime-types/issues"
},
"_id": "mime-types@1.0.2",
"_from": "mime-types@~1.0.0"
"_from": "mime-types@~1.0.1"
}
......@@ -23,6 +23,5 @@
"url": "https://github.com/guille/ms.js/issues"
},
"_id": "ms@0.6.2",
"_from": "ms@0.6.2",
"scripts": {}
"_from": "ms@0.6.2"
}
......@@ -43,5 +43,6 @@
"url": "https://github.com/visionmedia/debug/issues"
},
"_id": "debug@1.0.4",
"_from": "debug@1.0.4"
"_from": "debug@1.0.4",
"scripts": {}
}
......@@ -23,5 +23,6 @@
"url": "https://github.com/guille/ms.js/issues"
},
"_id": "ms@0.6.2",
"_from": "ms@0.6.2"
"_from": "ms@0.6.2",
"scripts": {}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment