@aws-amplify/ui-react 1.2.26-unstable.2 → 2.0.0

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 (164) hide show
  1. package/dist/esm/index.css +1 -0
  2. package/dist/esm/index.css.map +7 -0
  3. package/dist/esm/index.js +1 -0
  4. package/dist/esm/index.js.map +7 -0
  5. package/dist/esm/legacy.js +1 -0
  6. package/dist/esm/legacy.js.map +7 -0
  7. package/dist/index.css +1 -0
  8. package/dist/index.css.map +7 -0
  9. package/dist/index.d.ts +7533 -0
  10. package/dist/index.js +1 -0
  11. package/dist/index.js.map +7 -0
  12. package/dist/legacy.d.ts +1 -0
  13. package/dist/legacy.js +1 -0
  14. package/dist/legacy.js.map +7 -0
  15. package/dist/primitives.json +22168 -0
  16. package/legacy/package.json +7 -0
  17. package/package.json +82 -40
  18. package/CHANGELOG.md +0 -339
  19. package/README.md +0 -1
  20. package/build.js +0 -5
  21. package/dist/0.js +0 -269
  22. package/dist/0.js.map +0 -1
  23. package/dist/1.js +0 -2111
  24. package/dist/1.js.map +0 -1
  25. package/dist/10.js +0 -707
  26. package/dist/10.js.map +0 -1
  27. package/dist/11.js +0 -45
  28. package/dist/11.js.map +0 -1
  29. package/dist/12.js +0 -1152
  30. package/dist/12.js.map +0 -1
  31. package/dist/13.js +0 -114
  32. package/dist/13.js.map +0 -1
  33. package/dist/14.js +0 -1194
  34. package/dist/14.js.map +0 -1
  35. package/dist/15.js +0 -61
  36. package/dist/15.js.map +0 -1
  37. package/dist/16.js +0 -37
  38. package/dist/16.js.map +0 -1
  39. package/dist/17.js +0 -127
  40. package/dist/17.js.map +0 -1
  41. package/dist/18.js +0 -90
  42. package/dist/18.js.map +0 -1
  43. package/dist/19.js +0 -267
  44. package/dist/19.js.map +0 -1
  45. package/dist/2.js +0 -766
  46. package/dist/2.js.map +0 -1
  47. package/dist/20.js +0 -74
  48. package/dist/20.js.map +0 -1
  49. package/dist/21.js +0 -50
  50. package/dist/21.js.map +0 -1
  51. package/dist/22.js +0 -57
  52. package/dist/22.js.map +0 -1
  53. package/dist/23.js +0 -50
  54. package/dist/23.js.map +0 -1
  55. package/dist/24.js +0 -271
  56. package/dist/24.js.map +0 -1
  57. package/dist/25.js +0 -102
  58. package/dist/25.js.map +0 -1
  59. package/dist/26.js +0 -64
  60. package/dist/26.js.map +0 -1
  61. package/dist/27.js +0 -379
  62. package/dist/27.js.map +0 -1
  63. package/dist/28.js +0 -47
  64. package/dist/28.js.map +0 -1
  65. package/dist/29.js +0 -46
  66. package/dist/29.js.map +0 -1
  67. package/dist/3.js +0 -2787
  68. package/dist/3.js.map +0 -1
  69. package/dist/30.js +0 -503
  70. package/dist/30.js.map +0 -1
  71. package/dist/31.js +0 -2
  72. package/dist/31.js.map +0 -1
  73. package/dist/32.js +0 -2
  74. package/dist/32.js.map +0 -1
  75. package/dist/33.js +0 -13
  76. package/dist/33.js.map +0 -1
  77. package/dist/4.js +0 -4126
  78. package/dist/4.js.map +0 -1
  79. package/dist/5.js +0 -817
  80. package/dist/5.js.map +0 -1
  81. package/dist/6.js +0 -619
  82. package/dist/6.js.map +0 -1
  83. package/dist/7.js +0 -662
  84. package/dist/7.js.map +0 -1
  85. package/dist/8.js +0 -614
  86. package/dist/8.js.map +0 -1
  87. package/dist/9.js +0 -665
  88. package/dist/9.js.map +0 -1
  89. package/dist/@aws-amplify/ui-react.js +0 -31875
  90. package/dist/@aws-amplify/ui-react.js.map +0 -1
  91. package/dist/aws-amplify-react.min.js +0 -28
  92. package/dist/aws-amplify-react.min.js.map +0 -1
  93. package/dist/polyfills-core-js.js +0 -5211
  94. package/dist/polyfills-core-js.js.map +0 -1
  95. package/dist/polyfills-css-shim.js +0 -467
  96. package/dist/polyfills-css-shim.js.map +0 -1
  97. package/dist/polyfills-dom.js +0 -2098
  98. package/dist/polyfills-dom.js.map +0 -1
  99. package/jest.config.js +0 -12
  100. package/lib/components.d.ts +0 -56
  101. package/lib/components.js +0 -64
  102. package/lib/components.js.map +0 -1
  103. package/lib/index.d.ts +0 -2
  104. package/lib/index.js +0 -9
  105. package/lib/index.js.map +0 -1
  106. package/lib/react-component-lib/createComponent.d.ts +0 -2
  107. package/lib/react-component-lib/createComponent.js +0 -91
  108. package/lib/react-component-lib/createComponent.js.map +0 -1
  109. package/lib/react-component-lib/createControllerComponent.d.ts +0 -43
  110. package/lib/react-component-lib/createControllerComponent.js +0 -152
  111. package/lib/react-component-lib/createControllerComponent.js.map +0 -1
  112. package/lib/react-component-lib/createOverlayComponent.d.ts +0 -45
  113. package/lib/react-component-lib/createOverlayComponent.js +0 -148
  114. package/lib/react-component-lib/createOverlayComponent.js.map +0 -1
  115. package/lib/react-component-lib/index.d.ts +0 -3
  116. package/lib/react-component-lib/index.js +0 -9
  117. package/lib/react-component-lib/index.js.map +0 -1
  118. package/lib/react-component-lib/utils/attachEventProps.d.ts +0 -8
  119. package/lib/react-component-lib/utils/attachEventProps.js +0 -85
  120. package/lib/react-component-lib/utils/attachEventProps.js.map +0 -1
  121. package/lib/react-component-lib/utils/index.d.ts +0 -8
  122. package/lib/react-component-lib/utils/index.js +0 -36
  123. package/lib/react-component-lib/utils/index.js.map +0 -1
  124. package/lib/withAuthenticator.d.ts +0 -3
  125. package/lib/withAuthenticator.js +0 -127
  126. package/lib/withAuthenticator.js.map +0 -1
  127. package/lib-esm/components.d.ts +0 -56
  128. package/lib-esm/components.js +0 -62
  129. package/lib-esm/components.js.map +0 -1
  130. package/lib-esm/index.d.ts +0 -2
  131. package/lib-esm/index.js +0 -3
  132. package/lib-esm/index.js.map +0 -1
  133. package/lib-esm/react-component-lib/createComponent.d.ts +0 -2
  134. package/lib-esm/react-component-lib/createComponent.js +0 -86
  135. package/lib-esm/react-component-lib/createComponent.js.map +0 -1
  136. package/lib-esm/react-component-lib/createControllerComponent.d.ts +0 -43
  137. package/lib-esm/react-component-lib/createControllerComponent.js +0 -146
  138. package/lib-esm/react-component-lib/createControllerComponent.js.map +0 -1
  139. package/lib-esm/react-component-lib/createOverlayComponent.d.ts +0 -45
  140. package/lib-esm/react-component-lib/createOverlayComponent.js +0 -142
  141. package/lib-esm/react-component-lib/createOverlayComponent.js.map +0 -1
  142. package/lib-esm/react-component-lib/index.d.ts +0 -3
  143. package/lib-esm/react-component-lib/index.js +0 -4
  144. package/lib-esm/react-component-lib/index.js.map +0 -1
  145. package/lib-esm/react-component-lib/utils/attachEventProps.d.ts +0 -8
  146. package/lib-esm/react-component-lib/utils/attachEventProps.js +0 -79
  147. package/lib-esm/react-component-lib/utils/attachEventProps.js.map +0 -1
  148. package/lib-esm/react-component-lib/utils/index.d.ts +0 -8
  149. package/lib-esm/react-component-lib/utils/index.js +0 -28
  150. package/lib-esm/react-component-lib/utils/index.js.map +0 -1
  151. package/lib-esm/withAuthenticator.d.ts +0 -3
  152. package/lib-esm/withAuthenticator.js +0 -121
  153. package/lib-esm/withAuthenticator.js.map +0 -1
  154. package/src/components.ts +0 -65
  155. package/src/index.ts +0 -3
  156. package/src/react-component-lib/createComponent.tsx +0 -69
  157. package/src/react-component-lib/createControllerComponent.tsx +0 -71
  158. package/src/react-component-lib/createOverlayComponent.tsx +0 -79
  159. package/src/react-component-lib/index.ts +0 -3
  160. package/src/react-component-lib/utils/attachEventProps.ts +0 -87
  161. package/src/react-component-lib/utils/index.tsx +0 -31
  162. package/src/withAuthenticator.tsx +0 -62
  163. package/webpack.config.dev.js +0 -6
  164. package/webpack.config.js +0 -56
