remove-array-items

2018-11-09 admin

remove-array-items是什么

什么是remove-array-items,remove items from a javascript array without generating memory garbage

remove-array-items使用教程帮助文档

remove-array-items

Greenkeeper badge

remove items from a javascript array without generating memory garbage.

Build Status

Despite there being a number of “remove array items” in npm, I couldn’t find satisfying all criteria:

  • doesn’t generate garbage
  • performs similar or better to the native array.splice
  • has tests
  • es3+ compatible

so here we are.

originally inspired by https://gamealchemist.wordpress.com/2013/05/01/lets-get-those-javascript-arrays-to-work-fast/

(which is a gold mine for performant, non-garbage generating array operations by the way.)

api

removeItems(arr, startIdx, removeCount)

usage

const removeItems = require('remove-array-items')

const arr = [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ]

removeItems(arr, 3, 4)  // after running, arr === [ 1, 2, 3, 8, 9 ]

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-44958.html

文章标题:remove-array-items

回到顶部