lil'-type
Modern, reliable, full featured, type checking helpers (based on hu)
Name | type |
Version | 0.1.2 |
Size | 2 KB / >1 KB (gzipped) |
Environment | Node, Browser |
Features
- Full type-checking support
- Support upcoming ES6 data types (Generators, Promise, Map, WeakMap...)
- Support for binary data types (Blob, File, FileReader...)
- Support for buffer data types (ArrayBuffer, DataView...)
- Support for typed arrays (Int8Array, Float32Array...)
- Smart type inference
Installation
Node.js
npm install lil-type
Browser
Via Bower
bower install lil-type
Via Component
component install lil-js/type
Or loading the script remotely
Environments
- Node.js
- Chrome >= 5
- Firefox >= 3
- Safari >= 5
- Opera >= 10
- IE >= 9
Usage
You could fetch de module via require()
if it's available.
Otherwise, global fallback will be used, exposed via lil.type
var lil =
Type checking
lil // -> truelil // -> truelil // -> truelil // -> truelil // -> true
Content checking
lil // -> truelil // -> truelil // -> truelil // -> truelil // -> falselil // -> false
Getting data type
lil // -> 'string'lil // -> 'object'lil // -> 'array'lil // -> 'regexp'lil // -> 'function'lil // -> 'undefined'
Type handle helpers
lil // -> truelil // -> truelil // -> falselil // -> falselil // -> truelil // -> truelil // -> falselil // -> false
API
lil.isBool(o)
Alias: isBoolean
lil.isNumber(o)
lil.isNaN(o)
lil.isFinite(o)
lil.isString(o)
lil.isDate(o)
lil.isRegExp(o)
lil.isError(o)
lil.isFn(o)
Alias: isFunction
lil.isArguments(o)
lil.isSymbol(o)
lil.isArray(o)
lil.isTypedArray(o)
lil.isObject(o)
lil.isPlainObject(o)
lil.isElement(o)
lil.isNull(o)
lil.isUndefined(o)
lil.isPromise(o)
lil.isGenerator(o)
lil.isMap(o)
lil.isBinary(o)
lil.isBlob(o)
lil.isFile(o)
lil.isBuffer(o)
lil.isEmpty(o)
lil.notEmpty(o)
lil.isIterable(o)
lil.isPrimitive(o)
lil.isMutable(o)
lil.is(o)
Alias: isType
lil.type.VERSION
Contributing
Wanna help? Cool! It will be appreciated :)
You must add new test cases for any new feature or refactor you do, always following the same design/code patterns that already exist
Development
Only node.js is required for development
Clone the repository
$ git clone https://github.com/lil-js/type.git && cd type
Install dependencies
$ npm install
Generate browser bundle source
$ make browser
Run tests
$ make test
License
MIT © Tomas Aparicio