mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
another refactoring for #2333
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
// Generated by CoffeeScript 1.3.3
|
||||
(function() {
|
||||
var extend, flatten;
|
||||
var extend, flatten, _ref;
|
||||
|
||||
exports.starts = function(string, literal, start) {
|
||||
return literal === string.substr(start, literal.length);
|
||||
@@ -74,10 +74,10 @@
|
||||
return array[array.length - (back || 0) - 1];
|
||||
};
|
||||
|
||||
exports.any = function(array, fn) {
|
||||
exports.any = (_ref = Array.prototype.some) != null ? _ref : function(fn) {
|
||||
var e, _i, _len;
|
||||
for (_i = 0, _len = array.length; _i < _len; _i++) {
|
||||
e = array[_i];
|
||||
for (_i = 0, _len = this.length; _i < _len; _i++) {
|
||||
e = this[_i];
|
||||
if (fn(e)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1172,7 +1172,7 @@
|
||||
Obj.prototype.children = ['properties'];
|
||||
|
||||
Obj.prototype.compileNode = function(o) {
|
||||
var i, idt, indent, isDuplicate, join, lastNoncom, node, obj, prop, propName, propNames, props, _i, _j, _len, _len1, _ref2;
|
||||
var i, idt, indent, isDuplicate, join, lastNoncom, mp, node, obj, prop, propName, propNames, props, _i, _j, _len, _len1, _ref2;
|
||||
props = this.properties;
|
||||
propNames = [];
|
||||
_ref2 = this.properties;
|
||||
@@ -1183,32 +1183,29 @@
|
||||
}
|
||||
if (prop != null) {
|
||||
propName = prop.unwrapAll().value.toString();
|
||||
mp = propName.match(/^['"]/);
|
||||
isDuplicate = function(x) {
|
||||
var ep, ex;
|
||||
if (propName === x) {
|
||||
var mx;
|
||||
if (propName === x || +propName === +x) {
|
||||
return true;
|
||||
}
|
||||
ex = ep = null;
|
||||
if (!/^[a-z$_]/i.test(x)) {
|
||||
ex = eval(x);
|
||||
if (propName === ex) {
|
||||
mx = x.match(/^['"]/);
|
||||
if (mp && mx) {
|
||||
if (eval("" + propName + " === " + x)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (!/^[a-z$_]/i.test(propName)) {
|
||||
ep = eval(propName);
|
||||
if (x === ep) {
|
||||
} else if (mx) {
|
||||
if (eval("" + x + " === " + mx[0] + propName + mx[0])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if ((ex != null) && (ep != null)) {
|
||||
if (ex === ep) {
|
||||
} else if (mp) {
|
||||
if (eval("" + propName + " === " + mp[0] + x + mp[0])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
if (any(propNames, isDuplicate)) {
|
||||
if (any.call(propNames, isDuplicate)) {
|
||||
throw SyntaxError("multiple object literal properties named \"" + propName + "\"");
|
||||
}
|
||||
propNames.push(propName);
|
||||
|
||||
Reference in New Issue
Block a user