8000 Ensure the second argument passed to `_.assign` is not treated as a `… · lodash/lodash@02687f3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 02687f3

Browse files
committed
Ensure the second argument passed to _.assign is not treated as a callback. [closes #184]
Former-commit-id: 1254e11ab02d1d5055c08400cd0a4786ed71aef2
1 parent 7ea7a6c commit 02687f3

File tree

6 files changed

+32
-41
lines changed

6 files changed

+32
-41
lines changed

dist/lodash.compat.js

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,12 +1053,10 @@
10531053
'top':
10541054
defaultsIteratorOptions.top.replace(';',
10551055
';\n' +
1056-
'if (argsLength > 2) {\n' +
1057-
" if (typeof args[argsLength - 2] == 'function') {\n" +
1058-
' var callback = createCallback(args[--argsLength - 1], args[argsLength--], 2);\n' +
1059-
" } else if (typeof args[argsLength - 1] == 'function') {\n" +
1060-
' callback = args[--argsLength];\n' +
1061-
' }\n' +
1056+
"if (argsLength > 3 && typeof args[argsLength - 2] == 'function') {\n" +
1057+
' var callback = createCallback(args[--argsLength - 1], args[argsLength--], 2);\n' +
1058+
"} else if (argsLength > 2 && typeof args[argsLength - 1] == 'function') {\n" +
1059+
' callback = args[--argsLength];\n' +
10621060
'}'
10631061
),
10641062
'loop': 'result[index] = callback ? callback(result[index], iterable[index]) : iterable[index]'
@@ -1915,12 +1913,10 @@
19151913
if (typeof deepIndicator != 'number') {
19161914
length = args.length;
19171915
}
1918-
if (length > 2) {
1919-
if (typeof args[length - 2] == 'function') {
1920-
callback = createCallback(args[--length - 1], args[length--], 2);
1921-
} else if (typeof args[length - 1] == 'function') {
1922-
callback = args[--length];
1923-
}
1916+
if (length > 3 && typeof args[length - 2] == 'function') {
1917+
callback = createCallback(args[--length - 1], args[length--], 2);
1918+
} else if (length > 2 && typeof args[length - 1] == 'function') {
1919+
callback = args[--length];
19241920
}
19251921
}
19261922
while (++index < length) {

dist/lodash.compat.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/lodash.js

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -910,12 +910,10 @@
910910
'top':
911911
defaultsIteratorOptions.top.replace(';',
912912
';\n' +
913-
'if (argsLength > 2) {\n' +
914-
" if (typeof args[argsLength - 2] == 'function') {\n" +
915-
' var callback = createCallback(args[--argsLength - 1], args[argsLength--], 2);\n' +
916-
" } else if (typeof args[argsLength - 1] == 'function') {\n" +
917-
' callback = args[--argsLength];\n' +
918-
' }\n' +
913+
"if (argsLength > 3 && typeof args[argsLength - 2] == 'function') {\n" +
914+
' var callback = createCallback(args[--argsLength - 1], args[argsLength--], 2);\n' +
915+
"} else if (argsLength > 2 && typeof args[argsLength - 1] == 'function') {\n" +
916+
' callback = args[--argsLength];\n' +
919917
'}'
920918
),
921919
'loop': 'result[index] = callback ? callback(result[index], iterable[index]) : iterable[index]'
@@ -1772,12 +1770,10 @@
17721770
if (typeof deepIndicator != 'number') {
17731771
length = args.length;
17741772
}
1775-
if (length > 2) {
1776-
if (typeof args[length - 2] == 'function') {
1777-
callback = createCallback(args[--length - 1], args[length--], 2);
1778-
} else if (typeof args[length - 1] == 'function') {
1779-
callback = args[--length];
1780-
}
1773+
if (length > 3 && typeof args[length - 2] == 'function') {
1774+
callback = createCallback(args[--length - 1], args[length--], 2);
1775+
} else if (length > 2 && typeof args[length - 1] == 'function') {
1776+
callback = args[--length];
17811777
}
17821778
}
17831779
while (++index < length) {

0 commit comments

Comments
 (0)
0