package/dist/1.js DELETED
@@ -1,2111 +0,0 @@
1
- (this["webpackJsonpaws_amplify_react"] = this["webpackJsonpaws_amplify_react"] || []).push([[1],{
2
-
3
- /***/ "../../node_modules/base64-js/index.js":
4
- /*!********************************************************!*\
5
- !*** /root/amplify-js/node_modules/base64-js/index.js ***!
6
- \********************************************************/
7
- /*! no static exports found */
8
- /***/ (function(module, exports, __webpack_require__) {
9
-
10
- "use strict";
11
-
12
-
13
- exports.byteLength = byteLength
14
- exports.toByteArray = toByteArray
15
- exports.fromByteArray = fromByteArray
16
-
17
- var lookup = []
18
- var revLookup = []
19
- var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
20
-
21
- var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
22
- for (var i = 0, len = code.length; i < len; ++i) {
23
- lookup[i] = code[i]
24
- revLookup[code.charCodeAt(i)] = i
25
- }
26
-
27
- // Support decoding URL-safe base64 strings, as Node.js does.
28
- // See: https://en.wikipedia.org/wiki/Base64#URL_applications
29
- revLookup['-'.charCodeAt(0)] = 62
30
- revLookup['_'.charCodeAt(0)] = 63
31
-
32
- function getLens (b64) {
33
- var len = b64.length
34
-
35
- if (len % 4 > 0) {
36
- throw new Error('Invalid string. Length must be a multiple of 4')
37
- }
38
-
39
- // Trim off extra bytes after placeholder bytes are found
40
- // See: https://github.com/beatgammit/base64-js/issues/42
41
- var validLen = b64.indexOf('=')
42
- if (validLen === -1) validLen = len
43
-
44
- var placeHoldersLen = validLen === len
45
- ? 0
46
- : 4 - (validLen % 4)
47
-
48
- return [validLen, placeHoldersLen]
49
- }
50
-
51
- // base64 is 4/3 + up to two characters of the original data
52
- function byteLength (b64) {
53
- var lens = getLens(b64)
54
- var validLen = lens[0]
55
- var placeHoldersLen = lens[1]
56
- return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
57
- }
58
-
59
- function _byteLength (b64, validLen, placeHoldersLen) {
60
- return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
61
- }
62
-
63
- function toByteArray (b64) {
64
- var tmp
65
- var lens = getLens(b64)
66
- var validLen = lens[0]
67
- var placeHoldersLen = lens[1]
68
-
69
- var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
70
-
71
- var curByte = 0
72
-
73
- // if there are placeholders, only get up to the last complete 4 chars
74
- var len = placeHoldersLen > 0
75
- ? validLen - 4
76
- : validLen
77
-
78
- var i
79
- for (i = 0; i < len; i += 4) {
80
- tmp =
81
- (revLookup[b64.charCodeAt(i)] << 18) |
82
- (revLookup[b64.charCodeAt(i + 1)] << 12) |
83
- (revLookup[b64.charCodeAt(i + 2)] << 6) |
84
- revLookup[b64.charCodeAt(i + 3)]
85
- arr[curByte++] = (tmp >> 16) & 0xFF
86
- arr[curByte++] = (tmp >> 8) & 0xFF
87
- arr[curByte++] = tmp & 0xFF
88
- }
89
-
90
- if (placeHoldersLen === 2) {
91
- tmp =
92
- (revLookup[b64.charCodeAt(i)] << 2) |
93
- (revLookup[b64.charCodeAt(i + 1)] >> 4)
94
- arr[curByte++] = tmp & 0xFF
95
- }
96
-
97
- if (placeHoldersLen === 1) {
98
- tmp =
99
- (revLookup[b64.charCodeAt(i)] << 10) |
100
- (revLookup[b64.charCodeAt(i + 1)] << 4) |
101
- (revLookup[b64.charCodeAt(i + 2)] >> 2)
102
- arr[curByte++] = (tmp >> 8) & 0xFF
103
- arr[curByte++] = tmp & 0xFF
104
- }
105
-
106
- return arr
107
- }
108
-
109
- function tripletToBase64 (num) {
110
- return lookup[num >> 18 & 0x3F] +
111
- lookup[num >> 12 & 0x3F] +
112
- lookup[num >> 6 & 0x3F] +
113
- lookup[num & 0x3F]
114
- }
115
-
116
- function encodeChunk (uint8, start, end) {
117
- var tmp
118
- var output = []
119
- for (var i = start; i < end; i += 3) {
120
- tmp =
121
- ((uint8[i] << 16) & 0xFF0000) +
122
- ((uint8[i + 1] << 8) & 0xFF00) +
123
- (uint8[i + 2] & 0xFF)
124
- output.push(tripletToBase64(tmp))
125
- }
126
- return output.join('')
127
- }
128
-
129
- function fromByteArray (uint8) {
130
- var tmp
131
- var len = uint8.length
132
- var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
133
- var parts = []
134
- var maxChunkLength = 16383 // must be multiple of 3
135
-
136
- // go through the array every three bytes, we'll deal with trailing stuff later
137
- for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
138
- parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))
139
- }
140
-
141
- // pad the end with zeros, but make sure to not forget the extra bytes
142
- if (extraBytes === 1) {
143
- tmp = uint8[len - 1]
144
- parts.push(
145
- lookup[tmp >> 2] +
146
- lookup[(tmp << 4) & 0x3F] +
147
- '=='
148
- )
149
- } else if (extraBytes === 2) {
150
- tmp = (uint8[len - 2] << 8) + uint8[len - 1]
151
- parts.push(
152
- lookup[tmp >> 10] +
153
- lookup[(tmp >> 4) & 0x3F] +
154
- lookup[(tmp << 2) & 0x3F] +
155
- '='
156
- )
157
- }
158
-
159
- return parts.join('')
160
- }
161
-
162
-
163
- /***/ }),
164
-
165
- /***/ "../../node_modules/buffer/index.js":
166
- /*!*****************************************************!*\
167
- !*** /root/amplify-js/node_modules/buffer/index.js ***!
168
- \*****************************************************/
169
- /*! no static exports found */
170
- /***/ (function(module, exports, __webpack_require__) {
171
-
172
- "use strict";
173
- /* WEBPACK VAR INJECTION */(function(global) {/*!
174
- * The buffer module from node.js, for the browser.
175
- *
176
- * @author Feross Aboukhadijeh <http://feross.org>
177
- * @license MIT
178
- */
179
- /* eslint-disable no-proto */
180
-
181
-
182
-
183
- var base64 = __webpack_require__(/*! base64-js */ "../../node_modules/base64-js/index.js")
184
- var ieee754 = __webpack_require__(/*! ieee754 */ "../../node_modules/ieee754/index.js")
185
- var isArray = __webpack_require__(/*! isarray */ "../../node_modules/isarray/index.js")
186
-
187
- exports.Buffer = Buffer
188
- exports.SlowBuffer = SlowBuffer
189
- exports.INSPECT_MAX_BYTES = 50
190
-
191
- /**
192
- * If `Buffer.TYPED_ARRAY_SUPPORT`:
193
- * === true Use Uint8Array implementation (fastest)
194
- * === false Use Object implementation (most compatible, even IE6)
195
- *
196
- * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
197
- * Opera 11.6+, iOS 4.2+.
198
- *
199
- * Due to various browser bugs, sometimes the Object implementation will be used even
200
- * when the browser supports typed arrays.
201
- *
202
- * Note:
203
- *
204
- * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
205
- * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
206
- *
207
- * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
208
- *
209
- * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
210
- * incorrect length in some situations.
211
-
212
- * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
213
- * get the Object implementation, which is slower but behaves correctly.
214
- */
215
- Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
216
- ? global.TYPED_ARRAY_SUPPORT
217
- : typedArraySupport()
218
-
219
- /*
220
- * Export kMaxLength after typed array support is determined.
221
- */
222
- exports.kMaxLength = kMaxLength()
223
-
224
- function typedArraySupport () {
225
- try {
226
- var arr = new Uint8Array(1)
227
- arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
228
- return arr.foo() === 42 && // typed array instances can be augmented
229
- typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
230
- arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
231
- } catch (e) {
232
- return false
233
- }
234
- }
235
-
236
- function kMaxLength () {
237
- return Buffer.TYPED_ARRAY_SUPPORT
238
- ? 0x7fffffff
239
- : 0x3fffffff
240
- }
241
-
242
- function createBuffer (that, length) {
243
- if (kMaxLength() < length) {
244
- throw new RangeError('Invalid typed array length')
245
- }
246
- if (Buffer.TYPED_ARRAY_SUPPORT) {
247
- // Return an augmented `Uint8Array` instance, for best performance
248
- that = new Uint8Array(length)
249
- that.__proto__ = Buffer.prototype
250
- } else {
251
- // Fallback: Return an object instance of the Buffer class
252
- if (that === null) {
253
- that = new Buffer(length)
254
- }
255
- that.length = length
256
- }
257
-
258
- return that
259
- }
260
-
261
- /**
262
- * The Buffer constructor returns instances of `Uint8Array` that have their
263
- * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
264
- * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
265
- * and the `Uint8Array` methods. Square bracket notation works as expected -- it
266
- * returns a single octet.
267
- *
268
- * The `Uint8Array` prototype remains unmodified.
269
- */
270
-
271
- function Buffer (arg, encodingOrOffset, length) {
272
- if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
273
- return new Buffer(arg, encodingOrOffset, length)
274
- }
275
-
276
- // Common case.
277
- if (typeof arg === 'number') {
278
- if (typeof encodingOrOffset === 'string') {
279
- throw new Error(
280
- 'If encoding is specified then the first argument must be a string'
281
- )
282
- }
283
- return allocUnsafe(this, arg)
284
- }
285
- return from(this, arg, encodingOrOffset, length)
286
- }
287
-
288
- Buffer.poolSize = 8192 // not used by this implementation
289
-
290
- // TODO: Legacy, not needed anymore. Remove in next major version.
291
- Buffer._augment = function (arr) {
292
- arr.__proto__ = Buffer.prototype
293
- return arr
294
- }
295
-
296
- function from (that, value, encodingOrOffset, length) {
297
- if (typeof value === 'number') {
298
- throw new TypeError('"value" argument must not be a number')
299
- }
300
-
301
- if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
302
- return fromArrayBuffer(that, value, encodingOrOffset, length)
303
- }
304
-
305
- if (typeof value === 'string') {
306
- return fromString(that, value, encodingOrOffset)
307
- }
308
-
309
- return fromObject(that, value)
310
- }
311
-
312
- /**
313
- * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
314
- * if value is a number.
315
- * Buffer.from(str[, encoding])
316
- * Buffer.from(array)
317
- * Buffer.from(buffer)
318
- * Buffer.from(arrayBuffer[, byteOffset[, length]])
319
- **/
320
- Buffer.from = function (value, encodingOrOffset, length) {
321
- return from(null, value, encodingOrOffset, length)
322
- }
323
-
324
- if (Buffer.TYPED_ARRAY_SUPPORT) {
325
- Buffer.prototype.__proto__ = Uint8Array.prototype
326
- Buffer.__proto__ = Uint8Array
327
- if (typeof Symbol !== 'undefined' && Symbol.species &&
328
- Buffer[Symbol.species] === Buffer) {
329
- // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
330
- Object.defineProperty(Buffer, Symbol.species, {
331
- value: null,
332
- configurable: true
333
- })
334
- }
335
- }
336
-
337
- function assertSize (size) {
338
- if (typeof size !== 'number') {
339
- throw new TypeError('"size" argument must be a number')
340
- } else if (size < 0) {
341
- throw new RangeError('"size" argument must not be negative')
342
- }
343
- }
344
-
345
- function alloc (that, size, fill, encoding) {
346
- assertSize(size)
347
- if (size <= 0) {
348
- return createBuffer(that, size)
349
- }
350
- if (fill !== undefined) {
351
- // Only pay attention to encoding if it's a string. This
352
- // prevents accidentally sending in a number that would
353
- // be interpretted as a start offset.
354
- return typeof encoding === 'string'
355
- ? createBuffer(that, size).fill(fill, encoding)
356
- : createBuffer(that, size).fill(fill)
357
- }
358
- return createBuffer(that, size)
359
- }
360
-
361
- /**
362
- * Creates a new filled Buffer instance.
363
- * alloc(size[, fill[, encoding]])
364
- **/
365
- Buffer.alloc = function (size, fill, encoding) {
366
- return alloc(null, size, fill, encoding)
367
- }
368
-
369
- function allocUnsafe (that, size) {
370
- assertSize(size)
371
- that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
372
- if (!Buffer.TYPED_ARRAY_SUPPORT) {
373
- for (var i = 0; i < size; ++i) {
374
- that[i] = 0
375
- }
376
- }
377
- return that
378
- }
379
-
380
- /**
381
- * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
382
- * */
383
- Buffer.allocUnsafe = function (size) {
384
- return allocUnsafe(null, size)
385
- }
386
- /**
387
- * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
388
- */
389
- Buffer.allocUnsafeSlow = function (size) {
390
- return allocUnsafe(null, size)
391
- }
392
-
393
- function fromString (that, string, encoding) {
394
- if (typeof encoding !== 'string' || encoding === '') {
395
- encoding = 'utf8'
396
- }
397
-
398
- if (!Buffer.isEncoding(encoding)) {
399
- throw new TypeError('"encoding" must be a valid string encoding')
400
- }
401
-
402
- var length = byteLength(string, encoding) | 0
403
- that = createBuffer(that, length)
404
-
405
- var actual = that.write(string, encoding)
406
-
407
- if (actual !== length) {
408
- // Writing a hex string, for example, that contains invalid characters will
409
- // cause everything after the first invalid character to be ignored. (e.g.
410
- // 'abxxcd' will be treated as 'ab')
411
- that = that.slice(0, actual)
412
- }
413
-
414
- return that
415
- }
416
-
417
- function fromArrayLike (that, array) {
418
- var length = array.length < 0 ? 0 : checked(array.length) | 0
419
- that = createBuffer(that, length)
420
- for (var i = 0; i < length; i += 1) {
421
- that[i] = array[i] & 255
422
- }
423
- return that
424
- }
425
-
426
- function fromArrayBuffer (that, array, byteOffset, length) {
427
- array.byteLength // this throws if `array` is not a valid ArrayBuffer
428
-
429
- if (byteOffset < 0 || array.byteLength < byteOffset) {
430
- throw new RangeError('\'offset\' is out of bounds')
431
- }
432
-
433
- if (array.byteLength < byteOffset + (length || 0)) {
434
- throw new RangeError('\'length\' is out of bounds')
435
- }
436
-
437
- if (byteOffset === undefined && length === undefined) {
438
- array = new Uint8Array(array)
439
- } else if (length === undefined) {
440
- array = new Uint8Array(array, byteOffset)
441
- } else {
442
- array = new Uint8Array(array, byteOffset, length)
443
- }
444
-
445
- if (Buffer.TYPED_ARRAY_SUPPORT) {
446
- // Return an augmented `Uint8Array` instance, for best performance
447
- that = array
448
- that.__proto__ = Buffer.prototype
449
- } else {
450
- // Fallback: Return an object instance of the Buffer class
451
- that = fromArrayLike(that, array)
452
- }
453
- return that
454
- }
455
-
456
- function fromObject (that, obj) {
457
- if (Buffer.isBuffer(obj)) {
458
- var len = checked(obj.length) | 0
459
- that = createBuffer(that, len)
460
-
461
- if (that.length === 0) {
462
- return that
463
- }
464
-
465
- obj.copy(that, 0, 0, len)
466
- return that
467
- }
468
-
469
- if (obj) {
470
- if ((typeof ArrayBuffer !== 'undefined' &&
471
- obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
472
- if (typeof obj.length !== 'number' || isnan(obj.length)) {
473
- return createBuffer(that, 0)
474
- }
475
- return fromArrayLike(that, obj)
476
- }
477
-
478
- if (obj.type === 'Buffer' && isArray(obj.data)) {
479
- return fromArrayLike(that, obj.data)
480
- }
481
- }
482
-
483
- throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
484
- }
485
-
486
- function checked (length) {
487
- // Note: cannot use `length < kMaxLength()` here because that fails when
488
- // length is NaN (which is otherwise coerced to zero.)
489
- if (length >= kMaxLength()) {
490
- throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
491
- 'size: 0x' + kMaxLength().toString(16) + ' bytes')
492
- }
493
- return length | 0
494
- }
495
-
496
- function SlowBuffer (length) {
497
- if (+length != length) { // eslint-disable-line eqeqeq
498
- length = 0
499
- }
500
- return Buffer.alloc(+length)
501
- }
502
-
503
- Buffer.isBuffer = function isBuffer (b) {
504
- return !!(b != null && b._isBuffer)
505
- }
506
-
507
- Buffer.compare = function compare (a, b) {
508
- if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
509
- throw new TypeError('Arguments must be Buffers')
510
- }
511
-
512
- if (a === b) return 0
513
-
514
- var x = a.length
515
- var y = b.length
516
-
517
- for (var i = 0, len = Math.min(x, y); i < len; ++i) {
518
- if (a[i] !== b[i]) {
519
- x = a[i]
520
- y = b[i]
521
- break
522
- }
523
- }
524
-
525
- if (x < y) return -1
526
- if (y < x) return 1
527
- return 0
528
- }
529
-
530
- Buffer.isEncoding = function isEncoding (encoding) {
531
- switch (String(encoding).toLowerCase()) {
532
- case 'hex':
533
- case 'utf8':
534
- case 'utf-8':
535
- case 'ascii':
536
- case 'latin1':
537
- case 'binary':
538
- case 'base64':
539
- case 'ucs2':
540
- case 'ucs-2':
541
- case 'utf16le':
542
- case 'utf-16le':
543
- return true
544
- default:
545
- return false
546
- }
547
- }
548
-
549
- Buffer.concat = function concat (list, length) {
550
- if (!isArray(list)) {
551
- throw new TypeError('"list" argument must be an Array of Buffers')
552
- }
553
-
554
- if (list.length === 0) {
555
- return Buffer.alloc(0)
556
- }
557
-
558
- var i
559
- if (length === undefined) {
560
- length = 0
561
- for (i = 0; i < list.length; ++i) {
562
- length += list[i].length
563
- }
564
- }
565
-
566
- var buffer = Buffer.allocUnsafe(length)
567
- var pos = 0
568
- for (i = 0; i < list.length; ++i) {
569
- var buf = list[i]
570
- if (!Buffer.isBuffer(buf)) {
571
- throw new TypeError('"list" argument must be an Array of Buffers')
572
- }
573
- buf.copy(buffer, pos)
574
- pos += buf.length
575
- }
576
- return buffer
577
- }
578
-
579
- function byteLength (string, encoding) {
580
- if (Buffer.isBuffer(string)) {
581
- return string.length
582
- }
583
- if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
584
- (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
585
- return string.byteLength
586
- }
587
- if (typeof string !== 'string') {
588
- string = '' + string
589
- }
590
-
591
- var len = string.length
592
- if (len === 0) return 0
593
-
594
- // Use a for loop to avoid recursion
595
- var loweredCase = false
596
- for (;;) {
597
- switch (encoding) {
598
- case 'ascii':
599
- case 'latin1':
600
- case 'binary':
601
- return len
602
- case 'utf8':
603
- case 'utf-8':
604
- case undefined:
605
- return utf8ToBytes(string).length
606
- case 'ucs2':
607
- case 'ucs-2':
608
- case 'utf16le':
609
- case 'utf-16le':
610
- return len * 2
611
- case 'hex':
612
- return len >>> 1
613
- case 'base64':
614
- return base64ToBytes(string).length
615
- default:
616
- if (loweredCase) return utf8ToBytes(string).length // assume utf8
617
- encoding = ('' + encoding).toLowerCase()
618
- loweredCase = true
619
- }
620
- }
621
- }
622
- Buffer.byteLength = byteLength
623
-
624
- function slowToString (encoding, start, end) {
625
- var loweredCase = false
626
-
627
- // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
628
- // property of a typed array.
629
-
630
- // This behaves neither like String nor Uint8Array in that we set start/end
631
- // to their upper/lower bounds if the value passed is out of range.
632
- // undefined is handled specially as per ECMA-262 6th Edition,
633
- // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
634
- if (start === undefined || start < 0) {
635
- start = 0
636
- }
637
- // Return early if start > this.length. Done here to prevent potential uint32
638
- // coercion fail below.
639
- if (start > this.length) {
640
- return ''
641
- }
642
-
643
- if (end === undefined || end > this.length) {
644
- end = this.length
645
- }
646
-
647
- if (end <= 0) {
648
- return ''
649
- }
650
-
651
- // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
652
- end >>>= 0
653
- start >>>= 0
654
-
655
- if (end <= start) {
656
- return ''
657
- }
658
-
659
- if (!encoding) encoding = 'utf8'
660
-
661
- while (true) {
662
- switch (encoding) {
663
- case 'hex':
664
- return hexSlice(this, start, end)
665
-
666
- case 'utf8':
667
- case 'utf-8':
668
- return utf8Slice(this, start, end)
669
-
670
- case 'ascii':
671
- return asciiSlice(this, start, end)
672
-
673
- case 'latin1':
674
- case 'binary':
675
- return latin1Slice(this, start, end)
676
-
677
- case 'base64':
678
- return base64Slice(this, start, end)
679
-
680
- case 'ucs2':
681
- case 'ucs-2':
682
- case 'utf16le':
683
- case 'utf-16le':
684
- return utf16leSlice(this, start, end)
685
-
686
- default:
687
- if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
688
- encoding = (encoding + '').toLowerCase()
689
- loweredCase = true
690
- }
691
- }
692
- }
693
-
694
- // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
695
- // Buffer instances.
696
- Buffer.prototype._isBuffer = true
697
-
698
- function swap (b, n, m) {
699
- var i = b[n]
700
- b[n] = b[m]
701
- b[m] = i
702
- }
703
-
704
- Buffer.prototype.swap16 = function swap16 () {
705
- var len = this.length
706
- if (len % 2 !== 0) {
707
- throw new RangeError('Buffer size must be a multiple of 16-bits')
708
- }
709
- for (var i = 0; i < len; i += 2) {
710
- swap(this, i, i + 1)
711
- }
712
- return this
713
- }
714
-
715
- Buffer.prototype.swap32 = function swap32 () {
716
- var len = this.length
717
- if (len % 4 !== 0) {
718
- throw new RangeError('Buffer size must be a multiple of 32-bits')
719
- }
720
- for (var i = 0; i < len; i += 4) {
721
- swap(this, i, i + 3)
722
- swap(this, i + 1, i + 2)
723
- }
724
- return this
725
- }
726
-
727
- Buffer.prototype.swap64 = function swap64 () {
728
- var len = this.length
729
- if (len % 8 !== 0) {
730
- throw new RangeError('Buffer size must be a multiple of 64-bits')
731
- }
732
- for (var i = 0; i < len; i += 8) {
733
- swap(this, i, i + 7)
734
- swap(this, i + 1, i + 6)
735
- swap(this, i + 2, i + 5)
736
- swap(this, i + 3, i + 4)
737
- }
738
- return this
739
- }
740
-
741
- Buffer.prototype.toString = function toString () {
742
- var length = this.length | 0
743
- if (length === 0) return ''
744
- if (arguments.length === 0) return utf8Slice(this, 0, length)
745
- return slowToString.apply(this, arguments)
746
- }
747
-
748
- Buffer.prototype.equals = function equals (b) {
749
- if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
750
- if (this === b) return true
751
- return Buffer.compare(this, b) === 0
752
- }
753
-
754
- Buffer.prototype.inspect = function inspect () {
755
- var str = ''
756
- var max = exports.INSPECT_MAX_BYTES
757
- if (this.length > 0) {
758
- str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
759
- if (this.length > max) str += ' ... '
760
- }
761
- return '<Buffer ' + str + '>'
762
- }
763
-
764
- Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
765
- if (!Buffer.isBuffer(target)) {
766
- throw new TypeError('Argument must be a Buffer')
767
- }
768
-
769
- if (start === undefined) {
770
- start = 0
771
- }
772
- if (end === undefined) {
773
- end = target ? target.length : 0
774
- }
775
- if (thisStart === undefined) {
776
- thisStart = 0
777
- }
778
- if (thisEnd === undefined) {
779
- thisEnd = this.length
780
- }
781
-
782
- if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
783
- throw new RangeError('out of range index')
784
- }
785
-
786
- if (thisStart >= thisEnd && start >= end) {
787
- return 0
788
- }
789
- if (thisStart >= thisEnd) {
790
- return -1
791
- }
792
- if (start >= end) {
793
- return 1
794
- }
795
-
796
- start >>>= 0
797
- end >>>= 0
798
- thisStart >>>= 0
799
- thisEnd >>>= 0
800
-
801
- if (this === target) return 0
802
-
803
- var x = thisEnd - thisStart
804
- var y = end - start
805
- var len = Math.min(x, y)
806
-
807
- var thisCopy = this.slice(thisStart, thisEnd)
808
- var targetCopy = target.slice(start, end)
809
-
810
- for (var i = 0; i < len; ++i) {
811
- if (thisCopy[i] !== targetCopy[i]) {
812
- x = thisCopy[i]
813
- y = targetCopy[i]
814
- break
815
- }
816
- }
817
-
818
- if (x < y) return -1
819
- if (y < x) return 1
820
- return 0
821
- }
822
-
823
- // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
824
- // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
825
- //
826
- // Arguments:
827
- // - buffer - a Buffer to search
828
- // - val - a string, Buffer, or number
829
- // - byteOffset - an index into `buffer`; will be clamped to an int32
830
- // - encoding - an optional encoding, relevant is val is a string
831
- // - dir - true for indexOf, false for lastIndexOf
832
- function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
833
- // Empty buffer means no match
834
- if (buffer.length === 0) return -1
835
-
836
- // Normalize byteOffset
837
- if (typeof byteOffset === 'string') {
838
- encoding = byteOffset
839
- byteOffset = 0
840
- } else if (byteOffset > 0x7fffffff) {
841
- byteOffset = 0x7fffffff
842
- } else if (byteOffset < -0x80000000) {
843
- byteOffset = -0x80000000
844
- }
845
- byteOffset = +byteOffset // Coerce to Number.
846
- if (isNaN(byteOffset)) {
847
- // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
848
- byteOffset = dir ? 0 : (buffer.length - 1)
849
- }
850
-
851
- // Normalize byteOffset: negative offsets start from the end of the buffer
852
- if (byteOffset < 0) byteOffset = buffer.length + byteOffset
853
- if (byteOffset >= buffer.length) {
854
- if (dir) return -1
855
- else byteOffset = buffer.length - 1
856
- } else if (byteOffset < 0) {
857
- if (dir) byteOffset = 0
858
- else return -1
859
- }
860
-
861
- // Normalize val
862
- if (typeof val === 'string') {
863
- val = Buffer.from(val, encoding)
864
- }
865
-
866
- // Finally, search either indexOf (if dir is true) or lastIndexOf
867
- if (Buffer.isBuffer(val)) {
868
- // Special case: looking for empty string/buffer always fails
869
- if (val.length === 0) {
870
- return -1
871
- }
872
- return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
873
- } else if (typeof val === 'number') {
874
- val = val & 0xFF // Search for a byte value [0-255]
875
- if (Buffer.TYPED_ARRAY_SUPPORT &&
876
- typeof Uint8Array.prototype.indexOf === 'function') {
877
- if (dir) {
878
- return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
879
- } else {
880
- return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
881
- }
882
- }
883
- return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
884
- }
885
-
886
- throw new TypeError('val must be string, number or Buffer')
887
- }
888
-
889
- function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
890
- var indexSize = 1
891
- var arrLength = arr.length
892
- var valLength = val.length
893
-
894
- if (encoding !== undefined) {
895
- encoding = String(encoding).toLowerCase()
896
- if (encoding === 'ucs2' || encoding === 'ucs-2' ||
897
- encoding === 'utf16le' || encoding === 'utf-16le') {
898
- if (arr.length < 2 || val.length < 2) {
899
- return -1
900
- }
901
- indexSize = 2
902
- arrLength /= 2
903
- valLength /= 2
904
- byteOffset /= 2
905
- }
906
- }
907
-
908
- function read (buf, i) {
909
- if (indexSize === 1) {
910
- return buf[i]
911
- } else {
912
- return buf.readUInt16BE(i * indexSize)
913
- }
914
- }
915
-
916
- var i
917
- if (dir) {
918
- var foundIndex = -1
919
- for (i = byteOffset; i < arrLength; i++) {
920
- if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
921
- if (foundIndex === -1) foundIndex = i
922
- if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
923
- } else {
924
- if (foundIndex !== -1) i -= i - foundIndex
925
- foundIndex = -1
926
- }
927
- }
928
- } else {
929
- if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
930
- for (i = byteOffset; i >= 0; i--) {
931
- var found = true
932
- for (var j = 0; j < valLength; j++) {
933
- if (read(arr, i + j) !== read(val, j)) {
934
- found = false
935
- break
936
- }
937
- }
938
- if (found) return i
939
- }
940
- }
941
-
942
- return -1
943
- }
944
-
945
- Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
946
- return this.indexOf(val, byteOffset, encoding) !== -1
947
- }
948
-
949
- Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
950
- return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
951
- }
952
-
953
- Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
954
- return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
955
- }
956
-
957
- function hexWrite (buf, string, offset, length) {
958
- offset = Number(offset) || 0
959
- var remaining = buf.length - offset
960
- if (!length) {
961
- length = remaining
962
- } else {
963
- length = Number(length)
964
- if (length > remaining) {
965
- length = remaining
966
- }
967
- }
968
-
969
- // must be an even number of digits
970
- var strLen = string.length
971
- if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
972
-
973
- if (length > strLen / 2) {
974
- length = strLen / 2
975
- }
976
- for (var i = 0; i < length; ++i) {
977
- var parsed = parseInt(string.substr(i * 2, 2), 16)
978
- if (isNaN(parsed)) return i
979
- buf[offset + i] = parsed
980
- }
981
- return i
982
- }
983
-
984
- function utf8Write (buf, string, offset, length) {
985
- return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
986
- }
987
-
988
- function asciiWrite (buf, string, offset, length) {
989
- return blitBuffer(asciiToBytes(string), buf, offset, length)
990
- }
991
-
992
- function latin1Write (buf, string, offset, length) {
993
- return asciiWrite(buf, string, offset, length)
994
- }
995
-
996
- function base64Write (buf, string, offset, length) {
997
- return blitBuffer(base64ToBytes(string), buf, offset, length)
998
- }
999
-
1000
- function ucs2Write (buf, string, offset, length) {
1001
- return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
1002
- }
1003
-
1004
- Buffer.prototype.write = function write (string, offset, length, encoding) {
1005
- // Buffer#write(string)
1006
- if (offset === undefined) {
1007
- encoding = 'utf8'
1008
- length = this.length
1009
- offset = 0
1010
- // Buffer#write(string, encoding)
1011
- } else if (length === undefined && typeof offset === 'string') {
1012
- encoding = offset
1013
- length = this.length
1014
- offset = 0
1015
- // Buffer#write(string, offset[, length][, encoding])
1016
- } else if (isFinite(offset)) {
1017
- offset = offset | 0
1018
- if (isFinite(length)) {
1019
- length = length | 0
1020
- if (encoding === undefined) encoding = 'utf8'
1021
- } else {
1022
- encoding = length
1023
- length = undefined
1024
- }
1025
- // legacy write(string, encoding, offset, length) - remove in v0.13
1026
- } else {
1027
- throw new Error(
1028
- 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
1029
- )
1030
- }
1031
-
1032
- var remaining = this.length - offset
1033
- if (length === undefined || length > remaining) length = remaining
1034
-
1035
- if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
1036
- throw new RangeError('Attempt to write outside buffer bounds')
1037
- }
1038
-
1039
- if (!encoding) encoding = 'utf8'
1040
-
1041
- var loweredCase = false
1042
- for (;;) {
1043
- switch (encoding) {
1044
- case 'hex':
1045
- return hexWrite(this, string, offset, length)
1046
-
1047
- case 'utf8':
1048
- case 'utf-8':
1049
- return utf8Write(this, string, offset, length)
1050
-
1051
- case 'ascii':
1052
- return asciiWrite(this, string, offset, length)
1053
-
1054
- case 'latin1':
1055
- case 'binary':
1056
- return latin1Write(this, string, offset, length)
1057
-
1058
- case 'base64':
1059
- // Warning: maxLength not taken into account in base64Write
1060
- return base64Write(this, string, offset, length)
1061
-
1062
- case 'ucs2':
1063
- case 'ucs-2':
1064
- case 'utf16le':
1065
- case 'utf-16le':
1066
- return ucs2Write(this, string, offset, length)
1067
-
1068
- default:
1069
- if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
1070
- encoding = ('' + encoding).toLowerCase()
1071
- loweredCase = true
1072
- }
1073
- }
1074
- }
1075
-
1076
- Buffer.prototype.toJSON = function toJSON () {
1077
- return {
1078
- type: 'Buffer',
1079
- data: Array.prototype.slice.call(this._arr || this, 0)
1080
- }
1081
- }
1082
-
1083
- function base64Slice (buf, start, end) {
1084
- if (start === 0 && end === buf.length) {
1085
- return base64.fromByteArray(buf)
1086
- } else {
1087
- return base64.fromByteArray(buf.slice(start, end))
1088
- }
1089
- }
1090
-
1091
- function utf8Slice (buf, start, end) {
1092
- end = Math.min(buf.length, end)
1093
- var res = []
1094
-
1095
- var i = start
1096
- while (i < end) {
1097
- var firstByte = buf[i]
1098
- var codePoint = null
1099
- var bytesPerSequence = (firstByte > 0xEF) ? 4
1100
- : (firstByte > 0xDF) ? 3
1101
- : (firstByte > 0xBF) ? 2
1102
- : 1
1103
-
1104
- if (i + bytesPerSequence <= end) {
1105
- var secondByte, thirdByte, fourthByte, tempCodePoint
1106
-
1107
- switch (bytesPerSequence) {
1108
- case 1:
1109
- if (firstByte < 0x80) {
1110
- codePoint = firstByte
1111
- }
1112
- break
1113
- case 2:
1114
- secondByte = buf[i + 1]
1115
- if ((secondByte & 0xC0) === 0x80) {
1116
- tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
1117
- if (tempCodePoint > 0x7F) {
1118
- codePoint = tempCodePoint
1119
- }
1120
- }
1121
- break
1122
- case 3:
1123
- secondByte = buf[i + 1]
1124
- thirdByte = buf[i + 2]
1125
- if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
1126
- tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
1127
- if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
1128
- codePoint = tempCodePoint
1129
- }
1130
- }
1131
- break
1132
- case 4:
1133
- secondByte = buf[i + 1]
1134
- thirdByte = buf[i + 2]
1135
- fourthByte = buf[i + 3]
1136
- if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
1137
- tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
1138
- if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
1139
- codePoint = tempCodePoint
1140
- }
1141
- }
1142
- }
1143
- }
1144
-
1145
- if (codePoint === null) {
1146
- // we did not generate a valid codePoint so insert a
1147
- // replacement char (U+FFFD) and advance only 1 byte
1148
- codePoint = 0xFFFD
1149
- bytesPerSequence = 1
1150
- } else if (codePoint > 0xFFFF) {
1151
- // encode to utf16 (surrogate pair dance)
1152
- codePoint -= 0x10000
1153
- res.push(codePoint >>> 10 & 0x3FF | 0xD800)
1154
- codePoint = 0xDC00 | codePoint & 0x3FF
1155
- }
1156
-
1157
- res.push(codePoint)
1158
- i += bytesPerSequence
1159
- }
1160
-
1161
- return decodeCodePointsArray(res)
1162
- }
1163
-
1164
- // Based on http://stackoverflow.com/a/22747272/680742, the browser with
1165
- // the lowest limit is Chrome, with 0x10000 args.
1166
- // We go 1 magnitude less, for safety
1167
- var MAX_ARGUMENTS_LENGTH = 0x1000
1168
-
1169
- function decodeCodePointsArray (codePoints) {
1170
- var len = codePoints.length
1171
- if (len <= MAX_ARGUMENTS_LENGTH) {
1172
- return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
1173
- }
1174
-
1175
- // Decode in chunks to avoid "call stack size exceeded".
1176
- var res = ''
1177
- var i = 0
1178
- while (i < len) {
1179
- res += String.fromCharCode.apply(
1180
- String,
1181
- codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
1182
- )
1183
- }
1184
- return res
1185
- }
1186
-
1187
- function asciiSlice (buf, start, end) {
1188
- var ret = ''
1189
- end = Math.min(buf.length, end)
1190
-
1191
- for (var i = start; i < end; ++i) {
1192
- ret += String.fromCharCode(buf[i] & 0x7F)
1193
- }
1194
- return ret
1195
- }
1196
-
1197
- function latin1Slice (buf, start, end) {
1198
- var ret = ''
1199
- end = Math.min(buf.length, end)
1200
-
1201
- for (var i = start; i < end; ++i) {
1202
- ret += String.fromCharCode(buf[i])
1203
- }
1204
- return ret
1205
- }
1206
-
1207
- function hexSlice (buf, start, end) {
1208
- var len = buf.length
1209
-
1210
- if (!start || start < 0) start = 0
1211
- if (!end || end < 0 || end > len) end = len
1212
-
1213
- var out = ''
1214
- for (var i = start; i < end; ++i) {
1215
- out += toHex(buf[i])
1216
- }
1217
- return out
1218
- }
1219
-
1220
- function utf16leSlice (buf, start, end) {
1221
- var bytes = buf.slice(start, end)
1222
- var res = ''
1223
- for (var i = 0; i < bytes.length; i += 2) {
1224
- res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
1225
- }
1226
- return res
1227
- }
1228
-
1229
- Buffer.prototype.slice = function slice (start, end) {
1230
- var len = this.length
1231
- start = ~~start
1232
- end = end === undefined ? len : ~~end
1233
-
1234
- if (start < 0) {
1235
- start += len
1236
- if (start < 0) start = 0
1237
- } else if (start > len) {
1238
- start = len
1239
- }
1240
-
1241
- if (end < 0) {
1242
- end += len
1243
- if (end < 0) end = 0
1244
- } else if (end > len) {
1245
- end = len
1246
- }
1247
-
1248
- if (end < start) end = start
1249
-
1250
- var newBuf
1251
- if (Buffer.TYPED_ARRAY_SUPPORT) {
1252
- newBuf = this.subarray(start, end)
1253
- newBuf.__proto__ = Buffer.prototype
1254
- } else {
1255
- var sliceLen = end - start
1256
- newBuf = new Buffer(sliceLen, undefined)
1257
- for (var i = 0; i < sliceLen; ++i) {
1258
- newBuf[i] = this[i + start]
1259
- }
1260
- }
1261
-
1262
- return newBuf
1263
- }
1264
-
1265
- /*
1266
- * Need to make sure that buffer isn't trying to write out of bounds.
1267
- */
1268
- function checkOffset (offset, ext, length) {
1269
- if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
1270
- if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
1271
- }
1272
-
1273
- Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
1274
- offset = offset | 0
1275
- byteLength = byteLength | 0
1276
- if (!noAssert) checkOffset(offset, byteLength, this.length)
1277
-
1278
- var val = this[offset]
1279
- var mul = 1
1280
- var i = 0
1281
- while (++i < byteLength && (mul *= 0x100)) {
1282
- val += this[offset + i] * mul
1283
- }
1284
-
1285
- return val
1286
- }
1287
-
1288
- Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
1289
- offset = offset | 0
1290
- byteLength = byteLength | 0
1291
- if (!noAssert) {
1292
- checkOffset(offset, byteLength, this.length)
1293
- }
1294
-
1295
- var val = this[offset + --byteLength]
1296
- var mul = 1
1297
- while (byteLength > 0 && (mul *= 0x100)) {
1298
- val += this[offset + --byteLength] * mul
1299
- }
1300
-
1301
- return val
1302
- }
1303
-
1304
- Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
1305
- if (!noAssert) checkOffset(offset, 1, this.length)
1306
- return this[offset]
1307
- }
1308
-
1309
- Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
1310
- if (!noAssert) checkOffset(offset, 2, this.length)
1311
- return this[offset] | (this[offset + 1] << 8)
1312
- }
1313
-
1314
- Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
1315
- if (!noAssert) checkOffset(offset, 2, this.length)
1316
- return (this[offset] << 8) | this[offset + 1]
1317
- }
1318
-
1319
- Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
1320
- if (!noAssert) checkOffset(offset, 4, this.length)
1321
-
1322
- return ((this[offset]) |
1323
- (this[offset + 1] << 8) |
1324
- (this[offset + 2] << 16)) +
1325
- (this[offset + 3] * 0x1000000)
1326
- }
1327
-
1328
- Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
1329
- if (!noAssert) checkOffset(offset, 4, this.length)
1330
-
1331
- return (this[offset] * 0x1000000) +
1332
- ((this[offset + 1] << 16) |
1333
- (this[offset + 2] << 8) |
1334
- this[offset + 3])
1335
- }
1336
-
1337
- Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
1338
- offset = offset | 0
1339
- byteLength = byteLength | 0
1340
- if (!noAssert) checkOffset(offset, byteLength, this.length)
1341
-
1342
- var val = this[offset]
1343
- var mul = 1
1344
- var i = 0
1345
- while (++i < byteLength && (mul *= 0x100)) {
1346
- val += this[offset + i] * mul
1347
- }
1348
- mul *= 0x80
1349
-
1350
- if (val >= mul) val -= Math.pow(2, 8 * byteLength)
1351
-
1352
- return val
1353
- }
1354
-
1355
- Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
1356
- offset = offset | 0
1357
- byteLength = byteLength | 0
1358
- if (!noAssert) checkOffset(offset, byteLength, this.length)
1359
-
1360
- var i = byteLength
1361
- var mul = 1
1362
- var val = this[offset + --i]
1363
- while (i > 0 && (mul *= 0x100)) {
1364
- val += this[offset + --i] * mul
1365
- }
1366
- mul *= 0x80
1367
-
1368
- if (val >= mul) val -= Math.pow(2, 8 * byteLength)
1369
-
1370
- return val
1371
- }
1372
-
1373
- Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
1374
- if (!noAssert) checkOffset(offset, 1, this.length)
1375
- if (!(this[offset] & 0x80)) return (this[offset])
1376
- return ((0xff - this[offset] + 1) * -1)
1377
- }
1378
-
1379
- Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
1380
- if (!noAssert) checkOffset(offset, 2, this.length)
1381
- var val = this[offset] | (this[offset + 1] << 8)
1382
- return (val & 0x8000) ? val | 0xFFFF0000 : val
1383
- }
1384
-
1385
- Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
1386
- if (!noAssert) checkOffset(offset, 2, this.length)
1387
- var val = this[offset + 1] | (this[offset] << 8)
1388
- return (val & 0x8000) ? val | 0xFFFF0000 : val
1389
- }
1390
-
1391
- Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
1392
- if (!noAssert) checkOffset(offset, 4, this.length)
1393
-
1394
- return (this[offset]) |
1395
- (this[offset + 1] << 8) |
1396
- (this[offset + 2] << 16) |
1397
- (this[offset + 3] << 24)
1398
- }
1399
-
1400
- Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
1401
- if (!noAssert) checkOffset(offset, 4, this.length)
1402
-
1403
- return (this[offset] << 24) |
1404
- (this[offset + 1] << 16) |
1405
- (this[offset + 2] << 8) |
1406
- (this[offset + 3])
1407
- }
1408
-
1409
- Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
1410
- if (!noAssert) checkOffset(offset, 4, this.length)
1411
- return ieee754.read(this, offset, true, 23, 4)
1412
- }
1413
-
1414
- Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
1415
- if (!noAssert) checkOffset(offset, 4, this.length)
1416
- return ieee754.read(this, offset, false, 23, 4)
1417
- }
1418
-
1419
- Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
1420
- if (!noAssert) checkOffset(offset, 8, this.length)
1421
- return ieee754.read(this, offset, true, 52, 8)
1422
- }
1423
-
1424
- Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
1425
- if (!noAssert) checkOffset(offset, 8, this.length)
1426
- return ieee754.read(this, offset, false, 52, 8)
1427
- }
1428
-
1429
- function checkInt (buf, value, offset, ext, max, min) {
1430
- if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
1431
- if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
1432
- if (offset + ext > buf.length) throw new RangeError('Index out of range')
1433
- }
1434
-
1435
- Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
1436
- value = +value
1437
- offset = offset | 0
1438
- byteLength = byteLength | 0
1439
- if (!noAssert) {
1440
- var maxBytes = Math.pow(2, 8 * byteLength) - 1
1441
- checkInt(this, value, offset, byteLength, maxBytes, 0)
1442
- }
1443
-
1444
- var mul = 1
1445
- var i = 0
1446
- this[offset] = value & 0xFF
1447
- while (++i < byteLength && (mul *= 0x100)) {
1448
- this[offset + i] = (value / mul) & 0xFF
1449
- }
1450
-
1451
- return offset + byteLength
1452
- }
1453
-
1454
- Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
1455
- value = +value
1456
- offset = offset | 0
1457
- byteLength = byteLength | 0
1458
- if (!noAssert) {
1459
- var maxBytes = Math.pow(2, 8 * byteLength) - 1
1460
- checkInt(this, value, offset, byteLength, maxBytes, 0)
1461
- }
1462
-
1463
- var i = byteLength - 1
1464
- var mul = 1
1465
- this[offset + i] = value & 0xFF
1466
- while (--i >= 0 && (mul *= 0x100)) {
1467
- this[offset + i] = (value / mul) & 0xFF
1468
- }
1469
-
1470
- return offset + byteLength
1471
- }
1472
-
1473
- Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
1474
- value = +value
1475
- offset = offset | 0
1476
- if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
1477
- if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
1478
- this[offset] = (value & 0xff)
1479
- return offset + 1
1480
- }
1481
-
1482
- function objectWriteUInt16 (buf, value, offset, littleEndian) {
1483
- if (value < 0) value = 0xffff + value + 1
1484
- for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
1485
- buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
1486
- (littleEndian ? i : 1 - i) * 8
1487
- }
1488
- }
1489
-
1490
- Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
1491
- value = +value
1492
- offset = offset | 0
1493
- if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
1494
- if (Buffer.TYPED_ARRAY_SUPPORT) {
1495
- this[offset] = (value & 0xff)
1496
- this[offset + 1] = (value >>> 8)
1497
- } else {
1498
- objectWriteUInt16(this, value, offset, true)
1499
- }
1500
- return offset + 2
1501
- }
1502
-
1503
- Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
1504
- value = +value
1505
- offset = offset | 0
1506
- if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
1507
- if (Buffer.TYPED_ARRAY_SUPPORT) {
1508
- this[offset] = (value >>> 8)
1509
- this[offset + 1] = (value & 0xff)
1510
- } else {
1511
- objectWriteUInt16(this, value, offset, false)
1512
- }
1513
- return offset + 2
1514
- }
1515
-
1516
- function objectWriteUInt32 (buf, value, offset, littleEndian) {
1517
- if (value < 0) value = 0xffffffff + value + 1
1518
- for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
1519
- buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
1520
- }
1521
- }
1522
-
1523
- Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
1524
- value = +value
1525
- offset = offset | 0
1526
- if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
1527
- if (Buffer.TYPED_ARRAY_SUPPORT) {
1528
- this[offset + 3] = (value >>> 24)
1529
- this[offset + 2] = (value >>> 16)
1530
- this[offset + 1] = (value >>> 8)
1531
- this[offset] = (value & 0xff)
1532
- } else {
1533
- objectWriteUInt32(this, value, offset, true)
1534
- }
1535
- return offset + 4
1536
- }
1537
-
1538
- Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
1539
- value = +value
1540
- offset = offset | 0
1541
- if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
1542
- if (Buffer.TYPED_ARRAY_SUPPORT) {
1543
- this[offset] = (value >>> 24)
1544
- this[offset + 1] = (value >>> 16)
1545
- this[offset + 2] = (value >>> 8)
1546
- this[offset + 3] = (value & 0xff)
1547
- } else {
1548
- objectWriteUInt32(this, value, offset, false)
1549
- }
1550
- return offset + 4
1551
- }
1552
-
1553
- Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
1554
- value = +value
1555
- offset = offset | 0
1556
- if (!noAssert) {
1557
- var limit = Math.pow(2, 8 * byteLength - 1)
1558
-
1559
- checkInt(this, value, offset, byteLength, limit - 1, -limit)
1560
- }
1561
-
1562
- var i = 0
1563
- var mul = 1
1564
- var sub = 0
1565
- this[offset] = value & 0xFF
1566
- while (++i < byteLength && (mul *= 0x100)) {
1567
- if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
1568
- sub = 1
1569
- }
1570
- this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
1571
- }
1572
-
1573
- return offset + byteLength
1574
- }
1575
-
1576
- Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
1577
- value = +value
1578
- offset = offset | 0
1579
- if (!noAssert) {
1580
- var limit = Math.pow(2, 8 * byteLength - 1)
1581
-
1582
- checkInt(this, value, offset, byteLength, limit - 1, -limit)
1583
- }
1584
-
1585
- var i = byteLength - 1
1586
- var mul = 1
1587
- var sub = 0
1588
- this[offset + i] = value & 0xFF
1589
- while (--i >= 0 && (mul *= 0x100)) {
1590
- if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
1591
- sub = 1
1592
- }
1593
- this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
1594
- }
1595
-
1596
- return offset + byteLength
1597
- }
1598
-
1599
- Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
1600
- value = +value
1601
- offset = offset | 0
1602
- if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
1603
- if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
1604
- if (value < 0) value = 0xff + value + 1
1605
- this[offset] = (value & 0xff)
1606
- return offset + 1
1607
- }
1608
-
1609
- Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
1610
- value = +value
1611
- offset = offset | 0
1612
- if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
1613
- if (Buffer.TYPED_ARRAY_SUPPORT) {
1614
- this[offset] = (value & 0xff)
1615
- this[offset + 1] = (value >>> 8)
1616
- } else {
1617
- objectWriteUInt16(this, value, offset, true)
1618
- }
1619
- return offset + 2
1620
- }
1621
-
1622
- Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
1623
- value = +value
1624
- offset = offset | 0
1625
- if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
1626
- if (Buffer.TYPED_ARRAY_SUPPORT) {
1627
- this[offset] = (value >>> 8)
1628
- this[offset + 1] = (value & 0xff)
1629
- } else {
1630
- objectWriteUInt16(this, value, offset, false)
1631
- }
1632
- return offset + 2
1633
- }
1634
-
1635
- Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
1636
- value = +value
1637
- offset = offset | 0
1638
- if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
1639
- if (Buffer.TYPED_ARRAY_SUPPORT) {
1640
- this[offset] = (value & 0xff)
1641
- this[offset + 1] = (value >>> 8)
1642
- this[offset + 2] = (value >>> 16)
1643
- this[offset + 3] = (value >>> 24)
1644
- } else {
1645
- objectWriteUInt32(this, value, offset, true)
1646
- }
1647
- return offset + 4
1648
- }
1649
-
1650
- Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
1651
- value = +value
1652
- offset = offset | 0
1653
- if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
1654
- if (value < 0) value = 0xffffffff + value + 1
1655
- if (Buffer.TYPED_ARRAY_SUPPORT) {
1656
- this[offset] = (value >>> 24)
1657
- this[offset + 1] = (value >>> 16)
1658
- this[offset + 2] = (value >>> 8)
1659
- this[offset + 3] = (value & 0xff)
1660
- } else {
1661
- objectWriteUInt32(this, value, offset, false)
1662
- }
1663
- return offset + 4
1664
- }
1665
-
1666
- function checkIEEE754 (buf, value, offset, ext, max, min) {
1667
- if (offset + ext > buf.length) throw new RangeError('Index out of range')
1668
- if (offset < 0) throw new RangeError('Index out of range')
1669
- }
1670
-
1671
- function writeFloat (buf, value, offset, littleEndian, noAssert) {
1672
- if (!noAssert) {
1673
- checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
1674
- }
1675
- ieee754.write(buf, value, offset, littleEndian, 23, 4)
1676
- return offset + 4
1677
- }
1678
-
1679
- Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
1680
- return writeFloat(this, value, offset, true, noAssert)
1681
- }
1682
-
1683
- Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
1684
- return writeFloat(this, value, offset, false, noAssert)
1685
- }
1686
-
1687
- function writeDouble (buf, value, offset, littleEndian, noAssert) {
1688
- if (!noAssert) {
1689
- checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
1690
- }
1691
- ieee754.write(buf, value, offset, littleEndian, 52, 8)
1692
- return offset + 8
1693
- }
1694
-
1695
- Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
1696
- return writeDouble(this, value, offset, true, noAssert)
1697
- }
1698
-
1699
- Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
1700
- return writeDouble(this, value, offset, false, noAssert)
1701
- }
1702
-
1703
- // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
1704
- Buffer.prototype.copy = function copy (target, targetStart, start, end) {
1705
- if (!start) start = 0
1706
- if (!end && end !== 0) end = this.length
1707
- if (targetStart >= target.length) targetStart = target.length
1708
- if (!targetStart) targetStart = 0
1709
- if (end > 0 && end < start) end = start
1710
-
1711
- // Copy 0 bytes; we're done
1712
- if (end === start) return 0
1713
- if (target.length === 0 || this.length === 0) return 0
1714
-
1715
- // Fatal error conditions
1716
- if (targetStart < 0) {
1717
- throw new RangeError('targetStart out of bounds')
1718
- }
1719
- if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
1720
- if (end < 0) throw new RangeError('sourceEnd out of bounds')
1721
-
1722
- // Are we oob?
1723
- if (end > this.length) end = this.length
1724
- if (target.length - targetStart < end - start) {
1725
- end = target.length - targetStart + start
1726
- }
1727
-
1728
- var len = end - start
1729
- var i
1730
-
1731
- if (this === target && start < targetStart && targetStart < end) {
1732
- // descending copy from end
1733
- for (i = len - 1; i >= 0; --i) {
1734
- target[i + targetStart] = this[i + start]
1735
- }
1736
- } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
1737
- // ascending copy from start
1738
- for (i = 0; i < len; ++i) {
1739
- target[i + targetStart] = this[i + start]
1740
- }
1741
- } else {
1742
- Uint8Array.prototype.set.call(
1743
- target,
1744
- this.subarray(start, start + len),
1745
- targetStart
1746
- )
1747
- }
1748
-
1749
- return len
1750
- }
1751
-
1752
- // Usage:
1753
- // buffer.fill(number[, offset[, end]])
1754
- // buffer.fill(buffer[, offset[, end]])
1755
- // buffer.fill(string[, offset[, end]][, encoding])
1756
- Buffer.prototype.fill = function fill (val, start, end, encoding) {
1757
- // Handle string cases:
1758
- if (typeof val === 'string') {
1759
- if (typeof start === 'string') {
1760
- encoding = start
1761
- start = 0
1762
- end = this.length
1763
- } else if (typeof end === 'string') {
1764
- encoding = end
1765
- end = this.length
1766
- }
1767
- if (val.length === 1) {
1768
- var code = val.charCodeAt(0)
1769
- if (code < 256) {
1770
- val = code
1771
- }
1772
- }
1773
- if (encoding !== undefined && typeof encoding !== 'string') {
1774
- throw new TypeError('encoding must be a string')
1775
- }
1776
- if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
1777
- throw new TypeError('Unknown encoding: ' + encoding)
1778
- }
1779
- } else if (typeof val === 'number') {
1780
- val = val & 255
1781
- }
1782
-
1783
- // Invalid ranges are not set to a default, so can range check early.
1784
- if (start < 0 || this.length < start || this.length < end) {
1785
- throw new RangeError('Out of range index')
1786
- }
1787
-
1788
- if (end <= start) {
1789
- return this
1790
- }
1791
-
1792
- start = start >>> 0
1793
- end = end === undefined ? this.length : end >>> 0
1794
-
1795
- if (!val) val = 0
1796
-
1797
- var i
1798
- if (typeof val === 'number') {
1799
- for (i = start; i < end; ++i) {
1800
- this[i] = val
1801
- }
1802
- } else {
1803
- var bytes = Buffer.isBuffer(val)
1804
- ? val
1805
- : utf8ToBytes(new Buffer(val, encoding).toString())
1806
- var len = bytes.length
1807
- for (i = 0; i < end - start; ++i) {
1808
- this[i + start] = bytes[i % len]
1809
- }
1810
- }
1811
-
1812
- return this
1813
- }
1814
-
1815
- // HELPER FUNCTIONS
1816
- // ================
1817
-
1818
- var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
1819
-
1820
- function base64clean (str) {
1821
- // Node strips out invalid characters like \n and \t from the string, base64-js does not
1822
- str = stringtrim(str).replace(INVALID_BASE64_RE, '')
1823
- // Node converts strings with length < 2 to ''
1824
- if (str.length < 2) return ''
1825
- // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
1826
- while (str.length % 4 !== 0) {
1827
- str = str + '='
1828
- }
1829
- return str
1830
- }
1831
-
1832
- function stringtrim (str) {
1833
- if (str.trim) return str.trim()
1834
- return str.replace(/^\s+|\s+$/g, '')
1835
- }
1836
-
1837
- function toHex (n) {
1838
- if (n < 16) return '0' + n.toString(16)
1839
- return n.toString(16)
1840
- }
1841
-
1842
- function utf8ToBytes (string, units) {
1843
- units = units || Infinity
1844
- var codePoint
1845
- var length = string.length
1846
- var leadSurrogate = null
1847
- var bytes = []
1848
-
1849
- for (var i = 0; i < length; ++i) {
1850
- codePoint = string.charCodeAt(i)
1851
-
1852
- // is surrogate component
1853
- if (codePoint > 0xD7FF && codePoint < 0xE000) {
1854
- // last char was a lead
1855
- if (!leadSurrogate) {
1856
- // no lead yet
1857
- if (codePoint > 0xDBFF) {
1858
- // unexpected trail
1859
- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
1860
- continue
1861
- } else if (i + 1 === length) {
1862
- // unpaired lead
1863
- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
1864
- continue
1865
- }
1866
-
1867
- // valid lead
1868
- leadSurrogate = codePoint
1869
-
1870
- continue
1871
- }
1872
-
1873
- // 2 leads in a row
1874
- if (codePoint < 0xDC00) {
1875
- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
1876
- leadSurrogate = codePoint
1877
- continue
1878
- }
1879
-
1880
- // valid surrogate pair
1881
- codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
1882
- } else if (leadSurrogate) {
1883
- // valid bmp char, but last char was a lead
1884
- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
1885
- }
1886
-
1887
- leadSurrogate = null
1888
-
1889
- // encode utf8
1890
- if (codePoint < 0x80) {
1891
- if ((units -= 1) < 0) break
1892
- bytes.push(codePoint)
1893
- } else if (codePoint < 0x800) {
1894
- if ((units -= 2) < 0) break
1895
- bytes.push(
1896
- codePoint >> 0x6 | 0xC0,
1897
- codePoint & 0x3F | 0x80
1898
- )
1899
- } else if (codePoint < 0x10000) {
1900
- if ((units -= 3) < 0) break
1901
- bytes.push(
1902
- codePoint >> 0xC | 0xE0,
1903
- codePoint >> 0x6 & 0x3F | 0x80,
1904
- codePoint & 0x3F | 0x80
1905
- )
1906
- } else if (codePoint < 0x110000) {
1907
- if ((units -= 4) < 0) break
1908
- bytes.push(
1909
- codePoint >> 0x12 | 0xF0,
1910
- codePoint >> 0xC & 0x3F | 0x80,
1911
- codePoint >> 0x6 & 0x3F | 0x80,
1912
- codePoint & 0x3F | 0x80
1913
- )
1914
- } else {
1915
- throw new Error('Invalid code point')
1916
- }
1917
- }
1918
-
1919
- return bytes
1920
- }
1921
-
1922
- function asciiToBytes (str) {
1923
- var byteArray = []
1924
- for (var i = 0; i < str.length; ++i) {
1925
- // Node's code seems to be doing this and not & 0x7F..
1926
- byteArray.push(str.charCodeAt(i) & 0xFF)
1927
- }
1928
- return byteArray
1929
- }
1930
-
1931
- function utf16leToBytes (str, units) {
1932
- var c, hi, lo
1933
- var byteArray = []
1934
- for (var i = 0; i < str.length; ++i) {
1935
- if ((units -= 2) < 0) break
1936
-
1937
- c = str.charCodeAt(i)
1938
- hi = c >> 8
1939
- lo = c % 256
1940
- byteArray.push(lo)
1941
- byteArray.push(hi)
1942
- }
1943
-
1944
- return byteArray
1945
- }
1946
-
1947
- function base64ToBytes (str) {
1948
- return base64.toByteArray(base64clean(str))
1949
- }
1950
-
1951
- function blitBuffer (src, dst, offset, length) {
1952
- for (var i = 0; i < length; ++i) {
1953
- if ((i + offset >= dst.length) || (i >= src.length)) break
1954
- dst[i + offset] = src[i]
1955
- }
1956
- return i
1957
- }
1958
-
1959
- function isnan (val) {
1960
- return val !== val // eslint-disable-line no-self-compare
1961
- }
1962
-
1963
- /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
1964
-
1965
- /***/ }),
1966
-
1967
- /***/ "../../node_modules/ieee754/index.js":
1968
- /*!******************************************************!*\
1969
- !*** /root/amplify-js/node_modules/ieee754/index.js ***!
1970
- \******************************************************/
1971
- /*! no static exports found */
1972
- /***/ (function(module, exports) {
1973
-
1974
- /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
1975
- exports.read = function (buffer, offset, isLE, mLen, nBytes) {
1976
- var e, m
1977
- var eLen = (nBytes * 8) - mLen - 1
1978
- var eMax = (1 << eLen) - 1
1979
- var eBias = eMax >> 1
1980
- var nBits = -7
1981
- var i = isLE ? (nBytes - 1) : 0
1982
- var d = isLE ? -1 : 1
1983
- var s = buffer[offset + i]
1984
-
1985
- i += d
1986
-
1987
- e = s & ((1 << (-nBits)) - 1)
1988
- s >>= (-nBits)
1989
- nBits += eLen
1990
- for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
1991
-
1992
- m = e & ((1 << (-nBits)) - 1)
1993
- e >>= (-nBits)
1994
- nBits += mLen
1995
- for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
1996
-
1997
- if (e === 0) {
1998
- e = 1 - eBias
1999
- } else if (e === eMax) {
2000
- return m ? NaN : ((s ? -1 : 1) * Infinity)
2001
- } else {
2002
- m = m + Math.pow(2, mLen)
2003
- e = e - eBias
2004
- }
2005
- return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
2006
- }
2007
-
2008
- exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
2009
- var e, m, c
2010
- var eLen = (nBytes * 8) - mLen - 1
2011
- var eMax = (1 << eLen) - 1
2012
- var eBias = eMax >> 1
2013
- var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
2014
- var i = isLE ? 0 : (nBytes - 1)
2015
- var d = isLE ? 1 : -1
2016
- var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
2017
-
2018
- value = Math.abs(value)
2019
-
2020
- if (isNaN(value) || value === Infinity) {
2021
- m = isNaN(value) ? 1 : 0
2022
- e = eMax
2023
- } else {
2024
- e = Math.floor(Math.log(value) / Math.LN2)
2025
- if (value * (c = Math.pow(2, -e)) < 1) {
2026
- e--
2027
- c *= 2
2028
- }
2029
- if (e + eBias >= 1) {
2030
- value += rt / c
2031
- } else {
2032
- value += rt * Math.pow(2, 1 - eBias)
2033
- }
2034
- if (value * c >= 2) {
2035
- e++
2036
- c /= 2
2037
- }
2038
-
2039
- if (e + eBias >= eMax) {
2040
- m = 0
2041
- e = eMax
2042
- } else if (e + eBias >= 1) {
2043
- m = ((value * c) - 1) * Math.pow(2, mLen)
2044
- e = e + eBias
2045
- } else {
2046
- m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
2047
- e = 0
2048
- }
2049
- }
2050
-
2051
- for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
2052
-
2053
- e = (e << mLen) | m
2054
- eLen += mLen
2055
- for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
2056
-
2057
- buffer[offset + i - d] |= s * 128
2058
- }
2059
-
2060
-
2061
- /***/ }),
2062
-
2063
- /***/ "../../node_modules/isarray/index.js":
2064
- /*!******************************************************!*\
2065
- !*** /root/amplify-js/node_modules/isarray/index.js ***!
2066
- \******************************************************/
2067
- /*! no static exports found */
2068
- /***/ (function(module, exports) {
2069
-
2070
- var toString = {}.toString;
2071
-
2072
- module.exports = Array.isArray || function (arr) {
2073
- return toString.call(arr) == '[object Array]';
2074
- };
2075
-
2076
-
2077
- /***/ }),
2078
-
2079
- /***/ "../../node_modules/webpack/buildin/global.js":
2080
- /*!***********************************!*\
2081
- !*** (webpack)/buildin/global.js ***!
2082
- \***********************************/
2083
- /*! no static exports found */
2084
- /***/ (function(module, exports) {
2085
-
2086
- var g;
2087
-
2088
- // This works in non-strict mode
2089
- g = (function() {
2090
- return this;
2091
- })();
2092
-
2093
- try {
2094
- // This works if eval is allowed (see CSP)
2095
- g = g || new Function("return this")();
2096
- } catch (e) {
2097
- // This works if the window reference is available
2098
- if (typeof window === "object") g = window;
2099
- }
2100
-
2101
- // g can still be undefined, but nothing to do about it...
2102
- // We return undefined, instead of nothing here, so it's
2103
- // easier to handle this case. if(!global) { ...}
2104
-
2105
- module.exports = g;
2106
-
2107
-
2108
- /***/ })
2109
-
2110
- }]);
2111
- //# sourceMappingURL=1.js.map