@yuhere/js-ieee754
v1.2.2
Published
Read/write IEEE754 floating point numbers from/to a Buffer or array-like object
Maintainers
Readme
@yuhere/js-ieee754
[!NOTE] This project is forked from feross/ieee754 v1.2.1. The main changes are: source rewritten in TypeScript, repackaged as ES Module with Vite + Vitest.
Read/write IEEE754 floating point numbers from/to a Buffer or array-like object.
Differences from upstream
| Aspect | Upstream | This fork |
|--------|----------|-----------|
| Module format | CommonJS | ES Module |
| Source language | JavaScript | TypeScript |
| Build tool | None | Vite 8 (preserveModules) |
| Type declarations | Hand-written index.d.ts | Auto-generated from tsc |
| Test framework | tape | Vitest 4 (Node) |
| Test language | JavaScript | TypeScript |
| Coverage | None | Istanbul (100%) |
Detailed changes
- ESM —
exports.read/write→export function read/write, added"type": "module"and"exports"field topackage.json - TypeScript — converted
src/index.jstosrc/index.tswith full type annotations,var→let/const - Build — Vite with
preserveModulescompiles tolib/, tsc generates.d.tsand declaration maps - Tests — switched from tape to Vitest with
globals: true, Istanbul coverage at 100% (statements, branches, functions, lines) - Dev tooling — removed mocha, airtap, standard, tape; added Vite + Vitest + TypeScript stack
install
npm install @yuhere/js-ieee754methods
import { read, write } from '@yuhere/js-ieee754'read(buffer, offset, isLE, mLen, nBytes)
Read an IEEE754 floating point number from a buffer.
write(buffer, value, offset, isLE, mLen, nBytes)
Write a floating point number into a buffer using IEEE754 format.
Arguments:
buffer— the buffer (Uint8Array)offset— offset into the buffervalue— value to set (only forwrite)isLE— is little endian?mLen— mantissa length (float32: 23, float64: 52)nBytes— number of bytes (float32: 4, float64: 8)
what is ieee754?
The IEEE Standard for Floating-Point Arithmetic (IEEE 754) is a technical standard for floating-point computation. Read more.
license
BSD 3 Clause. Copyright (c) 2008, Fair Oaks Labs, Inc.
