fca-smart-shankar 12.0.0 → 13.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 (285) hide show
  1. package/.replit +12 -3
  2. package/.upm/store.json +1 -0
  3. package/CHANGELOG.md +2 -0
  4. package/README.md +0 -1
  5. package/generated-icon.png +0 -0
  6. package/index.js +507 -437
  7. package/package.json +378 -42
  8. package/replit.nix +3 -1
  9. package/shankar-fca.json +4 -0
  10. package/src/addUserToGroup.js +3 -3
  11. package/src/changeAdminStatus.js +2 -2
  12. package/src/changeArchivedStatus.js +2 -2
  13. package/src/changeAvatar.js +8 -8
  14. package/src/changeAvatarV2.js +1 -1
  15. package/src/changeBio.js +4 -4
  16. package/src/changeBlockedStatus.js +2 -2
  17. package/src/changeCover.js +2 -2
  18. package/src/changeGroupImage.js +4 -4
  19. package/src/changeName.js +2 -2
  20. package/src/changeNickname.js +2 -2
  21. package/src/changeThreadColor.js +3 -3
  22. package/src/changeThreadEmoji.js +2 -2
  23. package/src/changeUsername.js +3 -3
  24. package/src/createCommentPost.js +5 -5
  25. package/src/createNewGroup.js +5 -5
  26. package/src/createPoll.js +2 -2
  27. package/src/createPost.js +6 -5
  28. package/src/deleteMessage.js +2 -2
  29. package/src/deleteThread.js +2 -2
  30. package/src/editMessage.js +30 -18
  31. package/src/follow.js +8 -8
  32. package/src/forwardAttachment.js +2 -2
  33. package/src/getAccess.js +2 -2
  34. package/src/getAvatarUser.js +2 -2
  35. package/src/getCurrentUserID.js +4 -4
  36. package/src/getFriendsList.js +3 -3
  37. package/src/getMessage.js +2 -2
  38. package/src/getThreadHistory.js +2 -2
  39. package/src/getThreadHistoryDeprecated.js +2 -2
  40. package/src/getThreadInfo.js +1 -1
  41. package/src/getThreadInfoDeprecated.js +2 -2
  42. package/src/getThreadList.js +3 -3
  43. package/src/getThreadListDeprecated.js +3 -3
  44. package/src/getThreadPictures.js +2 -2
  45. package/src/getUID.js +4 -4
  46. package/src/getUserID.js +3 -3
  47. package/src/getUserInfo.js +52 -18
  48. package/src/handleFriendRequest.js +5 -5
  49. package/src/handleMessageRequest.js +2 -2
  50. package/src/httpGet.js +3 -3
  51. package/src/httpPost.js +3 -3
  52. package/src/httpPostFormData.js +3 -3
  53. package/src/listenMqtt.js +648 -659
  54. package/src/listenNotification.js +1 -1
  55. package/src/logout.js +3 -3
  56. package/src/markAsDelivered.js +5 -2
  57. package/src/markAsRead.js +5 -2
  58. package/src/markAsReadAll.js +2 -2
  59. package/src/markAsSeen.js +2 -2
  60. package/src/muteThread.js +2 -2
  61. package/src/refreshFb_dtsg.js +3 -3
  62. package/src/removeUserFromGroup.js +2 -2
  63. package/src/resolvePhotoUrl.js +2 -2
  64. package/src/searchStickers.js +1 -1
  65. package/src/sendMessage.js +11 -8
  66. package/src/sendMessageMqtt.js +4 -4
  67. package/src/sendTypingIndicator.js +14 -5
  68. package/src/sendTypingIndicatorV2.js +1 -1
  69. package/src/setMessageReaction.js +3 -3
  70. package/src/setPostReaction.js +4 -4
  71. package/src/setProfileGuard.js +3 -3
  72. package/src/setStoryReaction.js +1 -1
  73. package/src/setTitle.js +3 -3
  74. package/src/shareContact.js +1 -1
  75. package/src/shareLink.js +1 -1
  76. package/src/stopListenMqtt.js +5 -2
  77. package/src/unfriend.js +2 -2
  78. package/src/unsendMessage.js +2 -2
  79. package/src/uploadAttachment.js +2 -2
  80. package/test/data/shareAttach.js +146 -0
  81. package/test/data/something.mov +0 -0
  82. package/test/data/test.png +0 -0
  83. package/test/data/test.txt +7 -0
  84. package/test/test-page.js +1 -1
  85. package/utils.js +564 -391
  86. package/.cache/nix/binary-cache-v6.sqlite +0 -0
  87. package/.cache/nix/binary-cache-v6.sqlite-journal +0 -0
  88. package/.cache/replit/env/latest +0 -125
  89. package/.cache/replit/env/latest.json +0 -1
  90. package/.cache/replit/modules/nix.res +0 -1
  91. package/.cache/replit/modules/nodejs-20.res +0 -1
  92. package/.cache/replit/modules/replit.res +0 -1
  93. package/.cache/replit/modules.stamp +0 -0
  94. package/.cache/replit/nix/env.json +0 -1
  95. package/.cache/typescript/5.6/node_modules/.package-lock.json +0 -171
  96. package/.cache/typescript/5.6/node_modules/@types/bluebird/LICENSE +0 -21
  97. package/.cache/typescript/5.6/node_modules/@types/bluebird/README.md +0 -15
  98. package/.cache/typescript/5.6/node_modules/@types/bluebird/index.d.ts +0 -1365
  99. package/.cache/typescript/5.6/node_modules/@types/bluebird/package.json +0 -25
  100. package/.cache/typescript/5.6/node_modules/@types/caseless/LICENSE +0 -21
  101. package/.cache/typescript/5.6/node_modules/@types/caseless/README.md +0 -48
  102. package/.cache/typescript/5.6/node_modules/@types/caseless/index.d.ts +0 -29
  103. package/.cache/typescript/5.6/node_modules/@types/caseless/package.json +0 -35
  104. package/.cache/typescript/5.6/node_modules/@types/cheerio/LICENSE +0 -21
  105. package/.cache/typescript/5.6/node_modules/@types/cheerio/README.md +0 -15
  106. package/.cache/typescript/5.6/node_modules/@types/cheerio/index.d.ts +0 -318
  107. package/.cache/typescript/5.6/node_modules/@types/cheerio/package.json +0 -71
  108. package/.cache/typescript/5.6/node_modules/@types/mocha/LICENSE +0 -21
  109. package/.cache/typescript/5.6/node_modules/@types/mocha/README.md +0 -15
  110. package/.cache/typescript/5.6/node_modules/@types/mocha/index.d.ts +0 -2929
  111. package/.cache/typescript/5.6/node_modules/@types/mocha/package.json +0 -56
  112. package/.cache/typescript/5.6/node_modules/@types/node/LICENSE +0 -21
  113. package/.cache/typescript/5.6/node_modules/@types/node/README.md +0 -15
  114. package/.cache/typescript/5.6/node_modules/@types/node/assert/strict.d.ts +0 -8
  115. package/.cache/typescript/5.6/node_modules/@types/node/assert.d.ts +0 -1040
  116. package/.cache/typescript/5.6/node_modules/@types/node/async_hooks.d.ts +0 -541
  117. package/.cache/typescript/5.6/node_modules/@types/node/buffer.buffer.d.ts +0 -385
  118. package/.cache/typescript/5.6/node_modules/@types/node/buffer.d.ts +0 -1933
  119. package/.cache/typescript/5.6/node_modules/@types/node/child_process.d.ts +0 -1549
  120. package/.cache/typescript/5.6/node_modules/@types/node/cluster.d.ts +0 -579
  121. package/.cache/typescript/5.6/node_modules/@types/node/compatibility/disposable.d.ts +0 -16
  122. package/.cache/typescript/5.6/node_modules/@types/node/compatibility/index.d.ts +0 -9
  123. package/.cache/typescript/5.6/node_modules/@types/node/compatibility/indexable.d.ts +0 -23
  124. package/.cache/typescript/5.6/node_modules/@types/node/compatibility/iterators.d.ts +0 -21
  125. package/.cache/typescript/5.6/node_modules/@types/node/console.d.ts +0 -452
  126. package/.cache/typescript/5.6/node_modules/@types/node/constants.d.ts +0 -19
  127. package/.cache/typescript/5.6/node_modules/@types/node/crypto.d.ts +0 -4475
  128. package/.cache/typescript/5.6/node_modules/@types/node/dgram.d.ts +0 -596
  129. package/.cache/typescript/5.6/node_modules/@types/node/diagnostics_channel.d.ts +0 -554
  130. package/.cache/typescript/5.6/node_modules/@types/node/dns/promises.d.ts +0 -476
  131. package/.cache/typescript/5.6/node_modules/@types/node/dns.d.ts +0 -865
  132. package/.cache/typescript/5.6/node_modules/@types/node/dom-events.d.ts +0 -124
  133. package/.cache/typescript/5.6/node_modules/@types/node/domain.d.ts +0 -170
  134. package/.cache/typescript/5.6/node_modules/@types/node/events.d.ts +0 -931
  135. package/.cache/typescript/5.6/node_modules/@types/node/fs/promises.d.ts +0 -1275
  136. package/.cache/typescript/5.6/node_modules/@types/node/fs.d.ts +0 -4396
  137. package/.cache/typescript/5.6/node_modules/@types/node/globals.d.ts +0 -566
  138. package/.cache/typescript/5.6/node_modules/@types/node/globals.typedarray.d.ts +0 -21
  139. package/.cache/typescript/5.6/node_modules/@types/node/http.d.ts +0 -1958
  140. package/.cache/typescript/5.6/node_modules/@types/node/http2.d.ts +0 -2558
  141. package/.cache/typescript/5.6/node_modules/@types/node/https.d.ts +0 -543
  142. package/.cache/typescript/5.6/node_modules/@types/node/index.d.ts +0 -92
  143. package/.cache/typescript/5.6/node_modules/@types/node/inspector.d.ts +0 -3966
  144. package/.cache/typescript/5.6/node_modules/@types/node/module.d.ts +0 -402
  145. package/.cache/typescript/5.6/node_modules/@types/node/net.d.ts +0 -1001
  146. package/.cache/typescript/5.6/node_modules/@types/node/os.d.ts +0 -495
  147. package/.cache/typescript/5.6/node_modules/@types/node/package.json +0 -220
  148. package/.cache/typescript/5.6/node_modules/@types/node/path.d.ts +0 -200
  149. package/.cache/typescript/5.6/node_modules/@types/node/perf_hooks.d.ts +0 -965
  150. package/.cache/typescript/5.6/node_modules/@types/node/process.d.ts +0 -1963
  151. package/.cache/typescript/5.6/node_modules/@types/node/punycode.d.ts +0 -117
  152. package/.cache/typescript/5.6/node_modules/@types/node/querystring.d.ts +0 -153
  153. package/.cache/typescript/5.6/node_modules/@types/node/readline/promises.d.ts +0 -162
  154. package/.cache/typescript/5.6/node_modules/@types/node/readline.d.ts +0 -589
  155. package/.cache/typescript/5.6/node_modules/@types/node/repl.d.ts +0 -430
  156. package/.cache/typescript/5.6/node_modules/@types/node/sea.d.ts +0 -153
  157. package/.cache/typescript/5.6/node_modules/@types/node/sqlite.d.ts +0 -213
  158. package/.cache/typescript/5.6/node_modules/@types/node/stream/consumers.d.ts +0 -12
  159. package/.cache/typescript/5.6/node_modules/@types/node/stream/promises.d.ts +0 -90
  160. package/.cache/typescript/5.6/node_modules/@types/node/stream/web.d.ts +0 -609
  161. package/.cache/typescript/5.6/node_modules/@types/node/stream.d.ts +0 -1726
  162. package/.cache/typescript/5.6/node_modules/@types/node/string_decoder.d.ts +0 -67
  163. package/.cache/typescript/5.6/node_modules/@types/node/test.d.ts +0 -2248
  164. package/.cache/typescript/5.6/node_modules/@types/node/timers/promises.d.ts +0 -97
  165. package/.cache/typescript/5.6/node_modules/@types/node/timers.d.ts +0 -240
  166. package/.cache/typescript/5.6/node_modules/@types/node/tls.d.ts +0 -1226
  167. package/.cache/typescript/5.6/node_modules/@types/node/trace_events.d.ts +0 -197
  168. package/.cache/typescript/5.6/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +0 -385
  169. package/.cache/typescript/5.6/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +0 -19
  170. package/.cache/typescript/5.6/node_modules/@types/node/ts5.6/index.d.ts +0 -92
  171. package/.cache/typescript/5.6/node_modules/@types/node/tty.d.ts +0 -208
  172. package/.cache/typescript/5.6/node_modules/@types/node/url.d.ts +0 -972
  173. package/.cache/typescript/5.6/node_modules/@types/node/util.d.ts +0 -2371
  174. package/.cache/typescript/5.6/node_modules/@types/node/v8.d.ts +0 -808
  175. package/.cache/typescript/5.6/node_modules/@types/node/vm.d.ts +0 -976
  176. package/.cache/typescript/5.6/node_modules/@types/node/wasi.d.ts +0 -181
  177. package/.cache/typescript/5.6/node_modules/@types/node/worker_threads.d.ts +0 -745
  178. package/.cache/typescript/5.6/node_modules/@types/node/zlib.d.ts +0 -539
  179. package/.cache/typescript/5.6/node_modules/@types/request/LICENSE +0 -21
  180. package/.cache/typescript/5.6/node_modules/@types/request/README.md +0 -15
  181. package/.cache/typescript/5.6/node_modules/@types/request/index.d.ts +0 -395
  182. package/.cache/typescript/5.6/node_modules/@types/request/package.json +0 -70
  183. package/.cache/typescript/5.6/node_modules/@types/tough-cookie/LICENSE +0 -21
  184. package/.cache/typescript/5.6/node_modules/@types/tough-cookie/README.md +0 -15
  185. package/.cache/typescript/5.6/node_modules/@types/tough-cookie/index.d.ts +0 -321
  186. package/.cache/typescript/5.6/node_modules/@types/tough-cookie/package.json +0 -35
  187. package/.cache/typescript/5.6/node_modules/asynckit/LICENSE +0 -21
  188. package/.cache/typescript/5.6/node_modules/asynckit/README.md +0 -233
  189. package/.cache/typescript/5.6/node_modules/asynckit/bench.js +0 -76
  190. package/.cache/typescript/5.6/node_modules/asynckit/index.js +0 -6
  191. package/.cache/typescript/5.6/node_modules/asynckit/lib/abort.js +0 -29
  192. package/.cache/typescript/5.6/node_modules/asynckit/lib/async.js +0 -34
  193. package/.cache/typescript/5.6/node_modules/asynckit/lib/defer.js +0 -26
  194. package/.cache/typescript/5.6/node_modules/asynckit/lib/iterate.js +0 -75
  195. package/.cache/typescript/5.6/node_modules/asynckit/lib/readable_asynckit.js +0 -91
  196. package/.cache/typescript/5.6/node_modules/asynckit/lib/readable_parallel.js +0 -25
  197. package/.cache/typescript/5.6/node_modules/asynckit/lib/readable_serial.js +0 -25
  198. package/.cache/typescript/5.6/node_modules/asynckit/lib/readable_serial_ordered.js +0 -29
  199. package/.cache/typescript/5.6/node_modules/asynckit/lib/state.js +0 -37
  200. package/.cache/typescript/5.6/node_modules/asynckit/lib/streamify.js +0 -141
  201. package/.cache/typescript/5.6/node_modules/asynckit/lib/terminator.js +0 -29
  202. package/.cache/typescript/5.6/node_modules/asynckit/package.json +0 -63
  203. package/.cache/typescript/5.6/node_modules/asynckit/parallel.js +0 -43
  204. package/.cache/typescript/5.6/node_modules/asynckit/serial.js +0 -17
  205. package/.cache/typescript/5.6/node_modules/asynckit/serialOrdered.js +0 -75
  206. package/.cache/typescript/5.6/node_modules/asynckit/stream.js +0 -21
  207. package/.cache/typescript/5.6/node_modules/combined-stream/License +0 -19
  208. package/.cache/typescript/5.6/node_modules/combined-stream/Readme.md +0 -138
  209. package/.cache/typescript/5.6/node_modules/combined-stream/lib/combined_stream.js +0 -208
  210. package/.cache/typescript/5.6/node_modules/combined-stream/package.json +0 -25
  211. package/.cache/typescript/5.6/node_modules/combined-stream/yarn.lock +0 -17
  212. package/.cache/typescript/5.6/node_modules/delayed-stream/License +0 -19
  213. package/.cache/typescript/5.6/node_modules/delayed-stream/Makefile +0 -7
  214. package/.cache/typescript/5.6/node_modules/delayed-stream/Readme.md +0 -141
  215. package/.cache/typescript/5.6/node_modules/delayed-stream/lib/delayed_stream.js +0 -107
  216. package/.cache/typescript/5.6/node_modules/delayed-stream/package.json +0 -27
  217. package/.cache/typescript/5.6/node_modules/form-data/License +0 -19
  218. package/.cache/typescript/5.6/node_modules/form-data/Readme.md +0 -350
  219. package/.cache/typescript/5.6/node_modules/form-data/index.d.ts +0 -51
  220. package/.cache/typescript/5.6/node_modules/form-data/lib/browser.js +0 -2
  221. package/.cache/typescript/5.6/node_modules/form-data/lib/form_data.js +0 -484
  222. package/.cache/typescript/5.6/node_modules/form-data/lib/populate.js +0 -10
  223. package/.cache/typescript/5.6/node_modules/form-data/package.json +0 -72
  224. package/.cache/typescript/5.6/node_modules/mime-db/HISTORY.md +0 -507
  225. package/.cache/typescript/5.6/node_modules/mime-db/LICENSE +0 -23
  226. package/.cache/typescript/5.6/node_modules/mime-db/README.md +0 -100
  227. package/.cache/typescript/5.6/node_modules/mime-db/db.json +0 -8519
  228. package/.cache/typescript/5.6/node_modules/mime-db/index.js +0 -12
  229. package/.cache/typescript/5.6/node_modules/mime-db/package.json +0 -60
  230. package/.cache/typescript/5.6/node_modules/mime-types/HISTORY.md +0 -397
  231. package/.cache/typescript/5.6/node_modules/mime-types/LICENSE +0 -23
  232. package/.cache/typescript/5.6/node_modules/mime-types/README.md +0 -113
  233. package/.cache/typescript/5.6/node_modules/mime-types/index.js +0 -188
  234. package/.cache/typescript/5.6/node_modules/mime-types/package.json +0 -44
  235. package/.cache/typescript/5.6/node_modules/safe-buffer/LICENSE +0 -21
  236. package/.cache/typescript/5.6/node_modules/safe-buffer/README.md +0 -584
  237. package/.cache/typescript/5.6/node_modules/safe-buffer/index.d.ts +0 -187
  238. package/.cache/typescript/5.6/node_modules/safe-buffer/index.js +0 -65
  239. package/.cache/typescript/5.6/node_modules/safe-buffer/package.json +0 -51
  240. package/.cache/typescript/5.6/node_modules/types-registry/README.md +0 -2
  241. package/.cache/typescript/5.6/node_modules/types-registry/index.json +0 -1
  242. package/.cache/typescript/5.6/node_modules/types-registry/package.json +0 -20
  243. package/.cache/typescript/5.6/node_modules/undici-types/LICENSE +0 -21
  244. package/.cache/typescript/5.6/node_modules/undici-types/README.md +0 -6
  245. package/.cache/typescript/5.6/node_modules/undici-types/agent.d.ts +0 -31
  246. package/.cache/typescript/5.6/node_modules/undici-types/api.d.ts +0 -43
  247. package/.cache/typescript/5.6/node_modules/undici-types/balanced-pool.d.ts +0 -29
  248. package/.cache/typescript/5.6/node_modules/undici-types/cache.d.ts +0 -36
  249. package/.cache/typescript/5.6/node_modules/undici-types/client.d.ts +0 -108
  250. package/.cache/typescript/5.6/node_modules/undici-types/connector.d.ts +0 -34
  251. package/.cache/typescript/5.6/node_modules/undici-types/content-type.d.ts +0 -21
  252. package/.cache/typescript/5.6/node_modules/undici-types/cookies.d.ts +0 -28
  253. package/.cache/typescript/5.6/node_modules/undici-types/diagnostics-channel.d.ts +0 -66
  254. package/.cache/typescript/5.6/node_modules/undici-types/dispatcher.d.ts +0 -255
  255. package/.cache/typescript/5.6/node_modules/undici-types/env-http-proxy-agent.d.ts +0 -21
  256. package/.cache/typescript/5.6/node_modules/undici-types/errors.d.ts +0 -149
  257. package/.cache/typescript/5.6/node_modules/undici-types/eventsource.d.ts +0 -61
  258. package/.cache/typescript/5.6/node_modules/undici-types/fetch.d.ts +0 -209
  259. package/.cache/typescript/5.6/node_modules/undici-types/file.d.ts +0 -39
  260. package/.cache/typescript/5.6/node_modules/undici-types/filereader.d.ts +0 -54
  261. package/.cache/typescript/5.6/node_modules/undici-types/formdata.d.ts +0 -108
  262. package/.cache/typescript/5.6/node_modules/undici-types/global-dispatcher.d.ts +0 -9
  263. package/.cache/typescript/5.6/node_modules/undici-types/global-origin.d.ts +0 -7
  264. package/.cache/typescript/5.6/node_modules/undici-types/handlers.d.ts +0 -15
  265. package/.cache/typescript/5.6/node_modules/undici-types/header.d.ts +0 -4
  266. package/.cache/typescript/5.6/node_modules/undici-types/index.d.ts +0 -71
  267. package/.cache/typescript/5.6/node_modules/undici-types/interceptors.d.ts +0 -17
  268. package/.cache/typescript/5.6/node_modules/undici-types/mock-agent.d.ts +0 -50
  269. package/.cache/typescript/5.6/node_modules/undici-types/mock-client.d.ts +0 -25
  270. package/.cache/typescript/5.6/node_modules/undici-types/mock-errors.d.ts +0 -12
  271. package/.cache/typescript/5.6/node_modules/undici-types/mock-interceptor.d.ts +0 -93
  272. package/.cache/typescript/5.6/node_modules/undici-types/mock-pool.d.ts +0 -25
  273. package/.cache/typescript/5.6/node_modules/undici-types/package.json +0 -55
  274. package/.cache/typescript/5.6/node_modules/undici-types/patch.d.ts +0 -33
  275. package/.cache/typescript/5.6/node_modules/undici-types/pool-stats.d.ts +0 -19
  276. package/.cache/typescript/5.6/node_modules/undici-types/pool.d.ts +0 -39
  277. package/.cache/typescript/5.6/node_modules/undici-types/proxy-agent.d.ts +0 -28
  278. package/.cache/typescript/5.6/node_modules/undici-types/readable.d.ts +0 -60
  279. package/.cache/typescript/5.6/node_modules/undici-types/retry-agent.d.ts +0 -8
  280. package/.cache/typescript/5.6/node_modules/undici-types/retry-handler.d.ts +0 -116
  281. package/.cache/typescript/5.6/node_modules/undici-types/util.d.ts +0 -18
  282. package/.cache/typescript/5.6/node_modules/undici-types/webidl.d.ts +0 -222
  283. package/.cache/typescript/5.6/node_modules/undici-types/websocket.d.ts +0 -150
  284. package/.cache/typescript/5.6/package-lock.json +0 -183
  285. package/.cache/typescript/5.6/package.json +0 -1
