-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New: Created a micromodule from (currently still bundled) float support
- Loading branch information
Showing
6 changed files
with
595 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
Copyright (c) 2016, Daniel Wirtz All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are | ||
met: | ||
|
||
* Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above copyright | ||
notice, this list of conditions and the following disclaimer in the | ||
documentation and/or other materials provided with the distribution. | ||
* Neither the name of its author, nor the names of its contributors | ||
may be used to endorse or promote products derived from this software | ||
without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
@protobufjs/float | ||
================= | ||
[![npm](https://img.shields.io/npm/v/@protobufjs/float.svg)](https://www.npmjs.com/package/@protobufjs/float) | ||
|
||
Reads / writes floats / doubles from / to buffers in both modern and ancient browsers. Fast. | ||
|
||
API | ||
--- | ||
|
||
* **writeFloatLE(val: `number`, buf: `Uint8Array`, pos: `number`)**<br /> | ||
Writes a 32 bit float to a buffer using little endian byte order. | ||
|
||
* **writeFloatBE(val: `number`, buf: `Uint8Array`, pos: `number`)**<br /> | ||
Writes a 32 bit float to a buffer using big endian byte order. | ||
|
||
* **readFloatLE(buf: `Uint8Array`, pos: `number`): `number`**<br /> | ||
Reads a 32 bit float from a buffer using little endian byte order. | ||
|
||
* **readFloatBE(buf: `Uint8Array`, pos: `number`): `number`**<br /> | ||
Reads a 32 bit float from a buffer using big endian byte order. | ||
|
||
* **writeDoubleLE(val: `number`, buf: `Uint8Array`, pos: `number`)**<br /> | ||
Writes a 64 bit double to a buffer using little endian byte order. | ||
|
||
* **writeDoubleBE(val: `number`, buf: `Uint8Array`, pos: `number`)**<br /> | ||
Writes a 64 bit double to a buffer using big endian byte order. | ||
|
||
* **readDoubleLE(buf: `Uint8Array`, pos: `number`): `number`**<br /> | ||
Reads a 64 bit double from a buffer using little endian byte order. | ||
|
||
* **readDoubleBE(buf: `Uint8Array`, pos: `number`): `number`**<br /> | ||
Reads a 64 bit double from a buffer using big endian byte order. | ||
|
||
|
||
**License:** [BSD 3-Clause License](https://opensource.org/licenses/BSD-3-Clause) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/** | ||
* Writes a 32 bit float to a buffer using little endian byte order. | ||
* @name writeFloatLE | ||
* @function | ||
* @param {number} val Value to write | ||
* @param {Uint8Array} buf Target buffer | ||
* @param {number} pos Target buffer offset | ||
* @returns {undefined} | ||
*/ | ||
export function writeFloatLE(val: number, buf: Uint8Array, pos: number): void; | ||
|
||
/** | ||
* Writes a 32 bit float to a buffer using big endian byte order. | ||
* @name writeFloatBE | ||
* @function | ||
* @param {number} val Value to write | ||
* @param {Uint8Array} buf Target buffer | ||
* @param {number} pos Target buffer offset | ||
* @returns {undefined} | ||
*/ | ||
export function writeFloatBE(val: number, buf: Uint8Array, pos: number): void; | ||
|
||
/** | ||
* Reads a 32 bit float from a buffer using little endian byte order. | ||
* @name readFloatLE | ||
* @function | ||
* @param {Uint8Array} buf Source buffer | ||
* @param {number} pos Source buffer offset | ||
* @returns {number} Value read | ||
*/ | ||
export function readFloatLE(buf: Uint8Array, pos: number): number; | ||
|
||
/** | ||
* Reads a 32 bit float from a buffer using big endian byte order. | ||
* @name readFloatBE | ||
* @function | ||
* @param {Uint8Array} buf Source buffer | ||
* @param {number} pos Source buffer offset | ||
* @returns {number} Value read | ||
*/ | ||
export function readFloatBE(buf: Uint8Array, pos: number): number; | ||
|
||
/** | ||
* Writes a 64 bit double to a buffer using little endian byte order. | ||
* @name writeDoubleLE | ||
* @function | ||
* @param {number} val Value to write | ||
* @param {Uint8Array} buf Target buffer | ||
* @param {number} pos Target buffer offset | ||
* @returns {undefined} | ||
*/ | ||
export function writeDoubleLE(val: number, buf: Uint8Array, pos: number): void; | ||
|
||
/** | ||
* Writes a 64 bit double to a buffer using big endian byte order. | ||
* @name writeDoubleBE | ||
* @function | ||
* @param {number} val Value to write | ||
* @param {Uint8Array} buf Target buffer | ||
* @param {number} pos Target buffer offset | ||
* @returns {undefined} | ||
*/ | ||
export function writeDoubleBE(val: number, buf: Uint8Array, pos: number): void; | ||
|
||
/** | ||
* Reads a 64 bit double from a buffer using little endian byte order. | ||
* @name readDoubleLE | ||
* @function | ||
* @param {Uint8Array} buf Source buffer | ||
* @param {number} pos Source buffer offset | ||
* @returns {number} Value read | ||
*/ | ||
export function readDoubleLE(buf: Uint8Array, pos: number): number; | ||
|
||
/** | ||
* Reads a 64 bit double from a buffer using big endian byte order. | ||
* @name readDoubleBE | ||
* @function | ||
* @param {Uint8Array} buf Source buffer | ||
* @param {number} pos Source buffer offset | ||
* @returns {number} Value read | ||
*/ | ||
export function readDoubleBE(buf: Uint8Array, pos: number): number; |
Oops, something went wrong.