Internal functions now have some code documentation, and the runtime
dependency on arrays being iterable (for splatting arguments) was
removed.
const {
next: arrayIteratorNext,
} = Object.getPrototypeOf([][iteratorSymbol]());
const {
next: arrayIteratorNext,
} = Object.getPrototypeOf([][iteratorSymbol]());
+const argumentIterablePrototype = {
+ [iteratorSymbol]() {
+ return {
+ next: bind(
+ arrayIteratorNext,
+ call(arrayIterator, this.args, []),
+ [],
+ ),
+ };
+ },
+};
+const binaryCodeUnitIterablePrototype = {
+ [iteratorSymbol]() {
+ return {
+ next: bind(
+ arrayIteratorNext,
+ call(arrayIterator, this, []),
+ [],
+ ),
+ };
+ },
+};
+
const getBufferByteLength =
Object.getOwnPropertyDescriptor(bufferPrototype, "byteLength").get;
const getTypedArrayBuffer =
const getBufferByteLength =
Object.getOwnPropertyDescriptor(bufferPrototype, "byteLength").get;
const getTypedArrayBuffer =
typeof $ == "string"
? $
: hasOwnProperty($, "raw")
typeof $ == "string"
? $
: hasOwnProperty($, "raw")
+ ? rawString(
+ $,
+ ...objectCreate(argumentIterablePrototype, {
+ args: { value: $s },
+ }),
+ )
-const binaryCodeUnitIterablePrototype = {
- [iteratorSymbol]() {
- return {
- next: bind(
- arrayIteratorNext,
- call(arrayIterator, this, []),
- [],
- ),
- };
- },
-};
-
+/**
+ * Returns the result of decoding the provided base64 string into an
+ * ArrayBuffer.
+ *
+ * ※ This function is not exposed.
+ */
const decodeBase64 = (source, safe = false) => {
const u6s = map(
source.length % 4 == 0
const decodeBase64 = (source, safe = false) => {
const u6s = map(
source.length % 4 == 0
return call(getViewBuffer, dataView, []);
};
return call(getViewBuffer, dataView, []);
};
+/**
+ * Returns the result of encoding the provided ArrayBuffer into a
+ * base64 string.
+ *
+ * ※ This function is not exposed.
+ */
const encodeBase64 = (buffer, safe = false) => {
const dataView = new View(buffer);
const byteLength = call(getBufferByteLength, buffer, []);
const encodeBase64 = (buffer, safe = false) => {
const dataView = new View(buffer);
const byteLength = call(getBufferByteLength, buffer, []);
return stringFromCodeUnits(...resultingCodeUnits);
};
return stringFromCodeUnits(...resultingCodeUnits);
};
+/**
+ * Returns a source string generated from the arguments passed to a
+ * tag function.
+ *
+ * ※ This function is not exposed.
+ */
const sourceFromArgs = ($, $s) =>
stringReplace(
const sourceFromArgs = ($, $s) =>
stringReplace(
- typeof $ == "string"
- ? $
- : hasOwnProperty($, "raw")
- ? rawString($, ...$s)
+ typeof $ == "string" ? $ : hasOwnProperty($, "raw")
+ ? rawString(
+ $,
+ ...objectCreate(argumentIterablePrototype, {
+ args: { value: $s },
+ }),
+ )
: `${$}`,
/[\t\n\f\r ]+/gu,
"",
);
/**
: `${$}`,
/[\t\n\f\r ]+/gu,
"",
);
/**
- * Returns an ArrayBuffer generated from the provided Base64.
+ * Returns an ArrayBuffer generated from the provided base64 string.
*
* This function can also be used as a tag for a template literal. The
* literal will be interpreted akin to `String.raw`.
*
* This function can also be used as a tag for a template literal. The
* literal will be interpreted akin to `String.raw`.
decodeBase64(sourceFromArgs($, $s));
/**
decodeBase64(sourceFromArgs($, $s));
/**
- * Returns a (big‐endian) base64 string created from a typed array,
- * buffer, or (16‐bit) string.
+ * Returns a (big‐endian) base64 string created from the provided typed
+ * array, buffer, or (16‐bit) string.
*
* This function can also be used as a tag for a template literal. The
* literal will be interpreted akin to `String.raw`.
*
* This function can also be used as a tag for a template literal. The
* literal will be interpreted akin to `String.raw`.
/**
* Returns an ArrayBuffer generated from the provided filename‐safe
/**
* Returns an ArrayBuffer generated from the provided filename‐safe
*
* This function can also be used as a tag for a template literal. The
* literal will be interpreted akin to `String.raw`.
*
* This function can also be used as a tag for a template literal. The
* literal will be interpreted akin to `String.raw`.
decodeBase64(sourceFromArgs($, $s), true);
/**
decodeBase64(sourceFromArgs($, $s), true);
/**
- * Returns a (big‐endian) filename‐safe base64 string created from a
- * typed array, buffer, or (16‐bit) string.
+ * Returns a (big‐endian) filename‐safe base64 string created from the
+ * provided typed array, buffer, or (16‐bit) string.
*
* This function can also be used as a tag for a template literal. The
* literal will be interpreted akin to `String.raw`.
*
* This function can also be used as a tag for a template literal. The
* literal will be interpreted akin to `String.raw`.
/**
* Returns whether the provided value is a Base64 string.
*
/**
* Returns whether the provided value is a Base64 string.
*
- * Returns false if the provided value is not a string primitive.
+ * ※ This function returns false if the provided value is not a string
+ * primitive.
*/
export const isBase64 = ($) => {
if (typeof $ !== "string") {
*/
export const isBase64 = ($) => {
if (typeof $ !== "string") {
/**
* Returns whether the provided value is a filename‐safe base64 string.
*
/**
* Returns whether the provided value is a filename‐safe base64 string.
*
- * Returns false if the provided value is not a string primitive.
+ * ※ This function returns false if the provided value is not a string
+ * primitive.
*/
export const isFilenameSafeBase64 = ($) => {
if (typeof $ !== "string") {
*/
export const isFilenameSafeBase64 = ($) => {
if (typeof $ !== "string") {