Skip to content

vitaly-t/iter-ops-extras

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

iter-ops-extras

⭐ Collection of custom operators for iter-ops - ones based on existing operators.

💡 It is here to show implementation examples, plus share ideas of useful operations.

📋 These are just quick copy-n-paste snippets, they are not distributed anywhere.

📣 Feel free submitting PR-s with your own custom operators, to share with others.


  • appendIf - conditionally injects value(s) after the current value.
  • average - emits an average value, with optional key selector.
  • distinctUntilChanged - filters out repeated values.
  • distinctValues - selects unique key-values, then remaps into just values.
  • flat/flatMap - replacement for default ones, to replicate Array's methods.
  • group - groups objects by a property value.
  • interval - the same as delay, but without delaying the first value.
  • join - joins strings, with optional separator.
  • mapWait - remaps and sequentially awaits promises.
  • max - emits maximum value, with optional key selector.
  • min - emits minimum value, with optional key selector.
  • numberStats - emits basic number statistics: {min, max, avg, sum, count}.
  • pluck - maps each value to its specified nested property.
  • prependIf - conditionally injects value(s) before the current value.
  • removeNotType - removes values that are not of specified primitive type(s).
  • removeType - removes values of specified primitive type(s).
  • removeNil - removes all null and undefined values.
  • repeatAll - repeats the entire iterable N times.
  • replaceIf - conditionally injects value(s) in place of the current value.
  • replaceNil - replaces every null and undefined with an alternative value.
  • slice - implements Array->slice logic (for positive start/end only).
  • sum - sums up values, with optional key selector.
  • tapLog - logs values into the console, with optional tag + selector.
  • tapOnce - taps into the very first value only.
  • toBuffer - emits a Buffer from the iterable.
  • toReadable - emits a Readable stream from the iterable.

To use these, create a folder in your project, and copy over either select operators or the entire ./src folder, which also has file ./src/index.ts that includes everything.

Some of these operators may eventually land in the main iter-ops library. Use Discussions, if you want to propose and vote on such additions.

See also Custom Operators - explains API for custom operators.

💡 TIP: Operators consume and concurrencyFork are useful helpers for custom operators.

Releases

No releases published

Packages

No packages published