A JavaScript library to ask basic questions.
ask.isDefined(foo);
ask.isString('foo');
Returns true if the given argument is an array, false if it is not.
arr
{Array} - A given argument to analize.
ask.isArray([1, 2, 3]); // true
Returns true if the given argument is an object, false if it is not.
obj
{Object} - A given argument to analize.
ask.isObject({}); // true
Returns true if the given argument is a function, false if it is not.
fn
{Function} - A given argument to analize.
ask.isFunction(function(){}); // true
Returns true if the given argument is a string, false if it is not.
str
{String} - A given argument to analize.
ask.isString('Hello World!'); // true
Returns true if the given argument is a number, false if it is not.
num
{Number} - A given argument to analize.
ask.isNumber(1000); // true
Returns true if the given argument is a date, false if it is not.
date
{Date} - A given argument to analize.
ask.isDate(new Date()); // true
Returns true if the given argument is a regular expresion, false if it is not.
regexp
{RegExp} - A given argument to analize.
ask.isRegexp(new RegExp(foo)); // true
Returns true if the given argument is null, false if it is not.
obj
{Null} - A given argument to analize.
ask.isNull(null); // true
Returns true if the given argument is defined, false if it is not.
obj
{Object} - A given argument to analize.
ask.isNull(window); // true
Returns true if the given argument is a node element, false if it is not.
node
{HTMLElement} - A given argument to analize.
ask.isNodeElement(document.body); // true
Returns true if the given argument has focus, false if it has not.
node
{HTMLElement} - A given argument to analize.
ask.hasFocus(document); // true
Returns true if the given argument is visible into the viewport, false if it is not.
node
{HTMLElement} - A given argument to analize.
ask.isVisible(document); // true
Returns true if the given array is empty, false if it is not.
arr
{Array} - A given argument to analize.
ask.isEmpty([]); // true
Returns true if the given argument is in a given array or string, false if it is not.
value
{String} - A given value to analize.arr
{Array} - A given array or string to analize.str
{String} - A given array or string to analize.
ask.hasValue(2, [1,2,3]); // true
// or
ask.hasValue('World', 'Hello World'); // true
Returns true if a given object has a given key, false if it has not.
key
{String} - A given key to analize.obj
{Object} - A given object to analize.
ask.hasProperty('foo', {'foo': 'bar'}); // true
- Guillermo Paz (Frontend developer - JavaScript developer | Web standards lover)
- E-mail: [email protected]
- Twitter: @pazguille
- Web: http://pazguille.me
Licensed under the MIT license.
Copyright (c) 2013 @pazguille.