File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed
packages/core-js/internals Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -6,14 +6,16 @@ var lengthOfArrayLike = require('../internals/length-of-array-like');
6
6
7
7
var $TypeError = TypeError ;
8
8
9
+ var REDUCE_EMPTY = 'Reduce of empty array with no initial value' ;
10
+
9
11
// `Array.prototype.{ reduce, reduceRight }` methods implementation
10
12
var createMethod = function ( IS_RIGHT ) {
11
13
return function ( that , callbackfn , argumentsLength , memo ) {
12
14
var O = toObject ( that ) ;
13
15
var self = IndexedObject ( O ) ;
14
16
var length = lengthOfArrayLike ( O ) ;
15
17
aCallable ( callbackfn ) ;
16
- if ( length === 0 && argumentsLength < 2 ) throw new $TypeError ( 'Reduce of empty array with no initial value' ) ;
18
+ if ( length === 0 && argumentsLength < 2 ) throw new $TypeError ( REDUCE_EMPTY ) ;
17
19
var index = IS_RIGHT ? length - 1 : 0 ;
18
20
var i = IS_RIGHT ? - 1 : 1 ;
19
21
if ( argumentsLength < 2 ) while ( true ) {
@@ -24,7 +26,7 @@ var createMethod = function (IS_RIGHT) {
24
26
}
25
27
index += i ;
26
28
if ( IS_RIGHT ? index < 0 : length <= index ) {
27
- throw new $TypeError ( 'Reduce of empty array with no initial value' ) ;
29
+ throw new $TypeError ( REDUCE_EMPTY ) ;
28
30
}
29
31
}
30
32
for ( ; IS_RIGHT ? index >= 0 : length > index ; index += i ) if ( index in self ) {
You can’t perform that action at this time.
0 commit comments