@colony/colony-js-utils

Utilities for Colony JS packages

Stats

stars 🌟issues ⚠️updated 🛠created 🐣size 🏋️‍♀️
7712Jul 21, 2021Nov 28, 2017Minified + gzip package size for @colony/colony-js-utils in KB

Readme

colonyJS Utilities

Utilities for colonyJS packages.

Installation

yarn add @colony/colony-js-utils

Usage

import { raceAgainstTimeout } from '@colony/colony-js-utils';

class MyClass {
    async somethingVerySlow() {
        return mySlowPromise();
    }
    async doSomethingCoolAsync() {
        // Will either return the result of `somethingVerySlow()` or throw throw an error on timeout
        return raceAgainstTimeout(this.somethingVerySlow(), 30000);
    }
    async doSomethingElse() {
        // Will do something on timeout, e.g. remove an event listener
        return raceAgainstTimeout(
            this.somethingVerySlow(),
            30000,
            () => this.removeEventListener('something'),
        );
    }
}

Contributing

This package is part of the colonyJS monorepo.

Please read our contributing guidelines.

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.