Permalink
Browse files

New: Created a micromodule from (currently still bundled) float support

  • Loading branch information...
dcodeIO committed Apr 1, 2017
1 parent ca0dce2 commit 3c14ef42b3c8f2fef2d96d65d6e288211f86c9ef
Showing with 595 additions and 0 deletions.
  1. +26 −0 lib/float/LICENSE
  2. +35 −0 lib/float/README.md
  3. +83 −0 lib/float/index.d.ts
  4. +329 −0 lib/float/index.js
  5. +22 −0 lib/float/package.json
  6. +100 −0 lib/float/tests/index.js
@@ -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.
@@ -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)
@@ -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.

0 comments on commit 3c14ef4

Please sign in to comment.