LoudBit / is-too

Javascript type checking tool.
1 stars 0 forks source link

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

Open mrDarcyMurphy opened 9 years ago

mrDarcyMurphy commented 9 years ago

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
mrDarcyMurphy commented 9 years ago
var foo = 'bar'
is.lengthy(foo) // true - length greater than 0

A cute addition.

mrDarcyMurphy commented 9 years ago

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

mrDarcyMurphy commented 8 years ago

add minlength and maxlength as aliases.