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

ist

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ist

Mini assertion library

  • 1.1.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
10K
decreased by-0.62%
Maintainers
1
Weekly downloads
 
Created
Source

ist

This is a tiny assertion library (in the same space as require("assert")) that is only a handful of lines, and exports a simple API.

var ist = require("ist")

ist([] instanceof Array) // Assert that the argument is truthy
ist(1 + 1, 2)            // Assert that two values are the same
ist(1 + 1, 3, "<")       // Assert that 2 is less than 3
ist(a, b, myCompareFunc) // Pass an arbitrary compare function

ist.throws(function() { undefined.prop }) // Ensure something throws

ist(value)

Throws a exception of class ist.Failure when value is falsy.

ist(a, b, compare)

Compares a and b, and throws an ist.Failure if the comparison fails. compare defaults to ==, but you can pass a string that corresponds to a JavaScript comparison operator, or a custom function, to compare in a different way.

ist.throws(f, matches)

Ensure that calling f throws an exception, and optionally test whether the exception matches your expectation. matches may be a regexp, which is matched against the exception's message property, a string, which should be the same as the message, or a function that takes an exception and returns a boolean.

License

This software is licensed under an MIT license.

FAQs

Package last updated on 21 Aug 2020

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