+/**
+ * Returns the byte length for the provided array buffer or array
+ * buffer view.
+ *
+ * ☡ This function throws if the provided value is not an array buffer,
+ * data view, or typed array.
+ */
+export const getByteLength = ($) => {
+ try {
+ // Attempt to get the byte length from the provided value as an
+ // `ArrayBuffer`.
+ return call(getBufferByteLength, $, []);
+ } catch {
+ // The provided value is not an `ArrayBuffer`.
+ /* do nothing */
+ }
+ try {
+ // Attempt to get the byte length from the provided value as a
+ // `SharedArrayBuffer`.
+ return call(getSharedBufferByteLength, $, []);
+ } catch {
+ // The provided value is not a `SharedArrayBuffer`.
+ /* do nothing */
+ }
+ try {
+ // Attempt to get the byte length from the provided value as a
+ // data view.
+ return call(getViewByteLength, $, []);
+ } catch {
+ // The provided value is not a data view.
+ /* do nothing */
+ }
+ try {
+ // Attempt to get the byte length from the provided value as a
+ // typed array.
+ return call(getTypedArrayByteLength, $, []);
+ } catch {
+ // The provided value is not a typed array.
+ /* do nothing */
+ }
+ throw new TypeError(`Piscēs: Not an array buffer or view: ${$}.`);
+};
+
+/**
+ * Returns the byte offset for the provided array buffer or array
+ * buffer view.
+ *
+ * ※ This function always returns `0` for array buffers.
+ *
+ * ☡ This function throws if the provided value is not an array buffer,
+ * data view, or typed array.
+ */
+export const getByteOffset = ($) => {
+ if (isArrayBuffer($)) {
+ // The provided value is an array buffer.
+ return 0;
+ } else {
+ try {
+ // Attempt to get the byte offset from the provided value as a
+ // data view.
+ return call(getViewByteOffset, $, []);
+ } catch {
+ // The provided value is not a data view.
+ /* do nothing */
+ }
+ try {
+ // Attempt to get the byte offset from the provided value as a
+ // typed array.
+ return call(getTypedArrayByteOffset, $, []);
+ } catch {
+ // The provided value is not a typed array.
+ /* do nothing */
+ }
+ throw new TypeError(`Piscēs: Not an array buffer or view: ${$}.`);
+ }
+};
+