JSPM

@octetstream/invariant

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1421
  • Score
    100M100P100Q114489F
  • License MIT

Declarative errors throwing for Node.js

Package Exports

  • @octetstream/invariant

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@octetstream/invariant) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@octetstream/invariant

Declarative errors throwing for Node.js

dependencies Status devDependencies Status Build Status Code Coverage

API

This library have a two, a little bit different APIs:

invatiant(predicate, message[...format])

  • boolean predicate – a result of some condition
  • string message – an error message
  • any format – see more about the format in a sprintf-js documentation

invariant(predicate, Error, message[, ...format])

  • Function Error – custom error class that will be used as an error constructor

Example

  import invariant from "@octetstream/invariant"

  // some of your code...

  // Will threw a TypeError
  invariant(typeof foo === "string", TypeError, "Foo should be a string, but given type is: %s", typeof foo)