Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
remove-item-array
Advanced tools
πͺremove array duplicates or customized with JS.
install:
yarn add remove-item-array
npm install remove-item-array --save
use:
const {
removeItems,
removeDuplicates
} = require('remove-item-array')
let arr = ['π', 'π', 'π','π«','π','π','π','π','π','π','π«']
// remove all
removeDuplicates(arr)
// or remove 'π'
removeDuplicates(arr, 'π')
// remove nums
removeItems(arr, 1, 4)
removeDuplicates(arr, item(?))
Removes item duplicates from an array.
arr
: {Array<*>} The target array.item
: {<*>} Removes item specified duplicate.removeItems(arr, start, count)
Performs better to splice, use Proxy can compare splice with removeItems.
arr
: {Array<*>} The target array.start
: {Number} start The index to begin removing.count
: The count of items need to remove.The function that removes all repeating elements, I code four methods, and made a comparison.
The array:
arr = [1, 1, 2, 5, 3, 1, 1, 2, 5, 3, 1, 1, 2, 5, 3, 1, 1, 2, 5, 3, 1, 1, 2, 5, 3, 1, 1, 2, 5, 3, 1, 1, 2, 5, 3]
You can view the results via the https://jsperf.com/removeduplicatesarray
The results:
By comparison, it can be seen that the performance of filter()
is better, so the function adopts the filter()
.
just run
yarn test
MIT.
FAQs
remove array duplicates or customized with JS
We found that remove-item-array demonstrated a not healthy version release cadence and project activity because the last version was released a year ago.Β It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.