Modern TypeScript utilities inspired by lodash, aiming to be high performance while having minimal size impact.
npm i @extremejs/utilspnpm add @extremejs/utilsyarn add @extremejs/utilsimport { sumByFn, sumByProperty, sumBy } from "@extremejs/utils";
// or
import { sumByFn, sumByProperty, sumBy } from "@extremejs/utils/sum-by-fn";
const sum1 = sumByFn([{ a: 1 }, { a: 2 }, { a: 3 }], ({ a }) => a); // => 6
// or
const sum2 = sumByProperty([{ a: 1 }, { a: 2 }, { a: 3 }], "a"); // => 6
// or
const sum3 = sumBy([{ a: 1 }, { a: 2 }, { a: 3 }], ({ a }) => a); // => 6
// or
const sum4 = sumBy([{ a: 1 }, { a: 2 }, { a: 3 }], "a"); // => 6API usage documents are available here.
- Although this package is inspired by
lodash, the method names might not be exactly the same or have different usage API, so make sure to read the docs first before using it. - The methods do not type check at runtime
(e.g. The
Arraychunkmethod assumes thesizeparameter is always a valid positive integer) so make sure you pass the correct values based on thedocuments/typescripttypes.
We use SemVer for versioning. For the versions available, see the releases on this repository.
- Ardalan Amini - Core Maintainer - @ardalanamini
See also the list of contributors who participated in this project.
This project is licensed under the MIT License - see the LICENSE file for details.