Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@effect/data

Package Overview
Dependencies
Maintainers
3
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@effect/data

Functional programming in TypeScript

  • 0.18.1
  • Source
  • npm
  • Socket score

Version published
Maintainers
3
Created

What is @effect/data?

@effect/data is a functional programming library for JavaScript and TypeScript that provides a collection of data structures and utilities to work with immutable data, functional effects, and more. It aims to help developers write more predictable and maintainable code by leveraging functional programming principles.

What are @effect/data's main functionalities?

Immutable Data Structures

Provides immutable data structures like List, Map, and Set. These structures help in maintaining immutability in your code, making it easier to reason about state changes.

const { List } = require('@effect/data');

const list = List.of(1, 2, 3);
const newList = list.append(4);
console.log(newList.toArray()); // [1, 2, 3, 4]

Functional Effects

Allows you to work with functional effects, which are computations that can produce side effects. This helps in managing side effects in a controlled manner.

const { Effect } = require('@effect/data');

const effect = Effect.of(() => console.log('Hello, World!'));
effect.run();

Option and Either

Provides Option and Either types for handling optional values and computations that can fail, respectively. These types help in avoiding null or undefined values and managing errors more effectively.

const { Option, Either } = require('@effect/data');

const someValue = Option.some(42);
const noneValue = Option.none();

const rightValue = Either.right('Success');
const leftValue = Either.left('Error');

console.log(someValue.isSome()); // true
console.log(noneValue.isNone()); // true
console.log(rightValue.isRight()); // true
console.log(leftValue.isLeft()); // true

Pattern Matching

Supports pattern matching, which allows you to match values against patterns and execute code based on the matched pattern. This can make your code more expressive and concise.

const { match } = require('@effect/data');

const value = 2;
const result = match(value)
  .case(1, () => 'one')
  .case(2, () => 'two')
  .case(3, () => 'three')
  .default(() => 'unknown');

console.log(result); // 'two'

Other packages similar to @effect/data

FAQs

Package last updated on 31 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