https://github.com/caiogondim/arg-type.js
Like prop-types, but for vanilla JavaScript
https://github.com/caiogondim/arg-type.js
Last synced: about 2 months ago
JSON representation
Like prop-types, but for vanilla JavaScript
- Host: GitHub
- URL: https://github.com/caiogondim/arg-type.js
- Owner: caiogondim
- License: mit
- Created: 2018-11-29T20:49:09.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-12-10T21:07:42.000Z (over 5 years ago)
- Last Synced: 2025-03-24T21:51:09.375Z (2 months ago)
- Language: JavaScript
- Homepage: https://npm.im/@caiogondim/arg-type
- Size: 79.1 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# arg-type
> Like prop-types, but for vanilla JavaScript## Installation
```bash
npm i -S @caiogondim/arg-type
```## Usage
Example:
```js
import argType, { types } from '@caiogondim/arg-type'function sum(a, b) {
argType(a, types.number)
argType(b, types.number)return a + b
}sum(1, '2') // => throws TypeError because '2' is not a Number
```## Types
- `types.array`
- `types.bool`
- `types.func`
- `types.number`
- `types.object`
- `types.string`
- `types.null`
- `types.symbol`
- `types.instanceOf`
- `types.oneOf`
- `types.oneOfType`
- `types.arrayOf`
- `types.exact`---
[caiogondim.com](https://caiogondim.com) ·
GitHub [@caiogondim](https://github.com/caiogondim) ·
Twitter [@caio_gondim](https://twitter.com/caio_gondim)