@@ -1,385 +0,0 @@
1
- declare module "buffer" {
2
- global {
3
- interface BufferConstructor {
4
- // see buffer.d.ts for implementation shared with all TypeScript versions
5
-
6
- /**
7
- * Allocates a new buffer containing the given {str}.
8
- *
9
- * @param str String to store in buffer.
10
- * @param encoding encoding to use, optional. Default is 'utf8'
11
- * @deprecated since v10.0.0 - Use `Buffer.from(string[, encoding])` instead.
12
- */
13
- new(str: string, encoding?: BufferEncoding): Buffer<ArrayBuffer>;
14
- /**
15
- * Allocates a new buffer of {size} octets.
16
- *
17
- * @param size count of octets to allocate.
18
- * @deprecated since v10.0.0 - Use `Buffer.alloc()` instead (also see `Buffer.allocUnsafe()`).
19
- */
20
- new(size: number): Buffer<ArrayBuffer>;
21
- /**
22
- * Allocates a new buffer containing the given {array} of octets.
23
- *
24
- * @param array The octets to store.
25
- * @deprecated since v10.0.0 - Use `Buffer.from(array)` instead.
26
- */
27
- new(array: Uint8Array): Buffer<ArrayBuffer>;
28
- /**
29
- * Produces a Buffer backed by the same allocated memory as
30
- * the given {ArrayBuffer}/{SharedArrayBuffer}.
31
- *
32
- * @param arrayBuffer The ArrayBuffer with which to share memory.
33
- * @deprecated since v10.0.0 - Use `Buffer.from(arrayBuffer[, byteOffset[, length]])` instead.
34
- */
35
- new<TArrayBuffer extends ArrayBufferLike = ArrayBuffer>(arrayBuffer: TArrayBuffer): Buffer<TArrayBuffer>;
36
- /**
37
- * Allocates a new buffer containing the given {array} of octets.
38
- *
39
- * @param array The octets to store.
40
- * @deprecated since v10.0.0 - Use `Buffer.from(array)` instead.
41
- */
42
- new(array: readonly any[]): Buffer<ArrayBuffer>;
43
- /**
44
- * Copies the passed {buffer} data onto a new {Buffer} instance.
45
- *
46
- * @param buffer The buffer to copy.
47
- * @deprecated since v10.0.0 - Use `Buffer.from(buffer)` instead.
48
- */
49
- new(buffer: Buffer): Buffer<ArrayBuffer>;
50
- /**
51
- * Allocates a new `Buffer` using an `array` of bytes in the range `0` – `255`.
52
- * Array entries outside that range will be truncated to fit into it.
53
- *
54
- * ```js
55
- * import { Buffer } from 'node:buffer';
56
- *
57
- * // Creates a new Buffer containing the UTF-8 bytes of the string 'buffer'.
58
- * const buf = Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]);
59
- * ```
60
- *
61
- * If `array` is an `Array`\-like object (that is, one with a `length` property of
62
- * type `number`), it is treated as if it is an array, unless it is a `Buffer` or
63
- * a `Uint8Array`. This means all other `TypedArray` variants get treated as an `Array`. To create a `Buffer` from the bytes backing a `TypedArray`, use `Buffer.copyBytesFrom()`.
64
- *
65
- * A `TypeError` will be thrown if `array` is not an `Array` or another type
66
- * appropriate for `Buffer.from()` variants.
67
- *
68
- * `Buffer.from(array)` and `Buffer.from(string)` may also use the internal `Buffer` pool like `Buffer.allocUnsafe()` does.
69
- * @since v5.10.0
70
- */
71
- from<TArrayBuffer extends ArrayBufferLike>(
72
- arrayBuffer: WithImplicitCoercion<TArrayBuffer>,
73
- byteOffset?: number,
74
- length?: number,
75
- ): Buffer<TArrayBuffer>;
76
- /**
77
- * Creates a new Buffer using the passed {data}
78
- * @param data data to create a new Buffer
79
- */
80
- from(data: Uint8Array | readonly number[]): Buffer<ArrayBuffer>;
81
- from(data: WithImplicitCoercion<Uint8Array | readonly number[] | string>): Buffer<ArrayBuffer>;
82
- /**
83
- * Creates a new Buffer containing the given JavaScript string {str}.
84
- * If provided, the {encoding} parameter identifies the character encoding.
85
- * If not provided, {encoding} defaults to 'utf8'.
86
- */
87
- from(
88
- str:
89
- | WithImplicitCoercion<string>
90
- | {
91
- [Symbol.toPrimitive](hint: "string"): string;
92
- },
93
- encoding?: BufferEncoding,
94
- ): Buffer<ArrayBuffer>;
95
- /**
96
- * Creates a new Buffer using the passed {data}
97
- * @param values to create a new Buffer
98
- */
99
- of(...items: number[]): Buffer<ArrayBuffer>;
100
- /**
101
- * Returns a new `Buffer` which is the result of concatenating all the `Buffer` instances in the `list` together.
102
- *
103
- * If the list has no items, or if the `totalLength` is 0, then a new zero-length `Buffer` is returned.
104
- *
105
- * If `totalLength` is not provided, it is calculated from the `Buffer` instances
106
- * in `list` by adding their lengths.
107
- *
108
- * If `totalLength` is provided, it is coerced to an unsigned integer. If the
109
- * combined length of the `Buffer`s in `list` exceeds `totalLength`, the result is
110
- * truncated to `totalLength`.
111
- *
112
- * ```js
113
- * import { Buffer } from 'node:buffer';
114
- *
115
- * // Create a single `Buffer` from a list of three `Buffer` instances.
116
- *
117
- * const buf1 = Buffer.alloc(10);
118
- * const buf2 = Buffer.alloc(14);
119
- * const buf3 = Buffer.alloc(18);
120
- * const totalLength = buf1.length + buf2.length + buf3.length;
121
- *
122
- * console.log(totalLength);
123
- * // Prints: 42
124
- *
125
- * const bufA = Buffer.concat([buf1, buf2, buf3], totalLength);
126
- *
127
- * console.log(bufA);
128
- * // Prints: <Buffer 00 00 00 00 ...>
129
- * console.log(bufA.length);
130
- * // Prints: 42
131
- * ```
132
- *
133
- * `Buffer.concat()` may also use the internal `Buffer` pool like `Buffer.allocUnsafe()` does.
134
- * @since v0.7.11
135
- * @param list List of `Buffer` or {@link Uint8Array} instances to concatenate.
136
- * @param totalLength Total length of the `Buffer` instances in `list` when concatenated.
137
- */
138
- concat(list: readonly Uint8Array[], totalLength?: number): Buffer<ArrayBuffer>;
139
- /**
140
- * Copies the underlying memory of `view` into a new `Buffer`.
141
- *
142
- * ```js
143
- * const u16 = new Uint16Array([0, 0xffff]);
144
- * const buf = Buffer.copyBytesFrom(u16, 1, 1);
145
- * u16[1] = 0;
146
- * console.log(buf.length); // 2
147
- * console.log(buf[0]); // 255
148
- * console.log(buf[1]); // 255
149
- * ```
150
- * @since v19.8.0
151
- * @param view The {TypedArray} to copy.
152
- * @param [offset=0] The starting offset within `view`.
153
- * @param [length=view.length - offset] The number of elements from `view` to copy.
154
- */
155
- copyBytesFrom(view: NodeJS.TypedArray, offset?: number, length?: number): Buffer<ArrayBuffer>;
156
- /**
157
- * Allocates a new `Buffer` of `size` bytes. If `fill` is `undefined`, the`Buffer` will be zero-filled.
158
- *
159
- * ```js
160
- * import { Buffer } from 'node:buffer';
161
- *
162
- * const buf = Buffer.alloc(5);
163
- *
164
- * console.log(buf);
165
- * // Prints: <Buffer 00 00 00 00 00>
166
- * ```
167
- *
168
- * If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_OUT_OF_RANGE` is thrown.
169
- *
170
- * If `fill` is specified, the allocated `Buffer` will be initialized by calling `buf.fill(fill)`.
171
- *
172
- * ```js
173
- * import { Buffer } from 'node:buffer';
174
- *
175
- * const buf = Buffer.alloc(5, 'a');
176
- *
177
- * console.log(buf);
178
- * // Prints: <Buffer 61 61 61 61 61>
179
- * ```
180
- *
181
- * If both `fill` and `encoding` are specified, the allocated `Buffer` will be
182
- * initialized by calling `buf.fill(fill, encoding)`.
183
- *
184
- * ```js
185
- * import { Buffer } from 'node:buffer';
186
- *
187
- * const buf = Buffer.alloc(11, 'aGVsbG8gd29ybGQ=', 'base64');
188
- *
189
- * console.log(buf);
190
- * // Prints: <Buffer 68 65 6c 6c 6f 20 77 6f 72 6c 64>
191
- * ```
192
- *
193
- * Calling `Buffer.alloc()` can be measurably slower than the alternative `Buffer.allocUnsafe()` but ensures that the newly created `Buffer` instance
194
- * contents will never contain sensitive data from previous allocations, including
195
- * data that might not have been allocated for `Buffer`s.
196
- *
197
- * A `TypeError` will be thrown if `size` is not a number.
198
- * @since v5.10.0
199
- * @param size The desired length of the new `Buffer`.
200
- * @param [fill=0] A value to pre-fill the new `Buffer` with.
201
- * @param [encoding='utf8'] If `fill` is a string, this is its encoding.
202
- */
203
- alloc(size: number, fill?: string | Uint8Array | number, encoding?: BufferEncoding): Buffer<ArrayBuffer>;
204
- /**
205
- * Allocates a new `Buffer` of `size` bytes. If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_OUT_OF_RANGE` is thrown.
206
- *
207
- * The underlying memory for `Buffer` instances created in this way is _not_
208
- * _initialized_. The contents of the newly created `Buffer` are unknown and _may contain sensitive data_. Use `Buffer.alloc()` instead to initialize`Buffer` instances with zeroes.
209
- *
210
- * ```js
211
- * import { Buffer } from 'node:buffer';
212
- *
213
- * const buf = Buffer.allocUnsafe(10);
214
- *
215
- * console.log(buf);
216
- * // Prints (contents may vary): <Buffer a0 8b 28 3f 01 00 00 00 50 32>
217
- *
218
- * buf.fill(0);
219
- *
220
- * console.log(buf);
221
- * // Prints: <Buffer 00 00 00 00 00 00 00 00 00 00>
222
- * ```
223
- *
224
- * A `TypeError` will be thrown if `size` is not a number.
225
- *
226
- * The `Buffer` module pre-allocates an internal `Buffer` instance of
227
- * size `Buffer.poolSize` that is used as a pool for the fast allocation of new `Buffer` instances created using `Buffer.allocUnsafe()`, `Buffer.from(array)`,
228
- * and `Buffer.concat()` only when `size` is less than `Buffer.poolSize >>> 1` (floor of `Buffer.poolSize` divided by two).
229
- *
230
- * Use of this pre-allocated internal memory pool is a key difference between
231
- * calling `Buffer.alloc(size, fill)` vs. `Buffer.allocUnsafe(size).fill(fill)`.
232
- * Specifically, `Buffer.alloc(size, fill)` will _never_ use the internal `Buffer`pool, while `Buffer.allocUnsafe(size).fill(fill)`_will_ use the internal`Buffer` pool if `size` is less
233
- * than or equal to half `Buffer.poolSize`. The
234
- * difference is subtle but can be important when an application requires the
235
- * additional performance that `Buffer.allocUnsafe()` provides.
236
- * @since v5.10.0
237
- * @param size The desired length of the new `Buffer`.
238
- */
239
- allocUnsafe(size: number): Buffer<ArrayBuffer>;
240
- /**
241
- * Allocates a new `Buffer` of `size` bytes. If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_OUT_OF_RANGE` is thrown. A zero-length `Buffer` is created if
242
- * `size` is 0.
243
- *
244
- * The underlying memory for `Buffer` instances created in this way is _not_
245
- * _initialized_. The contents of the newly created `Buffer` are unknown and _may contain sensitive data_. Use `buf.fill(0)` to initialize
246
- * such `Buffer` instances with zeroes.
247
- *
248
- * When using `Buffer.allocUnsafe()` to allocate new `Buffer` instances,
249
- * allocations under 4 KiB are sliced from a single pre-allocated `Buffer`. This
250
- * allows applications to avoid the garbage collection overhead of creating many
251
- * individually allocated `Buffer` instances. This approach improves both
252
- * performance and memory usage by eliminating the need to track and clean up as
253
- * many individual `ArrayBuffer` objects.
254
- *
255
- * However, in the case where a developer may need to retain a small chunk of
256
- * memory from a pool for an indeterminate amount of time, it may be appropriate
257
- * to create an un-pooled `Buffer` instance using `Buffer.allocUnsafeSlow()` and
258
- * then copying out the relevant bits.
259
- *
260
- * ```js
261
- * import { Buffer } from 'node:buffer';
262
- *
263
- * // Need to keep around a few small chunks of memory.
264
- * const store = [];
265
- *
266
- * socket.on('readable', () => {
267
- * let data;
268
- * while (null !== (data = readable.read())) {
269
- * // Allocate for retained data.
270
- * const sb = Buffer.allocUnsafeSlow(10);
271
- *
272
- * // Copy the data into the new allocation.
273
- * data.copy(sb, 0, 0, 10);
274
- *
275
- * store.push(sb);
276
- * }
277
- * });
278
- * ```
279
- *
280
- * A `TypeError` will be thrown if `size` is not a number.
281
- * @since v5.12.0
282
- * @param size The desired length of the new `Buffer`.
283
- */
284
- allocUnsafeSlow(size: number): Buffer<ArrayBuffer>;
285
- }
286
- interface Buffer<TArrayBuffer extends ArrayBufferLike = ArrayBufferLike> extends Uint8Array<TArrayBuffer> {
287
- // see buffer.d.ts for implementation shared with all TypeScript versions
288
-
289
- /**
290
- * Returns a new `Buffer` that references the same memory as the original, but
291
- * offset and cropped by the `start` and `end` indices.
292
- *
293
- * This method is not compatible with the `Uint8Array.prototype.slice()`,
294
- * which is a superclass of `Buffer`. To copy the slice, use`Uint8Array.prototype.slice()`.
295
- *
296
- * ```js
297
- * import { Buffer } from 'node:buffer';
298
- *
299
- * const buf = Buffer.from('buffer');
300
- *
301
- * const copiedBuf = Uint8Array.prototype.slice.call(buf);
302
- * copiedBuf[0]++;
303
- * console.log(copiedBuf.toString());
304
- * // Prints: cuffer
305
- *
306
- * console.log(buf.toString());
307
- * // Prints: buffer
308
- *
309
- * // With buf.slice(), the original buffer is modified.
310
- * const notReallyCopiedBuf = buf.slice();
311
- * notReallyCopiedBuf[0]++;
312
- * console.log(notReallyCopiedBuf.toString());
313
- * // Prints: cuffer
314
- * console.log(buf.toString());
315
- * // Also prints: cuffer (!)
316
- * ```
317
- * @since v0.3.0
318
- * @deprecated Use `subarray` instead.
319
- * @param [start=0] Where the new `Buffer` will start.
320
- * @param [end=buf.length] Where the new `Buffer` will end (not inclusive).
321
- */
322
- slice(start?: number, end?: number): Buffer<ArrayBuffer>;
323
- /**
324
- * Returns a new `Buffer` that references the same memory as the original, but
325
- * offset and cropped by the `start` and `end` indices.
326
- *
327
- * Specifying `end` greater than `buf.length` will return the same result as
328
- * that of `end` equal to `buf.length`.
329
- *
330
- * This method is inherited from [`TypedArray.prototype.subarray()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/subarray).
331
- *
332
- * Modifying the new `Buffer` slice will modify the memory in the original `Buffer`because the allocated memory of the two objects overlap.
333
- *
334
- * ```js
335
- * import { Buffer } from 'node:buffer';
336
- *
337
- * // Create a `Buffer` with the ASCII alphabet, take a slice, and modify one byte
338
- * // from the original `Buffer`.
339
- *
340
- * const buf1 = Buffer.allocUnsafe(26);
341
- *
342
- * for (let i = 0; i < 26; i++) {
343
- * // 97 is the decimal ASCII value for 'a'.
344
- * buf1[i] = i + 97;
345
- * }
346
- *
347
- * const buf2 = buf1.subarray(0, 3);
348
- *
349
- * console.log(buf2.toString('ascii', 0, buf2.length));
350
- * // Prints: abc
351
- *
352
- * buf1[0] = 33;
353
- *
354
- * console.log(buf2.toString('ascii', 0, buf2.length));
355
- * // Prints: !bc
356
- * ```
357
- *
358
- * Specifying negative indexes causes the slice to be generated relative to the
359
- * end of `buf` rather than the beginning.
360
- *
361
- * ```js
362
- * import { Buffer } from 'node:buffer';
363
- *
364
- * const buf = Buffer.from('buffer');
365
- *
366
- * console.log(buf.subarray(-6, -1).toString());
367
- * // Prints: buffe
368
- * // (Equivalent to buf.subarray(0, 5).)
369
- *
370
- * console.log(buf.subarray(-6, -2).toString());
371
- * // Prints: buff
372
- * // (Equivalent to buf.subarray(0, 4).)
373
- *
374
- * console.log(buf.subarray(-5, -2).toString());
375
- * // Prints: uff
376
- * // (Equivalent to buf.subarray(1, 4).)
377
- * ```
378
- * @since v3.0.0
379
- * @param [start=0] Where the new `Buffer` will start.
380
- * @param [end=buf.length] Where the new `Buffer` will end (not inclusive).
381
- */
382
- subarray(start?: number, end?: number): Buffer<TArrayBuffer>;
383
- }
384
- }
385
- }