~canonical-isd-hackers/canonical-identity-provider/yubikey-merged

« back to all changes in this revision

Viewing changes to identityprovider/media/src-js/lazrjs/yui/json/json-stringify-debug.js

merged in latest trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
 
2
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
3
3
Code licensed under the BSD License:
4
 
http://developer.yahoo.net/yui/license.txt
5
 
version: 3.0.0
6
 
build: 1549
 
4
http://developer.yahoo.com/yui/license.html
 
5
version: 3.3.0
 
6
build: 3167
7
7
*/
8
8
YUI.add('json-stringify', function(Y) {
9
9
 
15
15
 * @for JSON
16
16
 * @static
17
17
 */
18
 
var _JSON     = Y.config.win.JSON,
 
18
var _JSON     = (Y.config.win || {}).JSON,
19
19
    Lang      = Y.Lang,
20
20
    isFunction= Lang.isFunction,
21
21
    isObject  = Lang.isObject,
22
22
    isArray   = Lang.isArray,
23
23
    _toStr    = Object.prototype.toString,
24
24
    Native    = (_toStr.call(_JSON) === '[object JSON]' && _JSON),
 
25
    useNative = !!Native,
25
26
    UNDEFINED = 'undefined',
26
27
    OBJECT    = 'object',
27
28
    NULL      = 'null',
51
52
    COLON     = ':',
52
53
    COLON_SP  = ': ',
53
54
    QUOTE     = '"',
 
55
 
54
56
    // Regex used to capture characters that need escaping before enclosing
55
57
    // their containing string in quotes.
56
58
    _SPECIAL_CHARS = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
 
59
 
57
60
    // Character substitution map for common escapes and special characters.
58
61
    _CHARS = {
59
62
        '\b': '\\b',
211
214
    return _serialize({'':o},'');
212
215
}
213
216
 
 
217
// Double check basic native functionality.  This is primarily to catch broken
 
218
// early JSON API implementations in Firefox 3.1 beta1 and beta2.
 
219
if ( Native ) {
 
220
    try {
 
221
        useNative = ( '0' === Native.stringify(0) );
 
222
    } catch ( e ) {
 
223
        useNative = false;
 
224
    }
 
225
}
 
226
 
214
227
Y.mix(Y.namespace('JSON'),{
215
228
    /**
216
229
     * Leverage native JSON stringify if the browser has a native
223
236
     * @default true
224
237
     * @static
225
238
     */
226
 
    useNativeStringify : !!Native,
 
239
    useNativeStringify : useNative,
227
240
 
228
241
    /**
229
242
     * Serializes a Date instance as a UTC date string.  Used internally by
233
246
     * @method dateToString
234
247
     * @param d {Date} The Date to serialize
235
248
     * @return {String} stringified Date in UTC format YYYY-MM-DDTHH:mm:SSZ
 
249
     * @deprecated Use a replacer function
236
250
     * @static
237
251
     */
238
252
    dateToString : function (d) {
282
296
});
283
297
 
284
298
 
285
 
}, '3.0.0' );
 
299
}, '3.3.0' );