tomi / fromfrom
- воскресенье, 24 марта 2019 г. в 00:18:52
TypeScript
A JS library written in TS to transform sequences of data from format to another
fromfrom is a LINQ inspired library to transform sequences of data.
npm install --save fromfromFind it here.
The library exports only a single function, from. from wraps the given source data into a Sequence. Sequence has a wide range of chainable methods to operate and transform the sequence. The sequence can then be converted into a JS type.
For example
import { from } from "fromfrom";
// Transform an array of users
const users = [
{ id: 1, name: "John", age: 31, active: true },
{ id: 2, name: "Jane", age: 32, active: false },
{ id: 3, name: "Luke", age: 33, active: false },
{ id: 4, name: "Mary", age: 34, active: true },
];
from(users)
.filter(user => user.active)
.sortByDescending(user => user.age)
.toArray();
// Returns
// [
// { id: 4, name: "Mary", age: 34, active: true },
// { id: 1, name: "John", age: 31, active: true }
// ]See "how does it work" section from the initial release blog post.
npm t: Run test suitenpm start: Run npm run build in watch modenpm run test:watch: Run test suite in interactive watch modenpm run test:prod: Run linting and generate coveragenpm run build: Generate bundles and typings, create docsnpm run lint: Lints codenpm run commit: Commit using conventional commit style (husky will tell you to use it if you haven't Made with
This project is a grateful recipient of the Futurice Open Source sponsorship program.
Forked from TypeScript library starter