[6a3a178] | 1 | /// <reference types="node" />
|
---|
| 2 | /**
|
---|
| 3 | * Object interface for constructing new SmartBuffer instances.
|
---|
| 4 | */
|
---|
| 5 | interface SmartBufferOptions {
|
---|
| 6 | encoding?: BufferEncoding;
|
---|
| 7 | size?: number;
|
---|
| 8 | buff?: Buffer;
|
---|
| 9 | }
|
---|
| 10 | declare class SmartBuffer {
|
---|
| 11 | length: number;
|
---|
| 12 | private _encoding;
|
---|
| 13 | private _buff;
|
---|
| 14 | private _writeOffset;
|
---|
| 15 | private _readOffset;
|
---|
| 16 | /**
|
---|
| 17 | * Creates a new SmartBuffer instance.
|
---|
| 18 | *
|
---|
| 19 | * @param options { SmartBufferOptions } The SmartBufferOptions to apply to this instance.
|
---|
| 20 | */
|
---|
| 21 | constructor(options?: SmartBufferOptions);
|
---|
| 22 | /**
|
---|
| 23 | * Creates a new SmartBuffer instance with the provided internal Buffer size and optional encoding.
|
---|
| 24 | *
|
---|
| 25 | * @param size { Number } The size of the internal Buffer.
|
---|
| 26 | * @param encoding { String } The BufferEncoding to use for strings.
|
---|
| 27 | *
|
---|
| 28 | * @return { SmartBuffer }
|
---|
| 29 | */
|
---|
| 30 | static fromSize(size: number, encoding?: BufferEncoding): SmartBuffer;
|
---|
| 31 | /**
|
---|
| 32 | * Creates a new SmartBuffer instance with the provided Buffer and optional encoding.
|
---|
| 33 | *
|
---|
| 34 | * @param buffer { Buffer } The Buffer to use as the internal Buffer value.
|
---|
| 35 | * @param encoding { String } The BufferEncoding to use for strings.
|
---|
| 36 | *
|
---|
| 37 | * @return { SmartBuffer }
|
---|
| 38 | */
|
---|
| 39 | static fromBuffer(buff: Buffer, encoding?: BufferEncoding): SmartBuffer;
|
---|
| 40 | /**
|
---|
| 41 | * Creates a new SmartBuffer instance with the provided SmartBufferOptions options.
|
---|
| 42 | *
|
---|
| 43 | * @param options { SmartBufferOptions } The options to use when creating the SmartBuffer instance.
|
---|
| 44 | */
|
---|
| 45 | static fromOptions(options: SmartBufferOptions): SmartBuffer;
|
---|
| 46 | /**
|
---|
| 47 | * Type checking function that determines if an object is a SmartBufferOptions object.
|
---|
| 48 | */
|
---|
| 49 | static isSmartBufferOptions(options: SmartBufferOptions): options is SmartBufferOptions;
|
---|
| 50 | /**
|
---|
| 51 | * Reads an Int8 value from the current read position or an optionally provided offset.
|
---|
| 52 | *
|
---|
| 53 | * @param offset { Number } The offset to read data from (optional)
|
---|
| 54 | * @return { Number }
|
---|
| 55 | */
|
---|
| 56 | readInt8(offset?: number): number;
|
---|
| 57 | /**
|
---|
| 58 | * Reads an Int16BE value from the current read position or an optionally provided offset.
|
---|
| 59 | *
|
---|
| 60 | * @param offset { Number } The offset to read data from (optional)
|
---|
| 61 | * @return { Number }
|
---|
| 62 | */
|
---|
| 63 | readInt16BE(offset?: number): number;
|
---|
| 64 | /**
|
---|
| 65 | * Reads an Int16LE value from the current read position or an optionally provided offset.
|
---|
| 66 | *
|
---|
| 67 | * @param offset { Number } The offset to read data from (optional)
|
---|
| 68 | * @return { Number }
|
---|
| 69 | */
|
---|
| 70 | readInt16LE(offset?: number): number;
|
---|
| 71 | /**
|
---|
| 72 | * Reads an Int32BE value from the current read position or an optionally provided offset.
|
---|
| 73 | *
|
---|
| 74 | * @param offset { Number } The offset to read data from (optional)
|
---|
| 75 | * @return { Number }
|
---|
| 76 | */
|
---|
| 77 | readInt32BE(offset?: number): number;
|
---|
| 78 | /**
|
---|
| 79 | * Reads an Int32LE value from the current read position or an optionally provided offset.
|
---|
| 80 | *
|
---|
| 81 | * @param offset { Number } The offset to read data from (optional)
|
---|
| 82 | * @return { Number }
|
---|
| 83 | */
|
---|
| 84 | readInt32LE(offset?: number): number;
|
---|
| 85 | /**
|
---|
| 86 | * Reads a BigInt64BE value from the current read position or an optionally provided offset.
|
---|
| 87 | *
|
---|
| 88 | * @param offset { Number } The offset to read data from (optional)
|
---|
| 89 | * @return { BigInt }
|
---|
| 90 | */
|
---|
| 91 | readBigInt64BE(offset?: number): bigint;
|
---|
| 92 | /**
|
---|
| 93 | * Reads a BigInt64LE value from the current read position or an optionally provided offset.
|
---|
| 94 | *
|
---|
| 95 | * @param offset { Number } The offset to read data from (optional)
|
---|
| 96 | * @return { BigInt }
|
---|
| 97 | */
|
---|
| 98 | readBigInt64LE(offset?: number): bigint;
|
---|
| 99 | /**
|
---|
| 100 | * Writes an Int8 value to the current write position (or at optional offset).
|
---|
| 101 | *
|
---|
| 102 | * @param value { Number } The value to write.
|
---|
| 103 | * @param offset { Number } The offset to write the value at.
|
---|
| 104 | *
|
---|
| 105 | * @return this
|
---|
| 106 | */
|
---|
| 107 | writeInt8(value: number, offset?: number): SmartBuffer;
|
---|
| 108 | /**
|
---|
| 109 | * Inserts an Int8 value at the given offset value.
|
---|
| 110 | *
|
---|
| 111 | * @param value { Number } The value to insert.
|
---|
| 112 | * @param offset { Number } The offset to insert the value at.
|
---|
| 113 | *
|
---|
| 114 | * @return this
|
---|
| 115 | */
|
---|
| 116 | insertInt8(value: number, offset: number): SmartBuffer;
|
---|
| 117 | /**
|
---|
| 118 | * Writes an Int16BE value to the current write position (or at optional offset).
|
---|
| 119 | *
|
---|
| 120 | * @param value { Number } The value to write.
|
---|
| 121 | * @param offset { Number } The offset to write the value at.
|
---|
| 122 | *
|
---|
| 123 | * @return this
|
---|
| 124 | */
|
---|
| 125 | writeInt16BE(value: number, offset?: number): SmartBuffer;
|
---|
| 126 | /**
|
---|
| 127 | * Inserts an Int16BE value at the given offset value.
|
---|
| 128 | *
|
---|
| 129 | * @param value { Number } The value to insert.
|
---|
| 130 | * @param offset { Number } The offset to insert the value at.
|
---|
| 131 | *
|
---|
| 132 | * @return this
|
---|
| 133 | */
|
---|
| 134 | insertInt16BE(value: number, offset: number): SmartBuffer;
|
---|
| 135 | /**
|
---|
| 136 | * Writes an Int16LE value to the current write position (or at optional offset).
|
---|
| 137 | *
|
---|
| 138 | * @param value { Number } The value to write.
|
---|
| 139 | * @param offset { Number } The offset to write the value at.
|
---|
| 140 | *
|
---|
| 141 | * @return this
|
---|
| 142 | */
|
---|
| 143 | writeInt16LE(value: number, offset?: number): SmartBuffer;
|
---|
| 144 | /**
|
---|
| 145 | * Inserts an Int16LE value at the given offset value.
|
---|
| 146 | *
|
---|
| 147 | * @param value { Number } The value to insert.
|
---|
| 148 | * @param offset { Number } The offset to insert the value at.
|
---|
| 149 | *
|
---|
| 150 | * @return this
|
---|
| 151 | */
|
---|
| 152 | insertInt16LE(value: number, offset: number): SmartBuffer;
|
---|
| 153 | /**
|
---|
| 154 | * Writes an Int32BE value to the current write position (or at optional offset).
|
---|
| 155 | *
|
---|
| 156 | * @param value { Number } The value to write.
|
---|
| 157 | * @param offset { Number } The offset to write the value at.
|
---|
| 158 | *
|
---|
| 159 | * @return this
|
---|
| 160 | */
|
---|
| 161 | writeInt32BE(value: number, offset?: number): SmartBuffer;
|
---|
| 162 | /**
|
---|
| 163 | * Inserts an Int32BE value at the given offset value.
|
---|
| 164 | *
|
---|
| 165 | * @param value { Number } The value to insert.
|
---|
| 166 | * @param offset { Number } The offset to insert the value at.
|
---|
| 167 | *
|
---|
| 168 | * @return this
|
---|
| 169 | */
|
---|
| 170 | insertInt32BE(value: number, offset: number): SmartBuffer;
|
---|
| 171 | /**
|
---|
| 172 | * Writes an Int32LE value to the current write position (or at optional offset).
|
---|
| 173 | *
|
---|
| 174 | * @param value { Number } The value to write.
|
---|
| 175 | * @param offset { Number } The offset to write the value at.
|
---|
| 176 | *
|
---|
| 177 | * @return this
|
---|
| 178 | */
|
---|
| 179 | writeInt32LE(value: number, offset?: number): SmartBuffer;
|
---|
| 180 | /**
|
---|
| 181 | * Inserts an Int32LE value at the given offset value.
|
---|
| 182 | *
|
---|
| 183 | * @param value { Number } The value to insert.
|
---|
| 184 | * @param offset { Number } The offset to insert the value at.
|
---|
| 185 | *
|
---|
| 186 | * @return this
|
---|
| 187 | */
|
---|
| 188 | insertInt32LE(value: number, offset: number): SmartBuffer;
|
---|
| 189 | /**
|
---|
| 190 | * Writes a BigInt64BE value to the current write position (or at optional offset).
|
---|
| 191 | *
|
---|
| 192 | * @param value { BigInt } The value to write.
|
---|
| 193 | * @param offset { Number } The offset to write the value at.
|
---|
| 194 | *
|
---|
| 195 | * @return this
|
---|
| 196 | */
|
---|
| 197 | writeBigInt64BE(value: bigint, offset?: number): SmartBuffer;
|
---|
| 198 | /**
|
---|
| 199 | * Inserts a BigInt64BE value at the given offset value.
|
---|
| 200 | *
|
---|
| 201 | * @param value { BigInt } The value to insert.
|
---|
| 202 | * @param offset { Number } The offset to insert the value at.
|
---|
| 203 | *
|
---|
| 204 | * @return this
|
---|
| 205 | */
|
---|
| 206 | insertBigInt64BE(value: bigint, offset: number): SmartBuffer;
|
---|
| 207 | /**
|
---|
| 208 | * Writes a BigInt64LE value to the current write position (or at optional offset).
|
---|
| 209 | *
|
---|
| 210 | * @param value { BigInt } The value to write.
|
---|
| 211 | * @param offset { Number } The offset to write the value at.
|
---|
| 212 | *
|
---|
| 213 | * @return this
|
---|
| 214 | */
|
---|
| 215 | writeBigInt64LE(value: bigint, offset?: number): SmartBuffer;
|
---|
| 216 | /**
|
---|
| 217 | * Inserts a Int64LE value at the given offset value.
|
---|
| 218 | *
|
---|
| 219 | * @param value { BigInt } The value to insert.
|
---|
| 220 | * @param offset { Number } The offset to insert the value at.
|
---|
| 221 | *
|
---|
| 222 | * @return this
|
---|
| 223 | */
|
---|
| 224 | insertBigInt64LE(value: bigint, offset: number): SmartBuffer;
|
---|
| 225 | /**
|
---|
| 226 | * Reads an UInt8 value from the current read position or an optionally provided offset.
|
---|
| 227 | *
|
---|
| 228 | * @param offset { Number } The offset to read data from (optional)
|
---|
| 229 | * @return { Number }
|
---|
| 230 | */
|
---|
| 231 | readUInt8(offset?: number): number;
|
---|
| 232 | /**
|
---|
| 233 | * Reads an UInt16BE value from the current read position or an optionally provided offset.
|
---|
| 234 | *
|
---|
| 235 | * @param offset { Number } The offset to read data from (optional)
|
---|
| 236 | * @return { Number }
|
---|
| 237 | */
|
---|
| 238 | readUInt16BE(offset?: number): number;
|
---|
| 239 | /**
|
---|
| 240 | * Reads an UInt16LE value from the current read position or an optionally provided offset.
|
---|
| 241 | *
|
---|
| 242 | * @param offset { Number } The offset to read data from (optional)
|
---|
| 243 | * @return { Number }
|
---|
| 244 | */
|
---|
| 245 | readUInt16LE(offset?: number): number;
|
---|
| 246 | /**
|
---|
| 247 | * Reads an UInt32BE value from the current read position or an optionally provided offset.
|
---|
| 248 | *
|
---|
| 249 | * @param offset { Number } The offset to read data from (optional)
|
---|
| 250 | * @return { Number }
|
---|
| 251 | */
|
---|
| 252 | readUInt32BE(offset?: number): number;
|
---|
| 253 | /**
|
---|
| 254 | * Reads an UInt32LE value from the current read position or an optionally provided offset.
|
---|
| 255 | *
|
---|
| 256 | * @param offset { Number } The offset to read data from (optional)
|
---|
| 257 | * @return { Number }
|
---|
| 258 | */
|
---|
| 259 | readUInt32LE(offset?: number): number;
|
---|
| 260 | /**
|
---|
| 261 | * Reads a BigUInt64BE value from the current read position or an optionally provided offset.
|
---|
| 262 | *
|
---|
| 263 | * @param offset { Number } The offset to read data from (optional)
|
---|
| 264 | * @return { BigInt }
|
---|
| 265 | */
|
---|
| 266 | readBigUInt64BE(offset?: number): bigint;
|
---|
| 267 | /**
|
---|
| 268 | * Reads a BigUInt64LE value from the current read position or an optionally provided offset.
|
---|
| 269 | *
|
---|
| 270 | * @param offset { Number } The offset to read data from (optional)
|
---|
| 271 | * @return { BigInt }
|
---|
| 272 | */
|
---|
| 273 | readBigUInt64LE(offset?: number): bigint;
|
---|
| 274 | /**
|
---|
| 275 | * Writes an UInt8 value to the current write position (or at optional offset).
|
---|
| 276 | *
|
---|
| 277 | * @param value { Number } The value to write.
|
---|
| 278 | * @param offset { Number } The offset to write the value at.
|
---|
| 279 | *
|
---|
| 280 | * @return this
|
---|
| 281 | */
|
---|
| 282 | writeUInt8(value: number, offset?: number): SmartBuffer;
|
---|
| 283 | /**
|
---|
| 284 | * Inserts an UInt8 value at the given offset value.
|
---|
| 285 | *
|
---|
| 286 | * @param value { Number } The value to insert.
|
---|
| 287 | * @param offset { Number } The offset to insert the value at.
|
---|
| 288 | *
|
---|
| 289 | * @return this
|
---|
| 290 | */
|
---|
| 291 | insertUInt8(value: number, offset: number): SmartBuffer;
|
---|
| 292 | /**
|
---|
| 293 | * Writes an UInt16BE value to the current write position (or at optional offset).
|
---|
| 294 | *
|
---|
| 295 | * @param value { Number } The value to write.
|
---|
| 296 | * @param offset { Number } The offset to write the value at.
|
---|
| 297 | *
|
---|
| 298 | * @return this
|
---|
| 299 | */
|
---|
| 300 | writeUInt16BE(value: number, offset?: number): SmartBuffer;
|
---|
| 301 | /**
|
---|
| 302 | * Inserts an UInt16BE value at the given offset value.
|
---|
| 303 | *
|
---|
| 304 | * @param value { Number } The value to insert.
|
---|
| 305 | * @param offset { Number } The offset to insert the value at.
|
---|
| 306 | *
|
---|
| 307 | * @return this
|
---|
| 308 | */
|
---|
| 309 | insertUInt16BE(value: number, offset: number): SmartBuffer;
|
---|
| 310 | /**
|
---|
| 311 | * Writes an UInt16LE value to the current write position (or at optional offset).
|
---|
| 312 | *
|
---|
| 313 | * @param value { Number } The value to write.
|
---|
| 314 | * @param offset { Number } The offset to write the value at.
|
---|
| 315 | *
|
---|
| 316 | * @return this
|
---|
| 317 | */
|
---|
| 318 | writeUInt16LE(value: number, offset?: number): SmartBuffer;
|
---|
| 319 | /**
|
---|
| 320 | * Inserts an UInt16LE value at the given offset value.
|
---|
| 321 | *
|
---|
| 322 | * @param value { Number } The value to insert.
|
---|
| 323 | * @param offset { Number } The offset to insert the value at.
|
---|
| 324 | *
|
---|
| 325 | * @return this
|
---|
| 326 | */
|
---|
| 327 | insertUInt16LE(value: number, offset: number): SmartBuffer;
|
---|
| 328 | /**
|
---|
| 329 | * Writes an UInt32BE value to the current write position (or at optional offset).
|
---|
| 330 | *
|
---|
| 331 | * @param value { Number } The value to write.
|
---|
| 332 | * @param offset { Number } The offset to write the value at.
|
---|
| 333 | *
|
---|
| 334 | * @return this
|
---|
| 335 | */
|
---|
| 336 | writeUInt32BE(value: number, offset?: number): SmartBuffer;
|
---|
| 337 | /**
|
---|
| 338 | * Inserts an UInt32BE value at the given offset value.
|
---|
| 339 | *
|
---|
| 340 | * @param value { Number } The value to insert.
|
---|
| 341 | * @param offset { Number } The offset to insert the value at.
|
---|
| 342 | *
|
---|
| 343 | * @return this
|
---|
| 344 | */
|
---|
| 345 | insertUInt32BE(value: number, offset: number): SmartBuffer;
|
---|
| 346 | /**
|
---|
| 347 | * Writes an UInt32LE value to the current write position (or at optional offset).
|
---|
| 348 | *
|
---|
| 349 | * @param value { Number } The value to write.
|
---|
| 350 | * @param offset { Number } The offset to write the value at.
|
---|
| 351 | *
|
---|
| 352 | * @return this
|
---|
| 353 | */
|
---|
| 354 | writeUInt32LE(value: number, offset?: number): SmartBuffer;
|
---|
| 355 | /**
|
---|
| 356 | * Inserts an UInt32LE value at the given offset value.
|
---|
| 357 | *
|
---|
| 358 | * @param value { Number } The value to insert.
|
---|
| 359 | * @param offset { Number } The offset to insert the value at.
|
---|
| 360 | *
|
---|
| 361 | * @return this
|
---|
| 362 | */
|
---|
| 363 | insertUInt32LE(value: number, offset: number): SmartBuffer;
|
---|
| 364 | /**
|
---|
| 365 | * Writes a BigUInt64BE value to the current write position (or at optional offset).
|
---|
| 366 | *
|
---|
| 367 | * @param value { Number } The value to write.
|
---|
| 368 | * @param offset { Number } The offset to write the value at.
|
---|
| 369 | *
|
---|
| 370 | * @return this
|
---|
| 371 | */
|
---|
| 372 | writeBigUInt64BE(value: bigint, offset?: number): SmartBuffer;
|
---|
| 373 | /**
|
---|
| 374 | * Inserts a BigUInt64BE value at the given offset value.
|
---|
| 375 | *
|
---|
| 376 | * @param value { Number } The value to insert.
|
---|
| 377 | * @param offset { Number } The offset to insert the value at.
|
---|
| 378 | *
|
---|
| 379 | * @return this
|
---|
| 380 | */
|
---|
| 381 | insertBigUInt64BE(value: bigint, offset: number): SmartBuffer;
|
---|
| 382 | /**
|
---|
| 383 | * Writes a BigUInt64LE value to the current write position (or at optional offset).
|
---|
| 384 | *
|
---|
| 385 | * @param value { Number } The value to write.
|
---|
| 386 | * @param offset { Number } The offset to write the value at.
|
---|
| 387 | *
|
---|
| 388 | * @return this
|
---|
| 389 | */
|
---|
| 390 | writeBigUInt64LE(value: bigint, offset?: number): SmartBuffer;
|
---|
| 391 | /**
|
---|
| 392 | * Inserts a BigUInt64LE value at the given offset value.
|
---|
| 393 | *
|
---|
| 394 | * @param value { Number } The value to insert.
|
---|
| 395 | * @param offset { Number } The offset to insert the value at.
|
---|
| 396 | *
|
---|
| 397 | * @return this
|
---|
| 398 | */
|
---|
| 399 | insertBigUInt64LE(value: bigint, offset: number): SmartBuffer;
|
---|
| 400 | /**
|
---|
| 401 | * Reads an FloatBE value from the current read position or an optionally provided offset.
|
---|
| 402 | *
|
---|
| 403 | * @param offset { Number } The offset to read data from (optional)
|
---|
| 404 | * @return { Number }
|
---|
| 405 | */
|
---|
| 406 | readFloatBE(offset?: number): number;
|
---|
| 407 | /**
|
---|
| 408 | * Reads an FloatLE value from the current read position or an optionally provided offset.
|
---|
| 409 | *
|
---|
| 410 | * @param offset { Number } The offset to read data from (optional)
|
---|
| 411 | * @return { Number }
|
---|
| 412 | */
|
---|
| 413 | readFloatLE(offset?: number): number;
|
---|
| 414 | /**
|
---|
| 415 | * Writes a FloatBE value to the current write position (or at optional offset).
|
---|
| 416 | *
|
---|
| 417 | * @param value { Number } The value to write.
|
---|
| 418 | * @param offset { Number } The offset to write the value at.
|
---|
| 419 | *
|
---|
| 420 | * @return this
|
---|
| 421 | */
|
---|
| 422 | writeFloatBE(value: number, offset?: number): SmartBuffer;
|
---|
| 423 | /**
|
---|
| 424 | * Inserts a FloatBE value at the given offset value.
|
---|
| 425 | *
|
---|
| 426 | * @param value { Number } The value to insert.
|
---|
| 427 | * @param offset { Number } The offset to insert the value at.
|
---|
| 428 | *
|
---|
| 429 | * @return this
|
---|
| 430 | */
|
---|
| 431 | insertFloatBE(value: number, offset: number): SmartBuffer;
|
---|
| 432 | /**
|
---|
| 433 | * Writes a FloatLE value to the current write position (or at optional offset).
|
---|
| 434 | *
|
---|
| 435 | * @param value { Number } The value to write.
|
---|
| 436 | * @param offset { Number } The offset to write the value at.
|
---|
| 437 | *
|
---|
| 438 | * @return this
|
---|
| 439 | */
|
---|
| 440 | writeFloatLE(value: number, offset?: number): SmartBuffer;
|
---|
| 441 | /**
|
---|
| 442 | * Inserts a FloatLE value at the given offset value.
|
---|
| 443 | *
|
---|
| 444 | * @param value { Number } The value to insert.
|
---|
| 445 | * @param offset { Number } The offset to insert the value at.
|
---|
| 446 | *
|
---|
| 447 | * @return this
|
---|
| 448 | */
|
---|
| 449 | insertFloatLE(value: number, offset: number): SmartBuffer;
|
---|
| 450 | /**
|
---|
| 451 | * Reads an DoublEBE value from the current read position or an optionally provided offset.
|
---|
| 452 | *
|
---|
| 453 | * @param offset { Number } The offset to read data from (optional)
|
---|
| 454 | * @return { Number }
|
---|
| 455 | */
|
---|
| 456 | readDoubleBE(offset?: number): number;
|
---|
| 457 | /**
|
---|
| 458 | * Reads an DoubleLE value from the current read position or an optionally provided offset.
|
---|
| 459 | *
|
---|
| 460 | * @param offset { Number } The offset to read data from (optional)
|
---|
| 461 | * @return { Number }
|
---|
| 462 | */
|
---|
| 463 | readDoubleLE(offset?: number): number;
|
---|
| 464 | /**
|
---|
| 465 | * Writes a DoubleBE value to the current write position (or at optional offset).
|
---|
| 466 | *
|
---|
| 467 | * @param value { Number } The value to write.
|
---|
| 468 | * @param offset { Number } The offset to write the value at.
|
---|
| 469 | *
|
---|
| 470 | * @return this
|
---|
| 471 | */
|
---|
| 472 | writeDoubleBE(value: number, offset?: number): SmartBuffer;
|
---|
| 473 | /**
|
---|
| 474 | * Inserts a DoubleBE value at the given offset value.
|
---|
| 475 | *
|
---|
| 476 | * @param value { Number } The value to insert.
|
---|
| 477 | * @param offset { Number } The offset to insert the value at.
|
---|
| 478 | *
|
---|
| 479 | * @return this
|
---|
| 480 | */
|
---|
| 481 | insertDoubleBE(value: number, offset: number): SmartBuffer;
|
---|
| 482 | /**
|
---|
| 483 | * Writes a DoubleLE value to the current write position (or at optional offset).
|
---|
| 484 | *
|
---|
| 485 | * @param value { Number } The value to write.
|
---|
| 486 | * @param offset { Number } The offset to write the value at.
|
---|
| 487 | *
|
---|
| 488 | * @return this
|
---|
| 489 | */
|
---|
| 490 | writeDoubleLE(value: number, offset?: number): SmartBuffer;
|
---|
| 491 | /**
|
---|
| 492 | * Inserts a DoubleLE value at the given offset value.
|
---|
| 493 | *
|
---|
| 494 | * @param value { Number } The value to insert.
|
---|
| 495 | * @param offset { Number } The offset to insert the value at.
|
---|
| 496 | *
|
---|
| 497 | * @return this
|
---|
| 498 | */
|
---|
| 499 | insertDoubleLE(value: number, offset: number): SmartBuffer;
|
---|
| 500 | /**
|
---|
| 501 | * Reads a String from the current read position.
|
---|
| 502 | *
|
---|
| 503 | * @param arg1 { Number | String } The number of bytes to read as a String, or the BufferEncoding to use for
|
---|
| 504 | * the string (Defaults to instance level encoding).
|
---|
| 505 | * @param encoding { String } The BufferEncoding to use for the string (Defaults to instance level encoding).
|
---|
| 506 | *
|
---|
| 507 | * @return { String }
|
---|
| 508 | */
|
---|
| 509 | readString(arg1?: number | BufferEncoding, encoding?: BufferEncoding): string;
|
---|
| 510 | /**
|
---|
| 511 | * Inserts a String
|
---|
| 512 | *
|
---|
| 513 | * @param value { String } The String value to insert.
|
---|
| 514 | * @param offset { Number } The offset to insert the string at.
|
---|
| 515 | * @param encoding { String } The BufferEncoding to use for writing strings (defaults to instance encoding).
|
---|
| 516 | *
|
---|
| 517 | * @return this
|
---|
| 518 | */
|
---|
| 519 | insertString(value: string, offset: number, encoding?: BufferEncoding): SmartBuffer;
|
---|
| 520 | /**
|
---|
| 521 | * Writes a String
|
---|
| 522 | *
|
---|
| 523 | * @param value { String } The String value to write.
|
---|
| 524 | * @param arg2 { Number | String } The offset to write the string at, or the BufferEncoding to use.
|
---|
| 525 | * @param encoding { String } The BufferEncoding to use for writing strings (defaults to instance encoding).
|
---|
| 526 | *
|
---|
| 527 | * @return this
|
---|
| 528 | */
|
---|
| 529 | writeString(value: string, arg2?: number | BufferEncoding, encoding?: BufferEncoding): SmartBuffer;
|
---|
| 530 | /**
|
---|
| 531 | * Reads a null-terminated String from the current read position.
|
---|
| 532 | *
|
---|
| 533 | * @param encoding { String } The BufferEncoding to use for the string (Defaults to instance level encoding).
|
---|
| 534 | *
|
---|
| 535 | * @return { String }
|
---|
| 536 | */
|
---|
| 537 | readStringNT(encoding?: BufferEncoding): string;
|
---|
| 538 | /**
|
---|
| 539 | * Inserts a null-terminated String.
|
---|
| 540 | *
|
---|
| 541 | * @param value { String } The String value to write.
|
---|
| 542 | * @param arg2 { Number | String } The offset to write the string to, or the BufferEncoding to use.
|
---|
| 543 | * @param encoding { String } The BufferEncoding to use for writing strings (defaults to instance encoding).
|
---|
| 544 | *
|
---|
| 545 | * @return this
|
---|
| 546 | */
|
---|
| 547 | insertStringNT(value: string, offset: number, encoding?: BufferEncoding): SmartBuffer;
|
---|
| 548 | /**
|
---|
| 549 | * Writes a null-terminated String.
|
---|
| 550 | *
|
---|
| 551 | * @param value { String } The String value to write.
|
---|
| 552 | * @param arg2 { Number | String } The offset to write the string to, or the BufferEncoding to use.
|
---|
| 553 | * @param encoding { String } The BufferEncoding to use for writing strings (defaults to instance encoding).
|
---|
| 554 | *
|
---|
| 555 | * @return this
|
---|
| 556 | */
|
---|
| 557 | writeStringNT(value: string, arg2?: number | BufferEncoding, encoding?: BufferEncoding): SmartBuffer;
|
---|
| 558 | /**
|
---|
| 559 | * Reads a Buffer from the internal read position.
|
---|
| 560 | *
|
---|
| 561 | * @param length { Number } The length of data to read as a Buffer.
|
---|
| 562 | *
|
---|
| 563 | * @return { Buffer }
|
---|
| 564 | */
|
---|
| 565 | readBuffer(length?: number): Buffer;
|
---|
| 566 | /**
|
---|
| 567 | * Writes a Buffer to the current write position.
|
---|
| 568 | *
|
---|
| 569 | * @param value { Buffer } The Buffer to write.
|
---|
| 570 | * @param offset { Number } The offset to write the Buffer to.
|
---|
| 571 | *
|
---|
| 572 | * @return this
|
---|
| 573 | */
|
---|
| 574 | insertBuffer(value: Buffer, offset: number): SmartBuffer;
|
---|
| 575 | /**
|
---|
| 576 | * Writes a Buffer to the current write position.
|
---|
| 577 | *
|
---|
| 578 | * @param value { Buffer } The Buffer to write.
|
---|
| 579 | * @param offset { Number } The offset to write the Buffer to.
|
---|
| 580 | *
|
---|
| 581 | * @return this
|
---|
| 582 | */
|
---|
| 583 | writeBuffer(value: Buffer, offset?: number): SmartBuffer;
|
---|
| 584 | /**
|
---|
| 585 | * Reads a null-terminated Buffer from the current read poisiton.
|
---|
| 586 | *
|
---|
| 587 | * @return { Buffer }
|
---|
| 588 | */
|
---|
| 589 | readBufferNT(): Buffer;
|
---|
| 590 | /**
|
---|
| 591 | * Inserts a null-terminated Buffer.
|
---|
| 592 | *
|
---|
| 593 | * @param value { Buffer } The Buffer to write.
|
---|
| 594 | * @param offset { Number } The offset to write the Buffer to.
|
---|
| 595 | *
|
---|
| 596 | * @return this
|
---|
| 597 | */
|
---|
| 598 | insertBufferNT(value: Buffer, offset: number): SmartBuffer;
|
---|
| 599 | /**
|
---|
| 600 | * Writes a null-terminated Buffer.
|
---|
| 601 | *
|
---|
| 602 | * @param value { Buffer } The Buffer to write.
|
---|
| 603 | * @param offset { Number } The offset to write the Buffer to.
|
---|
| 604 | *
|
---|
| 605 | * @return this
|
---|
| 606 | */
|
---|
| 607 | writeBufferNT(value: Buffer, offset?: number): SmartBuffer;
|
---|
| 608 | /**
|
---|
| 609 | * Clears the SmartBuffer instance to its original empty state.
|
---|
| 610 | */
|
---|
| 611 | clear(): SmartBuffer;
|
---|
| 612 | /**
|
---|
| 613 | * Gets the remaining data left to be read from the SmartBuffer instance.
|
---|
| 614 | *
|
---|
| 615 | * @return { Number }
|
---|
| 616 | */
|
---|
| 617 | remaining(): number;
|
---|
| 618 | /**
|
---|
| 619 | * Gets the current read offset value of the SmartBuffer instance.
|
---|
| 620 | *
|
---|
| 621 | * @return { Number }
|
---|
| 622 | */
|
---|
| 623 | /**
|
---|
| 624 | * Sets the read offset value of the SmartBuffer instance.
|
---|
| 625 | *
|
---|
| 626 | * @param offset { Number } - The offset value to set.
|
---|
| 627 | */
|
---|
| 628 | readOffset: number;
|
---|
| 629 | /**
|
---|
| 630 | * Gets the current write offset value of the SmartBuffer instance.
|
---|
| 631 | *
|
---|
| 632 | * @return { Number }
|
---|
| 633 | */
|
---|
| 634 | /**
|
---|
| 635 | * Sets the write offset value of the SmartBuffer instance.
|
---|
| 636 | *
|
---|
| 637 | * @param offset { Number } - The offset value to set.
|
---|
| 638 | */
|
---|
| 639 | writeOffset: number;
|
---|
| 640 | /**
|
---|
| 641 | * Gets the currently set string encoding of the SmartBuffer instance.
|
---|
| 642 | *
|
---|
| 643 | * @return { BufferEncoding } The string Buffer encoding currently set.
|
---|
| 644 | */
|
---|
| 645 | /**
|
---|
| 646 | * Sets the string encoding of the SmartBuffer instance.
|
---|
| 647 | *
|
---|
| 648 | * @param encoding { BufferEncoding } The string Buffer encoding to set.
|
---|
| 649 | */
|
---|
| 650 | encoding: BufferEncoding;
|
---|
| 651 | /**
|
---|
| 652 | * Gets the underlying internal Buffer. (This includes unmanaged data in the Buffer)
|
---|
| 653 | *
|
---|
| 654 | * @return { Buffer } The Buffer value.
|
---|
| 655 | */
|
---|
| 656 | readonly internalBuffer: Buffer;
|
---|
| 657 | /**
|
---|
| 658 | * Gets the value of the internal managed Buffer (Includes managed data only)
|
---|
| 659 | *
|
---|
| 660 | * @param { Buffer }
|
---|
| 661 | */
|
---|
| 662 | toBuffer(): Buffer;
|
---|
| 663 | /**
|
---|
| 664 | * Gets the String value of the internal managed Buffer
|
---|
| 665 | *
|
---|
| 666 | * @param encoding { String } The BufferEncoding to display the Buffer as (defaults to instance level encoding).
|
---|
| 667 | */
|
---|
| 668 | toString(encoding?: BufferEncoding): string;
|
---|
| 669 | /**
|
---|
| 670 | * Destroys the SmartBuffer instance.
|
---|
| 671 | */
|
---|
| 672 | destroy(): SmartBuffer;
|
---|
| 673 | /**
|
---|
| 674 | * Handles inserting and writing strings.
|
---|
| 675 | *
|
---|
| 676 | * @param value { String } The String value to insert.
|
---|
| 677 | * @param isInsert { Boolean } True if inserting a string, false if writing.
|
---|
| 678 | * @param arg2 { Number | String } The offset to insert the string at, or the BufferEncoding to use.
|
---|
| 679 | * @param encoding { String } The BufferEncoding to use for writing strings (defaults to instance encoding).
|
---|
| 680 | */
|
---|
| 681 | private _handleString;
|
---|
| 682 | /**
|
---|
| 683 | * Handles writing or insert of a Buffer.
|
---|
| 684 | *
|
---|
| 685 | * @param value { Buffer } The Buffer to write.
|
---|
| 686 | * @param offset { Number } The offset to write the Buffer to.
|
---|
| 687 | */
|
---|
| 688 | private _handleBuffer;
|
---|
| 689 | /**
|
---|
| 690 | * Ensures that the internal Buffer is large enough to read data.
|
---|
| 691 | *
|
---|
| 692 | * @param length { Number } The length of the data that needs to be read.
|
---|
| 693 | * @param offset { Number } The offset of the data that needs to be read.
|
---|
| 694 | */
|
---|
| 695 | private ensureReadable;
|
---|
| 696 | /**
|
---|
| 697 | * Ensures that the internal Buffer is large enough to insert data.
|
---|
| 698 | *
|
---|
| 699 | * @param dataLength { Number } The length of the data that needs to be written.
|
---|
| 700 | * @param offset { Number } The offset of the data to be written.
|
---|
| 701 | */
|
---|
| 702 | private ensureInsertable;
|
---|
| 703 | /**
|
---|
| 704 | * Ensures that the internal Buffer is large enough to write data.
|
---|
| 705 | *
|
---|
| 706 | * @param dataLength { Number } The length of the data that needs to be written.
|
---|
| 707 | * @param offset { Number } The offset of the data to be written (defaults to writeOffset).
|
---|
| 708 | */
|
---|
| 709 | private _ensureWriteable;
|
---|
| 710 | /**
|
---|
| 711 | * Ensures that the internal Buffer is large enough to write at least the given amount of data.
|
---|
| 712 | *
|
---|
| 713 | * @param minLength { Number } The minimum length of the data needs to be written.
|
---|
| 714 | */
|
---|
| 715 | private _ensureCapacity;
|
---|
| 716 | /**
|
---|
| 717 | * Reads a numeric number value using the provided function.
|
---|
| 718 | *
|
---|
| 719 | * @typeparam T { number | bigint } The type of the value to be read
|
---|
| 720 | *
|
---|
| 721 | * @param func { Function(offset: number) => number } The function to read data on the internal Buffer with.
|
---|
| 722 | * @param byteSize { Number } The number of bytes read.
|
---|
| 723 | * @param offset { Number } The offset to read from (optional). When this is not provided, the managed readOffset is used instead.
|
---|
| 724 | *
|
---|
| 725 | * @returns { T } the number value
|
---|
| 726 | */
|
---|
| 727 | private _readNumberValue;
|
---|
| 728 | /**
|
---|
| 729 | * Inserts a numeric number value based on the given offset and value.
|
---|
| 730 | *
|
---|
| 731 | * @typeparam T { number | bigint } The type of the value to be written
|
---|
| 732 | *
|
---|
| 733 | * @param func { Function(offset: T, offset?) => number} The function to write data on the internal Buffer with.
|
---|
| 734 | * @param byteSize { Number } The number of bytes written.
|
---|
| 735 | * @param value { T } The number value to write.
|
---|
| 736 | * @param offset { Number } the offset to write the number at (REQUIRED).
|
---|
| 737 | *
|
---|
| 738 | * @returns SmartBuffer this buffer
|
---|
| 739 | */
|
---|
| 740 | private _insertNumberValue;
|
---|
| 741 | /**
|
---|
| 742 | * Writes a numeric number value based on the given offset and value.
|
---|
| 743 | *
|
---|
| 744 | * @typeparam T { number | bigint } The type of the value to be written
|
---|
| 745 | *
|
---|
| 746 | * @param func { Function(offset: T, offset?) => number} The function to write data on the internal Buffer with.
|
---|
| 747 | * @param byteSize { Number } The number of bytes written.
|
---|
| 748 | * @param value { T } The number value to write.
|
---|
| 749 | * @param offset { Number } the offset to write the number at (REQUIRED).
|
---|
| 750 | *
|
---|
| 751 | * @returns SmartBuffer this buffer
|
---|
| 752 | */
|
---|
| 753 | private _writeNumberValue;
|
---|
| 754 | }
|
---|
| 755 | export { SmartBufferOptions, SmartBuffer };
|
---|