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

extra-iterable

Package Overview
Dependencies
Maintainers
1
Versions
468
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

extra-iterable

An iterable is a sequence of values.

  • 3.0.140
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.9K
increased by81.59%
Maintainers
1
Weekly downloads
Ā 
Created
Source

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


Index

PropertyDescription
isChecks if value is iterable.
getGets value at index.
setSets value at index.
swapExchanges two values.
indexGets zero-based index.
indexRangeGets index range of part of iterable.
isEmptyChecks is iterable is empty.
sizeCounts the number of values.
entriesLists all index-value pairs.
iteratorGives iterator for iterable.
manyConverts a once iterable to many.
fromConverts iterator to iterable.
takeKeeps first n values only.
dropDiscards first n values only.
headGets first value.
leftGets values from left.
concatAppends values from iterables.
pushAdds values to the end.
copyCopies part of iterable to another.
fillFills with given value.
sliceGets part of an iterable.
spliceRemoves or replaces existing values.
chunkBreaks iterable into chunks of given size.
cycleGives values that cycle through an iterable.
repeatRepeats an iterable given times.
reverseReverses the values.
rotateRotates values in iterable.
interleaveMerges values from iterables.
mergeMerges values from sorted iterables.
flatFlattens nested iterable to given depth.
minFinds smallest entry.
maxFinds largest entry.
rangeFinds smallest and largest entries.
countCounts values which satisfy a test.
partitionSegregates values by test result.
cutBreaks iterable when test passes.
splitBreaks iterable considering test as separator.
groupKeeps similar values together and in order.
joinJoins values together.
mapUpdates values based on map function.
filterKeeps the values which pass a test.
reduceReduces values to a single value.
accumulateProduces accumulating values.
cartesianProductLists cartesian product of iterables.
zipCombines values from iterables.
uniqueRemoves duplicate values.
unionGives values present in any iterable.
intersectionGives values present in both iterables.
differenceGives values not present in another iterable.
symmetricDifferenceGives values not present in both iterables.
isUniqueChecks if there are no duplicate values.
isDisjointChecks if iterables have no value in common.
hasValueChecks if iterable has a value.
hasPrefixChecks if iterable starts with a prefix.
hasSuffixChecks if iterable ends with a suffix.
hasInfixChecks if iterable contains an infix.
hasSubsequenceChecks if iterable has a subsequence.
isEqualChecks if two iterables are equal.
compareCompares two iterables.
searchFinds index of first value passing a test.
scanWhileScans from left, while a test passes.
findFinds first value passing a test.
forEachCalls a function for each value.
someChecks if any value satisfies a test.
everyChecks if all values satisfy a test.


Keywords

FAQs

Package last updated on 04 Sep 2022

Did you know?

Socket

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.

Install

Related posts

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