const bytesSet = Function.prototype.call.bind(Bytes.prototype.set)
const bytesFill = Function.prototype.call.bind(Bytes.prototype.fill)
-function get<T> (target: object, key: PropertyKey): (this: unknown) => T {
+/** An accessor's getter, taking the object to read as its argument. */
+function getter (target: object, key: PropertyKey): (self: unknown) => any {
const found = Object.getOwnPropertyDescriptor(target, key)
if (typeof found?.get !== 'function') {
throw new Nano25519TypeError(`Missing expected accessor while capturing builtins`)
}
- return found.get
+ return Function.prototype.call.bind(found.get)
}
/** Reads `[[TypedArrayName]]`; returns `undefined` for anything else. */
-const getTag = Function.prototype.call.bind(get<string>(TypedArray, Symbol.toStringTag))
+const getTag = getter(TypedArray, Symbol.toStringTag)
/** Reads internal slot `[[ViewedArrayBuffer]]`. */
-const getBuffer = Function.prototype.call.bind(get<ArrayBufferLike>(TypedArray, 'buffer'))
+const getBuffer = getter(TypedArray, 'buffer')
/** Throws if passed `SharedArrayBuffer`, distinguishing it from `ArrayBuffer`. */
-const getBufferByteLength = Function.prototype.call.bind(get<number>(ArrayBuffer.prototype, 'byteLength'))
+const getBufferByteLength = getter(ArrayBuffer.prototype, 'byteLength')
/** Reads internal slot `[[ByteLength]]`. */
-const getByteLength = Function.prototype.call.bind(get<number>(TypedArray, 'byteLength'))
+const getByteLength = getter(TypedArray, 'byteLength')
/** Reads internal slot `[[ByteOffset]]`. */
-const getByteOffset = Function.prototype.call.bind(get<number>(TypedArray, 'byteOffset'))
+const getByteOffset = getter(TypedArray, 'byteOffset')
/** True for a genuine `ArrayBuffer`, false for a `SharedArrayBuffer`. */
function isArrayBuffer (a: unknown): a is ArrayBuffer {