Socket
Socket
Sign inDemoInstall

coffeescript

Package Overview
Dependencies
Maintainers
3
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

coffeescript - npm Package Compare versions

Comparing version 1.5.0 to 1.6.0

lib/coffee-script/sourcemap.js

31

lib/coffee-script/browser.js

@@ -1,4 +0,5 @@

// Generated by CoffeeScript 1.5.0
// Generated by CoffeeScript 1.6.0
(function() {
var CoffeeScript, runScripts;
var CoffeeScript, 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; };

@@ -32,4 +33,7 @@ CoffeeScript = require('./coffee-script');

CoffeeScript.load = function(url, callback) {
CoffeeScript.load = function(url, callback, options) {
var xhr;
if (options == null) {
options = {};
}
xhr = window.ActiveXObject ? new window.ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest();

@@ -44,3 +48,3 @@ xhr.open('GET', url, true);

if ((_ref = xhr.status) === 0 || _ref === 200) {
CoffeeScript.run(xhr.responseText);
CoffeeScript.run(xhr.responseText, options);
} else {

@@ -58,10 +62,11 @@ throw new Error("Could not load " + url);

runScripts = function() {
var coffees, execute, index, length, s, scripts;
var coffees, coffeetypes, execute, index, length, s, scripts;
scripts = document.getElementsByTagName('script');
coffeetypes = ['text/coffeescript', 'text/literate-coffeescript'];
coffees = (function() {
var _i, _len, _results;
var _i, _len, _ref, _results;
_results = [];
for (_i = 0, _len = scripts.length; _i < _len; _i++) {
s = scripts[_i];
if (s.type === 'text/coffeescript') {
if (_ref = s.type, __indexOf.call(coffeetypes, _ref) >= 0) {
_results.push(s);

@@ -75,9 +80,13 @@ }

(execute = function() {
var script;
var mediatype, options, script;
script = coffees[index++];
if ((script != null ? script.type : void 0) === 'text/coffeescript') {
mediatype = script != null ? script.type : void 0;
if (__indexOf.call(coffeetypes, mediatype) >= 0) {
options = {
literate: mediatype === 'text/literate-coffeescript'
};
if (script.src) {
return CoffeeScript.load(script.src, execute);
return CoffeeScript.load(script.src, execute, options);
} else {
CoffeeScript.run(script.innerHTML);
CoffeeScript.run(script.innerHTML, options);
return execute();

@@ -84,0 +93,0 @@ }

@@ -1,2 +0,2 @@

// Generated by CoffeeScript 1.5.0
// Generated by CoffeeScript 1.6.0
(function() {

@@ -3,0 +3,0 @@ var CoffeeScript, cakefileDirectory, existsSync, fatalError, fs, helpers, missingTask, oparse, options, optparse, path, printTasks, switches, tasks;

@@ -1,5 +0,4 @@

// Generated by CoffeeScript 1.5.0
// Generated by CoffeeScript 1.6.0
(function() {
var Lexer, compile, ext, extensions, fs, lexer, loadFile, parser, path, vm, _i, _len,
__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; },
var Lexer, baseFileName, compile, ext, fs, helpers, lexer, loadFile, parser, path, sourcemap, vm, _i, _len, _ref,
__hasProp = {}.hasOwnProperty;

@@ -15,5 +14,7 @@

helpers = require('./helpers');
vm = require('vm');
extensions = ['.coffee', '.litcoffee'];
sourcemap = require('./sourcemap');

@@ -25,3 +26,4 @@ loadFile = function(module, filename) {

return module._compile(compile(stripped, {
filename: filename
filename: filename,
literate: helpers.isLiterate(filename)
}), filename);

@@ -31,4 +33,5 @@ };

if (require.extensions) {
for (_i = 0, _len = extensions.length; _i < _len; _i++) {
ext = extensions[_i];
_ref = ['.coffee', '.litcoffee', '.md', '.coffee.md'];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
ext = _ref[_i];
require.extensions[ext] = loadFile;

@@ -38,8 +41,14 @@ }

exports.VERSION = '1.5.0';
exports.VERSION = '1.6.0';
exports.helpers = require('./helpers');
baseFileName = function(fileName) {
var extension;
extension = path.extname(fileName);
return path.basename(fileName, extension);
};
exports.compile = compile = function(code, options) {
var header, js, merge;
var answer, coffeeFile, currentColumn, currentLine, fragment, fragments, header, js, jsFile, merge, newLines, sourceMap, _j, _len1;
if (options == null) {

@@ -50,6 +59,25 @@ options = {};

try {
js = (parser.parse(lexer.tokenize(code, options))).compile(options);
if (!options.header) {
return js;
if (options.sourceMap) {
coffeeFile = path.basename(options.filename);
jsFile = baseFileName(options.filename) + ".js";
sourceMap = new sourcemap.SourceMap();
}
fragments = (parser.parse(lexer.tokenize(code, options))).compileToFragments(options);
currentLine = 0;
currentColumn = 0;
js = "";
for (_j = 0, _len1 = fragments.length; _j < _len1; _j++) {
fragment = fragments[_j];
if (sourceMap) {
if (fragment.locationData) {
sourceMap.addMapping([fragment.locationData.first_line, fragment.locationData.first_column], [currentLine, currentColumn], {
noReplace: true
});
}
newLines = helpers.count(fragment.code, "\n");
currentLine += newLines;
currentColumn = fragment.code.length - (newLines ? fragment.code.lastIndexOf("\n") : 0);
}
js += fragment.code;
}
} catch (err) {

@@ -61,4 +89,18 @@ if (options.filename) {

}
header = "Generated by CoffeeScript " + this.VERSION;
return "// " + header + "\n" + js;
if (options.header) {
header = "Generated by CoffeeScript " + this.VERSION;
js = "// " + header + "\n" + js;
}
if (options.sourceMap || options.returnObject) {
answer = {
js: js
};
if (sourceMap) {
answer.sourceMap = sourceMap;
answer.v3SourceMap = sourcemap.generateV3SourceMap(sourceMap, coffeeFile, jsFile);
}
return answer;
} else {
return js;
}
};

@@ -79,3 +121,3 @@

exports.run = function(code, options) {
var mainModule, _ref;
var mainModule;
if (options == null) {

@@ -88,3 +130,3 @@ options = {};

mainModule.paths = require('module')._nodeModulePaths(path.dirname(fs.realpathSync(options.filename)));
if ((_ref = path.extname(mainModule.filename), __indexOf.call(extensions, _ref) < 0) || require.extensions) {
if (!helpers.isCoffee(mainModule.filename) || require.extensions) {
return mainModule._compile(compile(code, options), mainModule.filename);

@@ -97,3 +139,3 @@ } else {

exports["eval"] = function(code, options) {
var Module, Script, js, k, o, r, sandbox, v, _j, _len1, _module, _ref, _ref1, _require;
var Module, Script, js, k, o, r, sandbox, v, _j, _len1, _module, _ref1, _ref2, _require;
if (options == null) {

@@ -112,6 +154,6 @@ options = {};

sandbox = Script.createContext();
_ref = options.sandbox;
for (k in _ref) {
if (!__hasProp.call(_ref, k)) continue;
v = _ref[k];
_ref1 = options.sandbox;
for (k in _ref1) {
if (!__hasProp.call(_ref1, k)) continue;
v = _ref1[k];
sandbox[k] = v;

@@ -133,5 +175,5 @@ }

_module.filename = sandbox.__filename;
_ref1 = Object.getOwnPropertyNames(require);
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
r = _ref1[_j];
_ref2 = Object.getOwnPropertyNames(require);
for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) {
r = _ref2[_j];
if (r !== 'paths') {

@@ -138,0 +180,0 @@ _require[r] = require[r];

@@ -1,5 +0,4 @@

// Generated by CoffeeScript 1.5.0
// Generated by CoffeeScript 1.6.0
(function() {
var BANNER, CoffeeScript, EventEmitter, SWITCHES, coffee_exts, compileJoin, compileOptions, compilePath, compileScript, compileStdio, exec, exists, forkNode, fs, helpers, hidden, joinTimeout, lint, notSources, optionParser, optparse, opts, outputPath, parseOptions, path, printLine, printTokens, printWarn, removeSource, sourceCode, sources, spawn, timeLog, unwatchDir, usage, version, wait, watch, watchDir, watchers, 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; };
var BANNER, CoffeeScript, EventEmitter, SWITCHES, compileJoin, compileOptions, compilePath, compileScript, compileStdio, exec, exists, forkNode, fs, helpers, hidden, joinTimeout, lint, notSources, optionParser, optparse, opts, outputPath, parseOptions, path, printLine, printTokens, printWarn, removeSource, sourceCode, sources, spawn, timeLog, unwatchDir, usage, version, wait, watch, watchDir, watchers, writeJs, _ref;

@@ -38,3 +37,3 @@ fs = require('fs');

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'], ['-l', '--lint', 'pipe the compiled JavaScript through JavaScript Lint'], ['-n', '--nodes', 'print out the parse tree that the parser produces'], ['--nodejs [ARGS]', 'pass options directly to the "node" binary'], ['-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'], ['-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'], ['-l', '--lint', 'pipe the compiled JavaScript through JavaScript Lint'], ['-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'], ['-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'], ['-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']];

@@ -53,4 +52,2 @@ opts = {};

coffee_exts = ['.coffee', '.litcoffee'];
exports.run = function() {

@@ -96,3 +93,2 @@ var literals, source, _i, _len, _results;

return fs.stat(source, function(err, stats) {
var _ref1, _ref2;
if (err && err.code !== 'ENOENT') {

@@ -102,11 +98,4 @@ throw err;

if ((err != null ? err.code : void 0) === 'ENOENT') {
if (topLevel && source && (_ref1 = path.extname(source), __indexOf.call(coffee_exts, _ref1) < 0)) {
source = sources[sources.indexOf(source)] = "" + source + ".coffee";
return compilePath(source, topLevel, base);
}
if (topLevel) {
console.error("File not found: " + source);
process.exit(1);
}
return;
console.error("File not found: " + source);
process.exit(1);
}

@@ -118,3 +107,3 @@ if (stats.isDirectory() && path.dirname(source) !== 'node_modules') {

return fs.readdir(source, function(err, files) {
var file, index, _ref2, _ref3;
var file, index, _ref1, _ref2;
if (err && err.code !== 'ENOENT') {

@@ -130,3 +119,3 @@ throw err;

});
[].splice.apply(sources, [index, index - index + 1].concat(_ref2 = (function() {
[].splice.apply(sources, [index, index - index + 1].concat(_ref1 = (function() {
var _i, _len, _results;

@@ -139,6 +128,6 @@ _results = [];

return _results;
})())), _ref2;
[].splice.apply(sourceCode, [index, index - index + 1].concat(_ref3 = files.map(function() {
})())), _ref1;
[].splice.apply(sourceCode, [index, index - index + 1].concat(_ref2 = files.map(function() {
return null;
}))), _ref3;
}))), _ref2;
return files.forEach(function(file) {

@@ -148,3 +137,3 @@ return compilePath(path.join(source, file), false, base);

});
} else if (topLevel || (_ref2 = path.extname(source), __indexOf.call(coffee_exts, _ref2) >= 0)) {
} else if (topLevel || helpers.isCoffee(source)) {
if (opts.watch) {

@@ -170,3 +159,3 @@ watch(source, base);

compileScript = function(file, input, base) {
var o, options, t, task;
var compiled, o, options, t, task;
o = opts;

@@ -191,8 +180,10 @@ options = compileOptions(file);

} else {
t.output = CoffeeScript.compile(t.input, t.options);
compiled = CoffeeScript.compile(t.input, t.options);
t.output = compiled.js;
t.sourceMap = compiled.v3SourceMap;
CoffeeScript.emit('success', task);
if (o.print) {
return printLine(t.output.trim());
} else if (o.compile) {
return writeJs(t.file, t.output, base);
} else if (o.compile || o.map) {
return writeJs(base, t.file, t.output, t.sourceMap);
} else if (o.lint) {

@@ -388,26 +379,45 @@ return lint(t.file, t.output);

outputPath = function(source, base) {
var baseDir, dir, filename, srcDir;
filename = path.basename(source, path.extname(source)) + '.js';
outputPath = function(source, base, extension) {
var baseDir, basename, dir, srcDir, _ref1;
if (extension == null) {
extension = ".js";
}
basename = path.basename(source, ((_ref1 = source.match(/\.((lit)?coffee|coffee\.md)$/)) != null ? _ref1[0] : void 0) || path.extname(source));
srcDir = path.dirname(source);
baseDir = base === '.' ? srcDir : srcDir.substring(base.length);
dir = opts.output ? path.join(opts.output, baseDir) : srcDir;
return path.join(dir, filename);
return path.join(dir, basename + extension);
};
writeJs = function(source, js, base) {
var compile, jsDir, jsPath;
jsPath = outputPath(source, base);
writeJs = function(base, sourcePath, js, generatedSourceMap) {
var compile, jsDir, jsPath, sourceMapPath;
if (generatedSourceMap == null) {
generatedSourceMap = null;
}
jsPath = outputPath(sourcePath, base);
sourceMapPath = outputPath(sourcePath, base, ".map");
jsDir = path.dirname(jsPath);
compile = function() {
if (js.length <= 0) {
js = ' ';
if (opts.compile) {
if (js.length <= 0) {
js = ' ';
}
if (generatedSourceMap) {
js = "//@ sourceMappingURL=" + (path.basename(sourceMapPath)) + "\n" + js;
}
fs.writeFile(jsPath, js, function(err) {
if (err) {
return printLine(err.message);
} else if (opts.compile && opts.watch) {
return timeLog("compiled " + sourcePath);
}
});
}
return fs.writeFile(jsPath, js, function(err) {
if (err) {
return printLine(err.message);
} else if (opts.compile && opts.watch) {
return timeLog("compiled " + source);
}
});
if (generatedSourceMap) {
return fs.writeFile(sourceMapPath, generatedSourceMap, function(err) {
if (err) {
return printLine("Could not write source map: " + err.message);
}
});
}
};

@@ -445,3 +455,3 @@ return exists(jsDir, function(itExists) {

printTokens = function(tokens) {
var locationData, strings, tag, token, value;
var strings, tag, token, value;
strings = (function() {

@@ -454,4 +464,3 @@ var _i, _len, _results;

value = token[1].toString().replace(/\n/, '\\n');
locationData = helpers.locationDataToString(token[2]);
_results.push("[" + tag + " " + value + " " + locationData + "]");
_results.push("[" + tag + " " + value + "]");
}

@@ -468,3 +477,3 @@ return _results;

o.compile || (o.compile = !!o.output);
o.run = !(o.compile || o.print || o.lint);
o.run = !(o.compile || o.print || o.lint || o.map);
o.print = !!(o.print || (o["eval"] || o.stdio && o.compile));

@@ -479,9 +488,9 @@ sources = o["arguments"];

compileOptions = function(filename) {
var literate;
literate = path.extname(filename) === '.litcoffee';
return {
filename: filename,
literate: literate,
literate: helpers.isLiterate(filename),
bare: opts.bare,
header: opts.compile
header: opts.compile,
sourceMap: opts.map,
returnObject: true
};

@@ -488,0 +497,0 @@ };

@@ -1,2 +0,2 @@

// Generated by CoffeeScript 1.5.0
// Generated by CoffeeScript 1.6.0
(function() {

@@ -19,3 +19,2 @@ var Parser, alt, alternatives, grammar, name, o, operators, token, tokens, unwrap;

action = action.replace(/\b(?:Block\.wrap|extend)\b/g, 'yy.$&');
action = action.replace(/\b(Op|Value\.(create|wrap))\b/g, 'yy.$&');
addLocationDataFn = function(first, last) {

@@ -98,8 +97,8 @@ if (!last) {

o('ObjAssignable', function() {
return Value.wrap($1);
return new Value($1);
}), o('ObjAssignable : Expression', function() {
return new Assign(LOC(1)(Value.wrap($1)), $3, 'object');
return new Assign(LOC(1)(new Value($1)), $3, 'object');
}), o('ObjAssignable :\
INDENT Expression OUTDENT', function() {
return new Assign(LOC(1)(Value.wrap($1)), $4, 'object');
return new Assign(LOC(1)(new Value($1)), $4, 'object');
}), o('Comment')

@@ -165,7 +164,7 @@ ],

o('Identifier', function() {
return Value.wrap($1);
return new Value($1);
}), o('Value Accessor', function() {
return $1.add($2);
}), o('Invocation Accessor', function() {
return Value.wrap($1, [].concat($2));
return new Value($1, [].concat($2));
}), o('ThisProperty')

@@ -175,5 +174,5 @@ ],

o('SimpleAssignable'), o('Array', function() {
return Value.wrap($1);
return new Value($1);
}), o('Object', function() {
return Value.wrap($1);
return new Value($1);
})

@@ -183,7 +182,7 @@ ],

o('Assignable'), o('Literal', function() {
return Value.wrap($1);
return new Value($1);
}), o('Parenthetical', function() {
return Value.wrap($1);
return new Value($1);
}), o('Range', function() {
return Value.wrap($1);
return new Value($1);
}), o('This')

@@ -198,2 +197,4 @@ ],

return [LOC(1)(new Access(new Literal('prototype'))), LOC(2)(new Access($2))];
}), o('?:: Identifier', function() {
return [LOC(1)(new Access(new Literal('prototype'), 'soak')), LOC(2)(new Access($2))];
}), o('::', function() {

@@ -283,5 +284,5 @@ return new Access(new Literal('prototype'));

o('THIS', function() {
return Value.wrap(new Literal('this'));
return new Value(new Literal('this'));
}), o('@', function() {
return Value.wrap(new Literal('this'));
return new Value(new Literal('this'));
})

@@ -291,3 +292,3 @@ ],

o('@ Identifier', function() {
return Value.wrap(LOC(1)(new Literal('this')), [LOC(2)(new Access($2))], 'this');
return new Value(LOC(1)(new Literal('this')), [LOC(2)(new Access($2))], 'this');
})

@@ -359,3 +360,3 @@ ],

}), o('CATCH Object Block', function() {
return [LOC(2)(Value.wrap($2)), $3];
return [LOC(2)(new Value($2)), $3];
})

@@ -423,3 +424,3 @@ ],

return {
source: LOC(2)(Value.wrap($2))
source: LOC(2)(new Value($2))
};

@@ -443,5 +444,5 @@ }), o('ForStart ForSource', function() {

o('Identifier'), o('ThisProperty'), o('Array', function() {
return Value.wrap($1);
return new Value($1);
}), o('Object', function() {
return Value.wrap($1);
return new Value($1);
})

@@ -547,38 +548,38 @@ ],

o('UNARY Expression', function() {
return Op.create($1, $2);
return new Op($1, $2);
}), o('- Expression', (function() {
return Op.create('-', $2);
return new Op('-', $2);
}), {
prec: 'UNARY'
}), o('+ Expression', (function() {
return Op.create('+', $2);
return new Op('+', $2);
}), {
prec: 'UNARY'
}), o('-- SimpleAssignable', function() {
return Op.create('--', $2);
return new Op('--', $2);
}), o('++ SimpleAssignable', function() {
return Op.create('++', $2);
return new Op('++', $2);
}), o('SimpleAssignable --', function() {
return Op.create('--', $1, null, true);
return new Op('--', $1, null, true);
}), o('SimpleAssignable ++', function() {
return Op.create('++', $1, null, true);
return new Op('++', $1, null, true);
}), o('Expression ?', function() {
return new Existence($1);
}), o('Expression + Expression', function() {
return Op.create('+', $1, $3);
return new Op('+', $1, $3);
}), o('Expression - Expression', function() {
return Op.create('-', $1, $3);
return new Op('-', $1, $3);
}), o('Expression MATH Expression', function() {
return Op.create($2, $1, $3);
return new Op($2, $1, $3);
}), o('Expression SHIFT Expression', function() {
return Op.create($2, $1, $3);
return new Op($2, $1, $3);
}), o('Expression COMPARE Expression', function() {
return Op.create($2, $1, $3);
return new Op($2, $1, $3);
}), o('Expression LOGIC Expression', function() {
return Op.create($2, $1, $3);
return new Op($2, $1, $3);
}), o('Expression RELATION Expression', function() {
if ($2.charAt(0) === '!') {
return Op.create($2.slice(1), $1, $3).invert();
return new Op($2.slice(1), $1, $3).invert();
} else {
return Op.create($2, $1, $3);
return new Op($2, $1, $3);
}

@@ -600,3 +601,3 @@ }), o('SimpleAssignable COMPOUND_ASSIGN\

operators = [['left', '.', '?.', '::'], ['left', 'CALL_START', 'CALL_END'], ['nonassoc', '++', '--'], ['left', '?'], ['right', 'UNARY'], ['left', 'MATH'], ['left', '+', '-'], ['left', 'SHIFT'], ['left', 'RELATION'], ['left', 'COMPARE'], ['left', 'LOGIC'], ['nonassoc', 'INDENT', 'OUTDENT'], ['right', '=', ':', 'COMPOUND_ASSIGN', 'RETURN', 'THROW', 'EXTENDS'], ['right', 'FORIN', 'FOROF', 'BY', 'WHEN'], ['right', 'IF', 'ELSE', 'FOR', 'WHILE', 'UNTIL', 'LOOP', 'SUPER', 'CLASS'], ['right', 'POST_IF']];
operators = [['left', '.', '?.', '::', '?::'], ['left', 'CALL_START', 'CALL_END'], ['nonassoc', '++', '--'], ['left', '?'], ['right', 'UNARY'], ['left', 'MATH'], ['left', '+', '-'], ['left', 'SHIFT'], ['left', 'RELATION'], ['left', 'COMPARE'], ['left', 'LOGIC'], ['nonassoc', 'INDENT', 'OUTDENT'], ['right', '=', ':', 'COMPOUND_ASSIGN', 'RETURN', 'THROW', 'EXTENDS'], ['right', 'FORIN', 'FOROF', 'BY', 'WHEN'], ['right', 'IF', 'ELSE', 'FOR', 'WHILE', 'UNTIL', 'LOOP', 'SUPER', 'CLASS'], ['right', 'POST_IF']];

@@ -603,0 +604,0 @@ tokens = [];

@@ -1,2 +0,2 @@

// Generated by CoffeeScript 1.5.0
// Generated by CoffeeScript 1.6.0
(function() {

@@ -124,2 +124,10 @@ var buildLocationData, extend, flatten, _ref;

exports.isCoffee = function(file) {
return /\.((lit)?coffee|coffee\.md)$/.test(file);
};
exports.isLiterate = function(file) {
return /\.(litcoffee|coffee\.md)$/.test(file);
};
}).call(this);

@@ -1,2 +0,2 @@

// Generated by CoffeeScript 1.5.0
// Generated by CoffeeScript 1.6.0
(function() {

@@ -3,0 +3,0 @@ var key, val, _ref;

@@ -1,2 +0,2 @@

// Generated by CoffeeScript 1.5.0
// Generated by CoffeeScript 1.6.0
(function() {

@@ -20,3 +20,2 @@ 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, INDEXABLE, INVERSES, JSTOKEN, JS_FORBIDDEN, JS_KEYWORDS, LINE_BREAK, LINE_CONTINUER, LITERATE, LOGIC, Lexer, MATH, MULTILINER, MULTI_DENT, NOT_REGEX, NOT_SPACED_REGEX, NUMBER, OPERATOR, REGEX, RELATION, RESERVED, Rewriter, SHIFT, SIMPLESTR, STRICT_PROSCRIBED, TRAILING_SPACES, UNARY, WHITESPACE, compact, count, key, last, locationDataToString, starts, _ref, _ref1,

this.literate = opts.literate;
code = this.clean(code);
this.indent = 0;

@@ -30,2 +29,3 @@ this.indebt = 0;

this.chunkColumn = opts.column || 0;
code = this.clean(code);
i = 0;

@@ -52,6 +52,7 @@ while (this.chunk = code.slice(i)) {

}
code = code.replace(/\r/g, '').replace(TRAILING_SPACES, '');
if (WHITESPACE.test(code)) {
code = "\n" + code;
this.chunkLine--;
}
code = code.replace(/\r/g, '').replace(TRAILING_SPACES, '');
if (this.literate) {

@@ -89,3 +90,3 @@ lines = (function() {

}
forcedIdentifier = colon || (prev = last(this.tokens)) && (((_ref2 = prev[0]) === '.' || _ref2 === '?.' || _ref2 === '::') || !prev.spaced && prev[0] === '@');
forcedIdentifier = colon || (prev = last(this.tokens)) && (((_ref2 = prev[0]) === '.' || _ref2 === '?.' || _ref2 === '::' || _ref2 === '?::') || !prev.spaced && prev[0] === '@');
tag = 'IDENTIFIER';

@@ -533,2 +534,5 @@ if (!forcedIdentifier && (__indexOf.call(JS_KEYWORDS, id) >= 0 || __indexOf.call(COFFEE_KEYWORDS, id) >= 0)) {

}
if (this.literate) {
doc = doc.replace(/\n# \n/g, '\n\n');
}
if (!herecomment) {

@@ -740,4 +744,6 @@ doc = doc.replace(/^\n/, '');

var lastCharacter, locationData, token, _ref2, _ref3;
offsetInChunk = offsetInChunk || 0;
if (length === void 0) {
if (offsetInChunk == null) {
offsetInChunk = 0;
}
if (length == null) {
length = value.length;

@@ -747,3 +753,3 @@ }

_ref2 = this.getLineAndColumnFromChunk(offsetInChunk), locationData.first_line = _ref2[0], locationData.first_column = _ref2[1];
lastCharacter = length > 0 ? length - 1 : 0;
lastCharacter = Math.max(0, length - 1);
_ref3 = this.getLineAndColumnFromChunk(offsetInChunk + (length - 1)), locationData.last_line = _ref3[0], locationData.last_column = _ref3[1];

@@ -773,3 +779,3 @@ token = [tag, value, locationData];

var _ref2;
return LINE_CONTINUER.test(this.chunk) || ((_ref2 = this.tag()) === '\\' || _ref2 === '.' || _ref2 === '?.' || _ref2 === 'UNARY' || _ref2 === 'MATH' || _ref2 === '+' || _ref2 === '-' || _ref2 === 'SHIFT' || _ref2 === 'RELATION' || _ref2 === 'COMPARE' || _ref2 === 'LOGIC' || _ref2 === 'THROW' || _ref2 === 'EXTENDS');
return LINE_CONTINUER.test(this.chunk) || ((_ref2 = this.tag()) === '\\' || _ref2 === '.' || _ref2 === '?.' || _ref2 === '?::' || _ref2 === 'UNARY' || _ref2 === 'MATH' || _ref2 === '+' || _ref2 === '-' || _ref2 === 'SHIFT' || _ref2 === 'RELATION' || _ref2 === 'COMPARE' || _ref2 === 'LOGIC' || _ref2 === 'THROW' || _ref2 === 'EXTENDS');
};

@@ -849,3 +855,3 @@

OPERATOR = /^(?:[-=]>|[-+*\/%<>&|^!?=]=|>>>=?|([-+:])\1|([&|<>])\2=?|\?\.|\.{2,3})/;
OPERATOR = /^(?:[-=]>|[-+*\/%<>&|^!?=]=|>>>=?|([-+:])\1|([&|<>])\2=?|\?(\.|::)|\.{2,3})/;

@@ -852,0 +858,0 @@ WHITESPACE = /^[^\n\S]+/;

@@ -1,2 +0,2 @@

// Generated by CoffeeScript 1.5.0
// Generated by CoffeeScript 1.6.0
(function() {

@@ -3,0 +3,0 @@ var LONG_FLAG, MULTI_FLAG, OPTIONAL, OptionParser, SHORT_FLAG, buildRule, buildRules, normalizeArguments;

@@ -1,2 +0,2 @@

// Generated by CoffeeScript 1.5.0
// Generated by CoffeeScript 1.6.0
(function() {

@@ -19,3 +19,3 @@ var CoffeeScript, addMultilineHandler, merge, nodeREPL, replDefaults, vm;

input = input.replace(/(^|[\r\n]+)(\s*)##?(?:[^#\r\n][^\r\n]*|)($|[\r\n])/, '$1$2$3');
if (/^\s*$/.test(input)) {
if (/^(\s*|\(\s*\))$/.test(input)) {
return cb(null);

@@ -28,6 +28,6 @@ }

});
return cb(null, vm.runInContext(js, context, filename));
} catch (err) {
cb(err);
return cb(err);
}
return cb(null, vm.runInContext(js, context, filename));
}

@@ -34,0 +34,0 @@ };

@@ -1,7 +0,14 @@

// Generated by CoffeeScript 1.5.0
// Generated by CoffeeScript 1.6.0
(function() {
var BALANCED_PAIRS, EXPRESSION_CLOSE, EXPRESSION_END, EXPRESSION_START, IMPLICIT_BLOCK, IMPLICIT_CALL, IMPLICIT_END, IMPLICIT_FUNC, IMPLICIT_UNSPACED_CALL, INVERSES, LINEBREAKS, SINGLE_CLOSERS, SINGLE_LINERS, left, rite, _i, _len, _ref,
var BALANCED_PAIRS, EXPRESSION_CLOSE, EXPRESSION_END, EXPRESSION_START, IMPLICIT_BLOCK, 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; },
__slice = [].slice;
generate = function(tag, value) {
var tok;
tok = [tag, value];
tok.generated = true;
return tok;
};
exports.Rewriter = (function() {

@@ -19,4 +26,3 @@

this.tagPostfixConditionals();
this.addImplicitBraces();
this.addImplicitParentheses();
this.addImplicitBracesAndParens();
this.addLocationDataToGeneratedTokens();

@@ -116,111 +122,210 @@ return this.tokens;

Rewriter.prototype.addImplicitBraces = function() {
var action, condition, sameLine, stack, start, startIndent, startIndex, startsLine;
stack = [];
start = null;
startsLine = null;
sameLine = true;
startIndent = 0;
startIndex = 0;
condition = function(token, i) {
var one, tag, three, two, _ref, _ref1;
_ref = this.tokens.slice(i + 1, +(i + 3) + 1 || 9e9), one = _ref[0], two = _ref[1], three = _ref[2];
if ('HERECOMMENT' === (one != null ? one[0] : void 0)) {
return false;
Rewriter.prototype.matchTags = function() {
var fuzz, i, j, pattern, _i, _ref, _ref1;
i = arguments[0], pattern = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
fuzz = 0;
for (j = _i = 0, _ref = pattern.length; 0 <= _ref ? _i < _ref : _i > _ref; j = 0 <= _ref ? ++_i : --_i) {
while (this.tag(i + j + fuzz) === 'HERECOMMENT') {
fuzz += 2;
}
tag = token[0];
if (__indexOf.call(LINEBREAKS, tag) >= 0) {
sameLine = false;
if (pattern[j] == null) {
continue;
}
return (((tag === 'TERMINATOR' || tag === 'OUTDENT') || (__indexOf.call(IMPLICIT_END, tag) >= 0 && sameLine && !(i - startIndex === 1))) && ((!startsLine && this.tag(i - 1) !== ',') || !((two != null ? two[0] : void 0) === ':' || (one != null ? one[0] : void 0) === '@' && (three != null ? three[0] : void 0) === ':'))) || (tag === ',' && one && ((_ref1 = one[0]) !== 'IDENTIFIER' && _ref1 !== 'NUMBER' && _ref1 !== 'STRING' && _ref1 !== '@' && _ref1 !== 'TERMINATOR' && _ref1 !== 'OUTDENT'));
};
action = function(token, i) {
var tok;
tok = this.generate('}', '}');
return this.tokens.splice(i, 0, tok);
};
return this.scanTokens(function(token, i, tokens) {
var ago, idx, prevTag, tag, tok, value, _ref, _ref1;
if (_ref = (tag = token[0]), __indexOf.call(EXPRESSION_START, _ref) >= 0) {
stack.push([(tag === 'INDENT' && this.tag(i - 1) === '{' ? '{' : tag), i]);
return 1;
if (typeof pattern[j] === 'string') {
pattern[j] = [pattern[j]];
}
if (__indexOf.call(EXPRESSION_END, tag) >= 0) {
start = stack.pop();
return 1;
if (_ref1 = this.tag(i + j + fuzz), __indexOf.call(pattern[j], _ref1) < 0) {
return false;
}
if (!(tag === ':' && ((ago = this.tag(i - 2)) === ':' || ((_ref1 = stack[stack.length - 1]) != null ? _ref1[0] : void 0) !== '{'))) {
return 1;
}
return true;
};
Rewriter.prototype.looksObjectish = function(j) {
return this.matchTags(j, '@', null, ':') || this.matchTags(j, null, ':');
};
Rewriter.prototype.findTagsBackwards = function(i, tags) {
var backStack, _ref, _ref1, _ref2, _ref3, _ref4, _ref5;
backStack = [];
while (i >= 0 && (backStack.length || (_ref2 = this.tag(i), __indexOf.call(tags, _ref2) < 0) && ((_ref3 = this.tag(i), __indexOf.call(EXPRESSION_START, _ref3) < 0) || this.tokens[i].generated) && (_ref4 = this.tag(i), __indexOf.call(LINEBREAKS, _ref4) < 0))) {
if (_ref = this.tag(i), __indexOf.call(EXPRESSION_END, _ref) >= 0) {
backStack.push(this.tag(i));
}
sameLine = true;
startIndex = i + 1;
stack.push(['{']);
idx = ago === '@' ? i - 2 : i - 1;
while (this.tag(idx - 2) === 'HERECOMMENT') {
idx -= 2;
if ((_ref1 = this.tag(i), __indexOf.call(EXPRESSION_START, _ref1) >= 0) && backStack.length) {
backStack.pop();
}
prevTag = this.tag(idx - 1);
startsLine = !prevTag || (__indexOf.call(LINEBREAKS, prevTag) >= 0);
value = new String('{');
value.generated = true;
tok = this.generate('{', value);
tokens.splice(idx, 0, tok);
this.detectEnd(i + 2, condition, action);
return 2;
});
i -= 1;
}
return _ref5 = this.tag(i), __indexOf.call(tags, _ref5) >= 0;
};
Rewriter.prototype.addImplicitParentheses = function() {
var action, callIndex, condition, noCall, seenControl, seenSingle;
noCall = seenSingle = seenControl = false;
callIndex = null;
condition = function(token, i) {
var post, tag, _ref, _ref1;
Rewriter.prototype.addImplicitBracesAndParens = function() {
var stack;
stack = [];
return this.scanTokens(function(token, i, tokens) {
var endImplicitCall, endImplicitObject, forward, inImplicit, inImplicitCall, inImplicitControl, inImplicitObject, nextTag, offset, prevTag, s, sameLine, stackIdx, stackTag, stackTop, startIdx, startImplicitCall, startImplicitObject, startsLine, tag, _ref, _ref1, _ref2, _ref3, _ref4, _ref5;
tag = token[0];
if (!seenSingle && token.fromThen) {
return true;
prevTag = (i > 0 ? tokens[i - 1] : [])[0];
nextTag = (i < tokens.length - 1 ? tokens[i + 1] : [])[0];
stackTop = function() {
return stack[stack.length - 1];
};
startIdx = i;
forward = function(n) {
return i - startIdx + n;
};
inImplicit = function() {
var _ref, _ref1;
return (_ref = stackTop()) != null ? (_ref1 = _ref[2]) != null ? _ref1.ours : void 0 : void 0;
};
inImplicitCall = function() {
var _ref;
return inImplicit() && ((_ref = stackTop()) != null ? _ref[0] : void 0) === '(';
};
inImplicitObject = function() {
var _ref;
return inImplicit() && ((_ref = stackTop()) != null ? _ref[0] : void 0) === '{';
};
inImplicitControl = function() {
var _ref;
return inImplicit && ((_ref = stackTop()) != null ? _ref[0] : void 0) === 'CONTROL';
};
startImplicitCall = function(j) {
var idx;
idx = j != null ? j : i;
stack.push([
'(', idx, {
ours: true
}
]);
tokens.splice(idx, 0, generate('CALL_START', '('));
if (j == null) {
return i += 1;
}
};
endImplicitCall = function() {
stack.pop();
tokens.splice(i, 0, generate('CALL_END', ')'));
return i += 1;
};
startImplicitObject = function(j, startsLine) {
var idx;
if (startsLine == null) {
startsLine = true;
}
idx = j != null ? j : i;
stack.push([
'{', idx, {
sameLine: true,
startsLine: startsLine,
ours: true
}
]);
tokens.splice(idx, 0, generate('{', generate(new String('{'))));
if (j == null) {
return i += 1;
}
};
endImplicitObject = function(j) {
j = j != null ? j : i;
stack.pop();
tokens.splice(j, 0, generate('}', '}'));
return i += 1;
};
if (inImplicitCall() && (tag === 'IF' || tag === 'TRY' || tag === 'FINALLY' || tag === 'CATCH' || tag === 'CLASS' || tag === 'SWITCH')) {
stack.push([
'CONTROL', i, {
ours: true
}
]);
return forward(1);
}
if (tag === 'IF' || tag === 'ELSE' || tag === 'CATCH' || tag === '->' || tag === '=>' || tag === 'CLASS') {
seenSingle = true;
if (tag === 'INDENT' && inImplicit()) {
if (prevTag !== '=>' && prevTag !== '->' && prevTag !== '[' && prevTag !== '(' && prevTag !== ',' && prevTag !== '{' && prevTag !== 'TRY' && prevTag !== 'ELSE' && prevTag !== '=') {
while (inImplicitCall()) {
endImplicitCall();
}
}
if (inImplicitControl()) {
stack.pop();
}
stack.push([tag, i]);
return forward(1);
}
if (tag === 'IF' || tag === 'ELSE' || tag === 'SWITCH' || tag === 'TRY' || tag === '=') {
seenControl = true;
if (__indexOf.call(EXPRESSION_START, tag) >= 0) {
stack.push([tag, i]);
return forward(1);
}
if ((tag === '.' || tag === '?.' || tag === '::') && this.tag(i - 1) === 'OUTDENT') {
return true;
if (__indexOf.call(EXPRESSION_END, tag) >= 0) {
while (inImplicit()) {
if (inImplicitCall()) {
endImplicitCall();
} else if (inImplicitObject()) {
endImplicitObject();
} else {
stack.pop();
}
}
stack.pop();
}
return !token.generated && this.tag(i - 1) !== ',' && (__indexOf.call(IMPLICIT_END, tag) >= 0 || (tag === 'INDENT' && !seenControl)) && (tag !== 'INDENT' || (((_ref = this.tag(i - 2)) !== 'CLASS' && _ref !== 'EXTENDS') && (_ref1 = this.tag(i - 1), __indexOf.call(IMPLICIT_BLOCK, _ref1) < 0) && !(callIndex === i - 1 && (post = this.tokens[i + 1]) && post.generated && post[0] === '{')));
};
action = function(token, i) {
return this.tokens.splice(i, 0, this.generate('CALL_END', ')'));
};
return this.scanTokens(function(token, i, tokens) {
var callObject, current, next, prev, tag, _ref, _ref1, _ref2;
tag = token[0];
if (tag === 'CLASS' || tag === 'IF' || tag === 'FOR' || tag === 'WHILE') {
noCall = true;
if ((__indexOf.call(IMPLICIT_FUNC, tag) >= 0 && token.spaced || tag === '?' && i > 0 && !tokens[i - 1].spaced) && (__indexOf.call(IMPLICIT_CALL, nextTag) >= 0 || __indexOf.call(IMPLICIT_UNSPACED_CALL, nextTag) >= 0 && !((_ref = tokens[i + 1]) != null ? _ref.spaced : void 0) && !((_ref1 = tokens[i + 1]) != null ? _ref1.newLine : void 0))) {
if (tag === '?') {
tag = token[0] = 'FUNC_EXIST';
}
startImplicitCall(i + 1);
return forward(2);
}
_ref = tokens.slice(i - 1, +(i + 1) + 1 || 9e9), prev = _ref[0], current = _ref[1], next = _ref[2];
callObject = !noCall && tag === 'INDENT' && next && next.generated && next[0] === '{' && prev && (_ref1 = prev[0], __indexOf.call(IMPLICIT_FUNC, _ref1) >= 0);
seenSingle = false;
seenControl = false;
if (__indexOf.call(LINEBREAKS, tag) >= 0) {
noCall = false;
if (this.matchTags(i, IMPLICIT_FUNC, 'INDENT', null, ':') && !this.findTagsBackwards(i, ['CLASS', 'EXTENDS', 'IF', 'CATCH', 'SWITCH', 'LEADING_WHEN', 'FOR', 'WHILE', 'UNTIL'])) {
startImplicitCall(i + 1);
stack.push(['INDENT', i + 2]);
return forward(3);
}
if (prev && !prev.spaced && tag === '?') {
token.call = true;
if (tag === ':') {
if (this.tag(i - 2) === '@') {
s = i - 2;
} else {
s = i - 1;
}
while (this.tag(s - 2) === 'HERECOMMENT') {
s -= 2;
}
startsLine = s === 0 || (_ref2 = this.tag(s - 1), __indexOf.call(LINEBREAKS, _ref2) >= 0) || tokens[s - 1].newLine;
if (stackTop()) {
_ref3 = stackTop(), stackTag = _ref3[0], stackIdx = _ref3[1];
if ((stackTag === '{' || stackTag === 'INDENT' && this.tag(stackIdx - 1) === '{') && (startsLine || this.tag(s - 1) === ',' || this.tag(s - 1) === '{')) {
return forward(1);
}
}
startImplicitObject(s, !!startsLine);
return forward(2);
}
if (token.fromThen) {
return 1;
if (prevTag === 'OUTDENT' && inImplicitCall() && (tag === '.' || tag === '?.' || tag === '::' || tag === '?::')) {
endImplicitCall();
return forward(1);
}
if (!(callObject || (prev != null ? prev.spaced : void 0) && (prev.call || (_ref2 = prev[0], __indexOf.call(IMPLICIT_FUNC, _ref2) >= 0)) && (__indexOf.call(IMPLICIT_CALL, tag) >= 0 || !(token.spaced || token.newLine) && __indexOf.call(IMPLICIT_UNSPACED_CALL, tag) >= 0))) {
return 1;
if (inImplicitObject() && __indexOf.call(LINEBREAKS, tag) >= 0) {
stackTop()[2].sameLine = false;
}
callIndex = i;
tokens.splice(i, 0, this.generate('CALL_START', '(', token[2]));
this.detectEnd(i + 1, condition, action);
if (prev[0] === '?') {
prev[0] = 'FUNC_EXIST';
if (__indexOf.call(IMPLICIT_END, tag) >= 0) {
while (inImplicit()) {
_ref4 = stackTop(), stackTag = _ref4[0], stackIdx = _ref4[1], (_ref5 = _ref4[2], sameLine = _ref5.sameLine, startsLine = _ref5.startsLine);
if (inImplicitCall() && prevTag !== ',') {
endImplicitCall();
} else if (inImplicitObject() && sameLine && !startsLine) {
endImplicitObject();
} else if (inImplicitObject() && tag === 'TERMINATOR' && prevTag !== ',' && !(startsLine && this.looksObjectish(i + 1))) {
endImplicitObject();
} else {
break;
}
}
}
return 2;
if (tag === ',' && !this.looksObjectish(i + 1) && inImplicitObject() && (nextTag !== 'TERMINATOR' || !this.looksObjectish(i + 2))) {
offset = nextTag === 'OUTDENT' ? 1 : 0;
while (inImplicitObject()) {
endImplicitObject(i + offset);
}
}
return forward(1);
});

@@ -231,22 +336,19 @@ };

return this.scanTokens(function(token, i, tokens) {
var prevToken, tag;
tag = token[0];
if ((token.generated || token.explicit) && (!token[2])) {
if (i > 0) {
prevToken = tokens[i - 1];
token[2] = {
first_line: prevToken[2].last_line,
first_column: prevToken[2].last_column,
last_line: prevToken[2].last_line,
last_column: prevToken[2].last_column
};
} else {
token[2] = {
first_line: 0,
first_column: 0,
last_line: 0,
last_column: 0
};
}
var last_column, last_line, _ref, _ref1, _ref2;
if (token[2]) {
return 1;
}
if (!(token.generated || token.explicit)) {
return 1;
}
_ref2 = (_ref = (_ref1 = tokens[i - 1]) != null ? _ref1[2] : void 0) != null ? _ref : {
last_line: 0,
last_column: 0
}, last_line = _ref2.last_line, last_column = _ref2.last_column;
token[2] = {
first_line: last_line,
first_column: last_column,
last_line: last_line,
last_column: last_column
};
return 1;

@@ -336,8 +438,3 @@ });

Rewriter.prototype.generate = function(tag, value) {
var tok;
tok = [tag, value];
tok.generated = true;
return tok;
};
Rewriter.prototype.generate = generate;

@@ -344,0 +441,0 @@ Rewriter.prototype.tag = function(i) {

@@ -1,2 +0,2 @@

// Generated by CoffeeScript 1.5.0
// Generated by CoffeeScript 1.6.0
(function() {

@@ -42,3 +42,4 @@ var Scope, extend, last, _ref;

Scope.prototype.namedMethod = function() {
if (this.method.name || !this.parent) {
var _ref1;
if (((_ref1 = this.method) != null ? _ref1.name : void 0) || !this.parent) {
return this.method;

@@ -45,0 +46,0 @@ }

@@ -6,3 +6,3 @@ {

"author": "Jeremy Ashkenas",
"version": "1.5.0",
"version": "1.6.0",
"licenses": [{

@@ -9,0 +9,0 @@ "type": "MIT",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc