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-cloneip-designjoi-assertjuicyvojs-banyank0mmand3rhw9hybrid-chaihubot-budahippiehardhat-teaplughardhat-teaxyzhamjesthalva-clihcm-jsguruwayguruway.jslodown-rayford-smithlogankoester-nixtmakyolotide2loading-animatedluis-response-builderluis-entity-builderkrav@wesleymatthee/lotide@wojeong/lotide@xisha/lotide@xisha/lotide.@ukflava/lotide@thismr/bitmindtest-core@types/assertion-error@tzheng/lotide1@thedoctor0/vuex-shared-mutations@thahira_sheerin/lotide@xswap/v2-core@xusk_studio/geckoterminal-sdk@ya_lhl/lotide@xzess/localstoredb@yak-spirit/yak-swap-ui@zalastax/nolb-asse@zakwarsame/lotide@zabir.aa/lotide@zasal1990/lotidealrightalexa-skill-test-frameworkabbas-ahlan-rouletteTestchai2Testchai21axios-retry-ano@harinderlabana/lotide@halva-suite/halva-cli@haijoon2/lotide@haijoon2/lotidee@efeerkmen/lotide@hassanabdi/lotide@kangarooswapfinance/v2-corestart-starwars-libtype-your-package-name-heretinymce-plugin-toyui4htmltypescript-definition-testertotestip4truffle-asserttruffle-assertions@astro-my/sign-requestyemenzen-mock-clizona-xvue-router-generator@kylesferrazza/graphql-relay-updated@livecycle.io/rrweb-snapshot@lawwwlin/lotide
2.0.1

2 years ago

2.0.0

4 years ago

1.1.0

8 years ago

1.0.2

9 years ago

1.0.1

11 years ago

1.0.0

12 years ago

0.1.0

13 years ago