Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
extra-iterable
Advanced tools
An iterable is a sequence of values.
📦 Node.js,
🌐 Web,
📜 Files,
📰 Docs,
📘 Wiki.
Assumption here is that an iterable can only be iterated over once. Methods which require multiple iterations preserve old values in a backup array using many. Many methods accept both compare and map functions, and in some cases using only a map function enables faster comparision (like unique). I borrowed a lot of ideas from Haskell, Elm, Python, Basic, Lodash, and other NPM packages. These are mentioned in references of each method.
This package is available in Node.js and Web formats. The web format
is exposed as extra_iterable
standalone variable and can be loaded from
jsDelivr CDN.
Stability: Experimental.
const iterable = require('extra-iterable');
// import * as iterable from "extra-iterable";
// import * as iterable from "https://unpkg.com/extra-iterable/index.mjs"; (deno)
var x = [2, 4, 6, 8];
iterable.get(x, 1);
// 4
var x = [1, 2, 3, 4];
[...iterable.swap(x, 0, 1)];
// [ 2, 1, 3, 4 ]
var x = [1, 2, 3];
[...iterable.cycle(x, 0, 4)];
// [1, 2, 3, 1]
var x = [1, 2, 3, 4];
iterable.reduce(x, (acc, v) => acc+v);
// 10
Property | Description |
---|---|
is | Checks if value is iterable. |
get | Gets value at index. |
set | Sets value at index. |
swap | Exchanges two values. |
index | Gets zero-based index. |
indexRange | Gets index range of part of iterable. |
isEmpty | Checks is iterable is empty. |
size | Counts the number of values. |
entries | Lists all index-value pairs. |
iterator | Gives iterator for iterable. |
many | Converts a once iterable to many. |
from | Converts iterator to iterable. |
take | Keeps first n values only. |
drop | Discards first n values only. |
head | Gets first value. |
left | Gets values from left. |
concat | Appends values from iterables. |
push | Adds values to the end. |
copy | Copies part of iterable to another. |
fill | Fills with given value. |
slice | Gets part of an iterable. |
splice | Removes or replaces existing values. |
chunk | Breaks iterable into chunks of given size. |
cycle | Gives values that cycle through an iterable. |
repeat | Repeats an iterable given times. |
reverse | Reverses the values. |
rotate | Rotates values in iterable. |
interleave | Merges values from iterables. |
merge | Merges values from sorted iterables. |
flat | Flattens nested iterable to given depth. |
min | Finds smallest entry. |
max | Finds largest entry. |
range | Finds smallest and largest entries. |
count | Counts values which satisfy a test. |
partition | Segregates values by test result. |
cut | Breaks iterable when test passes. |
split | Breaks iterable considering test as separator. |
group | Keeps similar values together and in order. |
join | Joins values together. |
map | Updates values based on map function. |
filter | Keeps the values which pass a test. |
reduce | Reduces values to a single value. |
accumulate | Produces accumulating values. |
cartesianProduct | Lists cartesian product of iterables. |
zip | Combines values from iterables. |
unique | Removes duplicate values. |
union | Gives values present in any iterable. |
intersection | Gives values present in both iterables. |
difference | Gives values not present in another iterable. |
symmetricDifference | Gives values not present in both iterables. |
isUnique | Checks if there are no duplicate values. |
isDisjoint | Checks if iterables have no value in common. |
hasValue | Checks if iterable has a value. |
hasPrefix | Checks if iterable starts with a prefix. |
hasSuffix | Checks if iterable ends with a suffix. |
hasInfix | Checks if iterable contains an infix. |
hasSubsequence | Checks if iterable has a subsequence. |
isEqual | Checks if two iterables are equal. |
compare | Compares two iterables. |
search | Finds index of first value passing a test. |
scanWhile | Scans from left, while a test passes. |
find | Finds first value passing a test. |
forEach | Calls a function for each value. |
some | Checks if any value satisfies a test. |
every | Checks if all values satisfy a test. |
FAQs
An iterable is a sequence of values.
The npm package extra-iterable receives a total of 1,725 weekly downloads. As such, extra-iterable popularity was classified as popular.
We found that extra-iterable demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.