mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-12 03:47:50 +00:00
Fix failing unit test in Opera < 10.52 and add _.toArray benchmarks.
Former-commit-id: 0ed6d5c52b2486be4ccc212da7bbc7cb6d67cf7f
This commit is contained in:
2
build.js
2
build.js
@@ -814,7 +814,7 @@
|
|||||||
// remove IE `shift` and `splice` fix from mutator Array functions mixin
|
// remove IE `shift` and `splice` fix from mutator Array functions mixin
|
||||||
source = source.replace(/(?:\s*\/\/.*)*\n( +)if *\(value.length *=== *0[\s\S]+?\n\1}/, '');
|
source = source.replace(/(?:\s*\/\/.*)*\n( +)if *\(value.length *=== *0[\s\S]+?\n\1}/, '');
|
||||||
|
|
||||||
// remove `noCharByIndex` from `_.reduceRight` and `_.toArray`
|
// remove `noCharByIndex` from `_.reduceRight`
|
||||||
source = source.replace(/noCharByIndex *&&[^:]+: *([^;]+)/g, '$1');
|
source = source.replace(/noCharByIndex *&&[^:]+: *([^;]+)/g, '$1');
|
||||||
|
|
||||||
source = removeVar(source, 'extendIteratorOptions');
|
source = removeVar(source, 'extendIteratorOptions');
|
||||||
|
|||||||
@@ -129,12 +129,15 @@
|
|||||||
var hasDontEnumBug = !propertyIsEnumerable.call({ 'valueOf': 0 }, 'valueOf');
|
var hasDontEnumBug = !propertyIsEnumerable.call({ 'valueOf': 0 }, 'valueOf');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Detect support for accessing string characters by index:
|
* Detect lack of support for accessing string characters by index:
|
||||||
* IE < 8 can't access characters by index and IE 8 can only access
|
* IE < 8 can't access characters by index and IE 8 can only access
|
||||||
* characters by index on string literals.
|
* characters by index on string literals.
|
||||||
*/
|
*/
|
||||||
var noCharByIndex = ('x'[0] + Object('x')[0]) != 'xx';
|
var noCharByIndex = ('x'[0] + Object('x')[0]) != 'xx';
|
||||||
|
|
||||||
|
/** Detect if `Array#slice` cannot be used to convert strings to arrays (e.g. Opera < 10.52) */
|
||||||
|
var noArraySliceOnStrings = slice.call('x')[0] != 'x';
|
||||||
|
|
||||||
/* Detect if `Function#bind` exists and is inferred to be fast (i.e. all but V8) */
|
/* Detect if `Function#bind` exists and is inferred to be fast (i.e. all but V8) */
|
||||||
var isBindFast = nativeBind && /\n|Opera/.test(nativeBind + toString.call(window.opera));
|
var isBindFast = nativeBind && /\n|Opera/.test(nativeBind + toString.call(window.opera));
|
||||||
|
|
||||||
@@ -727,7 +730,7 @@
|
|||||||
'beforeLoop': {
|
'beforeLoop': {
|
||||||
'array': 'if (toString.call(iteratee) == stringClass) return collection.indexOf(target) > -1'
|
'array': 'if (toString.call(iteratee) == stringClass) return collection.indexOf(target) > -1'
|
||||||
},
|
},
|
||||||
'inLoop': 'if (iteratee[index] === target) return true',
|
'inLoop': 'if (iteratee[index] === target) return true'
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1171,7 +1174,7 @@
|
|||||||
}
|
}
|
||||||
var length = collection.length;
|
var length = collection.length;
|
||||||
if (length === length >>> 0) {
|
if (length === length >>> 0) {
|
||||||
return noCharByIndex && toString.call(collection) == stringClass
|
return (noArraySliceOnStrings ? toString.call(collection) == stringClass : typeof collection == 'string')
|
||||||
? collection.split('')
|
? collection.split('')
|
||||||
: slice.call(collection);
|
: slice.call(collection);
|
||||||
}
|
}
|
||||||
|
|||||||
22
perf/perf.js
22
perf/perf.js
@@ -872,6 +872,28 @@
|
|||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
suites.push(
|
||||||
|
Benchmark.Suite('`_.toArray` with an array')
|
||||||
|
.add('Lo-Dash', function() {
|
||||||
|
lodash.toArray(numbers);
|
||||||
|
})
|
||||||
|
.add('Underscore', function() {
|
||||||
|
_.toArray(numbers);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
suites.push(
|
||||||
|
Benchmark.Suite('`_.toArray` with an object')
|
||||||
|
.add('Lo-Dash', function() {
|
||||||
|
lodash.toArray(object);
|
||||||
|
})
|
||||||
|
.add('Underscore', function() {
|
||||||
|
_.toArray(object);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
suites.push(
|
suites.push(
|
||||||
Benchmark.Suite('`_.union`')
|
Benchmark.Suite('`_.union`')
|
||||||
.add('Lo-Dash', function() {
|
.add('Lo-Dash', function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user