Skip to content

Commit 308299f

Browse files
Merge pull request #3285 from xixixao/formatutils
Format utilities using single quoted literals
2 parents 6c786f0 + 1cc8463 commit 308299f

File tree

1 file changed

+29
-9
lines changed

1 file changed

+29
-9
lines changed

src/nodes.coffee

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2107,19 +2107,39 @@ UTILITIES =
21072107

21082108
# Correctly set up a prototype chain for inheritance, including a reference
21092109
# to the superclass for `super()` calls, and copies of any static properties.
2110-
extends: -> """
2111-
function(child, parent) { for (var key in parent) { if (#{utility 'hasProp'}.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }
2112-
"""
2110+
extends: -> "
2111+
function(child, parent) {
2112+
for (var key in parent) {
2113+
if (#{utility 'hasProp'}.call(parent, key)) child[key] = parent[key];
2114+
}
2115+
function ctor() {
2116+
this.constructor = child;
2117+
}
2118+
ctor.prototype = parent.prototype;
2119+
child.prototype = new ctor();
2120+
child.__super__ = parent.prototype;
2121+
return child;
2122+
}
2123+
"
21132124

21142125
# Create a function bound to the current value of "this".
2115-
bind: -> '''
2116-
function(fn, me){ return function(){ return fn.apply(me, arguments); }; }
2117-
'''
2126+
bind: -> '
2127+
function(fn, me){
2128+
return function(){
2129+
return fn.apply(me, arguments);
2130+
};
2131+
}
2132+
'
21182133

21192134
# Discover if an item is in an array.
2120-
indexOf: -> """
2121-
[].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }
2122-
"""
2135+
indexOf: -> "
2136+
[].indexOf || function(item) {
2137+
for (var i = 0, l = this.length; i < l; i++) {
2138+
if (i in this && this[i] === item) return i;
2139+
}
2140+
return -1;
2141+
}
2142+
"
21232143

21242144
# Shortcuts to speed up the lookup time for native functions.
21252145
hasProp: -> '{}.hasOwnProperty'

0 commit comments

Comments
 (0)