Comparing version 1.5.3 to 1.6.0
@@ -398,2 +398,70 @@ const ascii = require('./lib/ascii') | ||
function writeDoubleLE (buffer, value, offset) { | ||
if (offset === undefined) offset = 0 | ||
const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength) | ||
view.setFloat64(offset, value, true) | ||
return offset + 8 | ||
} | ||
function writeFloatLE (buffer, value, offset) { | ||
if (offset === undefined) offset = 0 | ||
const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength) | ||
view.setFloat32(offset, value, true) | ||
return offset + 4 | ||
} | ||
function writeUInt32LE (buffer, value, offset) { | ||
if (offset === undefined) offset = 0 | ||
const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength) | ||
view.setUint32(offset, value, true) | ||
return offset + 4 | ||
} | ||
function writeInt32LE (buffer, value, offset) { | ||
if (offset === undefined) offset = 0 | ||
const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength) | ||
view.setInt32(offset, value, true) | ||
return offset + 4 | ||
} | ||
function readDoubleLE (buffer, offset) { | ||
if (offset === undefined) offset = 0 | ||
const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength) | ||
return view.getFloat64(offset, true) | ||
} | ||
function readFloatLE (buffer, offset) { | ||
if (offset === undefined) offset = 0 | ||
const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength) | ||
return view.getFloat32(offset, true) | ||
} | ||
function readUInt32LE (buffer, offset) { | ||
if (offset === undefined) offset = 0 | ||
const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength) | ||
return view.getUint32(offset, true) | ||
} | ||
function readInt32LE (buffer, offset) { | ||
if (offset === undefined) offset = 0 | ||
const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength) | ||
return view.getInt32(offset, true) | ||
} | ||
module.exports = { | ||
@@ -420,3 +488,11 @@ isBuffer, | ||
toString, | ||
write | ||
write, | ||
writeDoubleLE, | ||
writeFloatLE, | ||
writeUInt32LE, | ||
writeInt32LE, | ||
readDoubleLE, | ||
readFloatLE, | ||
readUInt32LE, | ||
readInt32LE | ||
} |
42
index.js
@@ -86,2 +86,34 @@ function isBuffer (value) { | ||
function writeDoubleLE (buffer, value, offset) { | ||
return toBuffer(buffer).writeDoubleLE(value, offset) | ||
} | ||
function writeFloatLE (buffer, value, offset) { | ||
return toBuffer(buffer).writeFloatLE(value, offset) | ||
} | ||
function writeUInt32LE (buffer, value, offset) { | ||
return toBuffer(buffer).writeUInt32LE(value, offset) | ||
} | ||
function writeInt32LE (buffer, value, offset) { | ||
return toBuffer(buffer).writeInt32LE(value, offset) | ||
} | ||
function readDoubleLE (buffer, offset) { | ||
return toBuffer(buffer).readDoubleLE(offset) | ||
} | ||
function readFloatLE (buffer, offset) { | ||
return toBuffer(buffer).readFloatLE(offset) | ||
} | ||
function readUInt32LE (buffer, offset) { | ||
return toBuffer(buffer).readUInt32LE(offset) | ||
} | ||
function readInt32LE (buffer, offset) { | ||
return toBuffer(buffer).readInt32LE(offset) | ||
} | ||
module.exports = { | ||
@@ -108,3 +140,11 @@ isBuffer, | ||
toString, | ||
write | ||
write, | ||
writeDoubleLE, | ||
writeFloatLE, | ||
writeUInt32LE, | ||
writeInt32LE, | ||
readDoubleLE, | ||
readFloatLE, | ||
readUInt32LE, | ||
readInt32LE | ||
} |
{ | ||
"name": "b4a", | ||
"version": "1.5.3", | ||
"version": "1.6.0", | ||
"description": "Bridging the gap between buffers and typed arrays", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -111,4 +111,36 @@ # Buffer for Array | ||
#### `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 | ||
ISC |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27478
756
146