llonebot-dist 6.6.4

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 (134) hide show
  1. dist/default_config.json +68 -0
  2. dist/llonebot.js +48348 -0
  3. dist/llonebot.js.map +1 -0
  4. dist/node_modules/@borewit/text-codec/LICENSE.txt +9 -0
  5. dist/node_modules/@borewit/text-codec/README.md +76 -0
  6. dist/node_modules/@borewit/text-codec/lib/index.d.ts +8 -0
  7. dist/node_modules/@borewit/text-codec/lib/index.js +161 -0
  8. dist/node_modules/@borewit/text-codec/package.json +68 -0
  9. dist/node_modules/@minatojs/sql.js/LICENSE +44 -0
  10. dist/node_modules/@minatojs/sql.js/README.md +357 -0
  11. dist/node_modules/@minatojs/sql.js/dist/sql-wasm.d.ts +316 -0
  12. dist/node_modules/@minatojs/sql.js/dist/sql-wasm.js +225 -0
  13. dist/node_modules/@minatojs/sql.js/dist/sql-wasm.wasm +0 -0
  14. dist/node_modules/@minatojs/sql.js/package.json +58 -0
  15. dist/node_modules/@tokenizer/inflate/LICENSE +15 -0
  16. dist/node_modules/@tokenizer/inflate/README.md +114 -0
  17. dist/node_modules/@tokenizer/inflate/lib/GzipHandler.d.ts +6 -0
  18. dist/node_modules/@tokenizer/inflate/lib/GzipHandler.js +19 -0
  19. dist/node_modules/@tokenizer/inflate/lib/ZipHandler.d.ts +26 -0
  20. dist/node_modules/@tokenizer/inflate/lib/ZipHandler.js +233 -0
  21. dist/node_modules/@tokenizer/inflate/lib/ZipToken.d.ts +94 -0
  22. dist/node_modules/@tokenizer/inflate/lib/ZipToken.js +117 -0
  23. dist/node_modules/@tokenizer/inflate/lib/index.d.ts +3 -0
  24. dist/node_modules/@tokenizer/inflate/lib/index.js +2 -0
  25. dist/node_modules/@tokenizer/inflate/package.json +76 -0
  26. dist/node_modules/@tokenizer/token/README.md +19 -0
  27. dist/node_modules/@tokenizer/token/index.d.ts +30 -0
  28. dist/node_modules/@tokenizer/token/package.json +33 -0
  29. dist/node_modules/debug/LICENSE +20 -0
  30. dist/node_modules/debug/README.md +481 -0
  31. dist/node_modules/debug/package.json +64 -0
  32. dist/node_modules/debug/src/browser.js +272 -0
  33. dist/node_modules/debug/src/common.js +292 -0
  34. dist/node_modules/debug/src/index.js +10 -0
  35. dist/node_modules/debug/src/node.js +263 -0
  36. dist/node_modules/file-type/core.d.ts +253 -0
  37. dist/node_modules/file-type/core.js +1899 -0
  38. dist/node_modules/file-type/index.d.ts +98 -0
  39. dist/node_modules/file-type/index.js +86 -0
  40. dist/node_modules/file-type/license +9 -0
  41. dist/node_modules/file-type/package.json +288 -0
  42. dist/node_modules/file-type/readme.md +674 -0
  43. dist/node_modules/file-type/supported.js +356 -0
  44. dist/node_modules/file-type/util.js +60 -0
  45. dist/node_modules/ieee754/LICENSE +11 -0
  46. dist/node_modules/ieee754/README.md +51 -0
  47. dist/node_modules/ieee754/index.d.ts +10 -0
  48. dist/node_modules/ieee754/index.js +85 -0
  49. dist/node_modules/ieee754/package.json +52 -0
  50. dist/node_modules/ms/index.js +162 -0
  51. dist/node_modules/ms/license.md +21 -0
  52. dist/node_modules/ms/package.json +38 -0
  53. dist/node_modules/ms/readme.md +59 -0
  54. dist/node_modules/silk-wasm/LICENSE +21 -0
  55. dist/node_modules/silk-wasm/README.md +85 -0
  56. dist/node_modules/silk-wasm/lib/index.cjs +16 -0
  57. dist/node_modules/silk-wasm/lib/index.d.ts +70 -0
  58. dist/node_modules/silk-wasm/lib/index.mjs +16 -0
  59. dist/node_modules/silk-wasm/lib/silk.wasm +0 -0
  60. dist/node_modules/silk-wasm/lib/utils.d.ts +4 -0
  61. dist/node_modules/silk-wasm/package.json +39 -0
  62. dist/node_modules/strtok3/LICENSE.txt +21 -0
  63. dist/node_modules/strtok3/README.md +399 -0
  64. dist/node_modules/strtok3/lib/AbstractTokenizer.d.ts +76 -0
  65. dist/node_modules/strtok3/lib/AbstractTokenizer.js +108 -0
  66. dist/node_modules/strtok3/lib/BlobTokenizer.d.ts +29 -0
  67. dist/node_modules/strtok3/lib/BlobTokenizer.js +53 -0
  68. dist/node_modules/strtok3/lib/BufferTokenizer.d.ts +29 -0
  69. dist/node_modules/strtok3/lib/BufferTokenizer.js +52 -0
  70. dist/node_modules/strtok3/lib/FileTokenizer.d.ts +37 -0
  71. dist/node_modules/strtok3/lib/FileTokenizer.js +61 -0
  72. dist/node_modules/strtok3/lib/ReadStreamTokenizer.d.ts +31 -0
  73. dist/node_modules/strtok3/lib/ReadStreamTokenizer.js +102 -0
  74. dist/node_modules/strtok3/lib/core.d.ts +40 -0
  75. dist/node_modules/strtok3/lib/core.js +62 -0
  76. dist/node_modules/strtok3/lib/index.d.ts +16 -0
  77. dist/node_modules/strtok3/lib/index.js +22 -0
  78. dist/node_modules/strtok3/lib/stream/AbstractStreamReader.d.ts +54 -0
  79. dist/node_modules/strtok3/lib/stream/AbstractStreamReader.js +71 -0
  80. dist/node_modules/strtok3/lib/stream/Deferred.d.ts +6 -0
  81. dist/node_modules/strtok3/lib/stream/Deferred.js +10 -0
  82. dist/node_modules/strtok3/lib/stream/Errors.d.ts +10 -0
  83. dist/node_modules/strtok3/lib/stream/Errors.js +16 -0
  84. dist/node_modules/strtok3/lib/stream/StreamReader.d.ts +29 -0
  85. dist/node_modules/strtok3/lib/stream/StreamReader.js +83 -0
  86. dist/node_modules/strtok3/lib/stream/WebStreamByobReader.d.ts +14 -0
  87. dist/node_modules/strtok3/lib/stream/WebStreamByobReader.js +27 -0
  88. dist/node_modules/strtok3/lib/stream/WebStreamDefaultReader.d.ts +19 -0
  89. dist/node_modules/strtok3/lib/stream/WebStreamDefaultReader.js +62 -0
  90. dist/node_modules/strtok3/lib/stream/WebStreamReader.d.ts +14 -0
  91. dist/node_modules/strtok3/lib/stream/WebStreamReader.js +13 -0
  92. dist/node_modules/strtok3/lib/stream/WebStreamReaderFactory.d.ts +5 -0
  93. dist/node_modules/strtok3/lib/stream/WebStreamReaderFactory.js +19 -0
  94. dist/node_modules/strtok3/lib/stream/index.d.ts +6 -0
  95. dist/node_modules/strtok3/lib/stream/index.js +5 -0
  96. dist/node_modules/strtok3/lib/types.d.ts +139 -0
  97. dist/node_modules/strtok3/lib/types.js +1 -0
  98. dist/node_modules/strtok3/package.json +94 -0
  99. dist/node_modules/token-types/LICENSE.txt +9 -0
  100. dist/node_modules/token-types/README.md +120 -0
  101. dist/node_modules/token-types/lib/index.d.ts +135 -0
  102. dist/node_modules/token-types/lib/index.js +401 -0
  103. dist/node_modules/token-types/package.json +81 -0
  104. dist/node_modules/uint8array-extras/index.d.ts +312 -0
  105. dist/node_modules/uint8array-extras/index.js +321 -0
  106. dist/node_modules/uint8array-extras/license +9 -0
  107. dist/node_modules/uint8array-extras/package.json +54 -0
  108. dist/node_modules/uint8array-extras/readme.md +301 -0
  109. dist/node_modules/ws/LICENSE +20 -0
  110. dist/node_modules/ws/README.md +548 -0
  111. dist/node_modules/ws/browser.js +8 -0
  112. dist/node_modules/ws/index.js +13 -0
  113. dist/node_modules/ws/lib/buffer-util.js +131 -0
  114. dist/node_modules/ws/lib/constants.js +18 -0
  115. dist/node_modules/ws/lib/event-target.js +292 -0
  116. dist/node_modules/ws/lib/extension.js +203 -0
  117. dist/node_modules/ws/lib/limiter.js +55 -0
  118. dist/node_modules/ws/lib/permessage-deflate.js +528 -0
  119. dist/node_modules/ws/lib/receiver.js +706 -0
  120. dist/node_modules/ws/lib/sender.js +602 -0
  121. dist/node_modules/ws/lib/stream.js +161 -0
  122. dist/node_modules/ws/lib/subprotocol.js +62 -0
  123. dist/node_modules/ws/lib/validation.js +152 -0
  124. dist/node_modules/ws/lib/websocket-server.js +550 -0
  125. dist/node_modules/ws/lib/websocket.js +1388 -0
  126. dist/node_modules/ws/package.json +69 -0
  127. dist/node_modules/ws/wrapper.mjs +8 -0
  128. dist/package.json +1 -0
  129. dist/webui/assets/index-B9vGhdCO.js +256 -0
  130. dist/webui/assets/index-DaqFU7JR.css +1 -0
  131. dist/webui/index.html +13 -0
  132. dist/webui/logo.jpg +0 -0
  133. dist//344/275/277/347/224/250/350/257/264/346/230/216.txt +11 -0
  134. dist//346/233/264/346/226/260/346/227/245/345/277/227.txt +399 -0
