LoudBit / is-too

Javascript type checking tool.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

add `is.length`, `is.longerThan`, and `is.shorterThan`

mrDarcyMurphy opened this issue · comments

Wrap javascript's stock length attribute for usage in the-thing-is.

var foo = 'bar'
var fizz = ['buzz', 'fizzbuzz']
var empty = []

is.length(foo) // true - greater than 0 length
is.length(foo, 3) // true - length is 3
is.length(foo, 2) // false - length is not 2

is.length(fizz) // true
is.length(fizz, 2) // true

is.length(empty) // false
var foo = 'bar'
is.lengthy(foo) // true - length greater than 0

A cute addition.

Also add is.longerThan and is.shorterThan with the same pattern as greaterThan and lessThan, but specifically for length.

add minlength and maxlength as aliases.