Git Product home page Git Product logo

rescue's Introduction

Actions Status codecov License: MIT

Conditionally catch a JavaScript exception based on type and properties.

What Where
Discussion #1
Documentation https://bigeasy.github.io/rescue
Source https://github.com/bigeasy/rescue
Issues https://github.com/bigeasy/rescue/issues
CI https://travis-ci.org/bigeasy/rescue
Coverage: https://codecov.io/gh/bigeasy/rescue
License: MIT

Rescue installs from NPM.

npm install rescue

Current documentation.

Overview

Extant is an implementation of SQL's COALESCE that I've used for some time to deal with the fact that JavaScript truthiness will treat '' and 0 as true so the || operator can't always be used to create given or default one-liner.

const { compare, raise, equal } = require('rescue')

We use the name "extant" on NPM because we want the first extant argument.

Living README.md

This README.md is also a unit test using the Proof unit test framework. We'll use the Proof okay function to assert out statements in the readme. A Proof unit test generally looks like this.

require('proof')(4, async okay => {
    okay('always okay')
    okay(true, 'okay if true')
    okay(1, 1, 'okay if equal')
    okay({ value: 1 }, { value: 1 }, 'okay if deep strict equal')
})

You can run this unit test yourself to see the output from the various code sections of the readme.

git clone [email protected]:bigeasy/rescue.git
cd rescue
npm install --no-package-lock --no-save
node test/readme.t.js

Usage

The 'extant' module exports a single coalesce function.

const { compare, raise, equal } = require('depature')

Note that Extant is SQL's COALESCE. It returns the first non-null-like value, that is the first value that is not == null, which would be null or undefined. If there is no such argument it returns null.

okay('test')

rescue's People

Contributors

flatheadmill avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

rescue's Issues

Multiple conditions ORed together.

I see the need for multiple conditions ORed together. Doable because we'll never use a function as a conditional, functions are always responses. If I'm matching strings I can stop that so as to remove ambiguity from string return values. Regular expression conditionals only.

Obviously, anything more complicated than a regex and you can simply write code.

Rethrown error stacktrace

How can I rethrow error and preserve stacktrace? I want to see "caused by" in stacktrace, it will provide more information for understanding the problem.

Support `cause`.

Appear to be favoring Interrupt by searching an array of causes, but perhaps should also look for cause which might be provided by other libraries. Otherwise, document that for the purposes of searching nested exceptions the user should use Interrupt or else petition yours truly for the change.

Seems that there needs to be a convention in the application. Do not want to extend the pattern matching language to match trees arbitrarily.

Or do I? That could be a useful utility.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.