source: trip-planner-front/node_modules/@webassemblyjs/ieee754/lib/index.js@ 76712b2

Last change on this file since 76712b2 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.5 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.encodeF32 = encodeF32;
7exports.encodeF64 = encodeF64;
8exports.decodeF32 = decodeF32;
9exports.decodeF64 = decodeF64;
10exports.DOUBLE_PRECISION_MANTISSA = exports.SINGLE_PRECISION_MANTISSA = exports.NUMBER_OF_BYTE_F64 = exports.NUMBER_OF_BYTE_F32 = void 0;
11
12var _ieee = require("@xtuc/ieee754");
13
14/**
15 * According to https://webassembly.github.io/spec/binary/values.html#binary-float
16 * n = 32/8
17 */
18var NUMBER_OF_BYTE_F32 = 4;
19/**
20 * According to https://webassembly.github.io/spec/binary/values.html#binary-float
21 * n = 64/8
22 */
23
24exports.NUMBER_OF_BYTE_F32 = NUMBER_OF_BYTE_F32;
25var NUMBER_OF_BYTE_F64 = 8;
26exports.NUMBER_OF_BYTE_F64 = NUMBER_OF_BYTE_F64;
27var SINGLE_PRECISION_MANTISSA = 23;
28exports.SINGLE_PRECISION_MANTISSA = SINGLE_PRECISION_MANTISSA;
29var DOUBLE_PRECISION_MANTISSA = 52;
30exports.DOUBLE_PRECISION_MANTISSA = DOUBLE_PRECISION_MANTISSA;
31
32function encodeF32(v) {
33 var buffer = [];
34 (0, _ieee.write)(buffer, v, 0, true, SINGLE_PRECISION_MANTISSA, NUMBER_OF_BYTE_F32);
35 return buffer;
36}
37
38function encodeF64(v) {
39 var buffer = [];
40 (0, _ieee.write)(buffer, v, 0, true, DOUBLE_PRECISION_MANTISSA, NUMBER_OF_BYTE_F64);
41 return buffer;
42}
43
44function decodeF32(bytes) {
45 var buffer = Buffer.from(bytes);
46 return (0, _ieee.read)(buffer, 0, true, SINGLE_PRECISION_MANTISSA, NUMBER_OF_BYTE_F32);
47}
48
49function decodeF64(bytes) {
50 var buffer = Buffer.from(bytes);
51 return (0, _ieee.read)(buffer, 0, true, DOUBLE_PRECISION_MANTISSA, NUMBER_OF_BYTE_F64);
52}
Note: See TracBrowser for help on using the repository browser.