Path: blob/master/node_modules/@protobufjs/float/README.md
1126 views
@protobufjs/float
Reads / writes floats / doubles from / to buffers in both modern and ancient browsers. Fast.
API
writeFloatLE(val:
number
, buf:Uint8Array
, pos:number
)
Writes a 32 bit float to a buffer using little endian byte order.writeFloatBE(val:
number
, buf:Uint8Array
, pos:number
)
Writes a 32 bit float to a buffer using big endian byte order.readFloatLE(buf:
Uint8Array
, pos:number
):number
Reads a 32 bit float from a buffer using little endian byte order.readFloatBE(buf:
Uint8Array
, pos:number
):number
Reads a 32 bit float from a buffer using big endian byte order.writeDoubleLE(val:
number
, buf:Uint8Array
, pos:number
)
Writes a 64 bit double to a buffer using little endian byte order.writeDoubleBE(val:
number
, buf:Uint8Array
, pos:number
)
Writes a 64 bit double to a buffer using big endian byte order.readDoubleLE(buf:
Uint8Array
, pos:number
):number
Reads a 64 bit double from a buffer using little endian byte order.readDoubleBE(buf:
Uint8Array
, pos:number
):number
Reads a 64 bit double from a buffer using big endian byte order.
Performance
There is a simple benchmark included comparing raw read/write performance of this library (float), float's fallback for old browsers, the ieee754 module and node's buffer. On an i7-2600k running node 6.9.1 it yields:
To run it yourself:
License: BSD 3-Clause License