1 // ♓🌟 Piscēs ∷ string.js
2 // ====================================================================
4 // Copyright © 2022 Lady [@ Lady’s Computer].
6 // This Source Code Form is subject to the terms of the Mozilla Public
7 // License, v. 2.0. If a copy of the MPL was not distributed with this
8 // file, You can obtain one at <https://mozilla.org/MPL/2.0/>.
11 * Returns the result of converting the provided value to A·S·C·I·I
14 export const asciiLowercase
= ($) =>
17 Function
.prototype.call
.bind(String
.prototype.toLowerCase
),
21 * Returns the result of converting the provided value to A·S·C·I·I
24 export const asciiUppercase
= ($) =>
27 Function
.prototype.call
.bind(String
.prototype.toUpperCase
),
31 * Returns the result of converting the provided value to a string of
32 * scalar values by replacing (unpaired) surrogate values with U+FFFD.
34 export const scalarValueString
= ($) =>
37 for (const char of `${$}`) {
38 const scalar
= char.codePointAt(0);
39 yield scalar
>= 0xD800 && scalar
<= 0xDFFF ? 0xFFFD : scalar
;
45 * Returns the result of splitting the provided value on A·S·C·I·I
48 export const splitOnASCIIWhitespace
= ($) =>
49 stripAndCollapseASCIIWhitespace($).split(" ");
52 * Returns the result of splitting the provided value on commas,
53 * trimming A·S·C·I·I whitespace from the resulting tokens.
55 export const splitOnCommas
= ($) =>
56 stripLeadingAndTrailingASCIIWhitespace(
58 /[\n\r\t\f ]*,[\n\r\t\f ]*/gu,
64 * Returns the result of stripping leading and trailing A·S·C·I·I
65 * whitespace from the provided value.
67 export const stripLeadingAndTrailingASCIIWhitespace
= ($) =>
68 /^[\n\r\t\f ]*([^]*?)[\n\r\t\f ]*$/u.exec($)[1];
71 * Returns the result of stripping leading and trailing A·S·C·I·I
72 * whitespace from the provided value and collapsing other A·S·C·I·I
73 * whitespace in the provided value.
75 export const stripAndCollapseASCIIWhitespace
= ($) =>
76 stripLeadingAndTrailingASCIIWhitespace(