Skip to content

Commit

Permalink
move source code into src/ and convert to es6
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Reinstein committed May 26, 2020
1 parent 681c50f commit 3a67216
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"module": "dist/remove-array-items.esm.js",
"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",
"build:cjs": "rollup src/remove-array-items.js --file dist/remove-array-items.cjs.js --format cjs",
"build:esm": "rollup src/remove-array-items.js --file dist/remove-array-items.esm.js --format esm",
"prepublishOnly": "npm run build",
"test": "tap ./test"
},
Expand Down
6 changes: 3 additions & 3 deletions index.js → src/remove-array-items.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
* @param {number} removeCount How many items to remove
*/
export default function removeItems (arr, startIdx, removeCount) {
var i, length = arr.length
const length = arr.length

if (startIdx >= length || removeCount <= 0 || startIdx < 0)
return

removeCount = (startIdx + removeCount > length ? length - startIdx : removeCount)

var len = length - removeCount
const len = length - removeCount

for (i = startIdx; i < len; ++i)
for (let i = startIdx; i < len; ++i)
arr[i] = arr[i + removeCount]

arr.length = len
Expand Down

0 comments on commit 3a67216

Please sign in to comment.