2.0.0 • Published 6 years ago
@caiogondim/arg-type v2.0.0
arg-type
Like prop-types, but for vanilla JavaScript
Installation
npm i -S @caiogondim/arg-typeUsage
Example:
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 NumberTypes
types.arraytypes.booltypes.functypes.numbertypes.objecttypes.stringtypes.nulltypes.symboltypes.instanceOftypes.oneOftypes.oneOfTypetypes.arrayOftypes.exact
caiogondim.com · GitHub @caiogondim · Twitter @caio_gondim