tomi / fromfrom

A JS library written in TS to transform sequences of data from format to another
MIT License
480 stars 9 forks source link
collection linq sequence transform typescript

fromfrom

Greenkeeper badge Build Status Coveralls Dev Dependencies Sponsored All Contributors

fromfrom is a LINQ inspired library to transform sequences of data.

Installation

npm install --save fromfrom

Documentation

Find it here.

Usage

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 }
// ]

Features

How does it work

See "how does it work" section from the initial release blog post.

Development

NPM scripts

Acknowledgement

Made with :heart: by @TomiTurtiainen.

This project is a grateful recipient of the Futurice Open Source sponsorship program. :heart:

Forked from TypeScript library starter

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Tomi Turtiainen

πŸ’» πŸ“– πŸš‡ ⚠️

jtenner

πŸ’» ⚠️ πŸ“–

Ville Vaarala

🚧

Theo

πŸ’»

Rudolf Poels

πŸ“–

Andrew Ross

πŸ›

This project follows the all-contributors specification. Contributions of any kind welcome!