Socket
Socket
Sign inDemoInstall

@effect/io

Package Overview
Dependencies
Maintainers
3
Versions
183
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@effect/io

WIP.


Version published
Weekly downloads
127K
increased by44.88%
Maintainers
3
Weekly downloads
 
Created

What is @effect/io?

@effect/io is a library for building robust, type-safe, and composable applications in TypeScript. It provides a powerful set of tools for managing side effects, concurrency, and error handling in a functional programming style.

What are @effect/io's main functionalities?

Effect Management

This feature allows you to create and manage effects, which are computations that can produce values or perform side effects. The example demonstrates creating a simple effect that succeeds with the value 42 and then running it.

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

const effect = Effect.succeed(42);
effect.run().then(console.log); // Outputs: 42

Error Handling

This feature provides robust error handling capabilities. The example shows how to create an effect that fails with an error and how to handle that error when running the effect.

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

const effect = Effect.fail(new Error('Something went wrong'));
effect.run().catch(console.error); // Outputs: Error: Something went wrong

Concurrency

This feature allows you to compose and run effects concurrently. The example demonstrates combining two effects that succeed with values 1 and 2, respectively, and running them together.

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

const effect1 = Effect.succeed(1);
const effect2 = Effect.succeed(2);
const combinedEffect = Effect.zip(effect1, effect2);
combinedEffect.run().then(console.log); // Outputs: [1, 2]

Resource Management

This feature provides tools for managing resources that need to be acquired and released. The example shows how to create a resource, use it in an effect, and ensure that cleanup is performed afterward.

const { Effect, Resource } = require('@effect/io');

const resource = Resource.make(
  Effect.succeed('resource'),
  () => Effect.succeed(console.log('cleanup'))
);

resource.use(res => Effect.succeed(console.log(res))).run(); // Outputs: 'resource' and then 'cleanup'

Other packages similar to @effect/io

FAQs

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