Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

coffee-script

Package Overview
Dependencies
Maintainers
0
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

coffee-script - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

43

lib/browser.js

@@ -15,6 +15,6 @@ (function() {

};
if (typeof window == "undefined" || window === null) {
if (typeof window === "undefined" || window === null) {
return;
}
CoffeeScript.load = function(url, options) {
CoffeeScript.load = function(url, callback) {
var xhr;

@@ -27,4 +27,12 @@ xhr = new (window.ActiveXObject || XMLHttpRequest)('Microsoft.XMLHTTP');

xhr.onreadystatechange = function() {
var _ref;
if (xhr.readyState === 4) {
return CoffeeScript.run(xhr.responseText, options);
if ((_ref = xhr.status) === 0 || _ref === 200) {
CoffeeScript.run(xhr.responseText);
} else {
throw new Error("Could not load " + url);
}
if (callback) {
return callback();
}
}

@@ -35,14 +43,29 @@ };

runScripts = function() {
var script, _i, _len, _ref;
_ref = document.getElementsByTagName('script');
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
script = _ref[_i];
if (script.type === 'text/coffeescript') {
var coffees, execute, index, length, s, scripts;
scripts = document.getElementsByTagName('script');
coffees = (function() {
var _i, _len, _results;
_results = [];
for (_i = 0, _len = scripts.length; _i < _len; _i++) {
s = scripts[_i];
if (s.type === 'text/coffeescript') {
_results.push(s);
}
}
return _results;
})();
index = 0;
length = coffees.length;
(execute = function() {
var script;
script = coffees[index++];
if ((script != null ? script.type : void 0) === 'text/coffeescript') {
if (script.src) {
CoffeeScript.load(script.src);
return CoffeeScript.load(script.src, execute);
} else {
CoffeeScript.run(script.innerHTML);
return execute();
}
}
}
})();
return null;

@@ -49,0 +72,0 @@ };

(function() {
var Lexer, RESERVED, compile, fs, lexer, parser, path, _ref;
var Lexer, RESERVED, compile, fs, lexer, parser, path, vm, _ref;
fs = require('fs');
path = require('path');
vm = require('vm');
_ref = require('./lexer'), Lexer = _ref.Lexer, RESERVED = _ref.RESERVED;

@@ -10,3 +11,5 @@ parser = require('./parser').parser;

var content;
content = compile(fs.readFileSync(filename, 'utf8'));
content = compile(fs.readFileSync(filename, 'utf8'), {
filename: filename
});
return module._compile(content, filename);

@@ -19,3 +22,3 @@ };

}
exports.VERSION = '1.0.1';
exports.VERSION = '1.1.0';
exports.RESERVED = RESERVED;

@@ -47,3 +50,3 @@ exports.helpers = require('./helpers');

exports.run = function(code, options) {
var root;
var Module, root;
root = module;

@@ -53,6 +56,10 @@ while (root.parent) {

}
root.filename = options.filename ? fs.realpathSync(options.filename) : '.';
root.filename = process.argv[1] = options.filename ? fs.realpathSync(options.filename) : '.';
if (root.moduleCache) {
root.moduleCache = {};
}
if (process.binding('natives').module) {
Module = require('module').Module;
root.paths = Module._nodeModulePaths(path.dirname(options.filename));
}
if (path.extname(root.filename) !== '.coffee' || require.extensions) {

@@ -65,6 +72,24 @@ return root._compile(compile(code, options), root.filename);

exports.eval = function(code, options) {
var __dirname, __filename;
__filename = module.filename = options.filename;
__dirname = path.dirname(__filename);
return eval(compile(code, options));
var g, js, sandbox;
if (options == null) {
options = {};
}
sandbox = options.sandbox;
if (!sandbox) {
sandbox = {
require: require,
module: {
exports: {}
}
};
for (g in global) {
sandbox[g] = global[g];
}
sandbox.global = sandbox;
sandbox.global.global = sandbox.global.root = sandbox.global.GLOBAL = sandbox;
}
sandbox.__filename = options.filename || 'eval';
sandbox.__dirname = path.dirname(sandbox.__filename);
js = compile("_=(" + (code.trim()) + ")", options);
return vm.runInNewContext(js, sandbox, sandbox.__filename);
};

@@ -74,4 +99,4 @@ lexer = new Lexer;

lex: function() {
var tag, _ref;
_ref = this.tokens[this.pos++] || [''], tag = _ref[0], this.yytext = _ref[1], this.yylineno = _ref[2];
var tag, _ref2;
_ref2 = this.tokens[this.pos++] || [''], tag = _ref2[0], this.yytext = _ref2[1], this.yylineno = _ref2[2];
return tag;

@@ -78,0 +103,0 @@ },

@@ -18,3 +18,3 @@ (function() {

BANNER = 'Usage: coffee [options] path/to/script.coffee';
SWITCHES = [['-c', '--compile', 'compile to JavaScript and save as .js files'], ['-i', '--interactive', 'run an interactive CoffeeScript REPL'], ['-o', '--output [DIR]', 'set the directory for compiled JavaScript'], ['-j', '--join', 'concatenate the scripts before compiling'], ['-w', '--watch', 'watch scripts for changes, and recompile'], ['-p', '--print', 'print the compiled JavaScript to stdout'], ['-l', '--lint', 'pipe the compiled JavaScript through JSLint'], ['-s', '--stdio', 'listen for and compile scripts over stdio'], ['-e', '--eval', 'compile a string from the command line'], ['-r', '--require [FILE*]', 'require a library before executing your script'], ['-b', '--bare', 'compile without the top-level function wrapper'], ['-t', '--tokens', 'print the tokens that the lexer produces'], ['-n', '--nodes', 'print the parse tree that Jison produces'], ['--nodejs [ARGS]', 'pass options through to the "node" binary'], ['-v', '--version', 'display CoffeeScript version'], ['-h', '--help', 'display this help message']];
SWITCHES = [['-c', '--compile', 'compile to JavaScript and save as .js files'], ['-i', '--interactive', 'run an interactive CoffeeScript REPL'], ['-o', '--output [DIR]', 'set the directory for compiled JavaScript'], ['-j', '--join [FILE]', 'concatenate the scripts before compiling'], ['-w', '--watch', 'watch scripts for changes, and recompile'], ['-p', '--print', 'print the compiled JavaScript to stdout'], ['-l', '--lint', 'pipe the compiled JavaScript through JSLint'], ['-s', '--stdio', 'listen for and compile scripts over stdio'], ['-e', '--eval', 'compile a string from the command line'], ['-r', '--require [FILE*]', 'require a library before executing your script'], ['-b', '--bare', 'compile without the top-level function wrapper'], ['-t', '--tokens', 'print the tokens that the lexer produces'], ['-n', '--nodes', 'print the parse tree that Jison produces'], ['--nodejs [ARGS]', 'pass options through to the "node" binary'], ['-v', '--version', 'display CoffeeScript version'], ['-h', '--help', 'display this help message']];
opts = {};

@@ -54,2 +54,4 @@ sources = [];

process.ARGV = process.argv = process.argv.slice(0, 2).concat(opts.literals);
process.argv[0] = 'coffee';
process.execPath = process.mainModule.filename;
return compileScripts();

@@ -69,11 +71,14 @@ };

return fs.stat(source, function(err, stats) {
if (err) {
throw err;
}
if (stats.isDirectory()) {
return fs.readdir(source, function(err, files) {
var file, _i, _len, _results;
_results = [];
for (_i = 0, _len = files.length; _i < _len; _i++) {
file = files[_i];
_results.push(compile(path.join(source, file)));
var file, _j, _len2, _results2;
_results2 = [];
for (_j = 0, _len2 = files.length; _j < _len2; _j++) {
file = files[_j];
_results2.push(compile(path.join(source, file)));
}
return _results;
return _results2;
});

@@ -84,3 +89,3 @@ } else if (topLevel || path.extname(source) === '.coffee') {

contents[sources.indexOf(source)] = code.toString();
if (helpers.compact(contents).length === sources.length) {
if (helpers.compact(contents).length > 0) {
return compileJoin();

@@ -159,11 +164,11 @@ }

code = contents.join('\n');
return compileScript("concatenation", code, "concatenation");
return compileScript(opts.join, code, opts.join);
};
loadRequires = function() {
var realFilename, req, _i, _len, _ref;
var realFilename, req, _i, _len, _ref2;
realFilename = module.filename;
module.filename = '.';
_ref = opts.require;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
req = _ref[_i];
_ref2 = opts.require;
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
req = _ref2[_i];
require(req);

@@ -204,3 +209,3 @@ }

} else if (opts.compile && opts.watch) {
return console.log("" + ((new Date).toTimeString()) + " - compiled " + source);
return console.log("" + ((new Date).toLocaleTimeString()) + " - compiled " + source);
}

@@ -232,7 +237,7 @@ });

strings = (function() {
var _i, _len, _ref, _results;
var _i, _len, _ref2, _results;
_results = [];
for (_i = 0, _len = tokens.length; _i < _len; _i++) {
token = tokens[_i];
_ref = [token[0], token[1].toString().replace(/\n/, '\\n')], tag = _ref[0], value = _ref[1];
_ref2 = [token[0], token[1].toString().replace(/\n/, '\\n')], tag = _ref2[0], value = _ref2[1];
_results.push("[" + tag + " " + value + "]");

@@ -239,0 +244,0 @@ }

@@ -172,9 +172,7 @@ (function() {

return new Access(new Literal('prototype'));
}), o('Index'), o('Slice', function() {
return new Slice($1);
})
}), o('Index')
],
Index: [
o('INDEX_START Expression INDEX_END', function() {
return new Index($2);
o('INDEX_START IndexValue INDEX_END', function() {
return $2;
}), o('INDEX_SOAK Index', function() {

@@ -190,2 +188,9 @@ return extend($2, {

],
IndexValue: [
o('Expression', function() {
return new Index($1);
}), o('Slice', function() {
return new Slice($1);
})
],
Object: [

@@ -285,8 +290,8 @@ o('{ AssignList OptComma }', function() {

Slice: [
o('INDEX_START Expression RangeDots Expression INDEX_END', function() {
return new Range($2, $4, $3);
}), o('INDEX_START Expression RangeDots INDEX_END', function() {
return new Range($2, null, $3);
}), o('INDEX_START RangeDots Expression INDEX_END', function() {
return new Range(null, $3, $2);
o('Expression RangeDots Expression', function() {
return new Range($1, $3, $2);
}), o('Expression RangeDots', function() {
return new Range($1, null, $2);
}), o('RangeDots Expression', function() {
return new Range(null, $2, $1);
})

@@ -293,0 +298,0 @@ ],

(function() {
var ASSIGNED, BOOL, CALLABLE, CODE, COFFEE_ALIASES, COFFEE_KEYWORDS, COMMENT, COMPARE, COMPOUND_ASSIGN, HEREDOC, HEREDOC_INDENT, HEREGEX, HEREGEX_OMIT, IDENTIFIER, INDEXABLE, JSTOKEN, JS_FORBIDDEN, JS_KEYWORDS, LINE_BREAK, LINE_CONTINUER, LOGIC, Lexer, MATH, MULTILINER, MULTI_DENT, NOT_REGEX, NOT_SPACED_REGEX, NO_NEWLINE, NUMBER, OPERATOR, REGEX, RELATION, RESERVED, Rewriter, SHIFT, SIMPLESTR, TRAILING_SPACES, UNARY, WHITESPACE, compact, count, last, op, starts, _ref;
var ASSIGNED, BOOL, CALLABLE, CODE, COFFEE_ALIASES, COFFEE_ALIAS_MAP, COFFEE_KEYWORDS, COMMENT, COMPARE, COMPOUND_ASSIGN, HEREDOC, HEREDOC_ILLEGAL, HEREDOC_INDENT, HEREGEX, HEREGEX_OMIT, IDENTIFIER, INDEXABLE, JSTOKEN, JS_FORBIDDEN, JS_KEYWORDS, LINE_BREAK, LINE_CONTINUER, LOGIC, Lexer, MATH, MULTILINER, MULTI_DENT, NOT_REGEX, NOT_SPACED_REGEX, NO_NEWLINE, NUMBER, OPERATOR, REGEX, RELATION, RESERVED, Rewriter, SHIFT, SIMPLESTR, TRAILING_SPACES, UNARY, WHITESPACE, compact, count, key, last, starts, _ref;
var __indexOf = Array.prototype.indexOf || function(item) {

@@ -40,3 +40,3 @@ for (var i = 0, l = this.length; i < l; i++) {

Lexer.prototype.identifierToken = function() {
var colon, forcedIdentifier, id, input, match, prev, tag, _ref, _ref2;
var colon, forcedIdentifier, id, input, match, prev, tag, _ref2, _ref3;
if (!(match = IDENTIFIER.exec(this.chunk))) {

@@ -50,7 +50,7 @@ return 0;

}
forcedIdentifier = colon || (prev = last(this.tokens)) && !prev.spaced && ((_ref = prev[0]) === '.' || _ref === '?.' || _ref === '@' || _ref === '::');
forcedIdentifier = colon || (prev = last(this.tokens)) && (((_ref2 = prev[0]) === '.' || _ref2 === '?.' || _ref2 === '::') || !prev.spaced && prev[0] === '@');
tag = 'IDENTIFIER';
if (__indexOf.call(JS_KEYWORDS, id) >= 0 || !forcedIdentifier && __indexOf.call(COFFEE_KEYWORDS, id) >= 0) {
tag = id.toUpperCase();
if (tag === 'WHEN' && (_ref2 = this.tag(), __indexOf.call(LINE_BREAK, _ref2) >= 0)) {
if (tag === 'WHEN' && (_ref3 = this.tag(), __indexOf.call(LINE_BREAK, _ref3) >= 0)) {
tag = 'LEADING_WHEN';

@@ -86,4 +86,4 @@ } else if (tag === 'FOR') {

if (!forcedIdentifier) {
if (COFFEE_ALIASES.hasOwnProperty(id)) {
id = COFFEE_ALIASES[id];
if (__indexOf.call(COFFEE_ALIASES, id) >= 0) {
id = COFFEE_ALIAS_MAP[id];
}

@@ -181,3 +181,2 @@ tag = (function() {

comment = match[0], here = match[1];
this.line += count(comment, '\n');
if (here) {

@@ -190,2 +189,3 @@ this.token('HERECOMMENT', this.sanitizeHeredoc(here, {

}
this.line += count(comment, '\n');
return comment.length;

@@ -202,3 +202,3 @@ };

Lexer.prototype.regexToken = function() {
var match, prev, regex, _ref;
var match, prev, regex, _ref2;
if (this.chunk.charAt(0) !== '/') {

@@ -211,3 +211,3 @@ return 0;

prev = last(this.tokens);
if (prev && (_ref = prev[0], __indexOf.call((prev.spaced ? NOT_REGEX : NOT_SPACED_REGEX), _ref) >= 0)) {
if (prev && (_ref2 = prev[0], __indexOf.call((prev.spaced ? NOT_REGEX : NOT_SPACED_REGEX), _ref2) >= 0)) {
return 0;

@@ -223,3 +223,3 @@ }

Lexer.prototype.heregexToken = function(match) {
var body, flags, heregex, re, tag, tokens, value, _i, _len, _ref, _ref2, _ref3, _ref4;
var body, flags, heregex, re, tag, tokens, value, _i, _len, _ref2, _ref3, _ref4, _ref5;
heregex = match[0], body = match[1], flags = match[2];

@@ -234,7 +234,7 @@ if (0 > body.indexOf('#{')) {

tokens = [];
_ref = this.interpolateString(body, {
_ref2 = this.interpolateString(body, {
regex: true
});
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
_ref2 = _ref[_i], tag = _ref2[0], value = _ref2[1];
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
_ref3 = _ref2[_i], tag = _ref3[0], value = _ref3[1];
if (tag === 'TOKENS') {

@@ -252,6 +252,6 @@ tokens.push.apply(tokens, value);

tokens.pop();
if (((_ref3 = tokens[0]) != null ? _ref3[0] : void 0) !== 'STRING') {
if (((_ref4 = tokens[0]) != null ? _ref4[0] : void 0) !== 'STRING') {
this.tokens.push(['STRING', '""'], ['+', '+']);
}
(_ref4 = this.tokens).push.apply(_ref4, tokens);
(_ref5 = this.tokens).push.apply(_ref5, tokens);
if (flags) {

@@ -353,3 +353,3 @@ this.tokens.push([',', ','], ['STRING', '"' + flags + '"']);

Lexer.prototype.literalToken = function() {
var match, prev, tag, value, _ref, _ref2, _ref3, _ref4;
var match, prev, tag, value, _ref2, _ref3, _ref4, _ref5;
if (match = OPERATOR.exec(this.chunk)) {

@@ -366,6 +366,6 @@ value = match[0];

if (value === '=' && prev) {
if (!prev[1].reserved && (_ref = prev[1], __indexOf.call(JS_FORBIDDEN, _ref) >= 0)) {
if (!prev[1].reserved && (_ref2 = prev[1], __indexOf.call(JS_FORBIDDEN, _ref2) >= 0)) {
this.assignmentError();
}
if ((_ref2 = prev[1]) === '||' || _ref2 === '&&') {
if ((_ref3 = prev[1]) === '||' || _ref3 === '&&') {
prev[0] = 'COMPOUND_ASSIGN';

@@ -391,3 +391,3 @@ prev[1] += '=';

} else if (prev && !prev.spaced) {
if (value === '(' && (_ref3 = prev[0], __indexOf.call(CALLABLE, _ref3) >= 0)) {
if (value === '(' && (_ref4 = prev[0], __indexOf.call(CALLABLE, _ref4) >= 0)) {
if (prev[0] === '?') {

@@ -397,3 +397,3 @@ prev[0] = 'FUNC_EXIST';

tag = 'CALL_START';
} else if (value === '[' && (_ref4 = prev[0], __indexOf.call(INDEXABLE, _ref4) >= 0)) {
} else if (value === '[' && (_ref5 = prev[0], __indexOf.call(INDEXABLE, _ref5) >= 0)) {
tag = 'INDEX_START';

@@ -413,11 +413,15 @@ switch (prev[0]) {

Lexer.prototype.sanitizeHeredoc = function(doc, options) {
var attempt, herecomment, indent, match, _ref;
var attempt, herecomment, indent, match, _ref2;
indent = options.indent, herecomment = options.herecomment;
if (herecomment && 0 > doc.indexOf('\n')) {
return doc;
}
if (!herecomment) {
if (herecomment) {
if (HEREDOC_ILLEGAL.test(doc)) {
throw new Error("block comment cannot contain \"*/\", starting on line " + (this.line + 1));
}
if (doc.indexOf('\n') <= 0) {
return doc;
}
} else {
while (match = HEREDOC_INDENT.exec(doc)) {
attempt = match[1];
if (indent === null || (0 < (_ref = attempt.length) && _ref < indent.length)) {
if (indent === null || (0 < (_ref2 = attempt.length) && _ref2 < indent.length)) {
indent = attempt;

@@ -453,3 +457,3 @@ }

stack.pop();
} else {
} else if (tok[0] === '(') {
tok[0] = 'PARAM_START';

@@ -472,5 +476,5 @@ return this;

Lexer.prototype.balancedString = function(str, end) {
var i, letter, prev, stack, _ref;
var i, letter, prev, stack, _ref2;
stack = [end];
for (i = 1, _ref = str.length; (1 <= _ref ? i < _ref : i > _ref); (1 <= _ref ? i += 1 : i -= 1)) {
for (i = 1, _ref2 = str.length; 1 <= _ref2 ? i < _ref2 : i > _ref2; 1 <= _ref2 ? i++ : i--) {
switch (letter = str.charAt(i)) {

@@ -500,3 +504,3 @@ case '\\':

Lexer.prototype.interpolateString = function(str, options) {
var expr, heredoc, i, inner, interpolated, len, letter, nested, pi, regex, tag, tokens, value, _len, _ref, _ref2, _ref3;
var expr, heredoc, i, inner, interpolated, len, letter, nested, pi, regex, tag, tokens, value, _len, _ref2, _ref3, _ref4;
if (options == null) {

@@ -527,3 +531,3 @@ options = {};

nested.pop();
if (((_ref = nested[0]) != null ? _ref[0] : void 0) === 'TERMINATOR') {
if (((_ref2 = nested[0]) != null ? _ref2[0] : void 0) === 'TERMINATOR') {
nested.shift();

@@ -558,3 +562,3 @@ }

for (i = 0, _len = tokens.length; i < _len; i++) {
_ref2 = tokens[i], tag = _ref2[0], value = _ref2[1];
_ref3 = tokens[i], tag = _ref3[0], value = _ref3[1];
if (i) {

@@ -564,3 +568,3 @@ this.token('+', '+');

if (tag === 'TOKENS') {
(_ref3 = this.tokens).push.apply(_ref3, value);
(_ref4 = this.tokens).push.apply(_ref4, value);
} else {

@@ -611,3 +615,3 @@ this.token('STRING', this.makeString(value, '"', heredoc));

COFFEE_KEYWORDS = ['undefined', 'then', 'unless', 'until', 'loop', 'of', 'by', 'when'];
for (op in COFFEE_ALIASES = {
COFFEE_ALIAS_MAP = {
and: '&&',

@@ -622,5 +626,12 @@ or: '||',

off: 'false'
}) {
COFFEE_KEYWORDS.push(op);
}
};
COFFEE_ALIASES = (function() {
var _results;
_results = [];
for (key in COFFEE_ALIAS_MAP) {
_results.push(key);
}
return _results;
})();
COFFEE_KEYWORDS = COFFEE_KEYWORDS.concat(COFFEE_ALIASES);
RESERVED = ['case', 'default', 'function', 'var', 'void', 'with', 'const', 'let', 'enum', 'export', 'import', 'native', '__hasProp', '__extends', '__slice', '__bind', '__indexOf'];

@@ -639,3 +650,3 @@ JS_FORBIDDEN = JS_KEYWORDS.concat(RESERVED);

JSTOKEN = /^`[^\\`]*(?:\\.[^\\`]*)*`/;
REGEX = /^\/(?!\s)[^[\/\n\\]*(?:(?:\\[\s\S]|\[[^\]\n\\]*(?:\\[\s\S][^\]\n\\]*)*])[^[\/\n\\]*)*\/[imgy]{0,4}(?!\w)/;
REGEX = /^\/(?![\s=])[^[\/\n\\]*(?:(?:\\[\s\S]|\[[^\]\n\\]*(?:\\[\s\S][^\]\n\\]*)*])[^[\/\n\\]*)*\/[imgy]{0,4}(?!\w)/;
HEREGEX = /^\/{3}([\s\S]+?)\/{3}([imgy]{0,4})(?!\w)/;

@@ -645,4 +656,5 @@ HEREGEX_OMIT = /\s+(?:#.*)?/g;

HEREDOC_INDENT = /\n+([^\n\S]*)/g;
HEREDOC_ILLEGAL = /\*\//;
ASSIGNED = /^\s*@?([$A-Za-z_][$\w\x7f-\uffff]*|['"].*['"])[^\n\S]*?[:=][^:=>]/;
LINE_CONTINUER = /^\s*(?:,|\??\.(?!\.)|::)/;
LINE_CONTINUER = /^\s*(?:,|\??\.(?![.\d])|::)/;
TRAILING_SPACES = /\s+$/;

@@ -649,0 +661,0 @@ NO_NEWLINE = /^(?:[-+*&|\/%=<>!.\\][<>=&|]*|and|or|is(?:nt)?|n(?:ot|ew)|delete|typeof|instanceof)$/;

(function() {
var CoffeeScript, error, helpers, readline, repl, run, stdin, stdout;
var ACCESSOR, CoffeeScript, SIMPLEVAR, Script, autocomplete, backlog, completeAttribute, completeVariable, enableColours, error, getCompletions, getPropertyNames, inspect, readline, repl, run, stdin, stdout;
var __hasProp = Object.prototype.hasOwnProperty;
CoffeeScript = require('./coffee-script');
helpers = require('./helpers');
readline = require('readline');
inspect = require('util').inspect;
Script = require('vm').Script;
enableColours = false;
if (process.platform !== 'win32') {
enableColours = !process.env.NODE_DISABLE_COLORS;
}
stdin = process.openStdin();

@@ -11,26 +17,87 @@ stdout = process.stdout;

};
helpers.extend(global, {
quit: function() {
return process.exit(0);
backlog = '';
run = (function() {
var g, sandbox;
sandbox = {
require: require,
module: {
exports: {}
}
};
for (g in global) {
sandbox[g] = global[g];
}
});
run = function(buffer) {
var val;
try {
val = CoffeeScript.eval(buffer.toString(), {
bare: true,
globals: true,
filename: 'repl'
});
if (val !== void 0) {
process.stdout.write(val + '\n');
sandbox.global = sandbox;
sandbox.global.global = sandbox.global.root = sandbox.global.GLOBAL = sandbox;
return function(buffer) {
var code, val;
code = backlog += '\n' + buffer.toString();
if (code[code.length - 1] === '\\') {
return backlog = backlog.slice(0, backlog.length - 1);
}
} catch (err) {
error(err);
backlog = '';
try {
val = CoffeeScript.eval(code, {
sandbox: sandbox,
bare: true,
filename: 'repl'
});
if (val !== void 0) {
process.stdout.write(inspect(val, false, 2, enableColours) + '\n');
}
} catch (err) {
error(err);
}
return repl.prompt();
};
})();
ACCESSOR = /\s*([\w\.]+)(?:\.(\w*))$/;
SIMPLEVAR = /\s*(\w*)$/i;
autocomplete = function(text) {
return completeAttribute(text) || completeVariable(text) || [[], text];
};
completeAttribute = function(text) {
var all, completions, match, obj, prefix, val;
if (match = text.match(ACCESSOR)) {
all = match[0], obj = match[1], prefix = match[2];
try {
val = Script.runInThisContext(obj);
} catch (error) {
return [[], text];
}
completions = getCompletions(prefix, getPropertyNames(val));
return [completions, prefix];
}
return repl.prompt();
};
completeVariable = function(text) {
var completions, free, scope, _ref;
if (free = (_ref = text.match(SIMPLEVAR)) != null ? _ref[1] : void 0) {
scope = Script.runInThisContext('this');
completions = getCompletions(free, CoffeeScript.RESERVED.concat(getPropertyNames(scope)));
return [completions, free];
}
};
getCompletions = function(prefix, candidates) {
var el, _i, _len, _results;
_results = [];
for (_i = 0, _len = candidates.length; _i < _len; _i++) {
el = candidates[_i];
if (el.indexOf(prefix) === 0) {
_results.push(el);
}
}
return _results;
};
getPropertyNames = function(obj) {
var name, _results;
_results = [];
for (name in obj) {
if (!__hasProp.call(obj, name)) continue;
_results.push(name);
}
return _results;
};
process.on('uncaughtException', error);
if (readline.createInterface.length < 3) {
repl = readline.createInterface(stdin);
repl = readline.createInterface(stdin, autocomplete);
stdin.on('data', function(buffer) {

@@ -40,3 +107,3 @@ return repl.write(buffer);

} else {
repl = readline.createInterface(stdin, stdout);
repl = readline.createInterface(stdin, stdout, autocomplete);
}

@@ -43,0 +110,0 @@ repl.setPrompt('coffee> ');

@@ -124,3 +124,6 @@ (function() {

action = function(token, i) {
return this.tokens.splice(i, 0, ['}', '}', token[2]]);
var tok;
tok = ['}', '}', token[2]];
tok.generated = true;
return this.tokens.splice(i, 0, tok);
};

@@ -177,2 +180,5 @@ return this.scanTokens(function(token, i, tokens) {

}
if (token.fromThen) {
return 1;
}
if (!(callObject || (prev != null ? prev.spaced : void 0) && (prev.call || (_ref3 = prev[0], __indexOf.call(IMPLICIT_FUNC, _ref3) >= 0)) && (__indexOf.call(IMPLICIT_CALL, tag) >= 0 || !(token.spaced || token.newLine) && __indexOf.call(IMPLICIT_UNSPACED_CALL, tag) >= 0))) {

@@ -183,3 +189,3 @@ return 1;

this.detectEnd(i + 1, function(token, i) {
var post, _ref;
var post, _ref4;
tag = token[0];

@@ -195,3 +201,3 @@ if (!seenSingle && token.fromThen) {

}
return !token.generated && this.tag(i - 1) !== ',' && __indexOf.call(IMPLICIT_END, tag) >= 0 && (tag !== 'INDENT' || (this.tag(i - 2) !== 'CLASS' && (_ref = this.tag(i - 1), __indexOf.call(IMPLICIT_BLOCK, _ref) < 0) && !((post = this.tokens[i + 1]) && post.generated && post[0] === '{')));
return !token.generated && this.tag(i - 1) !== ',' && __indexOf.call(IMPLICIT_END, tag) >= 0 && (tag !== 'INDENT' || (this.tag(i - 2) !== 'CLASS' && (_ref4 = this.tag(i - 1), __indexOf.call(IMPLICIT_BLOCK, _ref4) < 0) && !((post = this.tokens[i + 1]) && post.generated && post[0] === '{')));
}, action);

@@ -229,4 +235,4 @@ if (prev[0] === '?') {

condition = function(token, i) {
var _ref;
return token[1] !== ';' && (_ref = token[0], __indexOf.call(SINGLE_CLOSERS, _ref) >= 0) && !(token[0] === 'ELSE' && (starter !== 'IF' && starter !== 'THEN'));
var _ref3;
return token[1] !== ';' && (_ref3 = token[0], __indexOf.call(SINGLE_CLOSERS, _ref3) >= 0) && !(token[0] === 'ELSE' && (starter !== 'IF' && starter !== 'THEN'));
};

@@ -233,0 +239,0 @@ action = function(token, i) {

@@ -49,3 +49,3 @@ (function() {

Scope.prototype.check = function(name, immediate) {
var found, _ref;
var found, _ref2;
found = !!this.type(name);

@@ -55,3 +55,3 @@ if (found || immediate) {

}
return !!((_ref = this.parent) != null ? _ref.check(name) : void 0);
return !!((_ref2 = this.parent) != null ? _ref2.check(name) : void 0);
};

@@ -66,6 +66,6 @@ Scope.prototype.temporary = function(name, index) {

Scope.prototype.type = function(name) {
var v, _i, _len, _ref;
_ref = this.variables;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
v = _ref[_i];
var v, _i, _len, _ref2;
_ref2 = this.variables;
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
v = _ref2[_i];
if (v.name === name) {

@@ -80,3 +80,3 @@ return v.type;

index = 0;
while (this.check((temp = this.temporary(type, index)), true)) {
while (this.check((temp = this.temporary(type, index)))) {
index++;

@@ -98,8 +98,8 @@ }

Scope.prototype.declaredVariables = function() {
var realVars, tempVars, v, _i, _len, _ref;
var realVars, tempVars, v, _i, _len, _ref2;
realVars = [];
tempVars = [];
_ref = this.variables;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
v = _ref[_i];
_ref2 = this.variables;
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
v = _ref2[_i];
if (v.type === 'var') {

@@ -112,7 +112,7 @@ (v.name.charAt(0) === '_' ? tempVars : realVars).push(v.name);

Scope.prototype.assignedVariables = function() {
var v, _i, _len, _ref, _results;
_ref = this.variables;
var v, _i, _len, _ref2, _results;
_ref2 = this.variables;
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
v = _ref[_i];
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
v = _ref2[_i];
if (v.type.assigned) {

@@ -119,0 +119,0 @@ _results.push("" + v.name + " = " + v.type.value);

{
"name": "coffee-script",
"description": "Unfancy JavaScript",
"keywords": ["javascript", "language", "coffeescript", "compiler"],
"author": "Jeremy Ashkenas",
"version": "1.0.1",
"licenses": [{
"type": "MIT",
"url": "http://github.com/jashkenas/coffee-script/raw/master/LICENSE"
}],
"engines": {
"node": ">=0.2.5"
},
"directories" : {
"lib" : "./lib"
},
"main" : "./lib/coffee-script",
"bin": {
"coffee": "./bin/coffee",
"cake": "./bin/cake"
}
"name": "coffee-script",
"description": "Unfancy JavaScript",
"keywords": ["javascript", "language", "coffeescript", "compiler"],
"author": "Jeremy Ashkenas",
"version": "1.1.0",
"licenses": [{
"type": "MIT",
"url": "http://github.com/jashkenas/coffee-script/raw/master/LICENSE"
}],
"engines": {
"node": ">=0.2.5"
},
"directories" : {
"lib" : "./lib"
},
"main" : "./lib/coffee-script",
"bin": {
"coffee": "./bin/coffee",
"cake": "./bin/cake"
},
"homepage": "http://coffeescript.org",
"repository": {
"type": "git",
"url": "git://github.com/jashkenas/coffee-script.git"
}
}

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

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

Sorry, the diff of this file is not supported yet

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