0.5.1 • Published 8 years ago

propable v0.5.1

Weekly downloads
-
License
BSD-3-Clause
Repository
bitbucket
Last release
8 years ago

Propable wercker status

A collection of prop types that can be used for checking and parsing values.

API Reference

Installing / Getting Started

Install the package

npm install --save propable

and 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); // undefined

You 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); // false

Developing

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 lint

Try to automatically fix linting errors

npm run lint:fix

Testing

Execute Jest unit tests using

npm test

Tests 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 build

This saves the production ready code into 'dist/'.

0.5.1

8 years ago

0.5.0

8 years ago

0.4.1

8 years ago

0.3.0

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago