Socket
Book a DemoInstallSign in
Socket

@synonymdev/result

Package Overview
Dependencies
Maintainers
9
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@synonymdev/result

Result helper class

latest
Source
npmnpm
Version
0.0.2
Version published
Maintainers
9
Created
Source

Result helper class

Description

Result helper class

Getting started

yarn add @synonymdev/result
#or
npm i -s @synonymdev/result

Usage

import { Result, err, ok } from '@synonymdev/result';
const func = (): Result<number> => {
  return ok(42);
  // OR
  return err('error message');
  // OR
  return err(new Error('error message'));
}

const result = func();

if (result.isOk()) {
    console.log(result.value); //42
}

if (result.isErr()) {
    console.error(result.error.message); // "error message"
}

Development

yarn build

Builds library ready for production use.

yarn test

Unit tests.

yarn format

Code formatting.

yarn lint

Code linting.

yarn prepublish

Prepares code for publishing by building and bumping package version.

FAQs

Package last updated on 06 Aug 2022

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