1.1.0 • Published 1 year ago

quite-possibly v1.1.0

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

quite-possibly

The idea for this library was taken straight from Rust's result and option types. The provided types are accessible through the Result and Option types, with functions for creating the respective variants.

Options

Options are used to wrap null values, and can be used like so

import { Option } from "quite-possibly";

let someValue = null;
let option = Option.from(someValue);

option
  .map((val) => {
    console.log(val);
  })
  .orElse(() => {
    console.log("Oh no");
  });

Results

Much like options, results can be used like the following:

import { Result } from "quite-possibly";

const throws = () => {
  // Image some code
};

const result = Result.wrap(throws);

result
  .map((value) => {
    console.log("Aye it worked", value);
  })
  .mapErr((ex) => {
    console.log("Oh no", ex);
  });
1.1.0

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago