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.1.3 to 1.2.0

22

lib/coffee-script/cake.js
(function() {
var CoffeeScript, cakefileDirectory, fs, helpers, missingTask, oparse, options, optparse, path, printTasks, switches, tasks;
var CoffeeScript, cakefileDirectory, fatalError, fs, helpers, missingTask, oparse, options, optparse, path, printTasks, switches, tasks;

@@ -53,3 +53,7 @@ fs = require('fs');

if (!args.length) return printTasks();
options = oparse.parse(args);
try {
options = oparse.parse(args);
} catch (e) {
return fatalError("" + e);
}
_ref = options.arguments;

@@ -65,4 +69,5 @@ _results = [];

printTasks = function() {
var desc, name, spaces, task;
console.log('');
var cakefilePath, desc, name, spaces, task;
cakefilePath = path.join(path.relative(__originalDirname, process.cwd()), 'Cakefile');
console.log("" + cakefilePath + " defines the following tasks:\n");
for (name in tasks) {

@@ -78,7 +83,12 @@ task = tasks[name];

missingTask = function(task) {
console.log("No such task: \"" + task + "\"");
fatalError = function(message) {
console.error(message + '\n');
console.log('To see a list of all tasks/options, run "cake"');
return process.exit(1);
};
missingTask = function(task) {
return fatalError("No such task: " + task);
};
cakefileDirectory = function(dir) {

@@ -85,0 +95,0 @@ var parent;

(function() {
var Lexer, RESERVED, compile, fs, lexer, parser, path, vm, _ref;
var __hasProp = Object.prototype.hasOwnProperty;
var Lexer, RESERVED, compile, fs, lexer, parser, path, vm, _ref,
__hasProp = Object.prototype.hasOwnProperty;

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

exports.VERSION = '1.1.3';
exports.VERSION = '1.2.0';

@@ -37,5 +37,7 @@ exports.RESERVED = RESERVED;

exports.compile = compile = function(code, options) {
var merge;
if (options == null) options = {};
merge = exports.helpers.merge;
try {
return (parser.parse(lexer.tokenize(code))).compile(options);
return (parser.parse(lexer.tokenize(code))).compile(merge({}, options));
} catch (err) {

@@ -42,0 +44,0 @@ if (options.filename) {

(function() {
var BANNER, CoffeeScript, EventEmitter, SWITCHES, compileJoin, compileOptions, compileScript, compileScripts, compileStdio, contents, exec, forkNode, fs, helpers, lint, loadRequires, optionParser, optparse, opts, parseOptions, path, printLine, printTokens, printWarn, sources, spawn, usage, version, watch, writeJs, _ref;
var BANNER, CoffeeScript, EventEmitter, SWITCHES, compileJoin, compileOptions, compilePath, compileScript, compileStdio, exec, forkNode, fs, helpers, joinTimeout, lint, loadRequires, notSources, optionParser, optparse, opts, outputPath, parseOptions, path, printLine, printTokens, printWarn, removeSource, sourceCode, sources, spawn, timeLog, unwatchDir, usage, version, wait, watch, watchDir, watchers, writeJs, _ref;

@@ -36,7 +36,12 @@ fs = require('fs');

contents = [];
sourceCode = [];
notSources = {};
watchers = {};
optionParser = null;
exports.run = function() {
var source, _i, _len, _results;
parseOptions();

@@ -48,2 +53,5 @@ if (opts.nodejs) return forkNode();

if (opts.interactive) return require('./repl');
if (opts.watch && !fs.watch) {
printWarn("The --watch feature depends on Node v0.6.0+. You are running " + process.version + ".");
}
if (opts.stdio) return compileStdio();

@@ -56,77 +64,57 @@ if (opts.eval) return compileScript(null, sources[0]);

process.execPath = require.main.filename;
return compileScripts();
_results = [];
for (_i = 0, _len = sources.length; _i < _len; _i++) {
source = sources[_i];
_results.push(compilePath(source, true, path.normalize(source)));
}
return _results;
};
compileScripts = function() {
var base, compile, remaining_files, source, trackCompleteFiles, trackUnprocessedFiles, unprocessed, _i, _j, _len, _len2, _results;
unprocessed = [];
remaining_files = function() {
var total, x, _i, _len;
total = 0;
for (_i = 0, _len = unprocessed.length; _i < _len; _i++) {
x = unprocessed[_i];
total += x;
}
return total;
};
trackUnprocessedFiles = function(sourceIndex, fileCount) {
var _ref2;
if ((_ref2 = unprocessed[sourceIndex]) == null) unprocessed[sourceIndex] = 0;
return unprocessed[sourceIndex] += fileCount;
};
trackCompleteFiles = function(sourceIndex, fileCount) {
unprocessed[sourceIndex] -= fileCount;
if (opts.join) {
if (helpers.compact(contents).length > 0 && remaining_files() === 0) {
return compileJoin();
compilePath = function(source, topLevel, base) {
return fs.stat(source, function(err, stats) {
if (err && err.code !== 'ENOENT') throw err;
if ((err != null ? err.code : void 0) === 'ENOENT') {
if (topLevel && source.slice(-7) !== '.coffee') {
source = sources[sources.indexOf(source)] = "" + source + ".coffee";
return compilePath(source, topLevel, base);
}
if (topLevel) {
console.error("File not found: " + source);
process.exit(1);
}
return;
}
};
for (_i = 0, _len = sources.length; _i < _len; _i++) {
source = sources[_i];
trackUnprocessedFiles(sources.indexOf(source), 1);
}
_results = [];
for (_j = 0, _len2 = sources.length; _j < _len2; _j++) {
source = sources[_j];
base = path.join(source);
compile = function(source, sourceIndex, topLevel) {
return path.exists(source, function(exists) {
if (topLevel && !exists && source.slice(-7) !== '.coffee') {
return compile("" + source + ".coffee", sourceIndex, topLevel);
if (stats.isDirectory()) {
if (opts.watch) watchDir(source, base);
return fs.readdir(source, function(err, files) {
var file, index, _i, _len, _ref2, _results;
if (err && err.code !== 'ENOENT') throw err;
if ((err != null ? err.code : void 0) === 'ENOENT') return;
files = files.map(function(file) {
return path.join(source, file);
});
index = sources.indexOf(source);
[].splice.apply(sources, [index, index - index + 1].concat(files)), files;
[].splice.apply(sourceCode, [index, index - index + 1].concat(_ref2 = files.map(function() {
return null;
}))), _ref2;
_results = [];
for (_i = 0, _len = files.length; _i < _len; _i++) {
file = files[_i];
_results.push(compilePath(file, false, base));
}
if (topLevel && !exists) throw new Error("File not found: " + source);
return fs.stat(source, function(err, stats) {
if (err) throw err;
if (stats.isDirectory()) {
return fs.readdir(source, function(err, files) {
var file, _k, _len3;
if (err) throw err;
trackUnprocessedFiles(sourceIndex, files.length);
for (_k = 0, _len3 = files.length; _k < _len3; _k++) {
file = files[_k];
compile(path.join(source, file), sourceIndex);
}
return trackCompleteFiles(sourceIndex, 1);
});
} else if (topLevel || path.extname(source) === '.coffee') {
fs.readFile(source, function(err, code) {
if (err) throw err;
if (opts.join) {
contents[sourceIndex] = helpers.compact([contents[sourceIndex], code.toString()]).join('\n');
} else {
compileScript(source, code.toString(), base);
}
return trackCompleteFiles(sourceIndex, 1);
});
if (opts.watch && !opts.join) return watch(source, base);
} else {
return trackCompleteFiles(sourceIndex, 1);
}
});
return _results;
});
};
_results.push(compile(source, sources.indexOf(source), true));
}
return _results;
} else if (topLevel || path.extname(source) === '.coffee') {
if (opts.watch) watch(source, base);
return fs.readFile(source, function(err, code) {
if (err && err.code !== 'ENOENT') throw err;
if ((err != null ? err.code : void 0) === 'ENOENT') return;
return compileScript(source, code.toString(), base);
});
} else {
notSources[source] = true;
return removeSource(source, base);
}
});
};

@@ -151,2 +139,5 @@

return CoffeeScript.run(t.input, t.options);
} else if (o.join && t.file !== o.join) {
sourceCode[sources.indexOf(t.file)] = t.input;
return compileJoin();
} else {

@@ -184,6 +175,14 @@ t.output = CoffeeScript.compile(t.input, t.options);

joinTimeout = null;
compileJoin = function() {
var code;
code = contents.join('\n');
return compileScript(opts.join, code, opts.join);
if (!opts.join) return;
if (!sourceCode.some(function(code) {
return code === null;
})) {
clearTimeout(joinTimeout);
return joinTimeout = wait(100, function() {
return compileScript(opts.join, sourceCode.join('\n'), opts.join);
});
}
};

@@ -204,24 +203,139 @@

watch = function(source, base) {
return fs.stat(source, function(err, prevStats) {
if (err) throw err;
return fs.watch(source, function(event) {
var callback, compile, compileTimeout, prevStats, watchErr, watcher;
prevStats = null;
compileTimeout = null;
watchErr = function(e) {
if (e.code === 'ENOENT') {
if (sources.indexOf(source) === -1) return;
removeSource(source, base, true);
return compileJoin();
} else {
throw e;
}
};
compile = function() {
clearTimeout(compileTimeout);
return compileTimeout = wait(25, function() {
return fs.stat(source, function(err, stats) {
if (err) return watchErr(err);
if (prevStats && (stats.size === prevStats.size && stats.mtime.getTime() === prevStats.mtime.getTime())) {
return;
}
prevStats = stats;
return fs.readFile(source, function(err, code) {
if (err) return watchErr(err);
return compileScript(source, code.toString(), base);
});
});
});
};
watchErr = function(e) {
if (e.code !== 'ENOENT') throw e;
removeSource(source, base, true);
return compileJoin();
};
try {
return watcher = fs.watch(source, callback = function(event) {
if (event === 'change') {
return fs.stat(source, function(err, stats) {
if (err) throw err;
if (stats.size === prevStats.size && stats.mtime.getTime() === prevStats.mtime.getTime()) {
return;
return compile();
} else if (event === 'rename') {
watcher.close();
return wait(250, function() {
compile();
try {
return watcher = fs.watch(source, callback);
} catch (e) {
return watchErr(e);
}
prevStats = stats;
return fs.readFile(source, function(err, code) {
if (err) throw err;
return compileScript(source, code.toString(), base);
});
}
});
} catch (e) {
return watchErr(e);
}
};
watchDir = function(source, base) {
var readdirTimeout, watcher;
readdirTimeout = null;
try {
return watcher = fs.watch(source, function() {
clearTimeout(readdirTimeout);
return readdirTimeout = wait(25, function() {
return fs.readdir(source, function(err, files) {
var file, _i, _len, _results;
if (err) {
if (err.code !== 'ENOENT') throw err;
watcher.close();
return unwatchDir(source, base);
}
files = files.map(function(file) {
return path.join(source, file);
});
_results = [];
for (_i = 0, _len = files.length; _i < _len; _i++) {
file = files[_i];
if (!(!notSources[file])) continue;
if (sources.some(function(s) {
return s.indexOf(file) >= 0;
})) {
continue;
}
sources.push(file);
sourceCode.push(null);
_results.push(compilePath(file, false, base));
}
return _results;
});
});
});
} catch (e) {
if (e.code !== 'ENOENT') throw e;
}
};
unwatchDir = function(source, base) {
var file, prevSources, toRemove, _i, _len;
prevSources = sources.slice();
toRemove = (function() {
var _i, _len, _results;
_results = [];
for (_i = 0, _len = sources.length; _i < _len; _i++) {
file = sources[_i];
if (file.indexOf(source) >= 0) _results.push(file);
}
return _results;
})();
for (_i = 0, _len = toRemove.length; _i < _len; _i++) {
file = toRemove[_i];
removeSource(file, base, true);
}
if (!sources.some(function(s, i) {
return prevSources[i] !== s;
})) {
return;
}
return compileJoin();
};
removeSource = function(source, base, removeJs) {
var index, jsPath;
index = sources.indexOf(source);
sources.splice(index, 1);
sourceCode.splice(index, 1);
if (removeJs && !opts.join) {
jsPath = outputPath(source, base);
return path.exists(jsPath, function(exists) {
if (exists) {
return fs.unlink(jsPath, function(err) {
if (err && err.code !== 'ENOENT') throw err;
return timeLog("removed " + source);
});
}
});
});
}
};
writeJs = function(source, js, base) {
var baseDir, compile, dir, filename, jsPath, srcDir;
outputPath = function(source, base) {
var baseDir, dir, filename, srcDir;
filename = path.basename(source, path.extname(source)) + '.js';

@@ -231,3 +345,9 @@ srcDir = path.dirname(source);

dir = opts.output ? path.join(opts.output, baseDir) : srcDir;
jsPath = path.join(dir, filename);
return path.join(dir, filename);
};
writeJs = function(source, js, base) {
var compile, jsDir, jsPath;
jsPath = outputPath(source, base);
jsDir = path.dirname(jsPath);
compile = function() {

@@ -239,11 +359,11 @@ if (js.length <= 0) js = ' ';

} else if (opts.compile && opts.watch) {
return console.log("" + ((new Date).toLocaleTimeString()) + " - compiled " + source);
return timeLog("compiled " + source);
}
});
};
return path.exists(dir, function(exists) {
return path.exists(jsDir, function(exists) {
if (exists) {
return compile();
} else {
return exec("mkdir -p " + dir, compile);
return exec("mkdir -p " + jsDir, compile);
}

@@ -253,2 +373,10 @@ });

wait = function(milliseconds, func) {
return setTimeout(func, milliseconds);
};
timeLog = function(message) {
return console.log("" + ((new Date).toLocaleTimeString()) + " - " + message);
};
lint = function(file, js) {

@@ -283,3 +411,3 @@ var conf, jsl, printIt;

parseOptions = function() {
var o;
var i, o, source, _len;
optionParser = new optparse.OptionParser(SWITCHES, BANNER);

@@ -290,3 +418,7 @@ o = opts = optionParser.parse(process.argv.slice(2));

o.print = !!(o.print || (o.eval || o.stdio && o.compile));
return sources = o.arguments;
sources = o.arguments;
for (i = 0, _len = sources.length; i < _len; i++) {
source = sources[i];
sourceCode[i] = null;
}
};

@@ -293,0 +425,0 @@

@@ -33,7 +33,7 @@ (function() {

Statement: [
o('Return'), o('Throw'), o('Comment'), o('STATEMENT', function() {
o('Return'), o('Comment'), o('STATEMENT', function() {
return new Literal($1);
})
],
Expression: [o('Value'), o('Invocation'), o('Code'), o('Operation'), o('Assign'), o('If'), o('Try'), o('While'), o('For'), o('Switch'), o('Class')],
Expression: [o('Value'), o('Invocation'), o('Code'), o('Operation'), o('Assign'), o('If'), o('Try'), o('While'), o('For'), o('Switch'), o('Class'), o('Throw')],
Block: [

@@ -63,2 +63,4 @@ o('INDENT OUTDENT', function() {

return new Literal($1);
}), o('DEBUGGER', function() {
return new Literal($1);
}), o('BOOL', function() {

@@ -74,2 +76,4 @@ var val;

return new Assign($1, $3);
}), o('Assignable = TERMINATOR Expression', function() {
return new Assign($1, $4);
}), o('Assignable = INDENT Expression OUTDENT', function() {

@@ -147,3 +151,3 @@ return new Assign($1, $4);

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

@@ -150,0 +154,0 @@ ],

(function() {
var 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, LOGIC, Lexer, MATH, MULTILINER, MULTI_DENT, NOT_REGEX, NOT_SPACED_REGEX, NUMBER, OPERATOR, REGEX, RELATION, RESERVED, Rewriter, SHIFT, SIMPLESTR, TRAILING_SPACES, UNARY, WHITESPACE, compact, count, key, last, starts, _ref, _ref2;
var __hasProp = Object.prototype.hasOwnProperty, __indexOf = Array.prototype.indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (__hasProp.call(this, i) && this[i] === item) return i; } return -1; };
var 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, LOGIC, Lexer, MATH, MULTILINER, MULTI_DENT, NOT_REGEX, NOT_SPACED_REGEX, NUMBER, OPERATOR, REGEX, RELATION, RESERVED, Rewriter, SHIFT, SIMPLESTR, TRAILING_SPACES, UNARY, WHITESPACE, compact, count, key, last, starts, _ref, _ref2,
__indexOf = Array.prototype.indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };

@@ -75,3 +75,3 @@ _ref = require('./rewriter'), Rewriter = _ref.Rewriter, INVERSES = _ref.INVERSES;

} else if (__indexOf.call(RESERVED, id) >= 0) {
this.error("reserved word \"" + word + "\"");
this.error("reserved word \"" + id + "\"");
}

@@ -98,3 +98,2 @@ }

case 'continue':
case 'debugger':
return 'STATEMENT';

@@ -512,4 +511,4 @@ default:

if (len > 1) {
nested.unshift(['(', '(']);
nested.push([')', ')']);
nested.unshift(['(', '(', this.line]);
nested.push([')', ')', this.line]);
}

@@ -516,0 +515,0 @@ tokens.push(['TOKENS', nested]);

(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 __hasProp = Object.prototype.hasOwnProperty, __indexOf = Array.prototype.indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (__hasProp.call(this, i) && this[i] === item) return i; } return -1; }, __slice = Array.prototype.slice;
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,
__indexOf = Array.prototype.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 = Array.prototype.slice;

@@ -103,5 +104,7 @@ exports.Rewriter = (function() {

Rewriter.prototype.addImplicitBraces = function() {
var action, condition, stack, start, startIndent;
var action, condition, sameLine, stack, start, startIndent, startsLine;
stack = [];
start = null;
startsLine = null;
sameLine = true;
startIndent = 0;

@@ -113,3 +116,4 @@ condition = function(token, i) {

tag = token[0];
return ((tag === 'TERMINATOR' || tag === 'OUTDENT') && !((two != null ? two[0] : void 0) === ':' || (one != null ? one[0] : void 0) === '@' && (three != null ? three[0] : void 0) === ':')) || (tag === ',' && one && ((_ref2 = one[0]) !== 'IDENTIFIER' && _ref2 !== 'NUMBER' && _ref2 !== 'STRING' && _ref2 !== '@' && _ref2 !== 'TERMINATOR' && _ref2 !== 'OUTDENT'));
if (__indexOf.call(LINEBREAKS, tag) >= 0) sameLine = false;
return (((tag === 'TERMINATOR' || tag === 'OUTDENT') || (__indexOf.call(IMPLICIT_END, tag) >= 0 && sameLine)) && ((!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 && ((_ref2 = one[0]) !== 'IDENTIFIER' && _ref2 !== 'NUMBER' && _ref2 !== 'STRING' && _ref2 !== '@' && _ref2 !== 'TERMINATOR' && _ref2 !== 'OUTDENT'));
};

@@ -123,3 +127,3 @@ action = function(token, i) {

return this.scanTokens(function(token, i, tokens) {
var ago, idx, tag, tok, value, _ref, _ref2;
var ago, idx, prevTag, tag, tok, value, _ref, _ref2;
if (_ref = (tag = token[0]), __indexOf.call(EXPRESSION_START, _ref) >= 0) {

@@ -136,2 +140,3 @@ stack.push([(tag === 'INDENT' && this.tag(i - 1) === '{' ? '{' : tag), i]);

}
sameLine = true;
stack.push(['{']);

@@ -142,2 +147,4 @@ idx = ago === '@' ? i - 2 : i - 1;

}
prevTag = this.tag(idx - 1);
startsLine = !prevTag || (__indexOf.call(LINEBREAKS, prevTag) >= 0);
value = new String('{');

@@ -154,4 +161,19 @@ value.generated = true;

Rewriter.prototype.addImplicitParentheses = function() {
var action, noCall;
noCall = false;
var action, condition, noCall, seenControl, seenSingle;
noCall = seenSingle = seenControl = false;
condition = function(token, i) {
var post, tag, _ref, _ref2;
tag = token[0];
if (!seenSingle && token.fromThen) return true;
if (tag === 'IF' || tag === 'ELSE' || tag === 'CATCH' || tag === '->' || tag === '=>' || tag === 'CLASS') {
seenSingle = true;
}
if (tag === 'IF' || tag === 'ELSE' || tag === 'SWITCH' || tag === 'TRY' || tag === '=') {
seenControl = true;
}
if ((tag === '.' || tag === '?.' || tag === '::') && this.tag(i - 1) === 'OUTDENT') {
return true;
}
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') && (_ref2 = this.tag(i - 1), __indexOf.call(IMPLICIT_BLOCK, _ref2) < 0) && !((post = this.tokens[i + 1]) && post.generated && post[0] === '{')));
};
action = function(token, i) {

@@ -161,3 +183,3 @@ return this.tokens.splice(i, 0, ['CALL_END', ')', token[2]]);

return this.scanTokens(function(token, i, tokens) {
var callObject, current, next, prev, seenControl, seenSingle, tag, _ref, _ref2, _ref3;
var callObject, current, next, prev, tag, _ref, _ref2, _ref3;
tag = token[0];

@@ -176,17 +198,3 @@ if (tag === 'CLASS' || tag === 'IF') noCall = true;

tokens.splice(i, 0, ['CALL_START', '(', token[2]]);
this.detectEnd(i + 1, function(token, i) {
var post, _ref4;
tag = token[0];
if (!seenSingle && token.fromThen) return true;
if (tag === 'IF' || tag === 'ELSE' || tag === 'CATCH' || tag === '->' || tag === '=>') {
seenSingle = true;
}
if (tag === 'IF' || tag === 'ELSE' || tag === 'SWITCH' || tag === 'TRY') {
seenControl = true;
}
if ((tag === '.' || tag === '?.' || tag === '::') && this.tag(i - 1) === 'OUTDENT') {
return true;
}
return !token.generated && this.tag(i - 1) !== ',' && (__indexOf.call(IMPLICIT_END, tag) >= 0 || (tag === 'INDENT' && !seenControl)) && (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);
this.detectEnd(i + 1, condition, action);
if (prev[0] === '?') prev[0] = 'FUNC_EXIST';

@@ -198,4 +206,13 @@ return 2;

Rewriter.prototype.addImplicitIndentation = function() {
var action, condition, indent, outdent, starter;
starter = indent = outdent = null;
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'));
};
action = function(token, i) {
return this.tokens.splice((this.tag(i - 1) === ',' ? i - 1 : i), 0, outdent);
};
return this.scanTokens(function(token, i, tokens) {
var action, condition, indent, outdent, starter, tag, _ref, _ref2;
var tag, _ref, _ref2;
tag = token[0];

@@ -220,9 +237,2 @@ if (tag === 'TERMINATOR' && this.tag(i + 1) === 'THEN') {

tokens.splice(i + 1, 0, indent);
condition = function(token, i) {
var _ref3;
return token[1] !== ';' && (_ref3 = token[0], __indexOf.call(SINGLE_CLOSERS, _ref3) >= 0) && !(token[0] === 'ELSE' && (starter !== 'IF' && starter !== 'THEN'));
};
action = function(token, i) {
return this.tokens.splice((this.tag(i - 1) === ',' ? i - 1 : i), 0, outdent);
};
this.detectEnd(i + 2, condition, action);

@@ -237,3 +247,4 @@ if (tag === 'THEN') tokens.splice(i, 1);

Rewriter.prototype.tagPostfixConditionals = function() {
var condition;
var action, condition, original;
original = null;
condition = function(token, i) {

@@ -243,9 +254,11 @@ var _ref;

};
action = function(token, i) {
if (token[0] !== 'INDENT' || (token.generated && !token.fromThen)) {
return original[0] = 'POST_' + original[0];
}
};
return this.scanTokens(function(token, i) {
var original;
if (token[0] !== 'IF') return 1;
original = token;
this.detectEnd(i + 1, condition, function(token, i) {
if (token[0] !== 'INDENT') return original[0] = 'POST_' + original[0];
});
this.detectEnd(i + 1, condition, action);
return 1;

@@ -252,0 +265,0 @@ });

@@ -25,6 +25,5 @@ (function() {

Scope.prototype.add = function(name, type, immediate) {
var pos;
if (this.shared && !immediate) return this.parent.add(name, type, immediate);
if (typeof (pos = this.positions[name]) === 'number') {
return this.variables[pos].type = type;
if (Object.prototype.hasOwnProperty.call(this.positions, name)) {
return this.variables[this.positions[name]].type = type;
} else {

@@ -74,9 +73,10 @@ return this.positions[name] = this.variables.push({

Scope.prototype.freeVariable = function(type) {
Scope.prototype.freeVariable = function(name, reserve) {
var index, temp;
if (reserve == null) reserve = true;
index = 0;
while (this.check((temp = this.temporary(type, index)))) {
while (this.check((temp = this.temporary(name, index)))) {
index++;
}
this.add(temp, 'var', true);
if (reserve) this.add(temp, 'var', true);
return temp;

@@ -89,3 +89,3 @@ };

assigned: true
});
}, true);
return this.hasAssignments = true;

@@ -92,0 +92,0 @@ };

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

"author": "Jeremy Ashkenas",
"version": "1.1.3",
"version": "1.2.0",
"licenses": [{

@@ -29,5 +29,5 @@ "type": "MIT",

"devDependencies": {
"uglify-js": "1.0.6",
"jison": "0.2.11"
"uglify-js": ">=1.0.0",
"jison": ">=0.2.0"
}
}

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