2 YUI 3.13.0 (build 508226d)
3 Copyright 2013 Yahoo! Inc. All rights reserved.
4 Licensed under the BSD License.
5 http://yuilibrary.com/license/
8 YUI.add('dump', function (Y, NAME) {
11 * Returns a simple string representation of the object or array.
12 * Other types of objects will be returned unprocessed. Arrays
13 * are expected to be indexed. Use object notation for
16 * If included, the dump method is added to the YUI instance.
28 * Returns a simple string representation of the object or array.
29 * Other types of objects will be returned unprocessed. Arrays
30 * are expected to be indexed.
33 * @param {Object} o The object to dump.
34 * @param {Number} d How deep to recurse child objects, default 3.
35 * @return {String} the dump result.
38 dump = function(o, d) {
39 var i, len, s = [], type = L.type(o);
41 // Cast non-objects to string
42 // Skip dates because the std toString is what we want
43 // Skip HTMLElement-like objects because trying to dump
44 // an element will cause an unhandled exception in FF 2.x
47 } else if (type == 'date') {
49 } else if (o.nodeType && o.tagName) {
50 return o.tagName + '#' + o.id;
51 } else if (o.document && o.navigator) {
53 } else if (o.location && o.body) {
55 } else if (type == 'function') {
59 // dig into child objects the depth specifed. Default 3
60 d = (L.isNumber(d)) ? d : 3;
63 if (type == 'array') {
65 for (i = 0, len = o.length; i < len; i = i + 1) {
66 if (L.isObject(o[i])) {
67 s.push((d > 0) ? L.dump(o[i], d - 1) : OBJ);
78 } else if (type == 'regexp') {
80 // objects {k1 => v1, k2 => v2}
84 if (o.hasOwnProperty(i)) {
87 if (L.isObject(o[i])) {
88 s.push((d > 0) ? L.dump(o[i], d - 1) : OBJ);
94 s.push('Error: ' + e.message);
112 }, '3.13.0', {"requires": ["yui-base"]});