Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@arecalde/nnmap
Advanced tools
Readme
A function for selectively mapping through arrays
function returnIfEven(n: any): any | null {
return (n % 2 === 0) ? n : null;
}
function quitIfThree(n: any): boolean {
if (n === 3) return true;
return false;
}
function quitOnThirdItem(n: any, index: number): boolean {
if (index >= 3) return true;
return false;
}
// skip nulls
const evenValues = nnmap([1, 2, 3, 4, 5, 6], returnIfEven); // [2, 4, 6]
// quit when value is 3
const quitWhenThree = nnmap([1, 2, 3, 4, 5]), (n) => n, quitIfThree); // [1, 2]
// map until the third index (maps indexes 0, 1, 2)
const firstThreeMappedItems = nnmap([1, 2, 3, 4, 5]), (n) => n, quitOnThirdItem); // [1, 2, 3]
Parameters
Name | type | Description |
---|---|---|
arr | any[] | The array to be mapped |
cb | Callback | The mapping callback function |
qcb? | QuitCallback | If this callback returns true, nnmap quits immediately |
// example
const mappedArray = nnmap([]), (n) => n, (n, i) => null);
cb: Callback
Whatever this callback returns is inserted in the resulting array
Parameters
Name | type | Description |
---|---|---|
currentItem | any | The current array item to map to a new value |
(item) => item.foo
qcb?: QuitCallback
When this callback returns true, nnmap quits immediately and returns an array with the values mapped up to this point
Name | type | Description |
---|---|---|
currentItem | any[] | The current array item to map to a new value |
currentIndex | number | The current index being mapped |
// quit based on the current value
(item) => item.quit === true;
// quit based on the current index
(item, index) => index > 10;
FAQs
Array mapping ignoring null values
The npm package @arecalde/nnmap receives a total of 3 weekly downloads. As such, @arecalde/nnmap popularity was classified as not popular.
We found that @arecalde/nnmap 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.