Home Manual Reference Source

Overview

Installation

Can be managed using yarn, npm, or jspm.

yarn

yarn add @failure-abstraction/error

npm

npm install @failure-abstraction/error --save

jspm

jspm install npm:@failure-abstraction/error

Usage

First, require the polyfill at the entry point of your application

require( 'regenerator-runtime/runtime' ) ;
// or
import 'regenerator-runtime/runtime.js' ;

Then, import the library where needed

const { ... } = require( '@failure-abstraction/error' ) ;
// or
import { ... } from '@failure-abstraction/error' ;

Examples

More examples in the test files.

StopIteration

import { iter } from '@iterable-iterator/iter' ;
import { next } from '@nextable-nextator/next' ;
import { StopIteration } from '@failure-abstraction/error' ;

const data = [] ;
const it = iter(data) ;

try {
    next(it);
}
catch ( e ) {
  if (e instanceof StopIteration) {
    ...
  }
}