zmdms-utils 0.0.81 → 0.0.83

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. package/dist/es/validate.js +168 -1
  2. package/dist/index.d.ts +0 -1
  3. package/dist/index.js +0 -1
  4. package/package.json +2 -6
  5. package/src/index.ts +0 -3
  6. package/src/validate.ts +198 -0
  7. package/dist/es/_virtual/FastBufferList.js +0 -7
  8. package/dist/es/_virtual/_commonjs-dynamic-modules.js +0 -5
  9. package/dist/es/_virtual/browser.js +0 -7
  10. package/dist/es/_virtual/browser2.js +0 -7
  11. package/dist/es/_virtual/debug.js +0 -7
  12. package/dist/es/_virtual/event.js +0 -7
  13. package/dist/es/_virtual/http-parser.js +0 -3
  14. package/dist/es/_virtual/iframe.js +0 -7
  15. package/dist/es/_virtual/index.js +0 -7
  16. package/dist/es/_virtual/index2.js +0 -7
  17. package/dist/es/_virtual/index3.js +0 -7
  18. package/dist/es/_virtual/index4.js +0 -7
  19. package/dist/es/_virtual/index5.js +0 -7
  20. package/dist/es/_virtual/index6.js +0 -7
  21. package/dist/es/_virtual/index7.js +0 -3
  22. package/dist/es/_virtual/index8.js +0 -7
  23. package/dist/es/_virtual/index9.js +0 -7
  24. package/dist/es/_virtual/inherits.js +0 -7
  25. package/dist/es/_virtual/inherits_browser.js +0 -7
  26. package/dist/es/_virtual/json3.js +0 -7
  27. package/dist/es/_virtual/node.js +0 -7
  28. package/dist/es/_virtual/node2.js +0 -7
  29. package/dist/es/_virtual/stomp-node.js +0 -3
  30. package/dist/es/_virtual/stomp.js +0 -3
  31. package/dist/es/_virtual/streams.js +0 -3
  32. package/dist/es/_virtual/utils.js +0 -3
  33. package/dist/es/node_modules/bufferutil/fallback.js +0 -43
  34. package/dist/es/node_modules/bufferutil/index.js +0 -21
  35. package/dist/es/node_modules/debug/src/browser.js +0 -192
  36. package/dist/es/node_modules/debug/src/common.js +0 -259
  37. package/dist/es/node_modules/debug/src/index.js +0 -25
  38. package/dist/es/node_modules/debug/src/node.js +0 -192
  39. package/dist/es/node_modules/eventsource/lib/eventsource.js +0 -493
  40. package/dist/es/node_modules/faye-websocket/lib/faye/eventsource.js +0 -150
  41. package/dist/es/node_modules/faye-websocket/lib/faye/websocket/api/event.js +0 -31
  42. package/dist/es/node_modules/faye-websocket/lib/faye/websocket/api/event_target.js +0 -41
  43. package/dist/es/node_modules/faye-websocket/lib/faye/websocket/api.js +0 -205
  44. package/dist/es/node_modules/faye-websocket/lib/faye/websocket/client.js +0 -107
  45. package/dist/es/node_modules/faye-websocket/lib/faye/websocket.js +0 -47
  46. package/dist/es/node_modules/has-flag/index.js +0 -17
  47. package/dist/es/node_modules/http-parser-js/http-parser.js +0 -471
  48. package/dist/es/node_modules/inherits/inherits.js +0 -14
  49. package/dist/es/node_modules/inherits/inherits_browser.js +0 -38
  50. package/dist/es/node_modules/is-typedarray/index.js +0 -51
  51. package/dist/es/node_modules/json3/lib/json3.js +0 -937
  52. package/dist/es/node_modules/ms/index.js +0 -172
  53. package/dist/es/node_modules/node-gyp-build/index.js +0 -21
  54. package/dist/es/node_modules/node-gyp-build/node-gyp-build.js +0 -222
  55. package/dist/es/node_modules/querystringify/index.js +0 -120
  56. package/dist/es/node_modules/requires-port/index.js +0 -38
  57. package/dist/es/node_modules/safe-buffer/index.js +0 -71
  58. package/dist/es/node_modules/supports-color/index.js +0 -143
  59. package/dist/es/node_modules/typedarray-to-buffer/index.js +0 -37
  60. package/dist/es/node_modules/url-parse/index.js +0 -594
  61. package/dist/es/node_modules/utf-8-validate/fallback.js +0 -71
  62. package/dist/es/node_modules/utf-8-validate/index.js +0 -21
  63. package/dist/es/node_modules/websocket/index.js +0 -15
  64. package/dist/es/node_modules/websocket/lib/Deprecation.js +0 -42
  65. package/dist/es/node_modules/websocket/lib/W3CWebSocket.js +0 -268
  66. package/dist/es/node_modules/websocket/lib/WebSocketClient.js +0 -380
  67. package/dist/es/node_modules/websocket/lib/WebSocketConnection.js +0 -914
  68. package/dist/es/node_modules/websocket/lib/WebSocketFrame.js +0 -293
  69. package/dist/es/node_modules/websocket/lib/WebSocketRequest.js +0 -543
  70. package/dist/es/node_modules/websocket/lib/WebSocketRouter.js +0 -172
  71. package/dist/es/node_modules/websocket/lib/WebSocketRouterRequest.js +0 -67
  72. package/dist/es/node_modules/websocket/lib/WebSocketServer.js +0 -272
  73. package/dist/es/node_modules/websocket/lib/utils.js +0 -80
  74. package/dist/es/node_modules/websocket/lib/version.js +0 -13
  75. package/dist/es/node_modules/websocket/lib/websocket.js +0 -31
  76. package/dist/es/node_modules/websocket/node_modules/debug/src/browser.js +0 -199
  77. package/dist/es/node_modules/websocket/node_modules/debug/src/debug.js +0 -215
  78. package/dist/es/node_modules/websocket/node_modules/debug/src/index.js +0 -25
  79. package/dist/es/node_modules/websocket/node_modules/debug/src/node.js +0 -266
  80. package/dist/es/node_modules/websocket/node_modules/ms/index.js +0 -162
  81. package/dist/es/node_modules/websocket/package.json.js +0 -77
  82. package/dist/es/node_modules/websocket/vendor/FastBufferList.js +0 -205
  83. package/dist/es/node_modules/websocket-driver/lib/websocket/driver/base.js +0 -202
  84. package/dist/es/node_modules/websocket-driver/lib/websocket/driver/client.js +0 -152
  85. package/dist/es/node_modules/websocket-driver/lib/websocket/driver/draft75.js +0 -128
  86. package/dist/es/node_modules/websocket-driver/lib/websocket/driver/draft76.js +0 -124
  87. package/dist/es/node_modules/websocket-driver/lib/websocket/driver/headers.js +0 -44
  88. package/dist/es/node_modules/websocket-driver/lib/websocket/driver/hybi/frame.js +0 -21
  89. package/dist/es/node_modules/websocket-driver/lib/websocket/driver/hybi/message.js +0 -37
  90. package/dist/es/node_modules/websocket-driver/lib/websocket/driver/hybi.js +0 -492
  91. package/dist/es/node_modules/websocket-driver/lib/websocket/driver/proxy.js +0 -108
  92. package/dist/es/node_modules/websocket-driver/lib/websocket/driver/server.js +0 -119
  93. package/dist/es/node_modules/websocket-driver/lib/websocket/driver/stream_reader.js +0 -72
  94. package/dist/es/node_modules/websocket-driver/lib/websocket/driver.js +0 -47
  95. package/dist/es/node_modules/websocket-driver/lib/websocket/http_parser.js +0 -140
  96. package/dist/es/node_modules/websocket-driver/lib/websocket/streams.js +0 -150
  97. package/dist/es/node_modules/websocket-extensions/lib/parser.js +0 -103
  98. package/dist/es/node_modules/websocket-extensions/lib/pipeline/cell.js +0 -56
  99. package/dist/es/node_modules/websocket-extensions/lib/pipeline/functor.js +0 -74
  100. package/dist/es/node_modules/websocket-extensions/lib/pipeline/index.js +0 -50
  101. package/dist/es/node_modules/websocket-extensions/lib/pipeline/pledge.js +0 -39
  102. package/dist/es/node_modules/websocket-extensions/lib/pipeline/ring_buffer.js +0 -66
  103. package/dist/es/node_modules/websocket-extensions/lib/websocket_extensions.js +0 -165
  104. package/dist/es/node_modules/yaeti/index.js +0 -17
  105. package/dist/es/node_modules/yaeti/lib/Event.js +0 -24
  106. package/dist/es/node_modules/yaeti/lib/EventTarget.js +0 -130
  107. package/dist/es/node_modules/zt-sockjs-client/lib/entry.js +0 -14
  108. package/dist/es/node_modules/zt-sockjs-client/lib/event/close.js +0 -21
  109. package/dist/es/node_modules/zt-sockjs-client/lib/event/event.js +0 -22
  110. package/dist/es/node_modules/zt-sockjs-client/lib/event/eventtarget.js +0 -62
  111. package/dist/es/node_modules/zt-sockjs-client/lib/event/trans-message.js +0 -19
  112. package/dist/es/node_modules/zt-sockjs-client/lib/facade.js +0 -40
  113. package/dist/es/node_modules/zt-sockjs-client/lib/iframe-bootstrap.js +0 -122
  114. package/dist/es/node_modules/zt-sockjs-client/lib/info-ajax.js +0 -57
  115. package/dist/es/node_modules/zt-sockjs-client/lib/info-iframe-receiver.js +0 -50
  116. package/dist/es/node_modules/zt-sockjs-client/lib/info-iframe.js +0 -81
  117. package/dist/es/node_modules/zt-sockjs-client/lib/info-receiver.js +0 -101
  118. package/dist/es/node_modules/zt-sockjs-client/lib/location.js +0 -12
  119. package/dist/es/node_modules/zt-sockjs-client/lib/main.js +0 -413
  120. package/dist/es/node_modules/zt-sockjs-client/lib/shims.js +0 -449
  121. package/dist/es/node_modules/zt-sockjs-client/lib/transport/driver/websocket.js +0 -5
  122. package/dist/es/node_modules/zt-sockjs-client/lib/transport/driver/xhr.js +0 -80
  123. package/dist/es/node_modules/zt-sockjs-client/lib/transport/eventsource.js +0 -34
  124. package/dist/es/node_modules/zt-sockjs-client/lib/transport/htmlfile.js +0 -31
  125. package/dist/es/node_modules/zt-sockjs-client/lib/transport/iframe.js +0 -154
  126. package/dist/es/node_modules/zt-sockjs-client/lib/transport/jsonp-polling.js +0 -41
  127. package/dist/es/node_modules/zt-sockjs-client/lib/transport/lib/ajax-based.js +0 -55
  128. package/dist/es/node_modules/zt-sockjs-client/lib/transport/lib/buffered-sender.js +0 -92
  129. package/dist/es/node_modules/zt-sockjs-client/lib/transport/lib/iframe-wrap.js +0 -39
  130. package/dist/es/node_modules/zt-sockjs-client/lib/transport/lib/polling.js +0 -65
  131. package/dist/es/node_modules/zt-sockjs-client/lib/transport/lib/sender-receiver.js +0 -52
  132. package/dist/es/node_modules/zt-sockjs-client/lib/transport/receiver/eventsource.js +0 -69
  133. package/dist/es/node_modules/zt-sockjs-client/lib/transport/receiver/htmlfile.js +0 -96
  134. package/dist/es/node_modules/zt-sockjs-client/lib/transport/receiver/jsonp.js +0 -193
  135. package/dist/es/node_modules/zt-sockjs-client/lib/transport/receiver/xhr.js +0 -75
  136. package/dist/es/node_modules/zt-sockjs-client/lib/transport/sender/jsonp.js +0 -104
  137. package/dist/es/node_modules/zt-sockjs-client/lib/transport/sender/xdr.js +0 -113
  138. package/dist/es/node_modules/zt-sockjs-client/lib/transport/sender/xhr-cors.js +0 -19
  139. package/dist/es/node_modules/zt-sockjs-client/lib/transport/sender/xhr-fake.js +0 -28
  140. package/dist/es/node_modules/zt-sockjs-client/lib/transport/sender/xhr-local.js +0 -21
  141. package/dist/es/node_modules/zt-sockjs-client/lib/transport/websocket.js +0 -108
  142. package/dist/es/node_modules/zt-sockjs-client/lib/transport/xdr-polling.js +0 -30
  143. package/dist/es/node_modules/zt-sockjs-client/lib/transport/xdr-streaming.js +0 -38
  144. package/dist/es/node_modules/zt-sockjs-client/lib/transport/xhr-polling.js +0 -40
  145. package/dist/es/node_modules/zt-sockjs-client/lib/transport/xhr-streaming.js +0 -50
  146. package/dist/es/node_modules/zt-sockjs-client/lib/transport-list.js +0 -28
  147. package/dist/es/node_modules/zt-sockjs-client/lib/utils/browser.js +0 -29
  148. package/dist/es/node_modules/zt-sockjs-client/lib/utils/escape.js +0 -53
  149. package/dist/es/node_modules/zt-sockjs-client/lib/utils/event.js +0 -78
  150. package/dist/es/node_modules/zt-sockjs-client/lib/utils/iframe.js +0 -205
  151. package/dist/es/node_modules/zt-sockjs-client/lib/utils/log.js +0 -20
  152. package/dist/es/node_modules/zt-sockjs-client/lib/utils/object.js +0 -24
  153. package/dist/es/node_modules/zt-sockjs-client/lib/utils/random.js +0 -30
  154. package/dist/es/node_modules/zt-sockjs-client/lib/utils/transport.js +0 -52
  155. package/dist/es/node_modules/zt-sockjs-client/lib/utils/url.js +0 -54
  156. package/dist/es/node_modules/zt-sockjs-client/lib/version.js +0 -11
  157. package/dist/es/node_modules/zt-stompjs/index.js +0 -23
  158. package/dist/es/node_modules/zt-stompjs/lib/stomp-node.js +0 -117
  159. package/dist/es/node_modules/zt-stompjs/lib/stomp.js +0 -536
  160. package/dist/es/stompClient.d.ts +0 -55
  161. package/dist/es/stompClient.js +0 -379
  162. package/src/stompClient.ts +0 -449
