JSPM

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

Preconditions utility for TypeScript and JavaScript.

Package Exports

  • @dozerg/condition
  • @dozerg/condition/dist/index.js

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

Readme

Condition

npm Downloads Build Status

Utilities for preconditions and assertions for TypeScript and JavaScript.

Install

npm i @dozerg/condition

Usage

import { isNonNull, assertNonNull } from '@dozerg/condition';

function foo(p?: string) {
  assertNonNull(p);
  p.length; // OK, p is string
  // ...

  const a = [1, undefined, 2];   // a is (number | undefined)[]
  const b = a.filter(isNonNull); // b is [1, 2], i.e. number[]
  // ...
}

APIs

License

MIT © Zhao DAI daidodo@gmail.com