1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00

Consistently using == instead of === in conjunction with typeof.

This commit is contained in:
Jeremy Ashkenas 2010-12-30 21:15:50 -05:00
parent 83d424f2f4
commit 9bed99482a
2 changed files with 4 additions and 4 deletions

View file

@ -591,7 +591,7 @@
}
rite = new Call(rite, this.args);
rite.isNew = this.isNew;
left = new Literal("typeof " + (left.compile(o)) + " === \"function\"");
left = new Literal("typeof " + (left.compile(o)) + " == \"function\"");
return new If(left, new Value(rite), {
soak: true
});
@ -660,7 +660,7 @@
}
if (this.isNew) {
idt = this.tab + TAB;
return "(function(func, args, ctor) {\n" + idt + "ctor.prototype = func.prototype;\n" + idt + "var child = new ctor, result = func.apply(child, args);\n" + idt + "return typeof result === \"object\" ? result : child;\n" + this.tab + "})(" + (this.variable.compile(o, LEVEL_LIST)) + ", " + splatArgs + ", function() {})";
return "(function(func, args, ctor) {\n" + idt + "ctor.prototype = func.prototype;\n" + idt + "var child = new ctor, result = func.apply(child, args);\n" + idt + "return typeof result == \"object\" ? result : child;\n" + this.tab + "})(" + (this.variable.compile(o, LEVEL_LIST)) + ", " + splatArgs + ", function() {})";
}
base = new Value(this.variable);
if ((name = base.properties.pop()) && base.isComplex()) {

View file

@ -471,7 +471,7 @@ exports.Call = class Call extends Base
rite = new Value left
rite = new Call rite, @args
rite.isNew = @isNew
left = new Literal "typeof #{ left.compile o } === \"function\""
left = new Literal "typeof #{ left.compile o } == \"function\""
return new If left, new Value(rite), soak: yes
call = this
list = []
@ -520,7 +520,7 @@ exports.Call = class Call extends Base
(function(func, args, ctor) {
#{idt}ctor.prototype = func.prototype;
#{idt}var child = new ctor, result = func.apply(child, args);
#{idt}return typeof result === "object" ? result : child;
#{idt}return typeof result == "object" ? result : child;
#{@tab}})(#{ @variable.compile o, LEVEL_LIST }, #{splatArgs}, function() {})
"""
base = new Value @variable