lil'-type
![Gitter chat](https://camo.githubusercontent.com/89d4a65f64e9e1199464500e371d7256a9cd3272181e7a9b84dc0ab0834b3900/68747470733a2f2f6261646765732e6769747465722e696d2f6c696c2d6a732f747970652e706e67)
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 |
- 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
npm install lil-type
Via Bower
bower install lil-type
Via Component
component install lil-js/type
Or loading the script remotely
<script src="//cdn.rawgit.com/lil-js/type/0.1.2/type.js"></script>
- Node.js
- Chrome >= 6
- Firefox >= 4
- Safari >= 5.1
- Opera >= 12
- IE >= 9
You could fetch de module via require()
if it's available.
Otherwise, global fallback will be used, exposed via lil.type
var lil = require('lil-type')
lil.isObject({}) // -> true
lil.isArray([1,2,3]) // -> true
lil.isNumber(1.2) // -> true
lil.isBool(1.2) // -> true
lil.isRegExp(/[a-z]/) // -> true
lil.isEmpty(void 0) // -> true
lil.isEmpty('') // -> true
lil.isEmpty([]) // -> true
lil.isEmpty({}) // -> true
lil.isEmpty(1.5) // -> false
lil.isEmpty(new Date) // -> false
lil.is('name') // -> 'string'
lil.is({}) // -> 'object'
lil.is([1]) // -> 'array'
lil.is(/[a-z]/) // -> 'regexp'
lil.is(function () {}) // -> 'function'
lil.is(void 0) // -> 'undefined'
lil.isIterable([1,2,3]) // -> true
lil.isIterable({ name: 'Chuck' }) // -> true
lil.isIterable(function () {}) // -> false
lil.isIterable(true) // -> false
lil.isMutable({}) // -> true
lil.isMutable([]) // -> true
lil.isMutable('') // -> false
lil.isMutable(/[a-z]/) // -> false
Alias: isBoolean
Alias: isFunction
Alias: isType
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
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
MIT © Tomas Aparicio