Skip to content
/ allreq Public

Declarative conditional template literal string type

License

Notifications You must be signed in to change notification settings

allreq/allreq

Repository files navigation

allreq

Declarative conditional template literal string type.

NPM Version NPM Downloads License [changelog]


npm install allreq
yarn add allreq

Examples

import { allreq } from 'allreq';

let v = allreq`this could be undefined.
               if ${undefined} is undefined.`;

v === undefined; // true

This is how to make a new allreq.

import { newAllReq } from 'allreq';

const allreq = newAllReq(
  (anyArg: number) => anyArg <= 5,
  (invalidArg) => `${invalidArg} is <= 5`
);

let v = allreq`${0}, ${1}, ${2}, ${999} these are all <= 5`;

v === '999 is <= 5'; // true

License

MIT