@petamoriken/float16
Advanced tools
Comparing version 3.4.8 to 3.4.9
@@ -1,2 +0,2 @@ | ||
/*! @petamoriken/float16 v3.4.8 | MIT License - https://git.io/float16 */ | ||
/*! @petamoriken/float16 v3.4.9 | MIT License - https://git.io/float16 */ | ||
@@ -208,4 +208,3 @@ const float16 = (function (exports) { | ||
// Inspired by util.types implementation of Node.js | ||
const TypedArrayPrototype = Reflect.getPrototypeOf(Uint8Array).prototype; | ||
const getTypedArrayPrototypeSybolToStringTag = Reflect.getOwnPropertyDescriptor(TypedArrayPrototype, Symbol.toStringTag).get; | ||
const getTypedArrayPrototypeSybolToStringTag = Reflect.getOwnPropertyDescriptor(Reflect.getPrototypeOf(Uint8Array).prototype, Symbol.toStringTag).get; | ||
@@ -228,4 +227,2 @@ /** | ||
const toString = Object.prototype.toString; | ||
/** | ||
@@ -244,6 +241,2 @@ * @param {unknown} value | ||
if (toString.call(value) !== "[object DataView]") { | ||
return false; | ||
} | ||
return true; | ||
@@ -257,3 +250,3 @@ } | ||
function isArrayBuffer(value) { | ||
return isObjectLike(value) && toString.call(value) === "[object ArrayBuffer]"; | ||
return isObjectLike(value) && value[Symbol.toStringTag] === "ArrayBuffer"; | ||
} | ||
@@ -266,3 +259,3 @@ | ||
function isSharedArrayBuffer(value) { | ||
return isObjectLike(value) && toString.call(value) === "[object SharedArrayBuffer]"; | ||
return isObjectLike(value) && value[Symbol.toStringTag] === "SharedArrayBuffer"; | ||
} | ||
@@ -288,3 +281,3 @@ | ||
const iterator = value[Symbol.iterator](); | ||
if (toString.call(iterator) !== "[object Array Iterator]") { | ||
if (iterator[Symbol.toStringTag] !== "Array Iterator") { | ||
return false; | ||
@@ -306,3 +299,3 @@ } | ||
const iterator = value[Symbol.iterator](); | ||
if (toString.call(iterator) !== "[object Array Iterator]") { | ||
if (iterator[Symbol.toStringTag] !== "Array Iterator") { | ||
return false; | ||
@@ -309,0 +302,0 @@ } |
{ | ||
"name": "@petamoriken/float16", | ||
"description": "half precision floating point for JavaScript", | ||
"version": "3.4.8", | ||
"main": "./lib/index.js", | ||
"version": "3.4.9", | ||
"main": "./lib/index.cjs", | ||
"module": "./src/index.mjs", | ||
"exports": { | ||
"require": "./lib/index.js", | ||
"import": "./src/index.mjs" | ||
".": { | ||
"import": "./src/index.mjs", | ||
"require": "./lib/index.cjs" | ||
}, | ||
"./inspect": { | ||
"import": "./inspect/node.mjs", | ||
"require": "./inspect/node.cjs" | ||
} | ||
}, | ||
@@ -27,2 +33,4 @@ "types": "index.d.ts", | ||
"browser", | ||
"inspect/node.mjs", | ||
"inspect/node.cjs", | ||
"index.d.ts" | ||
@@ -47,3 +55,3 @@ ], | ||
"build": "yarn run build:lib; yarn run build:browser", | ||
"build:lib": "babel src -d lib", | ||
"build:lib": "babel src -d lib --out-file-extension .cjs", | ||
"build:browser": "rollup -c", | ||
@@ -50,0 +58,0 @@ "docs": "mkdir -p docs && cp README.md docs/index.md; yarn run docs:test", |
@@ -51,3 +51,7 @@ # <a href="https://git.io/float16">@petamoriken/float16</a> | ||
// ES Modules | ||
import { Float16Array, isFloat16Array, getFloat16, setFloat16, hfround } from "@petamoriken/float16"; | ||
import { | ||
Float16Array, isFloat16Array, | ||
getFloat16, setFloat16, | ||
hfround, | ||
} from "@petamoriken/float16"; | ||
``` | ||
@@ -57,3 +61,7 @@ | ||
// CommonJS | ||
const { Float16Array, isFloat16Array, getFloat16, setFloat16, hfround } = require("@petamoriken/float16"); | ||
const { | ||
Float16Array, isFloat16Array, | ||
getFloat16, setFloat16, | ||
hfround, | ||
} = require("@petamoriken/float16"); | ||
``` | ||
@@ -66,3 +74,7 @@ | ||
```ts | ||
import { Float16Array, isFloat16Array, getFloat16, setFloat16, hfround } from "https://deno.land/x/float16/mod.ts"; | ||
import { | ||
Float16Array, isFloat16Array, | ||
getFloat16, setFloat16, | ||
hfround, | ||
} from "https://deno.land/x/float16/mod.ts"; | ||
``` | ||
@@ -77,3 +89,7 @@ | ||
<script type="module"> | ||
import { Float16Array, isFloat16Array, getFloat16, setFloat16, hfround } from "DEST/TO/float16.mjs"; | ||
import { | ||
Float16Array, isFloat16Array, | ||
getFloat16, setFloat16, | ||
hfround, | ||
} from "DEST/TO/float16.mjs"; | ||
</script> | ||
@@ -86,3 +102,7 @@ ``` | ||
<script> | ||
const { Float16Array, isFloat16Array, getFloat16, setFloat16, hfround } = float16; | ||
const { | ||
Float16Array, isFloat16Array, | ||
getFloat16, setFloat16, | ||
hfround, | ||
} = float16; | ||
</script> | ||
@@ -96,3 +116,7 @@ ``` | ||
<script type="module"> | ||
import { Float16Array, isFloat16Array, getFloat16, setFloat16, hfround } from "https://cdn.jsdelivr.net/npm/@petamoriken/float16/+esm"; | ||
import { | ||
Float16Array, isFloat16Array, | ||
getFloat16, setFloat16, | ||
hfround, | ||
} from "https://cdn.jsdelivr.net/npm/@petamoriken/float16/+esm"; | ||
</script> | ||
@@ -105,3 +129,7 @@ ``` | ||
<script> | ||
const { Float16Array, isFloat16Array, getFloat16, setFloat16, hfround } = float16; | ||
const { | ||
Float16Array, isFloat16Array, | ||
getFloat16, setFloat16, | ||
hfround, | ||
} = float16; | ||
</script> | ||
@@ -115,3 +143,7 @@ ``` | ||
<script type="module"> | ||
import { Float16Array, isFloat16Array, getFloat16, setFloat16, hfround } from "https://cdn.skypack.dev/@petamoriken/float16?min"; | ||
import { | ||
Float16Array, isFloat16Array, | ||
getFloat16, setFloat16, | ||
hfround, | ||
} from "https://cdn.skypack.dev/@petamoriken/float16?min"; | ||
</script> | ||
@@ -282,2 +314,35 @@ ``` | ||
## `Float16Array` Custom inspection | ||
Provides custom inspection for Node.js and Deno, which makes the results of `console.log` more readable. | ||
### Node.js | ||
```js | ||
// ES Modules | ||
import { Float16Array } from "@petamoriken/float16"; | ||
import { customInspect } from "@petamoriken/float16/inspect"; | ||
Float16Array.prototype[Symbol.for("nodejs.util.inspect.custom")] = customInspect; | ||
``` | ||
```js | ||
// CommonJS | ||
const { Float16Array } = require("@petamoriken/float16"); | ||
const { customInspect } = require("@petamoriken/float16/inspect"); | ||
Float16Array.prototype[Symbol.for("nodejs.util.inspect.custom")] = customInspect; | ||
``` | ||
### Deno | ||
```ts | ||
import { Float16Array } from "https://deno.land/x/float16/mod.ts"; | ||
import { customInspect } from "https://deno.land/x/float16/inspect.ts"; | ||
// deno-lint-ignore no-explicit-any | ||
(Float16Array.prototype as any)[Symbol.for("Deno.customInspect")] = customInspect; | ||
``` | ||
## Build | ||
@@ -284,0 +349,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
170699
28
4742
390