Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

assertion-error-diff

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

assertion-error-diff

A small library for creating AssertionError diffs

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

AssertionError Diff

Get It

npm install --save assertion-error-diff
# or
yarn add assertion-error-diff

API

createAssertionError :: string -> a -> a -> AssertionError a

Creates an AssertionError

Example:

import { createAssertionError } from 'assertion-error-diff'

const error = createAssertionError('Not a truthy value', true, false)

throw error
errorToString :: Error -> string

Given an Error it will create a string representation. If the Error given
is an AssertionError it will create a diff of the expected and actual values.

Example:

import { errorToString, createAsssertionError } from 'assertion-error-diff'

errorToString(new Error('foo')) // 'Error: foo'

errorToString(createAssertionError('foo', 'bar', 'baz'))
// AssertionError: foo
// - expected + actual
//
// bar !== baz
isAssertionError :: Error -> boolean

Given an Error it returns true if that Error is an AssertionError
false otherwise.

Example:

import { isAssertionError, createAssertionError } from 'assertion-error-diff'

isAssertionError(new Error('foo')) // false
isAssertionError(createAssertionError('foo', 'bar', 'baz')) // true

FAQs

Package last updated on 06 Jul 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc