-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
701db74
commit e65a777
Showing
11 changed files
with
182 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { isObject, isObjectLike } from "./is.mjs"; | ||
import { THE_CONSTRUCTOR_PROPERTY_VALUE_IS_NOT_AN_OBJECT } from "./messages.mjs"; | ||
import { NativeTypeError, ReflectGetPrototypeOf, ReflectHas, SymbolFor } from "./primordials.mjs"; | ||
|
||
export const brand = SymbolFor("__Float16Array__"); | ||
|
||
/** | ||
* @param {unknown} target | ||
* @throws {TypeError} | ||
* @returns {boolean} | ||
*/ | ||
export function hasFloat16ArrayBrand(target) { | ||
if (!isObjectLike(target)) { | ||
return false; | ||
} | ||
|
||
const prototype = ReflectGetPrototypeOf(target); | ||
if (!isObjectLike(prototype)) { | ||
return false; | ||
} | ||
|
||
const constructor = prototype.constructor; | ||
if (constructor === undefined) { | ||
return false; | ||
} | ||
if (!isObject(constructor)) { | ||
throw NativeTypeError(THE_CONSTRUCTOR_PROPERTY_VALUE_IS_NOT_AN_OBJECT); | ||
} | ||
|
||
return ReflectHas(constructor, brand); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
/* ignore unused exports */ | ||
|
||
export { hfround } from "./hfround.mjs"; | ||
export { Float16Array, isFloat16Array } from "./Float16Array.mjs"; | ||
export { isTypedArray } from "./isTypedArray.mjs"; | ||
export { getFloat16, setFloat16 } from "./DataView.mjs"; | ||
export { hfround } from "./hfround.mjs"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { isFloat16Array } from "./Float16Array.mjs"; | ||
import { isNativeTypedArray } from "./_util/is.mjs"; | ||
|
||
/** | ||
* @param {unknown} target | ||
* @returns {value is Uint8Array|Uint8ClampedArray|Uint16Array|Uint32Array|Int8Array|Int16Array|Int32Array|Float16Array|Float32Array|Float64Array|BigUint64Array|BigInt64Array} | ||
*/ | ||
export function isTypedArray(target) { | ||
return isNativeTypedArray(target) || isFloat16Array(target); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.