2.1.0 • Published 3 years ago
ts-array-ext v2.1.0
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
function | description |
---|---|
average | Calculate the average values of an attribute |
chunkByCount | Split array into amount of chunks by input |
chunkBySize | Split array into amount of chunks by size |
distinct | Get distinct elements by attribute |
findAndReplace | Find and replace or create value |
groupBy | Group array into arrays by difference value of attribute |
max | Find the element with the max value of selected attribute |
median | Find the element with the median value of selected attribute |
min | Find the element with the min value of selected attribute |
reduceAsync | Clean async version of .reduce |
shuffle | Shuffles the array |
sortByAttr | Sort the array by a selected attribute |
sum | Summation of values of a selected attribute |
unionSplit | Split 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