2.1.0 • Published 3 years ago

ts-array-ext v2.1.0

Weekly downloads
382
License
MPL-2.0
Repository
github
Last release
3 years ago

npm.io npm.io npm.io npm.io npm.io npm.io npm.io

TS-Array-Ext is a minimalist TypeScript library that provides a few utility functions to the Array prototype class. Inspired by LINQ functionality we aim to bring a few easy to use functions that we keep rewriting over and over. No longer. It is time to extend base JavaScript Array functions.

  • 🧠 Familiar LINQ operations & patterns
  • 💪 Strongly typed
  • 🔥 Chainable
  • 📦 <2kB mini library
  • 👫 Individual imports for optimization
  • 💯 100% coverage. No less.

Getting started

Installation

npm i ts-array-ext --save

Then either import the entire lib:

import "ts-array-ext";

Or the individual functions.

import "ts-array-ext/min";
import "ts-array-ext/sum";

Your arrays will have the functions.

const totalScore = myArr.sum(x => x.score);

Demo

Checkout this playground with all examples of usage from below.


API

functiondescription
averageCalculate the average values of an attribute
chunkByCountSplit array into amount of chunks by input
chunkBySizeSplit array into amount of chunks by size
distinctGet distinct elements by attribute
findAndReplaceFind and replace or create value
groupByGroup array into arrays by difference value of attribute
maxFind the element with the max value of selected attribute
medianFind the element with the median value of selected attribute
minFind the element with the min value of selected attribute
reduceAsyncClean async version of .reduce
shuffleShuffles the array
sortByAttrSort the array by a selected attribute
sumSummation of values of a selected attribute
unionSplitSplit the array by a given array and comparator into left/middle/right
2.1.0

3 years ago

2.0.1

3 years ago

2.0.0-rc.4

4 years ago

2.0.0

4 years ago

2.0.0-rc.2

4 years ago

2.0.0-rc.3

4 years ago

2.0.0-rc.1

4 years ago

1.1.5

4 years ago

1.1.4-rc.1

4 years ago

1.1.5-rc.1

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago