bireader 2.0.0 → 3.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.
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
- # BiReader
1
+ # BiReader / BiWriter
2
2
 
3
- A feature rich binary reader and writer that keeps track of your position to quickly create file structures. Includes shared naming conventions, programmable inputs and advanced math for easy data conversions to do low level parsing. Accepts `Uint8Array` or `Buffer`.
3
+ A feature rich binary reader ***and writer*** that keeps track of your position to quickly create file structures. Includes shared naming conventions, programmable inputs and advanced math for easy data conversions on low level parsing. Accepts `Uint8Array` or `Buffer`.
4
4
 
5
- Supported data types are:
5
+ Supported data types:
6
6
 
7
7
  - [Bitfields](#bit-field) ([u]bit{1-32}{le|be}) 1-32 bit signed or unsigned value in big or little endian order
8
8
  - [Bytes](#byte) ([u]int8, byte) 8 bit signed or unsigned value
@@ -14,6 +14,21 @@ Supported data types are:
14
14
  - [Double Floats](#double-float) (doublefloat, dfloat{le|be}) 64 bit decimal value in big or little endian
15
15
  - [Strings](#strings) (string) Fixed and non-fixed length, UTF, pascal, wide pascal. Includes all ```TextEncoder``` types
16
16
 
17
+ ## What's New?
18
+
19
+ ### v3.0
20
+ * Added better option for extending array buffer when writing data with ``extendBufferSize``.
21
+ * Consolidated all options argument into single object when creating class.
22
+ * Removed deprecated ``bireader`` and ``biwriter`` classes.
23
+ * Fixed standalone hexdump function.
24
+
25
+ ### v2.0
26
+ * Created new ``BiReader`` and ``BiWriter`` classes with easier *get* and *set* functions for faster coding.
27
+
28
+ ### v1.0
29
+ * Included math functions and value searches.
30
+ * Many bug fixes.
31
+
17
32
  ## Installation
18
33
 
19
34
  ```npm install bireader```
@@ -288,18 +303,18 @@ Common functions for setup, movement, manipulation and math shared by both.
288
303
  <tr>
289
304
  <tr>
290
305
  <td>Name</td>
291
- <td>new BiReader(<b>data</b>, byteOffset, bitOffset, endianess, strict)</td>
292
- <td align="center" rowspan="2"><b>Buffer or Uint8Array</b>, byte offset (default 0), bit offset (default 0), endian big or little (default little), strict mode true to restrict extending initially supplied data (default true for reader, false for writer)
306
+ <td>new BiReader(<b>data</b>, {byteOffset, bitOffset, endianess, strict, extendBufferSize})</td>
307
+ <td align="center" rowspan="2"><b>Buffer or Uint8Array</b>, byte offset (default 0), bit offset (default 0), endian big or little (default little), strict mode true to restrict extending initially supplied data (default true for reader, false for writer), extended Buffer size amount.
293
308
  </td>
294
- <td rowspan="2">Start with new Constructor.<br><br><b>Note:</b> Supplied data can always be found with .data.<br><br><b>BiWriter note:</b> while BiWriter can be created with a 0 length Uint8array or Buffer, each new value write will create a new array and concat the two. For large data writes this will lead to a degraded performance. It's best to supply a larger than needed buffer to start and use .trim() after you're finished.</td>
309
+ <td rowspan="2">Start with new Constructor.<br><br><b>Note:</b> Supplied data can always be found with .data.<br><br><b>Writing data note:</b> while BiWriter can be created with a 0 length Uint8Array or Buffer, each new value write will create a new array and concat the two. For large data writes this will lead to a degraded performance. It's best to supply a larger than needed buffer when creating the Writer and use .trim() after you're finished. You can also set the extendBufferSize value to always extend by a fixed amount when reaching the end. This will also change the logic for .return and .get to trim the remining data from the current position for you. Use .data instead if you want to get the whole padded buffer array.</td>
295
310
  </tr>
296
311
  <tr>
297
312
  <td>Name</td>
298
- <td>new BiWriter(data, byteOffset, bitOffset, endianess, strict)</td>
313
+ <td>new BiWriter(data, {byteOffset, bitOffset, endianess, strict, extendBufferSize})</td>
299
314
  </tr>
300
315
  <tr>
301
316
  <td>Name</td>
302
- <td>endianness(<b>bigOrLittle</b>)</td>
317
+ <td>endianness(<b>"big" | "little"</b>)</td>
303
318
  <td align="center" rowspan="2"><b>big</b> or <b>little</b> (default little)</td>
304
319
  <td rowspan="2">Set or change Endian. Can be changed at any time.</td>
305
320
  </tr>
@@ -310,7 +325,7 @@ Common functions for setup, movement, manipulation and math shared by both.
310
325
  <tr>
311
326
  <td>Name</td>
312
327
  <td>length</td>
313
- <td align="center" rowspan="2">none</td>
328
+ <td align="center" rowspan="2">None</td>
314
329
  <td rowspan="2">Gets the current buffer size in bytes.</td>
315
330
  </tr>
316
331
  <tr>
@@ -320,7 +335,7 @@ Common functions for setup, movement, manipulation and math shared by both.
320
335
  <tr>
321
336
  <td>Name</td>
322
337
  <td>lengthB</td>
323
- <td align="center" rowspan="2">none</td>
338
+ <td align="center" rowspan="2">None</td>
324
339
  <td rowspan="2">Gets the current buffer size in bits.</td>
325
340
  </tr>
326
341
  <tr>
@@ -330,7 +345,7 @@ Common functions for setup, movement, manipulation and math shared by both.
330
345
  <tr>
331
346
  <td>Name</td>
332
347
  <td>getOffset</td>
333
- <td align="center" rowspan="2">none</td>
348
+ <td align="center" rowspan="2">None</td>
334
349
  <td rowspan="2">Gets current byte position.</td>
335
350
  </tr>
336
351
  <tr>
@@ -340,7 +355,7 @@ Common functions for setup, movement, manipulation and math shared by both.
340
355
  <tr>
341
356
  <td>Name</td>
342
357
  <td>getOffsetBit</td>
343
- <td align="center" rowspan="2">none</td>
358
+ <td align="center" rowspan="2">None</td>
344
359
  <td rowspan="2">Gets current byte's bit position (0-7).</td>
345
360
  </tr>
346
361
  <tr>
@@ -350,7 +365,7 @@ Common functions for setup, movement, manipulation and math shared by both.
350
365
  <tr>
351
366
  <td>Name</td>
352
367
  <td>getOffsetAbsBit</td>
353
- <td align="center" rowspan="2">none</td>
368
+ <td align="center" rowspan="2">None</td>
354
369
  <td rowspan="2">Gets current absolute bit position from start of data.</td>
355
370
  </tr>
356
371
  <tr>
@@ -360,7 +375,7 @@ Common functions for setup, movement, manipulation and math shared by both.
360
375
  <tr>
361
376
  <td>Name</td>
362
377
  <td>remain</td>
363
- <td align="center" rowspan="2">none</td>
378
+ <td align="center" rowspan="2">None</td>
364
379
  <td rowspan="2">Size in bytes of current read position to the end.</td>
365
380
  </tr>
366
381
  <tr>
@@ -370,7 +385,7 @@ Common functions for setup, movement, manipulation and math shared by both.
370
385
  <tr>
371
386
  <td>Name</td>
372
387
  <td>remainB</td>
373
- <td align="center" rowspan="2">none</td>
388
+ <td align="center" rowspan="2">None</td>
374
389
  <td rowspan="2">Size in bits of current read position to the end.</td>
375
390
  </tr>
376
391
  <tr>
@@ -380,7 +395,7 @@ Common functions for setup, movement, manipulation and math shared by both.
380
395
  <tr>
381
396
  <td>Name</td>
382
397
  <td>getLine</td>
383
- <td align="center" rowspan="2">none</td>
398
+ <td align="center" rowspan="2">None</td>
384
399
  <td rowspan="2">Row line of the file (16 bytes per row).</td>
385
400
  </tr>
386
401
  <tr>
@@ -390,12 +405,18 @@ Common functions for setup, movement, manipulation and math shared by both.
390
405
  <tr>
391
406
  <td>Name</td>
392
407
  <td>get</td>
393
- <td align="center" rowspan="2">none</td>
394
- <td rowspan="2">Returns supplied data.</td>
408
+ <td align="center" rowspan="2">None</td>
409
+ <td rowspan="2">Returns supplied data. <b>Note:</b> Will use .trim() command if extendBufferSize is set (removes all data after current position). Use .data if you want the full padded data buffer.</td>
395
410
  </tr>
396
411
  <tr>
397
412
  <td>Aliases</td>
398
- <td>return, data</td>
413
+ <td>return</td>
414
+ </tr>
415
+ <tr>
416
+ <td>Name</td>
417
+ <td>data</td>
418
+ <td align="center">None</td>
419
+ <td >Returns full current buffer data.</td>
399
420
  </tr>
400
421
  <tr>
401
422
  <td>Name</td>
@@ -418,19 +439,19 @@ Common functions for setup, movement, manipulation and math shared by both.
418
439
  <tr>
419
440
  <td>Name</td>
420
441
  <td>unrestrict()</td>
421
- <td align="center">none</td>
442
+ <td align="center">None</td>
422
443
  <td>Sets strict mode to false, will extend array if data is outside of max size (<b>default true for reader, false for writer</b>)</td>
423
444
  </tr>
424
445
  <tr>
425
446
  <td>Name</td>
426
447
  <td>restrict()</td>
427
- <td align="center">none</td>
448
+ <td align="center">None</td>
428
449
  <td>Sets strict mode to true, won't extend array if data is outside of max size (<b>default true for reader, false for writer</b>)</td>
429
450
  </tr>
430
451
  <tr>
431
452
  <td>Name</td>
432
453
  <td>end()</td>
433
- <td align="center" rowspan="2">none</td>
454
+ <td align="center" rowspan="2">None</td>
434
455
  <td rowspan="2">Removes supplied data.</td>
435
456
  </tr>
436
457
  <tr>
@@ -522,7 +543,7 @@ Common functions for setup, movement, manipulation and math shared by both.
522
543
  <tr>
523
544
  <td>Name</td>
524
545
  <td>rewind()</td>
525
- <td align="center" rowspan="2">none</td>
546
+ <td align="center" rowspan="2">None</td>
526
547
  <td rowspan="2">Moves current byte position to start of data.</td>
527
548
  </tr>
528
549
  <tr>
@@ -532,7 +553,7 @@ Common functions for setup, movement, manipulation and math shared by both.
532
553
  <tr>
533
554
  <td>Name</td>
534
555
  <td>last()</td>
535
- <td align="center" rowspan="2">none</td>
556
+ <td align="center" rowspan="2">None</td>
536
557
  <td rowspan="2">Moves current byte position to end of data.</td>
537
558
  </tr>
538
559
  <tr>