@@ -0,0 +1,356 @@
1
+ export const extensions = [
2
+ 'jpg',
3
+ 'png',
4
+ 'apng',
5
+ 'gif',
6
+ 'webp',
7
+ 'flif',
8
+ 'xcf',
9
+ 'cr2',
10
+ 'cr3',
11
+ 'orf',
12
+ 'arw',
13
+ 'dng',
14
+ 'nef',
15
+ 'rw2',
16
+ 'raf',
17
+ 'tif',
18
+ 'bmp',
19
+ 'icns',
20
+ 'jxr',
21
+ 'psd',
22
+ 'indd',
23
+ 'zip',
24
+ 'tar',
25
+ 'rar',
26
+ 'gz',
27
+ 'bz2',
28
+ '7z',
29
+ 'dmg',
30
+ 'mp4',
31
+ 'mid',
32
+ 'mkv',
33
+ 'webm',
34
+ 'mov',
35
+ 'avi',
36
+ 'mpg',
37
+ 'mp2',
38
+ 'mp3',
39
+ 'm4a',
40
+ 'oga',
41
+ 'ogg',
42
+ 'ogv',
43
+ 'opus',
44
+ 'flac',
45
+ 'wav',
46
+ 'spx',
47
+ 'amr',
48
+ 'pdf',
49
+ 'epub',
50
+ 'elf',
51
+ 'macho',
52
+ 'exe',
53
+ 'swf',
54
+ 'rtf',
55
+ 'wasm',
56
+ 'woff',
57
+ 'woff2',
58
+ 'eot',
59
+ 'ttf',
60
+ 'otf',
61
+ 'ttc',
62
+ 'ico',
63
+ 'flv',
64
+ 'ps',
65
+ 'xz',
66
+ 'sqlite',
67
+ 'nes',
68
+ 'crx',
69
+ 'xpi',
70
+ 'cab',
71
+ 'deb',
72
+ 'ar',
73
+ 'rpm',
74
+ 'Z',
75
+ 'lz',
76
+ 'cfb',
77
+ 'mxf',
78
+ 'mts',
79
+ 'blend',
80
+ 'bpg',
81
+ 'docx',
82
+ 'pptx',
83
+ 'xlsx',
84
+ '3gp',
85
+ '3g2',
86
+ 'j2c',
87
+ 'jp2',
88
+ 'jpm',
89
+ 'jpx',
90
+ 'mj2',
91
+ 'aif',
92
+ 'qcp',
93
+ 'odt',
94
+ 'ods',
95
+ 'odp',
96
+ 'xml',
97
+ 'mobi',
98
+ 'heic',
99
+ 'cur',
100
+ 'ktx',
101
+ 'ape',
102
+ 'wv',
103
+ 'dcm',
104
+ 'ics',
105
+ 'glb',
106
+ 'pcap',
107
+ 'dsf',
108
+ 'lnk',
109
+ 'alias',
110
+ 'voc',
111
+ 'ac3',
112
+ 'm4v',
113
+ 'm4p',
114
+ 'm4b',
115
+ 'f4v',
116
+ 'f4p',
117
+ 'f4b',
118
+ 'f4a',
119
+ 'mie',
120
+ 'asf',
121
+ 'ogm',
122
+ 'ogx',
123
+ 'mpc',
124
+ 'arrow',
125
+ 'shp',
126
+ 'aac',
127
+ 'mp1',
128
+ 'it',
129
+ 's3m',
130
+ 'xm',
131
+ 'skp',
132
+ 'avif',
133
+ 'eps',
134
+ 'lzh',
135
+ 'pgp',
136
+ 'asar',
137
+ 'stl',
138
+ 'chm',
139
+ '3mf',
140
+ 'zst',
141
+ 'jxl',
142
+ 'vcf',
143
+ 'jls',
144
+ 'pst',
145
+ 'dwg',
146
+ 'parquet',
147
+ 'class',
148
+ 'arj',
149
+ 'cpio',
150
+ 'ace',
151
+ 'avro',
152
+ 'icc',
153
+ 'fbx',
154
+ 'vsdx',
155
+ 'vtt',
156
+ 'apk',
157
+ 'drc',
158
+ 'lz4',
159
+ 'potx',
160
+ 'xltx',
161
+ 'dotx',
162
+ 'xltm',
163
+ 'ott',
164
+ 'ots',
165
+ 'otp',
166
+ 'odg',
167
+ 'otg',
168
+ 'xlsm',
169
+ 'docm',
170
+ 'dotm',
171
+ 'potm',
172
+ 'pptm',
173
+ 'jar',
174
+ 'rm',
175
+ 'ppsm',
176
+ 'ppsx',
177
+ 'tar.gz',
178
+ 'reg',
179
+ 'dat',
180
+ ];
181
+
182
+ export const mimeTypes = [
183
+ 'image/jpeg',
184
+ 'image/png',
185
+ 'image/gif',
186
+ 'image/webp',
187
+ 'image/flif',
188
+ 'image/x-xcf',
189
+ 'image/x-canon-cr2',
190
+ 'image/x-canon-cr3',
191
+ 'image/tiff',
192
+ 'image/bmp',
193
+ 'image/vnd.ms-photo',
194
+ 'image/vnd.adobe.photoshop',
195
+ 'application/x-indesign',
196
+ 'application/epub+zip',
197
+ 'application/x-xpinstall',
198
+ 'application/vnd.ms-powerpoint.slideshow.macroenabled.12',
199
+ 'application/vnd.oasis.opendocument.text',
200
+ 'application/vnd.oasis.opendocument.spreadsheet',
201
+ 'application/vnd.oasis.opendocument.presentation',
202
+ 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
203
+ 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
204
+ 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
205
+ 'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
206
+ 'application/zip',
207
+ 'application/x-tar',
208
+ 'application/x-rar-compressed',
209
+ 'application/gzip',
210
+ 'application/x-bzip2',
211
+ 'application/x-7z-compressed',
212
+ 'application/x-apple-diskimage',
213
+ 'application/vnd.apache.arrow.file',
214
+ 'video/mp4',
215
+ 'audio/midi',
216
+ 'video/matroska',
217
+ 'video/webm',
218
+ 'video/quicktime',
219
+ 'video/vnd.avi',
220
+ 'audio/wav',
221
+ 'audio/qcelp',
222
+ 'audio/x-ms-asf',
223
+ 'video/x-ms-asf',
224
+ 'application/vnd.ms-asf',
225
+ 'video/mpeg',
226
+ 'video/3gpp',
227
+ 'audio/mpeg',
228
+ 'audio/mp4', // RFC 4337
229
+ 'video/ogg',
230
+ 'audio/ogg',
231
+ 'audio/ogg; codecs=opus',
232
+ 'application/ogg',
233
+ 'audio/flac',
234
+ 'audio/ape',
235
+ 'audio/wavpack',
236
+ 'audio/amr',
237
+ 'application/pdf',
238
+ 'application/x-elf',
239
+ 'application/x-mach-binary',
240
+ 'application/x-msdownload',
241
+ 'application/x-shockwave-flash',
242
+ 'application/rtf',
243
+ 'application/wasm',
244
+ 'font/woff',
245
+ 'font/woff2',
246
+ 'application/vnd.ms-fontobject',
247
+ 'font/ttf',
248
+ 'font/otf',
249
+ 'font/collection',
250
+ 'image/x-icon',
251
+ 'video/x-flv',
252
+ 'application/postscript',
253
+ 'application/eps',
254
+ 'application/x-xz',
255
+ 'application/x-sqlite3',
256
+ 'application/x-nintendo-nes-rom',
257
+ 'application/x-google-chrome-extension',
258
+ 'application/vnd.ms-cab-compressed',
259
+ 'application/x-deb',
260
+ 'application/x-unix-archive',
261
+ 'application/x-rpm',
262
+ 'application/x-compress',
263
+ 'application/x-lzip',
264
+ 'application/x-cfb',
265
+ 'application/x-mie',
266
+ 'application/mxf',
267
+ 'video/mp2t',
268
+ 'application/x-blender',
269
+ 'image/bpg',
270
+ 'image/j2c',
271
+ 'image/jp2',
272
+ 'image/jpx',
273
+ 'image/jpm',
274
+ 'image/mj2',
275
+ 'audio/aiff',
276
+ 'application/xml',
277
+ 'application/x-mobipocket-ebook',
278
+ 'image/heif',
279
+ 'image/heif-sequence',
280
+ 'image/heic',
281
+ 'image/heic-sequence',
282
+ 'image/icns',
283
+ 'image/ktx',
284
+ 'application/dicom',
285
+ 'audio/x-musepack',
286
+ 'text/calendar',
287
+ 'text/vcard',
288
+ 'text/vtt',
289
+ 'model/gltf-binary',
290
+ 'application/vnd.tcpdump.pcap',
291
+ 'audio/x-dsf', // Non-standard
292
+ 'application/x.ms.shortcut', // Invented by us
293
+ 'application/x.apple.alias', // Invented by us
294
+ 'audio/x-voc',
295
+ 'audio/vnd.dolby.dd-raw',
296
+ 'audio/x-m4a',
297
+ 'image/apng',
298
+ 'image/x-olympus-orf',
299
+ 'image/x-sony-arw',
300
+ 'image/x-adobe-dng',
301
+ 'image/x-nikon-nef',
302
+ 'image/x-panasonic-rw2',
303
+ 'image/x-fujifilm-raf',
304
+ 'video/x-m4v',
305
+ 'video/3gpp2',
306
+ 'application/x-esri-shape',
307
+ 'audio/aac',
308
+ 'audio/x-it',
309
+ 'audio/x-s3m',
310
+ 'audio/x-xm',
311
+ 'video/MP1S',
312
+ 'video/MP2P',
313
+ 'application/vnd.sketchup.skp',
314
+ 'image/avif',
315
+ 'application/x-lzh-compressed',
316
+ 'application/pgp-encrypted',
317
+ 'application/x-asar',
318
+ 'model/stl',
319
+ 'application/vnd.ms-htmlhelp',
320
+ 'model/3mf',
321
+ 'image/jxl',
322
+ 'application/zstd',
323
+ 'image/jls',
324
+ 'application/vnd.ms-outlook',
325
+ 'image/vnd.dwg',
326
+ 'application/vnd.apache.parquet',
327
+ 'application/java-vm',
328
+ 'application/x-arj',
329
+ 'application/x-cpio',
330
+ 'application/x-ace-compressed',
331
+ 'application/avro',
332
+ 'application/vnd.iccprofile',
333
+ 'application/x.autodesk.fbx', // Invented by us
334
+ 'application/vnd.visio',
335
+ 'application/vnd.android.package-archive',
336
+ 'application/vnd.google.draco', // Invented by us
337
+ 'application/x-lz4', // Invented by us
338
+ 'application/vnd.openxmlformats-officedocument.presentationml.template',
339
+ 'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
340
+ 'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
341
+ 'application/vnd.ms-excel.template.macroenabled.12',
342
+ 'application/vnd.oasis.opendocument.text-template',
343
+ 'application/vnd.oasis.opendocument.spreadsheet-template',
344
+ 'application/vnd.oasis.opendocument.presentation-template',
345
+ 'application/vnd.oasis.opendocument.graphics',
346
+ 'application/vnd.oasis.opendocument.graphics-template',
347
+ 'application/vnd.ms-excel.sheet.macroenabled.12',
348
+ 'application/vnd.ms-word.document.macroenabled.12',
349
+ 'application/vnd.ms-word.template.macroenabled.12',
350
+ 'application/vnd.ms-powerpoint.template.macroenabled.12',
351
+ 'application/vnd.ms-powerpoint.presentation.macroenabled.12',
352
+ 'application/java-archive',
353
+ 'application/vnd.rn-realmedia',
354
+ 'application/x-ms-regedit',
355
+ 'application/x-ft-windows-registry-hive',
356
+ ];
@@ -0,0 +1,60 @@
1
+ import {StringType} from 'token-types';
2
+
3
+ export function stringToBytes(string, encoding) {
4
+ if (encoding === 'utf-16le') {
5
+ const bytes = [];
6
+ for (let index = 0; index < string.length; index++) {
7
+ const code = string.charCodeAt(index); // eslint-disable-line unicorn/prefer-code-point
8
+ bytes.push(code & 0xFF, (code >> 8) & 0xFF); // High byte
9
+ }
10
+
11
+ return bytes;
12
+ }
13
+
14
+ if (encoding === 'utf-16be') {
15
+ const bytes = [];
16
+ for (let index = 0; index < string.length; index++) {
17
+ const code = string.charCodeAt(index); // eslint-disable-line unicorn/prefer-code-point
18
+ bytes.push((code >> 8) & 0xFF, code & 0xFF); // Low byte
19
+ }
20
+
21
+ return bytes;
22
+ }
23
+
24
+ return [...string].map(character => character.charCodeAt(0)); // eslint-disable-line unicorn/prefer-code-point
25
+ }
26
+
27
+ /**
28
+ Checks whether the TAR checksum is valid.
29
+
30
+ @param {Uint8Array} arrayBuffer - The TAR header `[offset ... offset + 512]`.
31
+ @param {number} offset - TAR header offset.
32
+ @returns {boolean} `true` if the TAR checksum is valid, otherwise `false`.
33
+ */
34
+ export function tarHeaderChecksumMatches(arrayBuffer, offset = 0) {
35
+ const readSum = Number.parseInt(new StringType(6).get(arrayBuffer, 148).replace(/\0.*$/, '').trim(), 8); // Read sum in header
36
+ if (Number.isNaN(readSum)) {
37
+ return false;
38
+ }
39
+
40
+ let sum = 8 * 0x20; // Initialize signed bit sum
41
+
42
+ for (let index = offset; index < offset + 148; index++) {
43
+ sum += arrayBuffer[index];
44
+ }
45
+
46
+ for (let index = offset + 156; index < offset + 512; index++) {
47
+ sum += arrayBuffer[index];
48
+ }
49
+
50
+ return readSum === sum;
51
+ }
52
+
53
+ /**
54
+ ID3 UINT32 sync-safe tokenizer token.
55
+ 28 bits (representing up to 256MB) integer, the msb is 0 to avoid "false syncsignals".
56
+ */
57
+ export const uint32SyncSafeToken = {
58
+ get: (buffer, offset) => (buffer[offset + 3] & 0x7F) | ((buffer[offset + 2]) << 7) | ((buffer[offset + 1]) << 14) | ((buffer[offset]) << 21),
59
+ len: 4,
60
+ };
@@ -0,0 +1,11 @@
1
+ Copyright 2008 Fair Oaks Labs, Inc.
2
+
3
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4
+
5
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6
+
7
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8
+
9
+ 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10
+
11
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,51 @@
1
+ # ieee754 [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url]
2
+
3
+ [travis-image]: https://img.shields.io/travis/feross/ieee754/master.svg
4
+ [travis-url]: https://travis-ci.org/feross/ieee754
5
+ [npm-image]: https://img.shields.io/npm/v/ieee754.svg
6
+ [npm-url]: https://npmjs.org/package/ieee754
7
+ [downloads-image]: https://img.shields.io/npm/dm/ieee754.svg
8
+ [downloads-url]: https://npmjs.org/package/ieee754
9
+ [standard-image]: https://img.shields.io/badge/code_style-standard-brightgreen.svg
10
+ [standard-url]: https://standardjs.com
11
+
12
+ [![saucelabs][saucelabs-image]][saucelabs-url]
13
+
14
+ [saucelabs-image]: https://saucelabs.com/browser-matrix/ieee754.svg
15
+ [saucelabs-url]: https://saucelabs.com/u/ieee754
16
+
17
+ ### Read/write IEEE754 floating point numbers from/to a Buffer or array-like object.
18
+
19
+ ## install
20
+
21
+ ```
22
+ npm install ieee754
23
+ ```
24
+
25
+ ## methods
26
+
27
+ `var ieee754 = require('ieee754')`
28
+
29
+ The `ieee754` object has the following functions:
30
+
31
+ ```
32
+ ieee754.read = function (buffer, offset, isLE, mLen, nBytes)
33
+ ieee754.write = function (buffer, value, offset, isLE, mLen, nBytes)
34
+ ```
35
+
36
+ The arguments mean the following:
37
+
38
+ - buffer = the buffer
39
+ - offset = offset into the buffer
40
+ - value = value to set (only for `write`)
41
+ - isLe = is little endian?
42
+ - mLen = mantissa length
43
+ - nBytes = number of bytes
44
+
45
+ ## what is ieee754?
46
+
47
+ The IEEE Standard for Floating-Point Arithmetic (IEEE 754) is a technical standard for floating-point computation. [Read more](http://en.wikipedia.org/wiki/IEEE_floating_point).
48
+
49
+ ## license
50
+
51
+ BSD 3 Clause. Copyright (c) 2008, Fair Oaks Labs, Inc.
@@ -0,0 +1,10 @@
1
+ declare namespace ieee754 {
2
+ export function read(
3
+ buffer: Uint8Array, offset: number, isLE: boolean, mLen: number,
4
+ nBytes: number): number;
5
+ export function write(
6
+ buffer: Uint8Array, value: number, offset: number, isLE: boolean,
7
+ mLen: number, nBytes: number): void;
8
+ }
9
+
10
+ export = ieee754;
@@ -0,0 +1,85 @@
1
+ /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
2
+ exports.read = function (buffer, offset, isLE, mLen, nBytes) {
3
+ var e, m
4
+ var eLen = (nBytes * 8) - mLen - 1
5
+ var eMax = (1 << eLen) - 1
6
+ var eBias = eMax >> 1
7
+ var nBits = -7
8
+ var i = isLE ? (nBytes - 1) : 0
9
+ var d = isLE ? -1 : 1
10
+ var s = buffer[offset + i]
11
+
12
+ i += d
13
+
14
+ e = s & ((1 << (-nBits)) - 1)
15
+ s >>= (-nBits)
16
+ nBits += eLen
17
+ for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
18
+
19
+ m = e & ((1 << (-nBits)) - 1)
20
+ e >>= (-nBits)
21
+ nBits += mLen
22
+ for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
23
+
24
+ if (e === 0) {
25
+ e = 1 - eBias
26
+ } else if (e === eMax) {
27
+ return m ? NaN : ((s ? -1 : 1) * Infinity)
28
+ } else {
29
+ m = m + Math.pow(2, mLen)
30
+ e = e - eBias
31
+ }
32
+ return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
33
+ }
34
+
35
+ exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
36
+ var e, m, c
37
+ var eLen = (nBytes * 8) - mLen - 1
38
+ var eMax = (1 << eLen) - 1
39
+ var eBias = eMax >> 1
40
+ var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
41
+ var i = isLE ? 0 : (nBytes - 1)
42
+ var d = isLE ? 1 : -1
43
+ var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
44
+
45
+ value = Math.abs(value)
46
+
47
+ if (isNaN(value) || value === Infinity) {
48
+ m = isNaN(value) ? 1 : 0
49
+ e = eMax
50
+ } else {
51
+ e = Math.floor(Math.log(value) / Math.LN2)
52
+ if (value * (c = Math.pow(2, -e)) < 1) {
53
+ e--
54
+ c *= 2
55
+ }
56
+ if (e + eBias >= 1) {
57
+ value += rt / c
58
+ } else {
59
+ value += rt * Math.pow(2, 1 - eBias)
60
+ }
61
+ if (value * c >= 2) {
62
+ e++
63
+ c /= 2
64
+ }
65
+
66
+ if (e + eBias >= eMax) {
67
+ m = 0
68
+ e = eMax
69
+ } else if (e + eBias >= 1) {
70
+ m = ((value * c) - 1) * Math.pow(2, mLen)
71
+ e = e + eBias
72
+ } else {
73
+ m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
74
+ e = 0
75
+ }
76
+ }
77
+
78
+ for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
79
+
80
+ e = (e << mLen) | m
81
+ eLen += mLen
82
+ for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
83
+
84
+ buffer[offset + i - d] |= s * 128
85
+ }
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "ieee754",
3
+ "description": "Read/write IEEE754 floating point numbers from/to a Buffer or array-like object",
4
+ "version": "1.2.1",
5
+ "author": {
6
+ "name": "Feross Aboukhadijeh",
7
+ "email": "feross@feross.org",
8
+ "url": "https://feross.org"
9
+ },
10
+ "contributors": [
11
+ "Romain Beauxis <toots@rastageeks.org>"
12
+ ],
13
+ "devDependencies": {
14
+ "airtap": "^3.0.0",
15
+ "standard": "*",
16
+ "tape": "^5.0.1"
17
+ },
18
+ "keywords": [
19
+ "IEEE 754",
20
+ "buffer",
21
+ "convert",
22
+ "floating point",
23
+ "ieee754"
24
+ ],
25
+ "license": "BSD-3-Clause",
26
+ "main": "index.js",
27
+ "types": "index.d.ts",
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "git://github.com/feross/ieee754.git"
31
+ },
32
+ "scripts": {
33
+ "test": "standard && npm run test-node && npm run test-browser",
34
+ "test-browser": "airtap -- test/*.js",
35
+ "test-browser-local": "airtap --local -- test/*.js",
36
+ "test-node": "tape test/*.js"
37
+ },
38
+ "funding": [
39
+ {
40
+ "type": "github",
41
+ "url": "https://github.com/sponsors/feross"
42
+ },
43
+ {
44
+ "type": "patreon",
45
+ "url": "https://www.patreon.com/feross"
46
+ },
47
+ {
48
+ "type": "consulting",
49
+ "url": "https://feross.org/support"
50
+ }
51
+ ]
52
+ }