-export const {
- /**
- * Returns a string created from the provided code units.
- *
- * ※ This is effectively an alias for `String.fromCharCode`, but
- * with the same error behaviour as `String.fromCodePoint`.
- *
- * ☡ This function throws an error if provided with an argument which
- * is not an integral number from 0 to FFFF₁₆ inclusive.
- */
- stringFromCodeUnits,
-} = (() => {
- const { fromCharCode } = String;
- const { isInteger: isIntegralNumber } = Number;
-
- return {
- stringFromCodeUnits: defineOwnProperties(
- (...codeUnits) => {
- for (let index = 0; index < codeUnits.length; ++index) {
- // Iterate over each provided code unit and throw if it is
- // out of range.
- const nextCU = +codeUnits[index];
- if (
- !isIntegralNumber(nextCU) || nextCU < 0 || nextCU > 0xFFFF
- ) {
- // The code unit is not an integral number between 0 and
- // 0xFFFF.
- throw new RangeError(
- `Piscēs: Code unit out of range: ${nextCU}.`,
- );
- } else {
- // The code unit is acceptable.
- /* do nothing */
- }
- }
- return call(fromCharCode, undefined, codeUnits);
- },
- { name: { value: "stringFromCodeUnits" }, length: { value: 1 } },
- ),
- };
-})();
-