|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
825 bytes
|
| Line | |
|---|
| 1 | // Internal function that returns an efficient (for current engines) version
|
|---|
| 2 | // of the passed-in callback, to be repeatedly applied in other Underscore
|
|---|
| 3 | // functions.
|
|---|
| 4 | function optimizeCb(func, context, argCount) {
|
|---|
| 5 | if (context === void 0) return func;
|
|---|
| 6 | switch (argCount == null ? 3 : argCount) {
|
|---|
| 7 | case 1: return function(value) {
|
|---|
| 8 | return func.call(context, value);
|
|---|
| 9 | };
|
|---|
| 10 | // The 2-argument case is omitted because we’re not using it.
|
|---|
| 11 | case 3: return function(value, index, collection) {
|
|---|
| 12 | return func.call(context, value, index, collection);
|
|---|
| 13 | };
|
|---|
| 14 | case 4: return function(accumulator, value, index, collection) {
|
|---|
| 15 | return func.call(context, accumulator, value, index, collection);
|
|---|
| 16 | };
|
|---|
| 17 | }
|
|---|
| 18 | return function() {
|
|---|
| 19 | return func.apply(context, arguments);
|
|---|
| 20 | };
|
|---|
| 21 | }
|
|---|
| 22 |
|
|---|
| 23 | module.exports = optimizeCb;
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.