We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
__spread
var tslib = require("tslib"); const { concat } = require('lodash') var testPushES6 = function(abc) { var arr1 = [1,2,3,-1] var arr2 = [4,5,6,7,8,9,10,12,13,14,15,16,17,18,29,30,31,32,33,34,35,36,37,38,39,40] const arr = arr1.push(...arr2) } var testPush = function(abc) { var arr1 = [1,2,3,-1] var arr2 = [4,5,6,7,8,9,10,12,13,14,15,16,17,18,29,30,31,32,33,34,35,36,37,38,39,40] Array.prototype.push.apply(arr1, arr2) } var testPush2 = function(flag) { var arr1 = [1,2,3,-1] var arr2 = [4,5,6,7,8,9,10,12,13,14,15,16,17,18,29,30,31,32,33,34,35,36,37,38,39,40] arr1.push.apply(arr1, tslib.__spread(arr2)); } var testConcat = function(abc) { var arr1 = [1,2,3,-1] var arr2 = [4,5,6,7,8,9,10,12,13,14,15,16,17,18,29,30,31,32,33,34,35,36,37,38,39,40] var arr = arr1.concat(arr2) } var testConcat = function(abc) { var arr1 = [1,2,3,-1] var arr2 = [4,5,6,7,8,9,10,12,13,14,15,16,17,18,29,30,31,32,33,34,35,36,37,38,39,40] var arr = concat(arr1, arr2) } var count = 1000000 var date = Date.now() for (var i = 0; i < count; i++) { testPushES6() } // 136 console.log(Date.now() - date) var date = Date.now() for (var i = 0; i < count; i++) { testPush() } // 139 console.log(Date.now() - date) var date = Date.now() for (var i = 0; i < count; i++) { testPush2() } // 1005 console.log(Date.now() - date) var date = Date.now() for (var i = 0; i < count; i++) { testConcat() } // 310 console.log(Date.now() - date) var date = Date.now() for (var i = 0; i < count; i++) { testConcat2() } // 810 console.log(Date.now() - date)
The text was updated successfully, but these errors were encountered:
see #133
Sorry, something went wrong.
arr1.push.apply(arr1, tslib.__spreadArray([], tslib.__read(arr2)))
is 15% faster than
arr1.push.apply(arr1, tslib.__spread(arr2))
No branches or pull requests
__spread
The text was updated successfully, but these errors were encountered: