0.1.7 • Published 5 years ago

simple-result v0.1.7

Weekly downloads
6
License
MIT
Repository
github
Last release
5 years ago

Simple Result

npm npm (tag) npm docs

Yet another Result type, inspired by Rust. This type allows you to encode a logical success or failure when it still may be useful to return a value.

For example, in some string parsing situations, it is useful to be able to parse from a list of options. In this case, a success would mean that the parsed string was one of the options, whereas a failure would imply that it wasn't. In this case, the parsed string could still be returned, such as to construct a more specific error message.

This package is part of the mcfunction-langserver project. It is published automatically - see the publishing strategy.

Example

import { Ok, Err, Result } from "simple-result";
import * as assert from "assert";

const value = Ok("Hello");
assert(isOk(value));
assert(!isErr(value));

function parse_from_option(
    parser: Parser,
    options: string[]
): Result<string, string | undefined>;
0.1.7

5 years ago

0.1.7-alpha.1

5 years ago

0.1.7-alpha.0

5 years ago

0.1.6

5 years ago

0.1.6-alpha.2

5 years ago

0.1.6-alpha.1

5 years ago

0.1.6-alpha.0

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago