Skip to content

Commit 32b83af

Browse files
committed
Merge pull request #1691 from megawac/chain
Simplify chain
2 parents a87161c + 47b72b5 commit 32b83af

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

underscore.js

+8-16
Original file line numberDiff line numberDiff line change
@@ -1317,9 +1317,11 @@
13171317
return template;
13181318
};
13191319

1320-
// Add a "chain" function, which will delegate to the wrapper.
1320+
// Add a "chain" function. Start chaining a wrapped Underscore object.
13211321
_.chain = function(obj) {
1322-
return _(obj).chain();
1322+
var instance = _(obj);
1323+
instance._chain = true;
1324+
return instance;
13231325
};
13241326

13251327
// OOP
@@ -1367,20 +1369,10 @@
13671369
};
13681370
});
13691371

1370-
_.extend(_.prototype, {
1371-
1372-
// Start chaining a wrapped Underscore object.
1373-
chain: function() {
1374-
this._chain = true;
1375-
return this;
1376-
},
1377-
1378-
// Extracts the result from a wrapped and chained object.
1379-
value: function() {
1380-
return this._wrapped;
1381-
}
1382-
1383-
});
1372+
// Extracts the result from a wrapped and chained object.
1373+
_.prototype.value = function() {
1374+
return this._wrapped;
1375+
};
13841376

13851377
// AMD registration happens at the end for compatibility with AMD loaders
13861378
// that may not enforce next-turn semantics on modules. Even though general

0 commit comments

Comments
 (0)