.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / loglevel / test / vendor / json2.js
diff --git a/.config/coc/extensions/node_modules/coc-prettier/node_modules/loglevel/test/vendor/json2.js b/.config/coc/extensions/node_modules/coc-prettier/node_modules/loglevel/test/vendor/json2.js
new file mode 100644 (file)
index 0000000..f7eb646
--- /dev/null
@@ -0,0 +1,486 @@
+/*\r
+    json2.js\r
+    2012-10-08\r
+\r
+    Public Domain.\r
+\r
+    NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\r
+\r
+    See http://www.JSON.org/js.html\r
+\r
+\r
+    This code should be minified before deployment.\r
+    See http://javascript.crockford.com/jsmin.html\r
+\r
+    USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO\r
+    NOT CONTROL.\r
+\r
+\r
+    This file creates a global JSON object containing two methods: stringify\r
+    and parse.\r
+\r
+        JSON.stringify(value, replacer, space)\r
+            value       any JavaScript value, usually an object or array.\r
+\r
+            replacer    an optional parameter that determines how object\r
+                        values are stringified for objects. It can be a\r
+                        function or an array of strings.\r
+\r
+            space       an optional parameter that specifies the indentation\r
+                        of nested structures. If it is omitted, the text will\r
+                        be packed without extra whitespace. If it is a number,\r
+                        it will specify the number of spaces to indent at each\r
+                        level. If it is a string (such as '\t' or ' '),\r
+                        it contains the characters used to indent at each level.\r
+\r
+            This method produces a JSON text from a JavaScript value.\r
+\r
+            When an object value is found, if the object contains a toJSON\r
+            method, its toJSON method will be called and the result will be\r
+            stringified. A toJSON method does not serialize: it returns the\r
+            value represented by the name/value pair that should be serialized,\r
+            or undefined if nothing should be serialized. The toJSON method\r
+            will be passed the key associated with the value, and this will be\r
+            bound to the value\r
+\r
+            For example, this would serialize Dates as ISO strings.\r
+\r
+                Date.prototype.toJSON = function (key) {\r
+                    function f(n) {\r
+                        // Format integers to have at least two digits.\r
+                        return n < 10 ? '0' + n : n;\r
+                    }\r
+\r
+                    return this.getUTCFullYear()   + '-' +\r
+                         f(this.getUTCMonth() + 1) + '-' +\r
+                         f(this.getUTCDate())      + 'T' +\r
+                         f(this.getUTCHours())     + ':' +\r
+                         f(this.getUTCMinutes())   + ':' +\r
+                         f(this.getUTCSeconds())   + 'Z';\r
+                };\r
+\r
+            You can provide an optional replacer method. It will be passed the\r
+            key and value of each member, with this bound to the containing\r
+            object. The value that is returned from your method will be\r
+            serialized. If your method returns undefined, then the member will\r
+            be excluded from the serialization.\r
+\r
+            If the replacer parameter is an array of strings, then it will be\r
+            used to select the members to be serialized. It filters the results\r
+            such that only members with keys listed in the replacer array are\r
+            stringified.\r
+\r
+            Values that do not have JSON representations, such as undefined or\r
+            functions, will not be serialized. Such values in objects will be\r
+            dropped; in arrays they will be replaced with null. You can use\r
+            a replacer function to replace those with JSON values.\r
+            JSON.stringify(undefined) returns undefined.\r
+\r
+            The optional space parameter produces a stringification of the\r
+            value that is filled with line breaks and indentation to make it\r
+            easier to read.\r
+\r
+            If the space parameter is a non-empty string, then that string will\r
+            be used for indentation. If the space parameter is a number, then\r
+            the indentation will be that many spaces.\r
+\r
+            Example:\r
+\r
+            text = JSON.stringify(['e', {pluribus: 'unum'}]);\r
+            // text is '["e",{"pluribus":"unum"}]'\r
+\r
+\r
+            text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');\r
+            // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'\r
+\r
+            text = JSON.stringify([new Date()], function (key, value) {\r
+                return this[key] instanceof Date ?\r
+                    'Date(' + this[key] + ')' : value;\r
+            });\r
+            // text is '["Date(---current time---)"]'\r
+\r
+\r
+        JSON.parse(text, reviver)\r
+            This method parses a JSON text to produce an object or array.\r
+            It can throw a SyntaxError exception.\r
+\r
+            The optional reviver parameter is a function that can filter and\r
+            transform the results. It receives each of the keys and values,\r
+            and its return value is used instead of the original value.\r
+            If it returns what it received, then the structure is not modified.\r
+            If it returns undefined then the member is deleted.\r
+\r
+            Example:\r
+\r
+            // Parse the text. Values that look like ISO date strings will\r
+            // be converted to Date objects.\r
+\r
+            myData = JSON.parse(text, function (key, value) {\r
+                var a;\r
+                if (typeof value === 'string') {\r
+                    a =\r
+/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);\r
+                    if (a) {\r
+                        return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],\r
+                            +a[5], +a[6]));\r
+                    }\r
+                }\r
+                return value;\r
+            });\r
+\r
+            myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {\r
+                var d;\r
+                if (typeof value === 'string' &&\r
+                        value.slice(0, 5) === 'Date(' &&\r
+                        value.slice(-1) === ')') {\r
+                    d = new Date(value.slice(5, -1));\r
+                    if (d) {\r
+                        return d;\r
+                    }\r
+                }\r
+                return value;\r
+            });\r
+\r
+\r
+    This is a reference implementation. You are free to copy, modify, or\r
+    redistribute.\r
+*/\r
+\r
+/*jslint evil: true, regexp: true */\r
+\r
+/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,\r
+    call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,\r
+    getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,\r
+    lastIndex, length, parse, prototype, push, replace, slice, stringify,\r
+    test, toJSON, toString, valueOf\r
+*/\r
+\r
+\r
+// Create a JSON object only if one does not already exist. We create the\r
+// methods in a closure to avoid creating global variables.\r
+\r
+if (typeof JSON !== 'object') {\r
+    JSON = {};\r
+}\r
+\r
+(function () {\r
+    'use strict';\r
+\r
+    function f(n) {\r
+        // Format integers to have at least two digits.\r
+        return n < 10 ? '0' + n : n;\r
+    }\r
+\r
+    if (typeof Date.prototype.toJSON !== 'function') {\r
+\r
+        Date.prototype.toJSON = function (key) {\r
+\r
+            return isFinite(this.valueOf())\r
+                ? this.getUTCFullYear()     + '-' +\r
+                    f(this.getUTCMonth() + 1) + '-' +\r
+                    f(this.getUTCDate())      + 'T' +\r
+                    f(this.getUTCHours())     + ':' +\r
+                    f(this.getUTCMinutes())   + ':' +\r
+                    f(this.getUTCSeconds())   + 'Z'\r
+                : null;\r
+        };\r
+\r
+        String.prototype.toJSON      =\r
+            Number.prototype.toJSON  =\r
+            Boolean.prototype.toJSON = function (key) {\r
+                return this.valueOf();\r
+            };\r
+    }\r
+\r
+    var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,\r
+        escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,\r
+        gap,\r
+        indent,\r
+        meta = {    // table of character substitutions\r
+            '\b': '\\b',\r
+            '\t': '\\t',\r
+            '\n': '\\n',\r
+            '\f': '\\f',\r
+            '\r': '\\r',\r
+            '"' : '\\"',\r
+            '\\': '\\\\'\r
+        },\r
+        rep;\r
+\r
+\r
+    function quote(string) {\r
+\r
+// If the string contains no control characters, no quote characters, and no\r
+// backslash characters, then we can safely slap some quotes around it.\r
+// Otherwise we must also replace the offending characters with safe escape\r
+// sequences.\r
+\r
+        escapable.lastIndex = 0;\r
+        return escapable.test(string) ? '"' + string.replace(escapable, function (a) {\r
+            var c = meta[a];\r
+            return typeof c === 'string'\r
+                ? c\r
+                : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);\r
+        }) + '"' : '"' + string + '"';\r
+    }\r
+\r
+\r
+    function str(key, holder) {\r
+\r
+// Produce a string from holder[key].\r
+\r
+        var i,          // The loop counter.\r
+            k,          // The member key.\r
+            v,          // The member value.\r
+            length,\r
+            mind = gap,\r
+            partial,\r
+            value = holder[key];\r
+\r
+// If the value has a toJSON method, call it to obtain a replacement value.\r
+\r
+        if (value && typeof value === 'object' &&\r
+                typeof value.toJSON === 'function') {\r
+            value = value.toJSON(key);\r
+        }\r
+\r
+// If we were called with a replacer function, then call the replacer to\r
+// obtain a replacement value.\r
+\r
+        if (typeof rep === 'function') {\r
+            value = rep.call(holder, key, value);\r
+        }\r
+\r
+// What happens next depends on the value's type.\r
+\r
+        switch (typeof value) {\r
+        case 'string':\r
+            return quote(value);\r
+\r
+        case 'number':\r
+\r
+// JSON numbers must be finite. Encode non-finite numbers as null.\r
+\r
+            return isFinite(value) ? String(value) : 'null';\r
+\r
+        case 'boolean':\r
+        case 'null':\r
+\r
+// If the value is a boolean or null, convert it to a string. Note:\r
+// typeof null does not produce 'null'. The case is included here in\r
+// the remote chance that this gets fixed someday.\r
+\r
+            return String(value);\r
+\r
+// If the type is 'object', we might be dealing with an object or an array or\r
+// null.\r
+\r
+        case 'object':\r
+\r
+// Due to a specification blunder in ECMAScript, typeof null is 'object',\r
+// so watch out for that case.\r
+\r
+            if (!value) {\r
+                return 'null';\r
+            }\r
+\r
+// Make an array to hold the partial results of stringifying this object value.\r
+\r
+            gap += indent;\r
+            partial = [];\r
+\r
+// Is the value an array?\r
+\r
+            if (Object.prototype.toString.apply(value) === '[object Array]') {\r
+\r
+// The value is an array. Stringify every element. Use null as a placeholder\r
+// for non-JSON values.\r
+\r
+                length = value.length;\r
+                for (i = 0; i < length; i += 1) {\r
+                    partial[i] = str(i, value) || 'null';\r
+                }\r
+\r
+// Join all of the elements together, separated with commas, and wrap them in\r
+// brackets.\r
+\r
+                v = partial.length === 0\r
+                    ? '[]'\r
+                    : gap\r
+                    ? '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']'\r
+                    : '[' + partial.join(',') + ']';\r
+                gap = mind;\r
+                return v;\r
+            }\r
+\r
+// If the replacer is an array, use it to select the members to be stringified.\r
+\r
+            if (rep && typeof rep === 'object') {\r
+                length = rep.length;\r
+                for (i = 0; i < length; i += 1) {\r
+                    if (typeof rep[i] === 'string') {\r
+                        k = rep[i];\r
+                        v = str(k, value);\r
+                        if (v) {\r
+                            partial.push(quote(k) + (gap ? ': ' : ':') + v);\r
+                        }\r
+                    }\r
+                }\r
+            } else {\r
+\r
+// Otherwise, iterate through all of the keys in the object.\r
+\r
+                for (k in value) {\r
+                    if (Object.prototype.hasOwnProperty.call(value, k)) {\r
+                        v = str(k, value);\r
+                        if (v) {\r
+                            partial.push(quote(k) + (gap ? ': ' : ':') + v);\r
+                        }\r
+                    }\r
+                }\r
+            }\r
+\r
+// Join all of the member texts together, separated with commas,\r
+// and wrap them in braces.\r
+\r
+            v = partial.length === 0\r
+                ? '{}'\r
+                : gap\r
+                ? '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}'\r
+                : '{' + partial.join(',') + '}';\r
+            gap = mind;\r
+            return v;\r
+        }\r
+    }\r
+\r
+// If the JSON object does not yet have a stringify method, give it one.\r
+\r
+    if (typeof JSON.stringify !== 'function') {\r
+        JSON.stringify = function (value, replacer, space) {\r
+\r
+// The stringify method takes a value and an optional replacer, and an optional\r
+// space parameter, and returns a JSON text. The replacer can be a function\r
+// that can replace values, or an array of strings that will select the keys.\r
+// A default replacer method can be provided. Use of the space parameter can\r
+// produce text that is more easily readable.\r
+\r
+            var i;\r
+            gap = '';\r
+            indent = '';\r
+\r
+// If the space parameter is a number, make an indent string containing that\r
+// many spaces.\r
+\r
+            if (typeof space === 'number') {\r
+                for (i = 0; i < space; i += 1) {\r
+                    indent += ' ';\r
+                }\r
+\r
+// If the space parameter is a string, it will be used as the indent string.\r
+\r
+            } else if (typeof space === 'string') {\r
+                indent = space;\r
+            }\r
+\r
+// If there is a replacer, it must be a function or an array.\r
+// Otherwise, throw an error.\r
+\r
+            rep = replacer;\r
+            if (replacer && typeof replacer !== 'function' &&\r
+                    (typeof replacer !== 'object' ||\r
+                    typeof replacer.length !== 'number')) {\r
+                throw new Error('JSON.stringify');\r
+            }\r
+\r
+// Make a fake root object containing our value under the key of ''.\r
+// Return the result of stringifying the value.\r
+\r
+            return str('', {'': value});\r
+        };\r
+    }\r
+\r
+\r
+// If the JSON object does not yet have a parse method, give it one.\r
+\r
+    if (typeof JSON.parse !== 'function') {\r
+        JSON.parse = function (text, reviver) {\r
+\r
+// The parse method takes a text and an optional reviver function, and returns\r
+// a JavaScript value if the text is a valid JSON text.\r
+\r
+            var j;\r
+\r
+            function walk(holder, key) {\r
+\r
+// The walk method is used to recursively walk the resulting structure so\r
+// that modifications can be made.\r
+\r
+                var k, v, value = holder[key];\r
+                if (value && typeof value === 'object') {\r
+                    for (k in value) {\r
+                        if (Object.prototype.hasOwnProperty.call(value, k)) {\r
+                            v = walk(value, k);\r
+                            if (v !== undefined) {\r
+                                value[k] = v;\r
+                            } else {\r
+                                delete value[k];\r
+                            }\r
+                        }\r
+                    }\r
+                }\r
+                return reviver.call(holder, key, value);\r
+            }\r
+\r
+\r
+// Parsing happens in four stages. In the first stage, we replace certain\r
+// Unicode characters with escape sequences. JavaScript handles many characters\r
+// incorrectly, either silently deleting them, or treating them as line endings.\r
+\r
+            text = String(text);\r
+            cx.lastIndex = 0;\r
+            if (cx.test(text)) {\r
+                text = text.replace(cx, function (a) {\r
+                    return '\\u' +\r
+                        ('0000' + a.charCodeAt(0).toString(16)).slice(-4);\r
+                });\r
+            }\r
+\r
+// In the second stage, we run the text against regular expressions that look\r
+// for non-JSON patterns. We are especially concerned with '()' and 'new'\r
+// because they can cause invocation, and '=' because it can cause mutation.\r
+// But just to be safe, we want to reject all unexpected forms.\r
+\r
+// We split the second stage into 4 regexp operations in order to work around\r
+// crippling inefficiencies in IE's and Safari's regexp engines. First we\r
+// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we\r
+// replace all simple value tokens with ']' characters. Third, we delete all\r
+// open brackets that follow a colon or comma or that begin the text. Finally,\r
+// we look to see that the remaining characters are only whitespace or ']' or\r
+// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.\r
+\r
+            if (/^[\],:{}\s]*$/\r
+                    .test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')\r
+                        .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']')\r
+                        .replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {\r
+\r
+// In the third stage we use the eval function to compile the text into a\r
+// JavaScript structure. The '{' operator is subject to a syntactic ambiguity\r
+// in JavaScript: it can begin a block or an object literal. We wrap the text\r
+// in parens to eliminate the ambiguity.\r
+\r
+                j = eval('(' + text + ')');\r
+\r
+// In the optional fourth stage, we recursively walk the new structure, passing\r
+// each name/value pair to a reviver function for possible transformation.\r
+\r
+                return typeof reviver === 'function'\r
+                    ? walk({'': j}, '')\r
+                    : j;\r
+            }\r
+\r
+// If the text is not JSON parseable, then a SyntaxError is thrown.\r
+\r
+            throw new SyntaxError('JSON.parse');\r
+        };\r
+    }\r
+}());\r