File tree Expand file tree Collapse file tree 2 files changed +8
-7
lines changed
Expand file tree Collapse file tree 2 files changed +8
-7
lines changed Original file line number Diff line number Diff line change 11var Benchmark = require ( 'benchmark' )
2- var Suite = new Benchmark . Suite
2+ var Suite = new Benchmark . Suite ( )
33var insert = require ( './index.js' )
44
55var testString = 'abcdefg'
Original file line number Diff line number Diff line change 66 * @returns {Array|String } New modified value depending on `input` type.
77 */
88module . exports = function ( input , value , index ) {
9- var isStringInput = typeof input === 'string'
10- if ( ! isStringInput && ! Array . isArray ( input ) )
9+ const isStringInput = typeof input === 'string'
10+ if ( ! isStringInput && ! Array . isArray ( input ) ) {
1111 throw new TypeError ( 'First argument invalid. Expected Array or String.' )
12- if ( typeof index !== 'undefined' && typeof index !== 'number' )
12+ }
13+ if ( typeof index !== 'undefined' && typeof index !== 'number' ) {
1314 throw new TypeError ( 'Third argument invalid. Expected Number.' )
14- // Avoid negative index offset
15- var beacon = index || 0
15+ }
16+ const beacon = index || 0
1617 // concat([value]) is faster than concat(value) for String, Number and Object
17- var insert = ( Array . isArray ( value ) || isStringInput ) ? value : [ value ]
18+ const insert = ( Array . isArray ( value ) || isStringInput ) ? value : [ value ]
1819 return input . slice ( 0 , beacon ) . concat ( insert ) . concat ( input . slice ( beacon ) )
1920}
You can’t perform that action at this time.
0 commit comments