first commit
This commit is contained in:
21
app_vue/node_modules/@webassemblyjs/floating-point-hex-parser/LICENSE
generated
vendored
Normal file
21
app_vue/node_modules/@webassemblyjs/floating-point-hex-parser/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2017 Mauro Bringolf
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
34
app_vue/node_modules/@webassemblyjs/floating-point-hex-parser/README.md
generated
vendored
Normal file
34
app_vue/node_modules/@webassemblyjs/floating-point-hex-parser/README.md
generated
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
# Parser function for floating point hexadecimals
|
||||
|
||||
[]()
|
||||
[]()
|
||||
[]()
|
||||
|
||||
> A JavaScript function to parse floating point hexadecimals as defined by the [WebAssembly specification](https://webassembly.github.io/spec/core/text/values.html#text-hexfloat).
|
||||
|
||||
## Usage
|
||||
|
||||
```javascript
|
||||
import parseHexFloat from '@webassemblyjs/floating-point-hex-parser'
|
||||
|
||||
parseHexFloat('0x1p-1') // 0.5
|
||||
parseHexFloat('0x1.921fb54442d18p+2') // 6.283185307179586
|
||||
```
|
||||
|
||||
## Tests
|
||||
|
||||
This module is tested in two ways. The first one is through a small set of test cases that can be found in [test/regular.test.js](https://github.com/maurobringolf/@webassemblyjs/floating-point-hex-parser/blob/master/test/regular.test.js). The second one is non-deterministic (sometimes called *fuzzing*):
|
||||
|
||||
1. Generate a random IEEE754 double precision value `x`.
|
||||
1. Compute its representation `y` in floating point hexadecimal format using the C standard library function `printf` since C supports this format.
|
||||
1. Give both values to JS testcase and see if `parseHexFloat(y) === x`.
|
||||
|
||||
By default one `npm test` run tests 100 random samples. If you want to do more, you can set the environment variable `FUZZ_AMOUNT` to whatever number of runs you'd like. Because it uses one child process for each sample, it is really slow though. For more details about the randomized tests see [the source](https://github.com/maurobringolf/@webassemblyjs/floating-point-hex-parser/tree/master/test/fuzzing).
|
||||
|
||||
## Links
|
||||
|
||||
* [maurobringolf.ch/2017/12/hexadecimal-floating-point-notation/](https://maurobringolf.ch/2017/12/hexadecimal-floating-point-notation/)
|
||||
|
||||
* [github.com/xtuc/js-webassembly-interpreter/issues/32](https://github.com/xtuc/js-webassembly-interpreter/issues/32)
|
||||
|
||||
* [github.com/WebAssembly/design/issues/292](https://github.com/WebAssembly/design/issues/292)
|
42
app_vue/node_modules/@webassemblyjs/floating-point-hex-parser/esm/index.js
generated
vendored
Normal file
42
app_vue/node_modules/@webassemblyjs/floating-point-hex-parser/esm/index.js
generated
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
export default function parse(input) {
|
||||
input = input.toUpperCase();
|
||||
var splitIndex = input.indexOf("P");
|
||||
var mantissa, exponent;
|
||||
|
||||
if (splitIndex !== -1) {
|
||||
mantissa = input.substring(0, splitIndex);
|
||||
exponent = parseInt(input.substring(splitIndex + 1));
|
||||
} else {
|
||||
mantissa = input;
|
||||
exponent = 0;
|
||||
}
|
||||
|
||||
var dotIndex = mantissa.indexOf(".");
|
||||
|
||||
if (dotIndex !== -1) {
|
||||
var integerPart = parseInt(mantissa.substring(0, dotIndex), 16);
|
||||
var sign = Math.sign(integerPart);
|
||||
integerPart = sign * integerPart;
|
||||
var fractionLength = mantissa.length - dotIndex - 1;
|
||||
var fractionalPart = parseInt(mantissa.substring(dotIndex + 1), 16);
|
||||
var fraction = fractionLength > 0 ? fractionalPart / Math.pow(16, fractionLength) : 0;
|
||||
|
||||
if (sign === 0) {
|
||||
if (fraction === 0) {
|
||||
mantissa = sign;
|
||||
} else {
|
||||
if (Object.is(sign, -0)) {
|
||||
mantissa = -fraction;
|
||||
} else {
|
||||
mantissa = fraction;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mantissa = sign * (integerPart + fraction);
|
||||
}
|
||||
} else {
|
||||
mantissa = parseInt(mantissa, 16);
|
||||
}
|
||||
|
||||
return mantissa * (splitIndex !== -1 ? Math.pow(2, exponent) : 1);
|
||||
}
|
49
app_vue/node_modules/@webassemblyjs/floating-point-hex-parser/lib/index.js
generated
vendored
Normal file
49
app_vue/node_modules/@webassemblyjs/floating-point-hex-parser/lib/index.js
generated
vendored
Normal file
@ -0,0 +1,49 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports["default"] = parse;
|
||||
|
||||
function parse(input) {
|
||||
input = input.toUpperCase();
|
||||
var splitIndex = input.indexOf("P");
|
||||
var mantissa, exponent;
|
||||
|
||||
if (splitIndex !== -1) {
|
||||
mantissa = input.substring(0, splitIndex);
|
||||
exponent = parseInt(input.substring(splitIndex + 1));
|
||||
} else {
|
||||
mantissa = input;
|
||||
exponent = 0;
|
||||
}
|
||||
|
||||
var dotIndex = mantissa.indexOf(".");
|
||||
|
||||
if (dotIndex !== -1) {
|
||||
var integerPart = parseInt(mantissa.substring(0, dotIndex), 16);
|
||||
var sign = Math.sign(integerPart);
|
||||
integerPart = sign * integerPart;
|
||||
var fractionLength = mantissa.length - dotIndex - 1;
|
||||
var fractionalPart = parseInt(mantissa.substring(dotIndex + 1), 16);
|
||||
var fraction = fractionLength > 0 ? fractionalPart / Math.pow(16, fractionLength) : 0;
|
||||
|
||||
if (sign === 0) {
|
||||
if (fraction === 0) {
|
||||
mantissa = sign;
|
||||
} else {
|
||||
if (Object.is(sign, -0)) {
|
||||
mantissa = -fraction;
|
||||
} else {
|
||||
mantissa = fraction;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mantissa = sign * (integerPart + fraction);
|
||||
}
|
||||
} else {
|
||||
mantissa = parseInt(mantissa, 16);
|
||||
}
|
||||
|
||||
return mantissa * (splitIndex !== -1 ? Math.pow(2, exponent) : 1);
|
||||
}
|
24
app_vue/node_modules/@webassemblyjs/floating-point-hex-parser/package.json
generated
vendored
Normal file
24
app_vue/node_modules/@webassemblyjs/floating-point-hex-parser/package.json
generated
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
{
|
||||
"name": "@webassemblyjs/floating-point-hex-parser",
|
||||
"scripts": {
|
||||
"build-fuzzer": "[ -f ./test/fuzzing/parse.out ] || gcc ./test/fuzzing/parse.c -o ./test/fuzzing/parse.out -lm -Wall"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/xtuc/webassemblyjs.git"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"version": "1.13.2",
|
||||
"description": "A function to parse floating point hexadecimal strings as defined by the WebAssembly specification",
|
||||
"main": "lib/index.js",
|
||||
"module": "esm/index.js",
|
||||
"keywords": [
|
||||
"webassembly",
|
||||
"floating-point"
|
||||
],
|
||||
"author": "Mauro Bringolf",
|
||||
"license": "MIT",
|
||||
"gitHead": "897aeb784f042a46a00626f1d1cca96159aa5db3"
|
||||
}
|
Reference in New Issue
Block a user