版博士V2.0程序
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 

383 wiersze
11 KiB

  1. export type BufferListAcceptedTypes =
  2. | Buffer
  3. | BufferList
  4. | Uint8Array
  5. | BufferListAcceptedTypes[]
  6. | string
  7. | number;
  8. export interface BufferListConstructor {
  9. new (initData?: BufferListAcceptedTypes): BufferList;
  10. (initData?: BufferListAcceptedTypes): BufferList;
  11. /**
  12. * Determines if the passed object is a BufferList. It will return true
  13. * if the passed object is an instance of BufferList or BufferListStream
  14. * and false otherwise.
  15. *
  16. * N.B. this won't return true for BufferList or BufferListStream instances
  17. * created by versions of this library before this static method was added.
  18. *
  19. * @param other
  20. */
  21. isBufferList(other: unknown): boolean;
  22. }
  23. interface BufferList {
  24. prototype: Object
  25. /**
  26. * Get the length of the list in bytes. This is the sum of the lengths
  27. * of all of the buffers contained in the list, minus any initial offset
  28. * for a semi-consumed buffer at the beginning. Should accurately
  29. * represent the total number of bytes that can be read from the list.
  30. */
  31. length: number;
  32. /**
  33. * Adds an additional buffer or BufferList to the internal list.
  34. * this is returned so it can be chained.
  35. *
  36. * @param buffer
  37. */
  38. append(buffer: BufferListAcceptedTypes): this;
  39. /**
  40. * Will return the byte at the specified index.
  41. * @param index
  42. */
  43. get(index: number): number;
  44. /**
  45. * Returns a new Buffer object containing the bytes within the
  46. * range specified. Both start and end are optional and will
  47. * default to the beginning and end of the list respectively.
  48. *
  49. * If the requested range spans a single internal buffer then a
  50. * slice of that buffer will be returned which shares the original
  51. * memory range of that Buffer. If the range spans multiple buffers
  52. * then copy operations will likely occur to give you a uniform Buffer.
  53. *
  54. * @param start
  55. * @param end
  56. */
  57. slice(start?: number, end?: number): Buffer;
  58. /**
  59. * Returns a new BufferList object containing the bytes within the
  60. * range specified. Both start and end are optional and will default
  61. * to the beginning and end of the list respectively.
  62. *
  63. * No copies will be performed. All buffers in the result share
  64. * memory with the original list.
  65. *
  66. * @param start
  67. * @param end
  68. */
  69. shallowSlice(start?: number, end?: number): this;
  70. /**
  71. * Copies the content of the list in the `dest` buffer, starting from
  72. * `destStart` and containing the bytes within the range specified
  73. * with `srcStart` to `srcEnd`.
  74. *
  75. * `destStart`, `start` and `end` are optional and will default to the
  76. * beginning of the dest buffer, and the beginning and end of the
  77. * list respectively.
  78. *
  79. * @param dest
  80. * @param destStart
  81. * @param srcStart
  82. * @param srcEnd
  83. */
  84. copy(
  85. dest: Buffer,
  86. destStart?: number,
  87. srcStart?: number,
  88. srcEnd?: number
  89. ): Buffer;
  90. /**
  91. * Performs a shallow-copy of the list. The internal Buffers remains the
  92. * same, so if you change the underlying Buffers, the change will be
  93. * reflected in both the original and the duplicate.
  94. *
  95. * This method is needed if you want to call consume() or pipe() and
  96. * still keep the original list.
  97. *
  98. * @example
  99. *
  100. * ```js
  101. * var bl = new BufferListStream();
  102. * bl.append('hello');
  103. * bl.append(' world');
  104. * bl.append('\n');
  105. * bl.duplicate().pipe(process.stdout, { end: false });
  106. *
  107. * console.log(bl.toString())
  108. * ```
  109. */
  110. duplicate(): this;
  111. /**
  112. * Will shift bytes off the start of the list. The number of bytes
  113. * consumed don't need to line up with the sizes of the internal
  114. * Buffers—initial offsets will be calculated accordingly in order
  115. * to give you a consistent view of the data.
  116. *
  117. * @param bytes
  118. */
  119. consume(bytes?: number): void;
  120. /**
  121. * Will return a string representation of the buffer. The optional
  122. * `start` and `end` arguments are passed on to `slice()`, while
  123. * the encoding is passed on to `toString()` of the resulting Buffer.
  124. *
  125. * See the [`Buffer#toString()`](http://nodejs.org/docs/latest/api/buffer.html#buffer_buf_tostring_encoding_start_end)
  126. * documentation for more information.
  127. *
  128. * @param encoding
  129. * @param start
  130. * @param end
  131. */
  132. toString(encoding?: string, start?: number, end?: number): string;
  133. /**
  134. * Will return the byte at the specified index. indexOf() method
  135. * returns the first index at which a given element can be found
  136. * in the BufferList, or -1 if it is not present.
  137. *
  138. * @param value
  139. * @param byteOffset
  140. * @param encoding
  141. */
  142. indexOf(
  143. value: string | number | Uint8Array | BufferList | Buffer,
  144. byteOffset?: number,
  145. encoding?: string
  146. ): number;
  147. /**
  148. * All of the standard byte-reading methods of the Buffer interface are implemented and will operate across internal Buffer boundaries transparently.
  149. * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html) documentation for how these work.
  150. *
  151. * @param offset
  152. */
  153. readDoubleBE: Buffer['readDoubleBE'];
  154. /**
  155. * All of the standard byte-reading methods of the Buffer interface are implemented and will operate across internal Buffer boundaries transparently.
  156. * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html) documentation for how these work.
  157. *
  158. * @param offset
  159. */
  160. readDoubleLE: Buffer['readDoubleLE'];
  161. /**
  162. * All of the standard byte-reading methods of the Buffer interface are implemented and will operate across internal Buffer boundaries transparently.
  163. * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html) documentation for how these work.
  164. *
  165. * @param offset
  166. */
  167. readFloatBE: Buffer['readFloatBE'];
  168. /**
  169. * All of the standard byte-reading methods of the Buffer interface are implemented and will operate across internal Buffer boundaries transparently.
  170. * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html) documentation for how these work.
  171. *
  172. * @param offset
  173. */
  174. readFloatLE: Buffer['readFloatLE'];
  175. /**
  176. * All of the standard byte-reading methods of the Buffer interface are implemented and will operate across internal Buffer boundaries transparently.
  177. * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html) documentation for how these work.
  178. *
  179. * @param offset
  180. */
  181. readInt32BE: Buffer['readInt32BE'];
  182. /**
  183. * All of the standard byte-reading methods of the Buffer interface are implemented and will operate across internal Buffer boundaries transparently.
  184. * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html) documentation for how these work.
  185. *
  186. * @param offset
  187. */
  188. readInt32LE: Buffer['readInt32LE'];
  189. /**
  190. * All of the standard byte-reading methods of the Buffer interface are implemented and will operate across internal Buffer boundaries transparently.
  191. * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html) documentation for how these work.
  192. *
  193. * @param offset
  194. */
  195. readUInt32BE: Buffer['readUInt32BE'];
  196. /**
  197. * All of the standard byte-reading methods of the Buffer interface are implemented and will operate across internal Buffer boundaries transparently.
  198. * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html) documentation for how these work.
  199. *
  200. * @param offset
  201. */
  202. readUInt32LE: Buffer['readUInt32LE'];
  203. /**
  204. * All of the standard byte-reading methods of the Buffer interface are implemented and will operate across internal Buffer boundaries transparently.
  205. * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html) documentation for how these work.
  206. *
  207. * @param offset
  208. */
  209. readInt16BE: Buffer['readInt16BE'];
  210. /**
  211. * All of the standard byte-reading methods of the Buffer interface are
  212. * implemented and will operate across internal Buffer boundaries transparently.
  213. *
  214. * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html)
  215. * documentation for how these work.
  216. *
  217. * @param offset
  218. */
  219. readInt16LE: Buffer['readInt16LE'];
  220. /**
  221. * All of the standard byte-reading methods of the Buffer interface are
  222. * implemented and will operate across internal Buffer boundaries transparently.
  223. *
  224. * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html)
  225. * documentation for how these work.
  226. *
  227. * @param offset
  228. */
  229. readUInt16BE: Buffer['readUInt16BE'];
  230. /**
  231. * All of the standard byte-reading methods of the Buffer interface are
  232. * implemented and will operate across internal Buffer boundaries transparently.
  233. *
  234. * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html)
  235. * documentation for how these work.
  236. *
  237. * @param offset
  238. */
  239. readUInt16LE: Buffer['readUInt16LE'];
  240. /**
  241. * All of the standard byte-reading methods of the Buffer interface are
  242. * implemented and will operate across internal Buffer boundaries transparently.
  243. *
  244. * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html)
  245. * documentation for how these work.
  246. *
  247. * @param offset
  248. */
  249. readInt8: Buffer['readInt8'];
  250. /**
  251. * All of the standard byte-reading methods of the Buffer interface are
  252. * implemented and will operate across internal Buffer boundaries transparently.
  253. *
  254. * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html)
  255. * documentation for how these work.
  256. *
  257. * @param offset
  258. */
  259. readUInt8: Buffer['readUInt8'];
  260. /**
  261. * All of the standard byte-reading methods of the Buffer interface are
  262. * implemented and will operate across internal Buffer boundaries transparently.
  263. *
  264. * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html)
  265. * documentation for how these work.
  266. *
  267. * @param offset
  268. */
  269. readIntBE: Buffer['readIntBE'];
  270. /**
  271. * All of the standard byte-reading methods of the Buffer interface are
  272. * implemented and will operate across internal Buffer boundaries transparently.
  273. *
  274. * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html)
  275. * documentation for how these work.
  276. *
  277. * @param offset
  278. */
  279. readIntLE: Buffer['readIntLE'];
  280. /**
  281. * All of the standard byte-reading methods of the Buffer interface are
  282. * implemented and will operate across internal Buffer boundaries transparently.
  283. *
  284. * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html)
  285. * documentation for how these work.
  286. *
  287. * @param offset
  288. */
  289. readUIntBE: Buffer['readUIntBE'];
  290. /**
  291. * All of the standard byte-reading methods of the Buffer interface are
  292. * implemented and will operate across internal Buffer boundaries transparently.
  293. *
  294. * See the [Buffer](http://nodejs.org/docs/latest/api/buffer.html)
  295. * documentation for how these work.
  296. *
  297. * @param offset
  298. */
  299. readUIntLE: Buffer['readUIntLE'];
  300. }
  301. /**
  302. * No arguments are required for the constructor, but you can initialise
  303. * the list by passing in a single Buffer object or an array of Buffer
  304. * objects.
  305. *
  306. * `new` is not strictly required, if you don't instantiate a new object,
  307. * it will be done automatically for you so you can create a new instance
  308. * simply with:
  309. *
  310. * ```js
  311. * const { BufferList } = require('bl')
  312. * const bl = BufferList()
  313. *
  314. * // equivalent to:
  315. *
  316. * const { BufferList } = require('bl')
  317. * const bl = new BufferList()
  318. * ```
  319. */
  320. declare const BufferList: BufferListConstructor;