JSPM

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

Assertion library for better codding

Package Exports

  • @shedevro/assert

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 (@shedevro/assert) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

GitHub Workflow Status Coveralls github npm GitHub stars

Assert

Provides assertion utility for better coding

Installation

npm install @shedevro/web-utils --save

Usage

Library uses typescript assert types like someFunction(value): asserts value is string etc.

import { Assert } from '@shedevro/assert';

// some of functions
Assert.string(val);
Assert.number(val);
Assert.boolean(val);
Assert.array(val);
Assert.instance(val, SomeInstanceClass);
...
For example
const stringValue = 'some string';

Assert.string(stringValue); // not throws error
const uppercasedValue = stringValue.toUppercase();

// OR
const mayBeStringValue = 123;
Assert.string(mayBeStringValue); // throws WebUtilsAssertionError (Error)
const uppercasedValue = mayBeStringValue.toUppercase();
...

Build

npm run build

Test

npm test