Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
lemons
Advanced tools
Changelog
v1.6.0
LazyResult.mapSuccess()
and LazyResult.mapFailure()
methodsReadme
🍋 Common algebraïc data types for JavaScript, 'cause when life hands you lemons...
Pseudo-type:
type Maybe<T>
= Just T
| Nothing
Usage example:
import Maybe, { Just, Nothing } from 'lemons/Maybe';
// or: import { Maybe, Just, Nothing } from 'lemons';
const r1: Maybe<number> = Just(42);
r1.isJust() // => true
r1.isNothing() // => false
r1.withDefault(99) // => 42
r1.unwrap() // => 42
r1.expect('Foo') // => 42
const r2: Maybe<number> = Nothing();
r2.isJust() // => false
r2.isNothing() // => true
r2.withDefault(99) // => 99
r2.unwrap() // throws Error('Cannot unwrap a Nothing')
r2.expect('Foo') // throws Error('Foo')
Pseudo-type:
type Result<E, T>
= Ok T
| Err E
Usage example:
import Result, { Ok, Err } from 'lemons/Result';
// or: import { Result, Ok, Err } from 'lemons';
const r1: Result<string, number> = Ok(42);
r1.isOk() // => true
r1.isErr() // => false
r1.withDefault(99) // => 42
r1.unwrap() // => 42
const r2: Result<string, number> = Err('Oops');
r2.isOk() // => false
r2.isErr() // => true
r2.withDefault(99) // => 99
r2.unwrap() // throws 'Oops'
Pseudo-type:
type LazyResult<E, T>
= Initial
| Loading
| Failure E
| Success T
Useful for state management that typically has an initial, loading, and a failure/success outcome state, like page loading, or submitting a form. The following example shows how you would use the LazyResult as part of a React app, but since ADTs are simple data structures, they work with any technology.
Annotated usage example:
FAQs
Common algebraïc data types for JavaScript
The npm package lemons receives a total of 2,528 weekly downloads. As such, lemons popularity was classified as popular.
We found that lemons 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.