1.0.0 • Published 1 year ago

@libgitname/voluptas-ea-id v1.0.0

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

Result

Result

Features

1) Data in success; 2) Error in failure; 3) Match with onSuccess & onFailure callbacks; 4) Factory.

Usage

Prepare

Create factory with Result class.

const resultFactory = new ResultFactory({
  Result
});

Commands

Result factory

ok
result.ok();
result.ok('Data');
fail
const error = new Error('Message');

result.fail(error);

Result

isSuccess

const isSuccess = result.success;

isFailure

const isFailure = result.failure;

getData

const data = result.getData();

getError

const error = result.getError();

match

result.match({
  onSuccess: () => {},
  onFailure: () => {}
});
1.0.0

1 year ago