fromfrom

LINQ inspired library to transform sequences of data.

Get started   Try it now

Simple API

The API is simple, consisting of only a single function, from. from wraps your data and allows you to define a set of chained operations on the data. Finally you explicitly converted it back into a JS type.

Type safe

The library is written 100 % with TypeScript and it comes with type definitions included. If you choose to use Typescript the whole API is built for excellent typing support.

Fast

The library uses lazy evaluation and pipelining. This means that all the elements of a sequence flow through the entire chain one by one, which means only a minimal amount of elements need to be iterated, saving precious cycles. Also there's no need for intermediary arrays, saving memory.


Getting started

Install the library using NPM

npm install --save fromfrom

Use it like a boss

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