Nobody's Perfect, Man

    This package has been deprecated

    Author message:

    No longer supported

    safety-net

    0.0.1 • Public • Published

    safety-net

    a toolset for adding safety to your asynchronous functional pipelines

    This module attempts to offer the same general API as handrail (for dealing with synchronous logical disjunctions / Eithers) but to model asynchronous operations (using the excellent fluture library) instead.

    Here's the mapping of APIs:

    handrail => safety-net

    • rail => anchor
    • handrail => safety-net
    • guideRail => tether

    Given the asynchronous goals of this library, multiRail doesn't make as much sense, as chaining over the resulting values is problematic (when you can instead just add a clause to the tether API)

    • multiRail => null

    Install

    yarn add safety-net -S
    

    or

    npm i safety-net -S
    

    API

    safetyNet

    Parameters

    • assertion function a function to test the input with
    • wrongPath function a function to prepare data before it passes into the Left path
    • rightPath function a function to modify after it passes into the Right path
    • input any any input

    Returns (GuidedLeft | GuidedRight) a Future

    anchor

    Add safety to your pipelines!

    Parameters

    • assertion function boolean-returning function
    • wrongPath function function invoked if the inputs are bad
    • input any any input

    Returns (GuidedRight | GuidedLeft) Left / Right -wrapped value

    tether

    tie multiple assertions some input

    Parameters

    • anchors Array<functions> an array of [assertion, failCase] pairs
    • goodPath function what to do if things go well
    • input any whatever

    Returns (GuidedLeft | GuidedRight) a Future

    bimap

    Parameters

    • rejectionMap function do something if function receives a rejection
    • resolutionMap function do something if function receives a resolution
    • future Future a Future(value)

    Returns Future a mapped future

    Keywords

    none

    Install

    npm i safety-net

    DownloadsWeekly Downloads

    3

    Version

    0.0.1

    License

    ISC

    Last publish

    Collaborators

    • brekk