2.0.1 • Published 2 years ago

assertion-error v2.0.1

Weekly downloads
4,196,390
License
MIT
Repository
github
Last release
2 years ago

What is AssertionError?

Assertion Error is a module that contains two classes: AssertionError, which is an instance of an Error, and AssertionResult which is not an instance of Error.

These can be useful for returning from a function - if the function "succeeds" return an AssertionResult and if the function fails return (or throw) an AssertionError.

Both AssertionError and AssertionResult implement the Result interface:

interface Result {
  name: "AssertionError" | "AssertionResult";
  ok: boolean;
  toJSON(...args: unknown[]): Record<string, unknown>;
}

So if a function returns AssertionResult | AssertionError it is easy to check which one is returned by checking either .name or .ok, or check instanceof Error.

Installation

Node.js

assertion-error is available on npm.

$ npm install --save assertion-error

Deno

assertion_error is available on Deno.land

import {
  AssertionError,
  AssertionResult,
} from "https://deno.land/x/assertion_error@2.0.0/mod.ts";
chai@arisageha/react-lazyload@arisageha/react-lazyload-fix@sonammalhotra/lotide@smishra17/lotide@cheapthrills/lotide@cujo-common/simple-hello-world-exampleopenid-passport@iobroker-community-adapters/iobroker.device-watcher@newhorizon-tech/dd-npm-package-template@nicholasjj/lotide@everything-registry/sub-chunk-1172synonym-jssvelvet-customwinx-form-winxwith-defer-esweb-component-tester-bundlevue-infinite-loading-propssparse-setspecify-assertionstest-solidity-npmthe_helper_packagethe_helper_packagesvite-plugin-nightwatchvisigothvcloudcam-playkit-js-hlsvue-dev-clone@dongwandonkim/lotide@donkswap/community-token-list@donkswap/default-token-list@donnadonnana1/lotide@dimcheify/dimui@coconuttt/lotide@cristianps1988/ds-template@ct-note/embed@cynax/cli-app-maker@dachico/timescript@cptntz2119/lotide@dowdev/lotide@cameron-martin/chai@borealisswap/borealis-swap-lib@benfinlay/lotide@rstock.co/lotide@pearl-d/lotideip-designjoi-assertjuicyvojs-banyank0mmand3r@kangarooswapfinance/v2-corestart-starwars-libtype-your-package-name-heretinymce-plugin-toyui4htmltypescript-definition-testertotestip4truffle-asserttruffle-assertions@aidanantony/lotide@amandip.h/lotide@amilajack/joker@arian324/lotide@appliedrec/cordova-plugin-ver-id@amoham/lotide-library@aurelianoa/metadataupdatable@astrangegoatintheshadows/lotide@astro-my/sign-request@astridcha1x/lotide@afria/afria-libraries@aiman03at/lotide@b1u3too/lotide@baloochat/react-native-svg-uri@bebopskull/lotide@beckpar/lotide@amblade/patswap-default-token-list@bethanypaul989/lotide@bseibz/lotide@brendsmvreal/lotide@cdevine49/react-numeric-input@ckeditor/ckeditor5-dev-tests@chiaraani/bouncing-ball@chakra-swap/core@4cadia/janus-indexer-smartcontract@accessors-hosts/node@abdmmn/lotide@aalibarre/lotide@academyjs/rover@chazdean/lotide@codingdud/coolicons@born3am/eslint-config@bossswap/default-token-list@bonsaiswap-lib/lib@bonsaiswapv3/core@bonsaiswapv3/deploy@bowogfc/bbpolymer@dexthefish/lotide@danispin/lotide@credbayswap/default-token-list@dannyjiang111/lotide2
2.0.1

2 years ago

2.0.0

4 years ago

1.1.0

7 years ago

1.0.2

9 years ago

1.0.1

10 years ago

1.0.0

12 years ago

0.1.0

12 years ago