Skip to content
/ FxTS Public
forked from marpple/FxTS

A functional programming library for TypeScript/JavaScript

License

Notifications You must be signed in to change notification settings

jin-Pro/FxTS

This branch is 12 commits behind marpple/FxTS:main.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Oct 21, 2024
787a538 · Oct 21, 2024
Oct 21, 2024
Nov 17, 2021
Mar 9, 2024
Oct 21, 2024
Oct 21, 2024
Oct 21, 2024
May 31, 2024
Jan 3, 2023
Nov 17, 2021
Jun 29, 2023
Jan 6, 2022
Nov 26, 2021
Jun 29, 2023
Sep 30, 2021
Apr 15, 2024
Nov 17, 2021
Mar 10, 2024
Oct 21, 2024
Oct 21, 2024
May 11, 2022
May 11, 2022
May 11, 2022
Feb 13, 2023
Nov 17, 2021
Nov 17, 2021

Repository files navigation

Build Status npm version

fxts-icon FxTS

FxTS is a functional library for TypeScript/JavaScript programmers.

Why FxTS?

  • Lazy evaluation
  • Handling concurrent requests
  • Type inference
  • Follow iteration protocols Iterable / AsyncIterable

Installation

npm install @fxts/core

Documentation

Please review the API documentation

Usage

import { each, filter, fx, map, pipe, range, take } from "@fxts/core";

pipe(
  range(10),
  map((a) => a + 10),
  filter((a) => a % 2 === 0),
  take(2),
  each((a) => console.log(a)),
);

// chaining
fx(range(10))
  .map((a) => a + 10)
  .filter((a) => a % 2 === 0)
  .take(2)
  .each((a) => console.log(a));

Usage(concurrent)

import { concurrent, countBy, flat, fx, map, pipe, toAsync } from "@fxts/core";

// maybe 1 seconds api
const fetchWiki = (page: string) =>
  fetch(`https://en.wikipedia.org/w/api.php?action=parse&page=${page}`);

const countWords = async (concurrency: number) =>
  pipe(
    ["html", "css", "javascript", "typescript"],
    toAsync,
    map(fetchWiki),
    map((res) => res.text()),
    map((words) => words.split(" ")),
    flat,
    concurrent(concurrency),
    countBy((word) => word),
  );

await countWords(); // 4 seconds
await countWords(2); // 2 seconds

you can start here

Build

  • npm run build

Running Test

  • npm test

Running Type Test

  • npm run compile:check

License

Apache License 2.0

About

A functional programming library for TypeScript/JavaScript

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 97.9%
  • JavaScript 1.7%
  • Other 0.4%