fromfrom

A JS library written in TS to transform sequences of data from format to another

fromfrom

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, fromfrom wraps the given source data into a SequenceSequence 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

  • Familiar method names – Even though it’s LINQ inspired, uses familiar method names from JS.
  • Supports all main JS types – Works with arrays, objects, maps, sets, and objects that implement the iterable protocol.
  • No dependencies – Guarantees small size.
  • Type safe – Written in TypeScript. Type definitions included.
  • Deferred execution – The execution of the sequence is deferred until you begin consuming the sequence.
  • Fully tested – 100% test coverage.

Subscribe to the Newsletter

Get our latest news,tutorials,guides,tips & deals delivered to your inbox.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.