0.2.0 • Published 3 months ago

@soulwallet/result v0.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

Table of Contents

Installing

Using npm:

$ npm install @soulwallet/result

Using yarn:

$ yarn add @soulwallet/result

Using pnpm:

$ pnpm add @soulwallet/result

Once the package is installed, you can import the library using import approach:

import { Result, Ok, Err } from '@soulwallet/result'

Example

import { Result, Ok, Err } from '@soulwallet/result'

async function div(a: number, b: number): Promise<Result<number, Error>> {
    if (b === 0) {
        return new Err(new Error('Division by zero'));
    }
    return new Ok(a / b);
}

async function test() {
    const result = await div(10, 2);
    if (result.isErr()) {
        console.log(`error: ${result.ERR.message}`);
    } else {
        console.log(`result: ${result.OK}`);
    }
}

License

ISC

0.2.0

3 months ago

0.1.3

5 months ago

0.1.2

7 months ago

0.1.1

9 months ago

0.0.6

9 months ago

0.0.5

9 months ago

0.0.4

9 months ago

0.0.3

10 months ago

0.0.2

10 months ago

0.0.1

10 months ago