0.0.10 • Published 4 years ago
@shedevro/web-utils v0.0.10
Web utils (WIP)
Provides assertion utility for better coding
Installation
npm install @shedevro/web-utils --save
Usage
Library uses typescript assert types like someFuntion(value): asserts value is string
etc.
import { Assert } from '@shedevro/web-utils';
// 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