Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

remove-array-items

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remove-array-items - npm Package Compare versions

Comparing version 2.0.1 to 3.0.0

CHANGELOG.md

20

package.json
{
"name": "remove-array-items",
"version": "2.0.1",
"version": "3.0.0",
"description": "remove items from a javascript array without generating memory garbage",
"main": "dist/remove-array-items.cjs.js",
"module": "dist/remove-array-items.esm.js",
"main": "src/remove-array-items.js",
"type": "module",
"scripts": {
"build": "npm-run-all -p build:*",
"build:cjs": "rollup index.js --file dist/remove-array-items.cjs.js --format cjs",
"build:esm": "rollup index.js --file dist/remove-array-items.esm.js --format esm",
"prepublishOnly": "npm run build",
"test": "tap ./test"
"prepublishOnly": "npm test",
"test": "tap --no-esm ./test/"
},

@@ -32,6 +29,7 @@ "repository": {

"devDependencies": {
"npm-run-all": "^4.1.3",
"rollup": "^0.67.1",
"tap": "^12.0.1"
"tap": "^14.11.0"
},
"engines": {
"node": ">=12.17"
}
}

@@ -12,4 +12,3 @@ # remove-array-items

* has tests
* es3+ compatible
* works in both commonjs (node) and es modules (import)
* is a pure es module

@@ -23,29 +22,14 @@ so here we are.

## api
## usage
```javascript
removeItems(arr, startIdx, removeCount)
```
import removeItems from 'remove-array-items'
`startIdx` is an integer `>= 0`, and `removeCount` is an integer `> 0`.
const arr = [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ]
## commonjs usage
const startIdx = 3 // integer >= 0
const removeCount = 4 // int >= 0
```javascript
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 ]
removeItems(arr, startIdx, removeCount) // after running, arr === [ 1, 2, 3, 8, 9 ]
```
## es module usage
```javascript
import removeItems from '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 ]
```

@@ -1,9 +0,7 @@

'use strict'
import removeItems from '../src/remove-array-items.js'
import tap from 'tap'
var removeItems = require('../dist/remove-array-items.cjs.js')
var test = require('tap').test
test('should return if the start index is greater than or equal to the length of the array', function(t) {
var arr = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
tap.test('should return if the start index is greater than or equal to the length of the array', function (t) {
const arr = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
removeItems(arr, arr.length + 1, 5)

@@ -14,4 +12,5 @@ t.equals(arr.length, 10)

test('should return if the remove count is 0', function(t) {
var arr = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
tap.test('should return if the remove count is 0', function (t) {
const arr = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
removeItems(arr, 2, 0)

@@ -22,4 +21,4 @@ t.equals(arr.length, 10)

test('should remove the number of elements specified from the array, starting from the start index', function(t) {
var arr = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
tap.test('should remove the number of elements specified from the array, starting from the start index', function (t) {
const arr = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
removeItems(arr, 3, 4)

@@ -30,4 +29,4 @@ t.deepEquals(arr, [ 1, 2, 3, 8, 9, 10 ])

test('should remove other elements if delete count is > than the number of elements after start index', function(t) {
var arr = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
tap.test('should remove other elements if delete count is > than the number of elements after start index', function (t) {
const arr = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
removeItems(arr, 7, 10)

@@ -38,4 +37,4 @@ t.deepEquals(arr, [ 1, 2, 3, 4, 5, 6, 7 ])

test('should remove no element if count <=0', function (t) {
var arr = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
tap.test('should remove no element if count <=0', function (t) {
const arr = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
removeItems(arr, 7, -2)

@@ -46,4 +45,4 @@ t.deepEquals(arr, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ])

test('should remove no element if start <=0', function (t) {
var arr = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
tap.test('should remove no element if start <=0', function (t) {
const arr = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
removeItems(arr, -7, 5)

@@ -54,7 +53,7 @@ t.deepEquals(arr, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ])

test("should remove the remaining elements start with 'start' if count > arr.length", function (t) {
var arr = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
tap.test("should remove the remaining elements start with 'start' if count > arr.length", function (t) {
const arr = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
removeItems(arr, 4, 100)
t.deepEquals(arr, [ 1, 2, 3, 4])
t.end()
})
})

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc