File size: 4,247 Bytes
bf237c2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# Buffer for Array

Buffer for Array (B4A) provides a set of functions for bridging the gap between the Node.js `Buffer` class and the `Uint8Array` class. A browser compatibility layer is also included, making it possible to use B4A in both Node.js and browsers without having to worry about whether you're dealing with buffers or typed arrays.

## Installation

```sh
npm install b4a
```

## API

#### `b4a.isBuffer(value)`

See https://nodejs.org/api/buffer.html#static-method-bufferisbufferobj

This will also return `true` when passed a `Uint8Array`.

#### `b4a.isEncoding(encoding)`

See https://nodejs.org/api/buffer.html#static-method-bufferisencodingencoding

#### `b4a.alloc(size[, fill[, encoding]])`

See https://nodejs.org/api/buffer.html#static-method-bufferallocsize-fill-encoding

#### `b4a.allocUnsafe(size)`

See https://nodejs.org/api/buffer.html#static-method-bufferallocunsafesize

#### `b4a.allocUnsafeSlow(size)`

See https://nodejs.org/api/buffer.html#static-method-bufferallocunsafeslowsize

#### `b4a.byteLength(string)`

See https://nodejs.org/api/buffer.html#static-method-bufferbytelengthstring-encoding

#### `b4a.compare(buf1, buf2)`

See https://nodejs.org/api/buffer.html#static-method-buffercomparebuf1-buf2

#### `b4a.concat(buffers[, totalLength])`

See https://nodejs.org/api/buffer.html#static-method-bufferconcatlist-totallength

#### `b4a.copy(source, target[, targetStart[, sourceStart[, sourceEnd]]])`

See https://nodejs.org/api/buffer.html#bufcopytarget-targetstart-sourcestart-sourceend

#### `b4a.equals(buf1, buf2)`

See https://nodejs.org/api/buffer.html#bufequalsotherbuffer

#### `b4a.fill(buffer, value[, offset[, end]][, encoding])`

See https://nodejs.org/api/buffer.html#buffillvalue-offset-end-encoding

#### `b4a.from(array)`

See https://nodejs.org/api/buffer.html#static-method-bufferfromarray

#### `b4a.from(arrayBuffer[, byteOffset[, length]])`

See https://nodejs.org/api/buffer.html#static-method-bufferfromarraybuffer-byteoffset-length

#### `b4a.from(buffer)`

See https://nodejs.org/api/buffer.html#static-method-bufferfrombuffer

#### `b4a.from(string[, encoding])`

See https://nodejs.org/api/buffer.html#static-method-bufferfromstring-encoding

#### `b4a.includes(buffer, value[, byteOffset][, encoding])`

See https://nodejs.org/api/buffer.html#bufincludesvalue-byteoffset-encoding

#### `b4a.indexOf(buffer, value[, byteOffset][, encoding])`

See https://nodejs.org/api/buffer.html#bufindexofvalue-byteoffset-encoding

#### `b4a.lastIndexOf(buffer, value[, byteOffset][, encoding])`

See https://nodejs.org/api/buffer.html#buflastindexofvalue-byteoffset-encoding

#### `b4a.swap16(buffer)`

See https://nodejs.org/api/buffer.html#bufswap16

#### `b4a.swap32(buffer)`

See https://nodejs.org/api/buffer.html#bufswap32

#### `b4a.swap64(buffer)`

See https://nodejs.org/api/buffer.html#bufswap64

#### `b4a.toBuffer(buffer)`

Convert a buffer to its canonical representation. In Node.js, the canonical representation is a `Buffer`. In the browser, the canonical representation is a `Uint8Array`.

#### `b4a.toString(buffer, [encoding[, start[, end]]])`

See https://nodejs.org/api/buffer.html#buftostringencoding-start-end

#### `b4a.write(buffer, string[, offset[, length]][, encoding])`

See https://nodejs.org/api/buffer.html#bufwritestring-offset-length-encoding

#### `b4a.writeDoubleLE(buffer, value[, offset])`

See https://nodejs.org/api/buffer.html#bufwritedoublelevalue-offset

#### `b4a.writeFloatLE(buffer, value[, offset])`

See https://nodejs.org/api/buffer.html#bufwritefloatlevalue-offset

#### `b4a.writeUInt32LE(buffer, value[, offset])`

https://nodejs.org/api/buffer.html#bufwriteuint32levalue-offset

#### `b4a.writeInt32LE(buffer, value[, offset])`

See https://nodejs.org/api/buffer.html#bufwriteint32levalue-offset

#### `b4a.readDoubleLE(buffer[, offset])`

See https://nodejs.org/api/buffer.html#bufreaddoubleleoffset

#### `b4a.readFloatLE(buffer[, offset])`

See https://nodejs.org/api/buffer.html#bufreadfloatleoffset

#### `b4a.readUInt32LE(buffer[, offset])`

See https://nodejs.org/api/buffer.html#bufreaduint32leoffset

#### `b4a.readInt32LE(buffer[, offset])`

See https://nodejs.org/api/buffer.html#bufreadint32leoffset

## License

Apache 2.0