New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@johnpaulada/maybe

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@johnpaulada/maybe

A simple Maybe implementation in JavaScript.

latest
Source
npmnpm
Version
3.0.2
Version published
Maintainers
1
Created
Source

Maybe

A simple Maybe implementation in JavaScript.

forthebadge forthebadge

Getting Started

Importing the library

To use the library, first import it:

In Node:

const Maybe = require('@johnpaulada/maybe')

As ES Module:

import Maybe from '@johnpaulada/maybe'

On the browser:

<script src="https://cdn.jsdelivr.net/npm/@johnpaulada/maybe@3.0.2/maybe.min.js"></script>

Using the library

To create a Maybe (Just/Nothing) use the of() method like this:

const value = Maybe.of(1) // Just(1)

To work with the value, you can map() for example:

const plusFive = value.map(x => x + 5) // Just(6)

To get the value outside of Maybe, use the reduce() method:

const sixValue = plusFive.reduce(x => x) // 6

or the value() method:

const sixValue = plusFive.value(0)

This will get the value of the Maybe if it's a Just and will return a 0 if it's a Nothing.

Development

  • Install Yarn.
  • Install Rollup.
  • Run yarn on the terminal to install dependencies.
  • Running rollup -c will build the library.

Roadmap

  • Lazy Evaluation
  • Example for ap
  • Example for branch

License

MIT

Keywords

maybe

FAQs

Package last updated on 07 Jul 2018

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