New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

gamla

Package Overview
Dependencies
Maintainers
1
Versions
91
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gamla

Functional programming with async

  • 12.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
123
decreased by-31.67%
Maintainers
1
Weekly downloads
 
Created
Source

Gamla

gamla is a functional programming library for Javascript/Typescript.

Installation

nodejs: npm install gamla

deno: import { pipe } from "https://deno.land/x/gamla/src/index.ts";

Docs

This library allows you to write in typescript/javascript using composition.

It has two main advantages over similar libs:

  1. It supports mixing async and sync functions
  2. It keeps the type information, so you still get type safety when programming in pipelines.

A basic example:

const histogram = pipe(
  split(""),
  filter(complement(anyjuxt(equals(" "), equals("'")))),
  // The function here is async.
  reduce((x, y) => Promise.resolve({ ...x, [y]: (x[y] || 0) + 1 }), () => ({})),
  sideEffect(console.log),
);

await histogram("let's see how many times each letter appears here");

Use case: throttling and mapping

  • you have a list of 1000 items
  • you have an async function process(item)
  • you need to process all items
  • it needs to be done concurrently, but not more than 25 at a time

then you can just do

map(throttle(25, process))(items)

FAQs

Package last updated on 03 Aug 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc