Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
giorgosart committed Apr 24, 2019
1 parent be884dc commit 9304b03
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,30 @@
[![Test](https://img.shields.io/npm/v/strong-typed.svg?style=flat)](https://www.npmjs.com/package/strong-typed)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)


# strong-typed
A tiny, no dependency javascript library for runtime type checking.

## Installation
```
npm i strong-typed
```

## Usage
Strong-typed takes two arguments:

| Parameter | Type | Description |
|-----------|----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Types | array | A javascript array of supported types (supported types are `any`, `date`, `integer`, `boolean`, `decimal`, `string`, `object`, `function` and `array`). The number of elements in the array **must** match the parameter number of function that's passed in. |
| Fn | function | The javascript function to be type checked |
### Examples
```
import st from 'strong-typed';
const myFunc = st(['string'], (a) => { console.log(a) });
myFunc(); // Error: Function expects 1 arguments, instead only 0 parameter(s) passed in.
myFunc(1); // Error: Expected argument 1 to be of type 'string'
myFunc("1"); // Will print 1 in the console
```

0 comments on commit 9304b03

Please sign in to comment.