0.5.1 • Published 9 years ago
propable v0.5.1
Propable 
A collection of prop types that can be used for checking and parsing values.
Installing / Getting Started
Install the package
npm install --save propableand import/require it
import { propTypes } from 'propable';
// OR (pre ES6)
var propTypes = require('propable').propTypes;Usage
const v = '2';
typeof v; // 'string'
propTypes.number.test(v); // true
propTypes.number.parse(v); // 2
typeof propTypes.number.parse(v); // 'number'
propTypes.array.test(v); // false
propTypes.array.parse(v); // undefinedYou can also define custom prop types using the PropType class:
import PropType from 'propable/proptype';
const boolProp = new PropType(
'myBOOL', // unique type id
(v) => !!v // parser (returns the parsed value or throws an error)
);
boolProp.test(0); // true
boolProp.parse(0); // falseDeveloping
This is what you do after you have cloned the repository:
npm install
npm run build(Install dependencies & build the project.)
Linting
Execute ESLint
npm run lintTry to automatically fix linting errors
npm run lint:fixTesting
Execute Jest unit tests using
npm testTests are defined in the same directory the module lives in. They are specified in 'module.test.js' files.
Building
To build the project, execute
npm run buildThis saves the production ready code into 'dist/'.