
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@sweet-monads/async
Advanced tools
Package for better developer experience with Promise
and @sweet-monad/interfaces/Monad
sweet-monads — easy-to-use monads implementation with static types definition and separated packages.
npm install @sweet-monads/async
import { chain } from "@sweet-monads/async";
import { right } from "@sweet-monads/either";
const fn = () =>
Promise.resolve(right("Hello, Sweet Monad."))
.then(chain(doSomethingAsync))
.then(chain(doOneMoreAsyncThing));
chain
chain<T, R>(fn: (v: T) => Promise<Monad<R>>): (m: Monad<T>) => Promise<Monad<R>>;
f: (v: T) => Promise<Monad<R>>
- async function which convert a Monad to another one.Promise
with mapped by fn
function value wrapped by Monad
by the Monad
implementation rule.Example:
declare function getUser(email: string): Promise<Either<UserNotFoundError, User>>;
declare function arePasswordsMatched(password: string, user: User): Promise<Either<WrongCredentialsError, boolean>>;
// result is Promise<Either<UserNotFoundError | WrongCredentialsError, boolean>>
const result = getUser("some@email.com")
.then(chain(user => arePasswordsMatched("some password", user.password)));
MIT (c) Artem Kobzar see LICENSE file.
FAQs
Promise helpers for monad
The npm package @sweet-monads/async receives a total of 0 weekly downloads. As such, @sweet-monads/async popularity was classified as not popular.
We found that @sweet-monads/async demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.