@@ -1,937 +0,0 @@
1
- import { commonjsGlobal } from '../../../_virtual/_commonjsHelpers.js';
2
- import { exports as json3Exports, __module as json3 } from '../../../_virtual/json3.js';
3
-
4
- /*! JSON v3.3.2 | https://bestiejs.github.io/json3 | Copyright 2012-2015, Kit Cambridge, Benjamin Tan | http://kit.mit-license.org */
5
-
6
- (function (module, exports) {
7
- (function () {
8
- // Detect the `define` function exposed by asynchronous module loaders. The
9
- // strict `define` check is necessary for compatibility with `r.js`.
10
- var isLoader = typeof undefined === "function" ;
11
-
12
- // A set of types used to distinguish objects from primitives.
13
- var objectTypes = {
14
- "function": true,
15
- "object": true
16
- };
17
-
18
- // Detect the `exports` object exposed by CommonJS implementations.
19
- var freeExports = exports && !exports.nodeType && exports;
20
-
21
- // Use the `global` object exposed by Node (including Browserify via
22
- // `insert-module-globals`), Narwhal, and Ringo as the default context,
23
- // and the `window` object in browsers. Rhino exports a `global` function
24
- // instead.
25
- var root = objectTypes[typeof window] && window || this,
26
- freeGlobal = freeExports && objectTypes['object'] && module && !module.nodeType && typeof commonjsGlobal == "object" && commonjsGlobal;
27
-
28
- if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal || freeGlobal.self === freeGlobal)) {
29
- root = freeGlobal;
30
- }
31
-
32
- // Public: Initializes JSON 3 using the given `context` object, attaching the
33
- // `stringify` and `parse` functions to the specified `exports` object.
34
- function runInContext(context, exports) {
35
- context || (context = root.Object());
36
- exports || (exports = root.Object());
37
-
38
- // Native constructor aliases.
39
- var Number = context.Number || root.Number,
40
- String = context.String || root.String,
41
- Object = context.Object || root.Object,
42
- Date = context.Date || root.Date,
43
- SyntaxError = context.SyntaxError || root.SyntaxError,
44
- TypeError = context.TypeError || root.TypeError,
45
- Math = context.Math || root.Math,
46
- nativeJSON = context.JSON || root.JSON;
47
-
48
- // Delegate to the native `stringify` and `parse` implementations.
49
- if (typeof nativeJSON == "object" && nativeJSON) {
50
- exports.stringify = nativeJSON.stringify;
51
- exports.parse = nativeJSON.parse;
52
- }
53
-
54
- // Convenience aliases.
55
- var objectProto = Object.prototype,
56
- getClass = objectProto.toString,
57
- isProperty = objectProto.hasOwnProperty,
58
- undefined$1;
59
-
60
- // Internal: Contains `try...catch` logic used by other functions.
61
- // This prevents other functions from being deoptimized.
62
- function attempt(func, errorFunc) {
63
- try {
64
- func();
65
- } catch (exception) {
66
- if (errorFunc) {
67
- errorFunc();
68
- }
69
- }
70
- }
71
-
72
- // Test the `Date#getUTC*` methods. Based on work by @Yaffle.
73
- var isExtended = new Date(-3509827334573292);
74
- attempt(function () {
75
- // The `getUTCFullYear`, `Month`, and `Date` methods return nonsensical
76
- // results for certain dates in Opera >= 10.53.
77
- isExtended = isExtended.getUTCFullYear() == -109252 && isExtended.getUTCMonth() === 0 && isExtended.getUTCDate() === 1 &&
78
- isExtended.getUTCHours() == 10 && isExtended.getUTCMinutes() == 37 && isExtended.getUTCSeconds() == 6 && isExtended.getUTCMilliseconds() == 708;
79
- });
80
-
81
- // Internal: Determines whether the native `JSON.stringify` and `parse`
82
- // implementations are spec-compliant. Based on work by Ken Snyder.
83
- function has(name) {
84
- if (has[name] != null) {
85
- // Return cached feature test result.
86
- return has[name];
87
- }
88
- var isSupported;
89
- if (name == "bug-string-char-index") {
90
- // IE <= 7 doesn't support accessing string characters using square
91
- // bracket notation. IE 8 only supports this for primitives.
92
- isSupported = "a"[0] != "a";
93
- } else if (name == "json") {
94
- // Indicates whether both `JSON.stringify` and `JSON.parse` are
95
- // supported.
96
- isSupported = has("json-stringify") && has("date-serialization") && has("json-parse");
97
- } else if (name == "date-serialization") {
98
- // Indicates whether `Date`s can be serialized accurately by `JSON.stringify`.
99
- isSupported = has("json-stringify") && isExtended;
100
- if (isSupported) {
101
- var stringify = exports.stringify;
102
- attempt(function () {
103
- isSupported =
104
- // JSON 2, Prototype <= 1.7, and older WebKit builds incorrectly
105
- // serialize extended years.
106
- stringify(new Date(-8.64e15)) == '"-271821-04-20T00:00:00.000Z"' &&
107
- // The milliseconds are optional in ES 5, but required in 5.1.
108
- stringify(new Date(8.64e15)) == '"+275760-09-13T00:00:00.000Z"' &&
109
- // Firefox <= 11.0 incorrectly serializes years prior to 0 as negative
110
- // four-digit years instead of six-digit years. Credits: @Yaffle.
111
- stringify(new Date(-621987552e5)) == '"-000001-01-01T00:00:00.000Z"' &&
112
- // Safari <= 5.1.5 and Opera >= 10.53 incorrectly serialize millisecond
113
- // values less than 1000. Credits: @Yaffle.
114
- stringify(new Date(-1)) == '"1969-12-31T23:59:59.999Z"';
115
- });
116
- }
117
- } else {
118
- var value, serialized = '{"a":[1,true,false,null,"\\u0000\\b\\n\\f\\r\\t"]}';
119
- // Test `JSON.stringify`.
120
- if (name == "json-stringify") {
121
- var stringify = exports.stringify, stringifySupported = typeof stringify == "function";
122
- if (stringifySupported) {
123
- // A test function object with a custom `toJSON` method.
124
- (value = function () {
125
- return 1;
126
- }).toJSON = value;
127
- attempt(function () {
128
- stringifySupported =
129
- // Firefox 3.1b1 and b2 serialize string, number, and boolean
130
- // primitives as object literals.
131
- stringify(0) === "0" &&
132
- // FF 3.1b1, b2, and JSON 2 serialize wrapped primitives as object
133
- // literals.
134
- stringify(new Number()) === "0" &&
135
- stringify(new String()) == '""' &&
136
- // FF 3.1b1, 2 throw an error if the value is `null`, `undefined`, or
137
- // does not define a canonical JSON representation (this applies to
138
- // objects with `toJSON` properties as well, *unless* they are nested
139
- // within an object or array).
140
- stringify(getClass) === undefined$1 &&
141
- // IE 8 serializes `undefined` as `"undefined"`. Safari <= 5.1.7 and
142
- // FF 3.1b3 pass this test.
143
- stringify(undefined$1) === undefined$1 &&
144
- // Safari <= 5.1.7 and FF 3.1b3 throw `Error`s and `TypeError`s,
145
- // respectively, if the value is omitted entirely.
146
- stringify() === undefined$1 &&
147
- // FF 3.1b1, 2 throw an error if the given value is not a number,
148
- // string, array, object, Boolean, or `null` literal. This applies to
149
- // objects with custom `toJSON` methods as well, unless they are nested
150
- // inside object or array literals. YUI 3.0.0b1 ignores custom `toJSON`
151
- // methods entirely.
152
- stringify(value) === "1" &&
153
- stringify([value]) == "[1]" &&
154
- // Prototype <= 1.6.1 serializes `[undefined]` as `"[]"` instead of
155
- // `"[null]"`.
156
- stringify([undefined$1]) == "[null]" &&
157
- // YUI 3.0.0b1 fails to serialize `null` literals.
158
- stringify(null) == "null" &&
159
- // FF 3.1b1, 2 halts serialization if an array contains a function:
160
- // `[1, true, getClass, 1]` serializes as "[1,true,],". FF 3.1b3
161
- // elides non-JSON values from objects and arrays, unless they
162
- // define custom `toJSON` methods.
163
- stringify([undefined$1, getClass, null]) == "[null,null,null]" &&
164
- // Simple serialization test. FF 3.1b1 uses Unicode escape sequences
165
- // where character escape codes are expected (e.g., `\b` => `\u0008`).
166
- stringify({ "a": [value, true, false, null, "\x00\b\n\f\r\t"] }) == serialized &&
167
- // FF 3.1b1 and b2 ignore the `filter` and `width` arguments.
168
- stringify(null, value) === "1" &&
169
- stringify([1, 2], null, 1) == "[\n 1,\n 2\n]";
170
- }, function () {
171
- stringifySupported = false;
172
- });
173
- }
174
- isSupported = stringifySupported;
175
- }
176
- // Test `JSON.parse`.
177
- if (name == "json-parse") {
178
- var parse = exports.parse, parseSupported;
179
- if (typeof parse == "function") {
180
- attempt(function () {
181
- // FF 3.1b1, b2 will throw an exception if a bare literal is provided.
182
- // Conforming implementations should also coerce the initial argument to
183
- // a string prior to parsing.
184
- if (parse("0") === 0 && !parse(false)) {
185
- // Simple parsing test.
186
- value = parse(serialized);
187
- parseSupported = value["a"].length == 5 && value["a"][0] === 1;
188
- if (parseSupported) {
189
- attempt(function () {
190
- // Safari <= 5.1.2 and FF 3.1b1 allow unescaped tabs in strings.
191
- parseSupported = !parse('"\t"');
192
- });
193
- if (parseSupported) {
194
- attempt(function () {
195
- // FF 4.0 and 4.0.1 allow leading `+` signs and leading
196
- // decimal points. FF 4.0, 4.0.1, and IE 9-10 also allow
197
- // certain octal literals.
198
- parseSupported = parse("01") !== 1;
199
- });
200
- }
201
- if (parseSupported) {
202
- attempt(function () {
203
- // FF 4.0, 4.0.1, and Rhino 1.7R3-R4 allow trailing decimal
204
- // points. These environments, along with FF 3.1b1 and 2,
205
- // also allow trailing commas in JSON objects and arrays.
206
- parseSupported = parse("1.") !== 1;
207
- });
208
- }
209
- }
210
- }
211
- }, function () {
212
- parseSupported = false;
213
- });
214
- }
215
- isSupported = parseSupported;
216
- }
217
- }
218
- return has[name] = !!isSupported;
219
- }
220
- has["bug-string-char-index"] = has["date-serialization"] = has["json"] = has["json-stringify"] = has["json-parse"] = null;
221
-
222
- if (!has("json")) {
223
- // Common `[[Class]]` name aliases.
224
- var functionClass = "[object Function]",
225
- dateClass = "[object Date]",
226
- numberClass = "[object Number]",
227
- stringClass = "[object String]",
228
- arrayClass = "[object Array]",
229
- booleanClass = "[object Boolean]";
230
-
231
- // Detect incomplete support for accessing string characters by index.
232
- var charIndexBuggy = has("bug-string-char-index");
233
-
234
- // Internal: Normalizes the `for...in` iteration algorithm across
235
- // environments. Each enumerated key is yielded to a `callback` function.
236
- var forOwn = function (object, callback) {
237
- var size = 0, Properties, dontEnums, property;
238
-
239
- // Tests for bugs in the current environment's `for...in` algorithm. The
240
- // `valueOf` property inherits the non-enumerable flag from
241
- // `Object.prototype` in older versions of IE, Netscape, and Mozilla.
242
- (Properties = function () {
243
- this.valueOf = 0;
244
- }).prototype.valueOf = 0;
245
-
246
- // Iterate over a new instance of the `Properties` class.
247
- dontEnums = new Properties();
248
- for (property in dontEnums) {
249
- // Ignore all properties inherited from `Object.prototype`.
250
- if (isProperty.call(dontEnums, property)) {
251
- size++;
252
- }
253
- }
254
- Properties = dontEnums = null;
255
-
256
- // Normalize the iteration algorithm.
257
- if (!size) {
258
- // A list of non-enumerable properties inherited from `Object.prototype`.
259
- dontEnums = ["valueOf", "toString", "toLocaleString", "propertyIsEnumerable", "isPrototypeOf", "hasOwnProperty", "constructor"];
260
- // IE <= 8, Mozilla 1.0, and Netscape 6.2 ignore shadowed non-enumerable
261
- // properties.
262
- forOwn = function (object, callback) {
263
- var isFunction = getClass.call(object) == functionClass, property, length;
264
- var hasProperty = !isFunction && typeof object.constructor != "function" && objectTypes[typeof object.hasOwnProperty] && object.hasOwnProperty || isProperty;
265
- for (property in object) {
266
- // Gecko <= 1.0 enumerates the `prototype` property of functions under
267
- // certain conditions; IE does not.
268
- if (!(isFunction && property == "prototype") && hasProperty.call(object, property)) {
269
- callback(property);
270
- }
271
- }
272
- // Manually invoke the callback for each non-enumerable property.
273
- for (length = dontEnums.length; property = dontEnums[--length];) {
274
- if (hasProperty.call(object, property)) {
275
- callback(property);
276
- }
277
- }
278
- };
279
- } else {
280
- // No bugs detected; use the standard `for...in` algorithm.
281
- forOwn = function (object, callback) {
282
- var isFunction = getClass.call(object) == functionClass, property, isConstructor;
283
- for (property in object) {
284
- if (!(isFunction && property == "prototype") && isProperty.call(object, property) && !(isConstructor = property === "constructor")) {
285
- callback(property);
286
- }
287
- }
288
- // Manually invoke the callback for the `constructor` property due to
289
- // cross-environment inconsistencies.
290
- if (isConstructor || isProperty.call(object, (property = "constructor"))) {
291
- callback(property);
292
- }
293
- };
294
- }
295
- return forOwn(object, callback);
296
- };
297
-
298
- // Public: Serializes a JavaScript `value` as a JSON string. The optional
299
- // `filter` argument may specify either a function that alters how object and
300
- // array members are serialized, or an array of strings and numbers that
301
- // indicates which properties should be serialized. The optional `width`
302
- // argument may be either a string or number that specifies the indentation
303
- // level of the output.
304
- if (!has("json-stringify") && !has("date-serialization")) {
305
- // Internal: A map of control characters and their escaped equivalents.
306
- var Escapes = {
307
- 92: "\\\\",
308
- 34: '\\"',
309
- 8: "\\b",
310
- 12: "\\f",
311
- 10: "\\n",
312
- 13: "\\r",
313
- 9: "\\t"
314
- };
315
-
316
- // Internal: Converts `value` into a zero-padded string such that its
317
- // length is at least equal to `width`. The `width` must be <= 6.
318
- var leadingZeroes = "000000";
319
- var toPaddedString = function (width, value) {
320
- // The `|| 0` expression is necessary to work around a bug in
321
- // Opera <= 7.54u2 where `0 == -0`, but `String(-0) !== "0"`.
322
- return (leadingZeroes + (value || 0)).slice(-width);
323
- };
324
-
325
- // Internal: Serializes a date object.
326
- var serializeDate = function (value) {
327
- var getData, year, month, date, time, hours, minutes, seconds, milliseconds;
328
- // Define additional utility methods if the `Date` methods are buggy.
329
- if (!isExtended) {
330
- var floor = Math.floor;
331
- // A mapping between the months of the year and the number of days between
332
- // January 1st and the first of the respective month.
333
- var Months = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334];
334
- // Internal: Calculates the number of days between the Unix epoch and the
335
- // first day of the given month.
336
- var getDay = function (year, month) {
337
- return Months[month] + 365 * (year - 1970) + floor((year - 1969 + (month = +(month > 1))) / 4) - floor((year - 1901 + month) / 100) + floor((year - 1601 + month) / 400);
338
- };
339
- getData = function (value) {
340
- // Manually compute the year, month, date, hours, minutes,
341
- // seconds, and milliseconds if the `getUTC*` methods are
342
- // buggy. Adapted from @Yaffle's `date-shim` project.
343
- date = floor(value / 864e5);
344
- for (year = floor(date / 365.2425) + 1970 - 1; getDay(year + 1, 0) <= date; year++);
345
- for (month = floor((date - getDay(year, 0)) / 30.42); getDay(year, month + 1) <= date; month++);
346
- date = 1 + date - getDay(year, month);
347
- // The `time` value specifies the time within the day (see ES
348
- // 5.1 section 15.9.1.2). The formula `(A % B + B) % B` is used
349
- // to compute `A modulo B`, as the `%` operator does not
350
- // correspond to the `modulo` operation for negative numbers.
351
- time = (value % 864e5 + 864e5) % 864e5;
352
- // The hours, minutes, seconds, and milliseconds are obtained by
353
- // decomposing the time within the day. See section 15.9.1.10.
354
- hours = floor(time / 36e5) % 24;
355
- minutes = floor(time / 6e4) % 60;
356
- seconds = floor(time / 1e3) % 60;
357
- milliseconds = time % 1e3;
358
- };
359
- } else {
360
- getData = function (value) {
361
- year = value.getUTCFullYear();
362
- month = value.getUTCMonth();
363
- date = value.getUTCDate();
364
- hours = value.getUTCHours();
365
- minutes = value.getUTCMinutes();
366
- seconds = value.getUTCSeconds();
367
- milliseconds = value.getUTCMilliseconds();
368
- };
369
- }
370
- serializeDate = function (value) {
371
- if (value > -1 / 0 && value < 1 / 0) {
372
- // Dates are serialized according to the `Date#toJSON` method
373
- // specified in ES 5.1 section 15.9.5.44. See section 15.9.1.15
374
- // for the ISO 8601 date time string format.
375
- getData(value);
376
- // Serialize extended years correctly.
377
- value = (year <= 0 || year >= 1e4 ? (year < 0 ? "-" : "+") + toPaddedString(6, year < 0 ? -year : year) : toPaddedString(4, year)) +
378
- "-" + toPaddedString(2, month + 1) + "-" + toPaddedString(2, date) +
379
- // Months, dates, hours, minutes, and seconds should have two
380
- // digits; milliseconds should have three.
381
- "T" + toPaddedString(2, hours) + ":" + toPaddedString(2, minutes) + ":" + toPaddedString(2, seconds) +
382
- // Milliseconds are optional in ES 5.0, but required in 5.1.
383
- "." + toPaddedString(3, milliseconds) + "Z";
384
- year = month = date = hours = minutes = seconds = milliseconds = null;
385
- } else {
386
- value = null;
387
- }
388
- return value;
389
- };
390
- return serializeDate(value);
391
- };
392
-
393
- // For environments with `JSON.stringify` but buggy date serialization,
394
- // we override the native `Date#toJSON` implementation with a
395
- // spec-compliant one.
396
- if (has("json-stringify") && !has("date-serialization")) {
397
- // Internal: the `Date#toJSON` implementation used to override the native one.
398
- function dateToJSON (key) {
399
- return serializeDate(this);
400
- }
401
-
402
- // Public: `JSON.stringify`. See ES 5.1 section 15.12.3.
403
- var nativeStringify = exports.stringify;
404
- exports.stringify = function (source, filter, width) {
405
- var nativeToJSON = Date.prototype.toJSON;
406
- Date.prototype.toJSON = dateToJSON;
407
- var result = nativeStringify(source, filter, width);
408
- Date.prototype.toJSON = nativeToJSON;
409
- return result;
410
- };
411
- } else {
412
- // Internal: Double-quotes a string `value`, replacing all ASCII control
413
- // characters (characters with code unit values between 0 and 31) with
414
- // their escaped equivalents. This is an implementation of the
415
- // `Quote(value)` operation defined in ES 5.1 section 15.12.3.
416
- var unicodePrefix = "\\u00";
417
- var escapeChar = function (character) {
418
- var charCode = character.charCodeAt(0), escaped = Escapes[charCode];
419
- if (escaped) {
420
- return escaped;
421
- }
422
- return unicodePrefix + toPaddedString(2, charCode.toString(16));
423
- };
424
- var reEscape = /[\x00-\x1f\x22\x5c]/g;
425
- var quote = function (value) {
426
- reEscape.lastIndex = 0;
427
- return '"' +
428
- (
429
- reEscape.test(value)
430
- ? value.replace(reEscape, escapeChar)
431
- : value
432
- ) +
433
- '"';
434
- };
435
-
436
- // Internal: Recursively serializes an object. Implements the
437
- // `Str(key, holder)`, `JO(value)`, and `JA(value)` operations.
438
- var serialize = function (property, object, callback, properties, whitespace, indentation, stack) {
439
- var value, type, className, results, element, index, length, prefix, result;
440
- attempt(function () {
441
- // Necessary for host object support.
442
- value = object[property];
443
- });
444
- if (typeof value == "object" && value) {
445
- if (value.getUTCFullYear && getClass.call(value) == dateClass && value.toJSON === Date.prototype.toJSON) {
446
- value = serializeDate(value);
447
- } else if (typeof value.toJSON == "function") {
448
- value = value.toJSON(property);
449
- }
450
- }
451
- if (callback) {
452
- // If a replacement function was provided, call it to obtain the value
453
- // for serialization.
454
- value = callback.call(object, property, value);
455
- }
456
- // Exit early if value is `undefined` or `null`.
457
- if (value == undefined$1) {
458
- return value === undefined$1 ? value : "null";
459
- }
460
- type = typeof value;
461
- // Only call `getClass` if the value is an object.
462
- if (type == "object") {
463
- className = getClass.call(value);
464
- }
465
- switch (className || type) {
466
- case "boolean":
467
- case booleanClass:
468
- // Booleans are represented literally.
469
- return "" + value;
470
- case "number":
471
- case numberClass:
472
- // JSON numbers must be finite. `Infinity` and `NaN` are serialized as
473
- // `"null"`.
474
- return value > -1 / 0 && value < 1 / 0 ? "" + value : "null";
475
- case "string":
476
- case stringClass:
477
- // Strings are double-quoted and escaped.
478
- return quote("" + value);
479
- }
480
- // Recursively serialize objects and arrays.
481
- if (typeof value == "object") {
482
- // Check for cyclic structures. This is a linear search; performance
483
- // is inversely proportional to the number of unique nested objects.
484
- for (length = stack.length; length--;) {
485
- if (stack[length] === value) {
486
- // Cyclic structures cannot be serialized by `JSON.stringify`.
487
- throw TypeError();
488
- }
489
- }
490
- // Add the object to the stack of traversed objects.
491
- stack.push(value);
492
- results = [];
493
- // Save the current indentation level and indent one additional level.
494
- prefix = indentation;
495
- indentation += whitespace;
496
- if (className == arrayClass) {
497
- // Recursively serialize array elements.
498
- for (index = 0, length = value.length; index < length; index++) {
499
- element = serialize(index, value, callback, properties, whitespace, indentation, stack);
500
- results.push(element === undefined$1 ? "null" : element);
501
- }
502
- result = results.length ? (whitespace ? "[\n" + indentation + results.join(",\n" + indentation) + "\n" + prefix + "]" : ("[" + results.join(",") + "]")) : "[]";
503
- } else {
504
- // Recursively serialize object members. Members are selected from
505
- // either a user-specified list of property names, or the object
506
- // itself.
507
- forOwn(properties || value, function (property) {
508
- var element = serialize(property, value, callback, properties, whitespace, indentation, stack);
509
- if (element !== undefined$1) {
510
- // According to ES 5.1 section 15.12.3: "If `gap` {whitespace}
511
- // is not the empty string, let `member` {quote(property) + ":"}
512
- // be the concatenation of `member` and the `space` character."
513
- // The "`space` character" refers to the literal space
514
- // character, not the `space` {width} argument provided to
515
- // `JSON.stringify`.
516
- results.push(quote(property) + ":" + (whitespace ? " " : "") + element);
517
- }
518
- });
519
- result = results.length ? (whitespace ? "{\n" + indentation + results.join(",\n" + indentation) + "\n" + prefix + "}" : ("{" + results.join(",") + "}")) : "{}";
520
- }
521
- // Remove the object from the traversed object stack.
522
- stack.pop();
523
- return result;
524
- }
525
- };
526
-
527
- // Public: `JSON.stringify`. See ES 5.1 section 15.12.3.
528
- exports.stringify = function (source, filter, width) {
529
- var whitespace, callback, properties, className;
530
- if (objectTypes[typeof filter] && filter) {
531
- className = getClass.call(filter);
532
- if (className == functionClass) {
533
- callback = filter;
534
- } else if (className == arrayClass) {
535
- // Convert the property names array into a makeshift set.
536
- properties = {};
537
- for (var index = 0, length = filter.length, value; index < length;) {
538
- value = filter[index++];
539
- className = getClass.call(value);
540
- if (className == "[object String]" || className == "[object Number]") {
541
- properties[value] = 1;
542
- }
543
- }
544
- }
545
- }
546
- if (width) {
547
- className = getClass.call(width);
548
- if (className == numberClass) {
549
- // Convert the `width` to an integer and create a string containing
550
- // `width` number of space characters.
551
- if ((width -= width % 1) > 0) {
552
- if (width > 10) {
553
- width = 10;
554
- }
555
- for (whitespace = ""; whitespace.length < width;) {
556
- whitespace += " ";
557
- }
558
- }
559
- } else if (className == stringClass) {
560
- whitespace = width.length <= 10 ? width : width.slice(0, 10);
561
- }
562
- }
563
- // Opera <= 7.54u2 discards the values associated with empty string keys
564
- // (`""`) only if they are used directly within an object member list
565
- // (e.g., `!("" in { "": 1})`).
566
- return serialize("", (value = {}, value[""] = source, value), callback, properties, whitespace, "", []);
567
- };
568
- }
569
- }
570
-
571
- // Public: Parses a JSON source string.
572
- if (!has("json-parse")) {
573
- var fromCharCode = String.fromCharCode;
574
-
575
- // Internal: A map of escaped control characters and their unescaped
576
- // equivalents.
577
- var Unescapes = {
578
- 92: "\\",
579
- 34: '"',
580
- 47: "/",
581
- 98: "\b",
582
- 116: "\t",
583
- 110: "\n",
584
- 102: "\f",
585
- 114: "\r"
586
- };
587
-
588
- // Internal: Stores the parser state.
589
- var Index, Source;
590
-
591
- // Internal: Resets the parser state and throws a `SyntaxError`.
592
- var abort = function () {
593
- Index = Source = null;
594
- throw SyntaxError();
595
- };
596
-
597
- // Internal: Returns the next token, or `"$"` if the parser has reached
598
- // the end of the source string. A token may be a string, number, `null`
599
- // literal, or Boolean literal.
600
- var lex = function () {
601
- var source = Source, length = source.length, value, begin, position, isSigned, charCode;
602
- while (Index < length) {
603
- charCode = source.charCodeAt(Index);
604
- switch (charCode) {
605
- case 9: case 10: case 13: case 32:
606
- // Skip whitespace tokens, including tabs, carriage returns, line
607
- // feeds, and space characters.
608
- Index++;
609
- break;
610
- case 123: case 125: case 91: case 93: case 58: case 44:
611
- // Parse a punctuator token (`{`, `}`, `[`, `]`, `:`, or `,`) at
612
- // the current position.
613
- value = charIndexBuggy ? source.charAt(Index) : source[Index];
614
- Index++;
615
- return value;
616
- case 34:
617
- // `"` delimits a JSON string; advance to the next character and
618
- // begin parsing the string. String tokens are prefixed with the
619
- // sentinel `@` character to distinguish them from punctuators and
620
- // end-of-string tokens.
621
- for (value = "@", Index++; Index < length;) {
622
- charCode = source.charCodeAt(Index);
623
- if (charCode < 32) {
624
- // Unescaped ASCII control characters (those with a code unit
625
- // less than the space character) are not permitted.
626
- abort();
627
- } else if (charCode == 92) {
628
- // A reverse solidus (`\`) marks the beginning of an escaped
629
- // control character (including `"`, `\`, and `/`) or Unicode
630
- // escape sequence.
631
- charCode = source.charCodeAt(++Index);
632
- switch (charCode) {
633
- case 92: case 34: case 47: case 98: case 116: case 110: case 102: case 114:
634
- // Revive escaped control characters.
635
- value += Unescapes[charCode];
636
- Index++;
637
- break;
638
- case 117:
639
- // `\u` marks the beginning of a Unicode escape sequence.
640
- // Advance to the first character and validate the
641
- // four-digit code point.
642
- begin = ++Index;
643
- for (position = Index + 4; Index < position; Index++) {
644
- charCode = source.charCodeAt(Index);
645
- // A valid sequence comprises four hexdigits (case-
646
- // insensitive) that form a single hexadecimal value.
647
- if (!(charCode >= 48 && charCode <= 57 || charCode >= 97 && charCode <= 102 || charCode >= 65 && charCode <= 70)) {
648
- // Invalid Unicode escape sequence.
649
- abort();
650
- }
651
- }
652
- // Revive the escaped character.
653
- value += fromCharCode("0x" + source.slice(begin, Index));
654
- break;
655
- default:
656
- // Invalid escape sequence.
657
- abort();
658
- }
659
- } else {
660
- if (charCode == 34) {
661
- // An unescaped double-quote character marks the end of the
662
- // string.
663
- break;
664
- }
665
- charCode = source.charCodeAt(Index);
666
- begin = Index;
667
- // Optimize for the common case where a string is valid.
668
- while (charCode >= 32 && charCode != 92 && charCode != 34) {
669
- charCode = source.charCodeAt(++Index);
670
- }
671
- // Append the string as-is.
672
- value += source.slice(begin, Index);
673
- }
674
- }
675
- if (source.charCodeAt(Index) == 34) {
676
- // Advance to the next character and return the revived string.
677
- Index++;
678
- return value;
679
- }
680
- // Unterminated string.
681
- abort();
682
- default:
683
- // Parse numbers and literals.
684
- begin = Index;
685
- // Advance past the negative sign, if one is specified.
686
- if (charCode == 45) {
687
- isSigned = true;
688
- charCode = source.charCodeAt(++Index);
689
- }
690
- // Parse an integer or floating-point value.
691
- if (charCode >= 48 && charCode <= 57) {
692
- // Leading zeroes are interpreted as octal literals.
693
- if (charCode == 48 && ((charCode = source.charCodeAt(Index + 1)), charCode >= 48 && charCode <= 57)) {
694
- // Illegal octal literal.
695
- abort();
696
- }
697
- isSigned = false;
698
- // Parse the integer component.
699
- for (; Index < length && ((charCode = source.charCodeAt(Index)), charCode >= 48 && charCode <= 57); Index++);
700
- // Floats cannot contain a leading decimal point; however, this
701
- // case is already accounted for by the parser.
702
- if (source.charCodeAt(Index) == 46) {
703
- position = ++Index;
704
- // Parse the decimal component.
705
- for (; position < length; position++) {
706
- charCode = source.charCodeAt(position);
707
- if (charCode < 48 || charCode > 57) {
708
- break;
709
- }
710
- }
711
- if (position == Index) {
712
- // Illegal trailing decimal.
713
- abort();
714
- }
715
- Index = position;
716
- }
717
- // Parse exponents. The `e` denoting the exponent is
718
- // case-insensitive.
719
- charCode = source.charCodeAt(Index);
720
- if (charCode == 101 || charCode == 69) {
721
- charCode = source.charCodeAt(++Index);
722
- // Skip past the sign following the exponent, if one is
723
- // specified.
724
- if (charCode == 43 || charCode == 45) {
725
- Index++;
726
- }
727
- // Parse the exponential component.
728
- for (position = Index; position < length; position++) {
729
- charCode = source.charCodeAt(position);
730
- if (charCode < 48 || charCode > 57) {
731
- break;
732
- }
733
- }
734
- if (position == Index) {
735
- // Illegal empty exponent.
736
- abort();
737
- }
738
- Index = position;
739
- }
740
- // Coerce the parsed value to a JavaScript number.
741
- return +source.slice(begin, Index);
742
- }
743
- // A negative sign may only precede numbers.
744
- if (isSigned) {
745
- abort();
746
- }
747
- // `true`, `false`, and `null` literals.
748
- var temp = source.slice(Index, Index + 4);
749
- if (temp == "true") {
750
- Index += 4;
751
- return true;
752
- } else if (temp == "fals" && source.charCodeAt(Index + 4 ) == 101) {
753
- Index += 5;
754
- return false;
755
- } else if (temp == "null") {
756
- Index += 4;
757
- return null;
758
- }
759
- // Unrecognized token.
760
- abort();
761
- }
762
- }
763
- // Return the sentinel `$` character if the parser has reached the end
764
- // of the source string.
765
- return "$";
766
- };
767
-
768
- // Internal: Parses a JSON `value` token.
769
- var get = function (value) {
770
- var results, hasMembers;
771
- if (value == "$") {
772
- // Unexpected end of input.
773
- abort();
774
- }
775
- if (typeof value == "string") {
776
- if ((charIndexBuggy ? value.charAt(0) : value[0]) == "@") {
777
- // Remove the sentinel `@` character.
778
- return value.slice(1);
779
- }
780
- // Parse object and array literals.
781
- if (value == "[") {
782
- // Parses a JSON array, returning a new JavaScript array.
783
- results = [];
784
- for (;;) {
785
- value = lex();
786
- // A closing square bracket marks the end of the array literal.
787
- if (value == "]") {
788
- break;
789
- }
790
- // If the array literal contains elements, the current token
791
- // should be a comma separating the previous element from the
792
- // next.
793
- if (hasMembers) {
794
- if (value == ",") {
795
- value = lex();
796
- if (value == "]") {
797
- // Unexpected trailing `,` in array literal.
798
- abort();
799
- }
800
- } else {
801
- // A `,` must separate each array element.
802
- abort();
803
- }
804
- } else {
805
- hasMembers = true;
806
- }
807
- // Elisions and leading commas are not permitted.
808
- if (value == ",") {
809
- abort();
810
- }
811
- results.push(get(value));
812
- }
813
- return results;
814
- } else if (value == "{") {
815
- // Parses a JSON object, returning a new JavaScript object.
816
- results = {};
817
- for (;;) {
818
- value = lex();
819
- // A closing curly brace marks the end of the object literal.
820
- if (value == "}") {
821
- break;
822
- }
823
- // If the object literal contains members, the current token
824
- // should be a comma separator.
825
- if (hasMembers) {
826
- if (value == ",") {
827
- value = lex();
828
- if (value == "}") {
829
- // Unexpected trailing `,` in object literal.
830
- abort();
831
- }
832
- } else {
833
- // A `,` must separate each object member.
834
- abort();
835
- }
836
- } else {
837
- hasMembers = true;
838
- }
839
- // Leading commas are not permitted, object property names must be
840
- // double-quoted strings, and a `:` must separate each property
841
- // name and value.
842
- if (value == "," || typeof value != "string" || (charIndexBuggy ? value.charAt(0) : value[0]) != "@" || lex() != ":") {
843
- abort();
844
- }
845
- results[value.slice(1)] = get(lex());
846
- }
847
- return results;
848
- }
849
- // Unexpected token encountered.
850
- abort();
851
- }
852
- return value;
853
- };
854
-
855
- // Internal: Updates a traversed object member.
856
- var update = function (source, property, callback) {
857
- var element = walk(source, property, callback);
858
- if (element === undefined$1) {
859
- delete source[property];
860
- } else {
861
- source[property] = element;
862
- }
863
- };
864
-
865
- // Internal: Recursively traverses a parsed JSON object, invoking the
866
- // `callback` function for each value. This is an implementation of the
867
- // `Walk(holder, name)` operation defined in ES 5.1 section 15.12.2.
868
- var walk = function (source, property, callback) {
869
- var value = source[property], length;
870
- if (typeof value == "object" && value) {
871
- // `forOwn` can't be used to traverse an array in Opera <= 8.54
872
- // because its `Object#hasOwnProperty` implementation returns `false`
873
- // for array indices (e.g., `![1, 2, 3].hasOwnProperty("0")`).
874
- if (getClass.call(value) == arrayClass) {
875
- for (length = value.length; length--;) {
876
- update(getClass, forOwn, value, length, callback);
877
- }
878
- } else {
879
- forOwn(value, function (property) {
880
- update(value, property, callback);
881
- });
882
- }
883
- }
884
- return callback.call(source, property, value);
885
- };
886
-
887
- // Public: `JSON.parse`. See ES 5.1 section 15.12.2.
888
- exports.parse = function (source, callback) {
889
- var result, value;
890
- Index = 0;
891
- Source = "" + source;
892
- result = get(lex());
893
- // If a JSON string contains multiple tokens, it is invalid.
894
- if (lex() != "$") {
895
- abort();
896
- }
897
- // Reset the parser state.
898
- Index = Source = null;
899
- return callback && getClass.call(callback) == functionClass ? walk((value = {}, value[""] = result, value), "", callback) : result;
900
- };
901
- }
902
- }
903
-
904
- exports.runInContext = runInContext;
905
- return exports;
906
- }
907
-
908
- if (freeExports && !isLoader) {
909
- // Export for CommonJS environments.
910
- runInContext(root, freeExports);
911
- } else {
912
- // Export for web browsers and JavaScript engines.
913
- var nativeJSON = root.JSON,
914
- previousJSON = root.JSON3,
915
- isRestored = false;
916
-
917
- var JSON3 = runInContext(root, (root.JSON3 = {
918
- // Public: Restores the original value of the global `JSON` object and
919
- // returns a reference to the `JSON3` object.
920
- "noConflict": function () {
921
- if (!isRestored) {
922
- isRestored = true;
923
- root.JSON = nativeJSON;
924
- root.JSON3 = previousJSON;
925
- nativeJSON = previousJSON = null;
926
- }
927
- return JSON3;
928
- }
929
- }));
930
-
931
- root.JSON = {
932
- "parse": JSON3.parse,
933
- "stringify": JSON3.stringify
934
- };
935
- }
936
- }).call(commonjsGlobal);
937
- } (json3, json3Exports));