sweet-array-slice
sweet.js macro for array slice. It's specifically intended to deal with deoptimization due to arguments slicing.
How to use
npm install sweet-array-slice sweet npm install -g sweet.js # if you don't already have sweet.js sjs -m sweet-array-slice <your-sweet-code>
Example
Before
// test.js // example 1var a = ;// example 2var b = ;// example 3var c = ;
After
// example 1var length$311 = argumentslength;var a$312 = length$311;for var i$313 = 0; i$313 < length$311; i$313++ a$312i$313 = argumentsi$313;// example 2var length$315 = argumentslength;var start$316 = Math;var b$317 = length$315 - start$316;for var i$318 = start$316; i$318 < length$315; i$318++ b$317i$318 = argumentsi$318;// example 3var length$320 = argumentslength;var start$321 = Math;var end$322 = Math;var c$323 = end$322 - start$321;for var i$324 = start$321; i$324 < end$322; i$324++ c$323i$324 = argumentsi$324;