mirror of
https://github.com/pezkuwichain/pezkuwi-common.git
synced 2026-04-22 13:48:09 +00:00
chore: update to version 14.0.11 and align website URLs
This commit is contained in:
Vendored
+1
@@ -0,0 +1 @@
|
||||
export { floatToU8a } from './toU8a.js';
|
||||
@@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.floatToU8a = void 0;
|
||||
var toU8a_js_1 = require("./toU8a.js");
|
||||
Object.defineProperty(exports, "floatToU8a", { enumerable: true, get: function () { return toU8a_js_1.floatToU8a; } });
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
interface Options {
|
||||
bitLength?: 32 | 64;
|
||||
isLe?: boolean;
|
||||
}
|
||||
/**
|
||||
* @name floatToU8a
|
||||
* @description Converts a float into a U8a representation (While we don't use BE in SCALE
|
||||
* we still allow for either representation, although, as elsewhere, isLe is default)
|
||||
*/
|
||||
export declare function floatToU8a(value?: String | string | number | Number, { bitLength, isLe }?: Options): Uint8Array;
|
||||
export {};
|
||||
@@ -0,0 +1,22 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.floatToU8a = floatToU8a;
|
||||
/**
|
||||
* @name floatToU8a
|
||||
* @description Converts a float into a U8a representation (While we don't use BE in SCALE
|
||||
* we still allow for either representation, although, as elsewhere, isLe is default)
|
||||
*/
|
||||
function floatToU8a(value = 0.0, { bitLength = 32, isLe = true } = {}) {
|
||||
if (bitLength !== 32 && bitLength !== 64) {
|
||||
throw new Error('Invalid bitLength provided, expected 32 or 64');
|
||||
}
|
||||
const result = new Uint8Array(bitLength / 8);
|
||||
const dv = new DataView(result.buffer, result.byteOffset);
|
||||
if (bitLength === 32) {
|
||||
dv.setFloat32(0, Number(value), isLe);
|
||||
}
|
||||
else {
|
||||
dv.setFloat64(0, Number(value), isLe);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
Reference in New Issue
Block a user