yui-lang.js revision b39897a381c2203466da5568bfd2862a54a81311
/**
* The YUI module contains the components required for building the YUI
* seed file. This includes the script loading mechanism, a simple queue,
* and the core utilities for the library.
* @module yui
* @submodule yui-base
*/
// (function() {
/**
* Provides the language utilites and extensions used by the library
* @class Lang
* @static
*/
var L = Y.Lang,
ARRAY = 'array',
BOOLEAN = 'boolean',
DATE = 'date',
ERROR = 'error',
FUNCTION = 'function',
NUMBER = 'number',
NULL = 'null',
OBJECT = 'object',
REGEX = 'regexp',
STRING = 'string',
UNDEFINED = 'undefined',
TYPES = {
'undefined' : UNDEFINED,
'number' : NUMBER,
'boolean' : BOOLEAN,
'string' : STRING,
'[object Function]' : FUNCTION,
'[object RegExp]' : REGEX,
'[object Array]' : ARRAY,
'[object Date]' : DATE,
'[object Error]' : ERROR
},
TRIMREGEX = /^\s+|\s+$/g,
EMPTYSTRING = '',
SUBREGEX = /\{\s*([^\|\}]+?)\s*(?:\|([^\}]*))?\s*\}/g;
/**
* Determines whether or not the provided item is an array.
* Returns false for array-like collections such as the
* function arguments collection or HTMLElement collection
* will return false. You can use @see Array.test if you
* want to
* @method isArray
* @static
* @param o The object to test.
* @return {boolean} true if o is an array.
*/
L.isArray = function(o) {
};
/**
* Determines whether or not the provided item is a boolean
* @method isBoolean
* @static
* @param o The object to test.
* @return {boolean} true if o is a boolean.
*/
L.isBoolean = function(o) {
return typeof o === BOOLEAN;
};
/**
* Determines whether or not the provided item is a function
* Note: Internet Explorer thinks certain functions are objects:
*
* var obj = document.createElement("object");
* Y.Lang.isFunction(obj.getAttribute) // reports false in IE
*
* var input = document.createElement("input"); // append to body
* Y.Lang.isFunction(input.focus) // reports false in IE
*
* You will have to implement additional tests if these functions
* matter to you.
*
* @method isFunction
* @static
* @param o The object to test.
* @return {boolean} true if o is a function.
*/
L.isFunction = function(o) {
};
/**
* Determines whether or not the supplied item is a date instance
* @method isDate
* @static
* @param o The object to test.
* @return {boolean} true if o is a date.
*/
L.isDate = function(o) {
// return o instanceof Date;
};
/**
* Determines whether or not the provided item is null
* @method isNull
* @static
* @param o The object to test.
* @return {boolean} true if o is null.
*/
L.isNull = function(o) {
return o === null;
};
/**
* Determines whether or not the provided item is a legal number
* @method isNumber
* @static
* @param o The object to test.
* @return {boolean} true if o is a number.
*/
L.isNumber = function(o) {
};
/**
* Determines whether or not the provided item is of type object
* or function
* @method isObject
* @static
* @param o The object to test.
* @param failfn {boolean} fail if the input is a function.
* @return {boolean} true if o is an object.
*/
var t = typeof o;
return (o && (t === OBJECT ||
};
/**
* Determines whether or not the provided item is a string
* @method isString
* @static
* @param o The object to test.
* @return {boolean} true if o is a string.
*/
L.isString = function(o) {
return typeof o === STRING;
};
/**
* Determines whether or not the provided item is undefined
* @method isUndefined
* @static
* @param o The object to test.
* @return {boolean} true if o is undefined.
*/
L.isUndefined = function(o) {
return typeof o === UNDEFINED;
};
/**
* Returns a string without any leading or trailing whitespace. If
* the input is not a string, the input will be returned untouched.
* @method trim
* @static
* @param s {string} the string to trim.
* @return {string} the trimmed string.
*/
L.trim = function(s) {
try {
} catch (e) {
return s;
}
};
/**
* A convenience method for detecting a legitimate non-null value.
* including 0/false/''
* @method isValue
* @static
* @param o The item to test.
*/
L.isValue = function(o) {
var t = L.type(o);
switch (t) {
case NUMBER:
return isFinite(o);
case NULL:
case UNDEFINED:
return false;
default:
return !!(t);
}
};
/**
* Returns a string representing the type of the item passed in.
* Known issues:
* typeof HTMLElementCollection returns function in Safari, but
* Y.type() reports object, which could be a good thing --
* but it actually caused the logic in Y.Lang.isObject to fail.
* @method type
* @param o the item to test.
* @return {string} the detected type.
*/
L.type = function(o) {
};
/**
* Lightweight version of @see Y.substitute... it uses the same template
* structure as Y.substitute, but doesn't support recursion, auto-object
* coersion, or formats
* @method sub
* @since 3.2.0
* @return {string} the substitute result.
*/
L.sub = function(s, o) {
}) : s);
};
// })();