@thi.ng/strings 3.7.33 → 3.7.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2024-05-08T18:24:31Z
3
+ - **Last updated**: 2024-06-21T19:34:38Z
4
4
  - **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
5
5
 
6
6
  All notable changes to this project will be documented in this file.
@@ -9,6 +9,13 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
9
9
  **Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
10
10
  and/or version bumps of transitive dependencies.
11
11
 
12
+ ### [3.7.34](https://github.com/thi-ng/umbrella/tree/@thi.ng/strings@3.7.34) (2024-06-21)
13
+
14
+ #### ♻️ Refactoring
15
+
16
+ - rename various rest args to be more semantically meaningful ([8088a56](https://github.com/thi-ng/umbrella/commit/8088a56))
17
+ - enforce uniform naming convention of internal functions ([56992b2](https://github.com/thi-ng/umbrella/commit/56992b2))
18
+
12
19
  ### [3.7.31](https://github.com/thi-ng/umbrella/tree/@thi.ng/strings@3.7.31) (2024-04-20)
13
20
 
14
21
  #### ♻️ Refactoring
package/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  [![Mastodon Follow](https://img.shields.io/mastodon/follow/109331703950160316?domain=https%3A%2F%2Fmastodon.thi.ng&style=social)](https://mastodon.thi.ng/@toxi)
8
8
 
9
9
  > [!NOTE]
10
- > This is one of 192 standalone projects, maintained as part
10
+ > This is one of 193 standalone projects, maintained as part
11
11
  > of the [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo
12
12
  > and anti-framework.
13
13
  >
package/ansi.d.ts CHANGED
@@ -2,10 +2,12 @@
2
2
  * Removes all ANSI control sequences from given string.
3
3
  *
4
4
  * @example
5
- * ```ts
5
+ * ```ts tangle:../export/strip-ansi.ts
6
6
  * import { stripAnsi } from "@thi.ng/strings";
7
7
  *
8
- * stripAnsi("\x1B[32mhello\x1B[0m \x1B[91mworld\x1B[0m!"");
8
+ * console.log(
9
+ * stripAnsi("\x1B[32mhello\x1B[0m \x1B[91mworld\x1B[0m!")
10
+ * );
9
11
  * // 'hello world!'
10
12
  * ```
11
13
  *
package/api.d.ts CHANGED
@@ -4,7 +4,7 @@ import type { Fn, Fn2, FnU } from "@thi.ng/api";
4
4
  * https://en.wikipedia.org/wiki/Byte_order_mark
5
5
  */
6
6
  export declare const BOM = "\uFEFF";
7
- export type Stringer<T> = (x: T, ...xs: any[]) => string;
7
+ export type Stringer<T> = (x: T, ...args: any[]) => string;
8
8
  export type FnS = FnU<string>;
9
9
  export interface WordWrapOpts {
10
10
  /**
package/case.d.ts CHANGED
@@ -22,10 +22,12 @@ export declare const capitalize: FnS;
22
22
  * delimiter (`-` by default).
23
23
  *
24
24
  * @example
25
- * ```ts
25
+ * ```ts tangle:../export/kebab.ts
26
26
  * import { kebab } from "@thi.ng/strings";
27
27
  *
28
- * kebab("FooBar23Baz");
28
+ * console.log(
29
+ * kebab("FooBar23Baz")
30
+ * );
29
31
  * // "foo-bar23-baz"
30
32
  * ```
31
33
  *
package/center.d.ts CHANGED
@@ -10,22 +10,24 @@ import type { Stringer } from "./api.js";
10
10
  * Note: The padding string can contain multiple characters.
11
11
  *
12
12
  * @example
13
- * ```ts
14
- * import { center, wrap } from "@thi.ng/strings";
13
+ * ```ts tangle:../export/center.ts
14
+ * import { center } from "@thi.ng/strings";
15
15
  *
16
- * center(20, "<>")(wrap(" ")("thi.ng"))
16
+ * console.log(
17
+ * center(20, "<>")(" thi.ng ")
18
+ * );
17
19
  * // "<><><> thi.ng <><><>"
18
20
  * ```
19
21
  *
20
22
  * @example
21
- * ```ts
23
+ * ```ts tangle:../export/center-2.ts
22
24
  * import { comp } from "@thi.ng/compose";
23
25
  * import { center, wrap } from "@thi.ng/strings";
24
26
  *
25
27
  * // compose formatting function
26
28
  * const fmt = comp(center(20,"<>"), wrap(" "));
27
29
  *
28
- * fmt("thi.ng")
30
+ * console.log(fmt("thi.ng"));
29
31
  * // "<><><> thi.ng <><><>"
30
32
  * ```
31
33
  *
package/cursor.d.ts CHANGED
@@ -8,14 +8,18 @@
8
8
  * optional `offset` arg (also in `[line,column]` order).
9
9
  *
10
10
  * @example
11
- * ```ts
11
+ * ```ts tangle:../export/compute-cursor-pos.ts
12
12
  * import { computeCursorPos } from "@thi.ng/strings";
13
13
  *
14
- * computeCursorPos("thi.ng\numbrella", 10);
14
+ * console.log(
15
+ * computeCursorPos("thi.ng\numbrella", 10)
16
+ * );
15
17
  * // [ 2, 4 ]
16
18
  *
17
19
  * // w/ custom offset
18
- * computeCursorPos("thi.ng\numbrella", 10, "\n", [11, 1]);
20
+ * console.log(
21
+ * computeCursorPos("thi.ng\numbrella", 10, "\n", [11, 1])
22
+ * );
19
23
  * // [ 12, 4 ]
20
24
  * ```
21
25
  *
package/escape.d.ts CHANGED
@@ -10,6 +10,8 @@ export declare const ESCAPES_REV: Record<number, string>;
10
10
  * - Non-BMP chars will be escaped using `\Uxxxxxxxx`
11
11
  * - Chars outside 0x20 - 0x7e range will be escaped using `\uxxxxx`
12
12
  *
13
+ * Also see {@link unescape}.
14
+ *
13
15
  * @param src -
14
16
  */
15
17
  export declare const escape: (src: string) => string;
@@ -26,11 +28,13 @@ export declare const escape: (src: string) => string;
26
28
  * - https://www.branah.com/unicode-converter
27
29
  *
28
30
  * @example
29
- * ```ts
31
+ * ```ts tangle:../export/unescape.ts
30
32
  * import { unescape } from "@thi.ng/strings";
31
33
  *
32
- * unescape("\\ud83d\\ude0e \\U0001f60e")
33
- * // '😎'
34
+ * console.log(
35
+ * unescape("\\ud83d\\ude0e \\U0001f60e")
36
+ * );
37
+ * // '😎 😎'
34
38
  * ```
35
39
  *
36
40
  * @param src -
package/float.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { memoizeJ } from "@thi.ng/memoize/memoizej";
2
2
  import { padLeft } from "./pad-left.js";
3
3
  const float = memoizeJ(
4
- (prec, special = false) => special ? (x) => nanOrInf(x) || x.toFixed(prec) : (x) => x.toFixed(prec)
4
+ (prec, special = false) => special ? (x) => __nanOrInf(x) || x.toFixed(prec) : (x) => x.toFixed(prec)
5
5
  );
6
6
  const floatFixedWidth = memoizeJ((width, prec = 3) => {
7
7
  const l = width - prec - 1;
@@ -12,17 +12,17 @@ const floatFixedWidth = memoizeJ((width, prec = 3) => {
12
12
  return (x) => {
13
13
  const ax = Math.abs(x);
14
14
  return pad(
15
- nanOrInf(x) || (x === 0 ? "0" : ax < pr || ax >= pl ? exp(x, width) : x.toFixed(prec - (x < pln ? 1 : 0)))
15
+ __nanOrInf(x) || (x === 0 ? "0" : ax < pr || ax >= pl ? __exp(x, width) : x.toFixed(prec - (x < pln ? 1 : 0)))
16
16
  );
17
17
  };
18
18
  });
19
- const exp = (x, w) => x.toExponential(
19
+ const __exp = (x, w) => x.toExponential(
20
20
  Math.max(
21
21
  w - 4 - (Math.log(Math.abs(x)) / Math.LN10 >= 10 ? 2 : 1) - (x < 0 ? 1 : 0),
22
22
  0
23
23
  )
24
24
  );
25
- const nanOrInf = (x) => isNaN(x) ? "NaN" : x === Infinity ? "+\u221E" : x === -Infinity ? "-\u221E" : void 0;
25
+ const __nanOrInf = (x) => isNaN(x) ? "NaN" : x === Infinity ? "+\u221E" : x === -Infinity ? "-\u221E" : void 0;
26
26
  export {
27
27
  float,
28
28
  floatFixedWidth
package/groups.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { charRange } from "./range.js";
2
- const defGroup = (...xs) => {
2
+ const __defGroup = (...ranges) => {
3
3
  const acc = {};
4
- for (let range of xs) {
4
+ for (let range of ranges) {
5
5
  for (let c of range) {
6
6
  acc[c] = true;
7
7
  }
@@ -16,21 +16,21 @@ const WS = Object.freeze({
16
16
  "\r": true,
17
17
  " ": true
18
18
  });
19
- const DIGITS = defGroup(charRange("0", "9"));
20
- const HEX = defGroup(
19
+ const DIGITS = __defGroup(charRange("0", "9"));
20
+ const HEX = __defGroup(
21
21
  charRange("0", "9"),
22
22
  charRange("A", "F"),
23
23
  charRange("a", "f")
24
24
  );
25
- const LOWER = defGroup(charRange("a", "z"));
26
- const UPPER = defGroup(charRange("A", "Z"));
25
+ const LOWER = __defGroup(charRange("a", "z"));
26
+ const UPPER = __defGroup(charRange("A", "Z"));
27
27
  const ALPHA = Object.freeze({ ...UPPER, ...LOWER });
28
28
  const ALPHA_NUM = Object.freeze({
29
29
  ...ALPHA,
30
30
  ...DIGITS,
31
31
  _: true
32
32
  });
33
- const PUNCTUATION = defGroup(
33
+ const PUNCTUATION = __defGroup(
34
34
  charRange("!", "/"),
35
35
  charRange(":", "@"),
36
36
  charRange("[", "`"),
package/hollerith.d.ts CHANGED
@@ -2,18 +2,21 @@ import type { Stringer } from "./api.js";
2
2
  /**
3
3
  * Formats given value `x` as Fortran style Hollerith string.
4
4
  *
5
+ * @remarks
6
+ * References:
7
+ * - https://en.wikipedia.org/wiki/Hollerith_constant
8
+ * - https://en.wikipedia.org/wiki/IGES#File_format
9
+ *
5
10
  * @example
6
- * ```ts
11
+ * ```ts tangle:../export/hstr.ts
7
12
  * import { hstr } from "@thi.ng/strings";
8
13
  *
9
- * hstr("abc") // "3Habc"
10
- * hstr(123.45) // "6H123.45"
11
- * hstr("") // "0H"
12
- * hstr(null) // ""
14
+ * console.log(hstr("abc")); // "3Habc"
15
+ * console.log(hstr(123.45)); // "6H123.45"
16
+ * console.log(hstr("")); // "0H"
17
+ * console.log(hstr(null)); // ""
13
18
  * ```
14
19
  *
15
- * https://en.wikipedia.org/wiki/Hollerith_constant
16
- *
17
20
  * @param x -
18
21
  */
19
22
  export declare const hstr: Stringer<any>;
package/initials.d.ts CHANGED
@@ -4,14 +4,22 @@
4
4
  * (default: uppercase). If `mode` is null, the original casing will be kept.
5
5
  *
6
6
  * @example
7
- * ```ts
8
- * initials(["alicia", "bella", "carerra"]);
7
+ * ```ts tangle:../export/initials.ts
8
+ * import { initials } from "@thi.ng/strings";
9
+ *
10
+ * console.log(
11
+ * initials(["alicia", "bella", "carerra"])
12
+ * );
9
13
  * // "ABC"
10
14
  *
11
- * initials("shader-ast-GLSL".split("-"))
15
+ * console.log(
16
+ * initials("shader-ast-GLSL".split("-"))
17
+ * );
12
18
  * // "SAG"
13
19
  *
14
- * initials("Ludwig van Beethoven".split(" "), null)
20
+ * console.log(
21
+ * initials("Ludwig van Beethoven".split(" "), null)
22
+ * );
15
23
  * // "LvB"
16
24
  * ```
17
25
  *
package/interpolate.d.ts CHANGED
@@ -4,9 +4,16 @@ import type { IObjectOf, NumOrString } from "@thi.ng/api";
4
4
  * number of args. Replaces numbered terms with their respective args
5
5
  * given.
6
6
  *
7
+ * @remarks
8
+ * Also see {@link interpolateKeys}.
9
+ *
7
10
  * @example
8
- * ```ts
9
- * interpolate("let {0}: {2} = {1};", "a", 42, "number")
11
+ * ```ts tangle:../export/interpolate.ts
12
+ * import { interpolate } from "@thi.ng/strings";
13
+ *
14
+ * console.log(
15
+ * interpolate("let {0}: {2} = {1};", "a", 42, "number")
16
+ * );
10
17
  * // "let a: number = 42;"
11
18
  * ```
12
19
  *
@@ -19,11 +26,15 @@ export declare const interpolate: (src: string, ...args: any[]) => string;
19
26
  * template string and an object of values for the stated keys.
20
27
  *
21
28
  * @example
22
- * ```ts
23
- * interpolateKeys(
24
- * "let {id}: {type} = {val};",
25
- * { id: "a", type: "number", val: 42 }
26
- * )
29
+ * ```ts tangle:../export/interpolate-keys.ts
30
+ * import { interpolateKeys } from "@thi.ng/strings";
31
+ *
32
+ * console.log(
33
+ * interpolateKeys(
34
+ * "let {id}: {type} = {val};",
35
+ * { id: "a", type: "number", val: 42 }
36
+ * )
37
+ * );
27
38
  * // "let a: number = 42;"
28
39
  * ```
29
40
  *
package/join.d.ts CHANGED
@@ -5,13 +5,15 @@ import type { Stringer } from "./api.js";
5
5
  * separator into a result string.
6
6
  *
7
7
  * @example
8
- * ```ts
8
+ * ```ts tangle:../export/join.ts
9
9
  * import { format, join } from "@thi.ng/strings";
10
10
  * import { partial } from "@thi.ng/compose";
11
11
  *
12
12
  * const slashes = join("/");
13
13
  *
14
- * slashes([1, 2, 3]);
14
+ * console.log(
15
+ * slashes([1, 2, 3])
16
+ * );
15
17
  * // "1/2/3"
16
18
  *
17
19
  * // pre-compose formatter function w/ partial arguments
@@ -19,7 +21,9 @@ import type { Stringer } from "./api.js";
19
21
  * format, ["f ", slashes, " ", slashes, " ", slashes]
20
22
  * );
21
23
  *
22
- * formatOBJFace([1, 2], [3, 4], [5, 6]);
24
+ * console.log(
25
+ * formatOBJFace([1, 2], [3, 4], [5, 6])
26
+ * );
23
27
  * // "f 1/2 3/4 5/6"
24
28
  * ```
25
29
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/strings",
3
- "version": "3.7.33",
3
+ "version": "3.7.34",
4
4
  "description": "Various string formatting & utility functions",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -10,7 +10,7 @@
10
10
  "type": "git",
11
11
  "url": "https://github.com/thi-ng/umbrella.git"
12
12
  },
13
- "homepage": "https://github.com/thi-ng/umbrella/tree/develop/packages/format#readme",
13
+ "homepage": "https://thi.ng/format",
14
14
  "funding": [
15
15
  {
16
16
  "type": "github",
@@ -36,16 +36,16 @@
36
36
  "tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
37
37
  },
38
38
  "dependencies": {
39
- "@thi.ng/api": "^8.11.2",
40
- "@thi.ng/errors": "^2.5.7",
41
- "@thi.ng/hex": "^2.3.46",
42
- "@thi.ng/memoize": "^3.3.4"
39
+ "@thi.ng/api": "^8.11.3",
40
+ "@thi.ng/errors": "^2.5.8",
41
+ "@thi.ng/hex": "^2.3.47",
42
+ "@thi.ng/memoize": "^3.3.5"
43
43
  },
44
44
  "devDependencies": {
45
- "@microsoft/api-extractor": "^7.43.2",
46
- "esbuild": "^0.21.1",
45
+ "@microsoft/api-extractor": "^7.47.0",
46
+ "esbuild": "^0.21.5",
47
47
  "typedoc": "^0.25.13",
48
- "typescript": "^5.4.5"
48
+ "typescript": "^5.5.2"
49
49
  },
50
50
  "keywords": [
51
51
  "ansi",
@@ -203,5 +203,5 @@
203
203
  "thi.ng": {
204
204
  "year": 2015
205
205
  },
206
- "gitHead": "df34b4a9e650cc7323575356de207d78933bdcf3\n"
206
+ "gitHead": "154c95cf9d6bab32174498ec3b5b5d87e42be7f9\n"
207
207
  }
package/ruler.d.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  * ticks and `b` for minor ticks.
4
4
  *
5
5
  * @example
6
- * ```ts
6
+ * ```ts tangle:../export/ruler.ts
7
7
  * import { ruler } from "@thi.ng/strings";
8
8
  *
9
9
  * console.log(ruler(40))
@@ -24,7 +24,7 @@ export declare const ruler: (width: number, major?: number, a?: string, b?: stri
24
24
  * `h`. The optional `chars` can be used to customize the grid.
25
25
  *
26
26
  * @example
27
- * ```ts
27
+ * ```ts tangle:../export/grid.ts
28
28
  * import { grid } from "@thi.ng/strings";
29
29
  *
30
30
  * console.log(grid(3, 3, 4, 2));
package/slugify.d.ts CHANGED
@@ -4,10 +4,12 @@ import type { Stringer } from "./api.js";
4
4
  * https://medium.com/@matthagemann/the-ultimate-way-to-slugify-a-url-string-in-javascript-b8e4a0d849e1
5
5
  *
6
6
  * @example
7
- * ```ts
7
+ * ```ts tangle:../export/slugify.ts
8
8
  * import { slugify } from "@thi.ng/strings";
9
9
  *
10
- * slugify("Me, myself (& ëye) 😀!")
10
+ * console.log(
11
+ * slugify("Me, myself (& ëye) 😀!")
12
+ * );
11
13
  * // "me-myself-and-eye"
12
14
  * ```
13
15
  *
@@ -19,10 +21,12 @@ export declare const slugify: Stringer<string>;
19
21
  * for headings in markdown files (AFAICT).
20
22
  *
21
23
  * @example
22
- * ```ts
24
+ * ```ts tangle:../export/slugify-gh.ts
23
25
  * import { slugifyGH } from "@thi.ng/strings";
24
26
  *
25
- * slugifyGH("Me, myself (& ëye) 😀!")
27
+ * console.log(
28
+ * slugifyGH("Me, myself (& ëye) 😀!")
29
+ * );
26
30
  * // "me-myself--ëye-"
27
31
  * ```
28
32
  *
package/slugify.js CHANGED
@@ -1,8 +1,8 @@
1
- const src = "\xE0\xE1\xE4\xE2\xE3\xE5\xE8\xE9\xEB\xEA\xEC\xED\xEF\xEE\xF2\xF3\xF6\xF4\xF9\xFA\xFC\xFB\xF1\xE7\xDF\xFF\u0153\xE6\u0155\u015B\u0144\u1E55\u1E83\u01F5\u01F9\u1E3F\u01D8\u1E8D\u017A\u1E27\xB7/_,:;";
2
- const dest = "aaaaaaeeeeiiiioooouuuuncsyoarsnpwgnmuxzh------";
3
- const re = new RegExp(src.split("").join("|"), "g");
1
+ const SRC = "\xE0\xE1\xE4\xE2\xE3\xE5\xE8\xE9\xEB\xEA\xEC\xED\xEF\xEE\xF2\xF3\xF6\xF4\xF9\xFA\xFC\xFB\xF1\xE7\xDF\xFF\u0153\xE6\u0155\u015B\u0144\u1E55\u1E83\u01F5\u01F9\u1E3F\u01D8\u1E8D\u017A\u1E27\xB7/_,:;";
2
+ const DEST = "aaaaaaeeeeiiiioooouuuuncsyoarsnpwgnmuxzh------";
3
+ const RE = new RegExp(SRC.split("").join("|"), "g");
4
4
  const slugify = (str) => {
5
- return str.toLowerCase().replace(/\s+/g, "-").replace(re, (c) => dest[src.indexOf(c)]).replace(/&+/g, "-and-").replace(/[^\w-]+/g, "").replace(/\p{Emoji_Presentation}/gu, "").replace(/-{2,}/g, "-").replace(/(^-+)|(-+$)/g, "");
5
+ return str.toLowerCase().replace(/\s+/g, "-").replace(RE, (c) => DEST[SRC.indexOf(c)]).replace(/&+/g, "-and-").replace(/[^\w-]+/g, "").replace(/\p{Emoji_Presentation}/gu, "").replace(/-{2,}/g, "-").replace(/(^-+)|(-+$)/g, "");
6
6
  };
7
7
  const slugifyGH = (str) => {
8
8
  return str.toLowerCase().replace(
package/stringify.d.ts CHANGED
@@ -7,16 +7,22 @@ import type { Stringer } from "./api.js";
7
7
  * null, indent)`
8
8
  *
9
9
  * @example
10
- * ```ts
10
+ * ```ts tangle:../export/stringify.ts
11
11
  * import { stringify } from "@thi.ng/strings";
12
12
  *
13
- * stringify()("hello");
13
+ * console.log(
14
+ * stringify()("hello")
15
+ * );
14
16
  * // hello
15
17
  *
16
- * stringify(true)("hello");
18
+ * console.log(
19
+ * stringify(true)("hello")
20
+ * );
17
21
  * // "hello"
18
22
  *
19
- * stringify()({ a: "hello" })
23
+ * console.log(
24
+ * stringify()({ a: "hello" })
25
+ * );
20
26
  * // { "a": "hello" }
21
27
  * ```
22
28
  *
package/tabs.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  * Multi-line version of {@link tabsToSpacesLine}.
3
3
  *
4
4
  * @example
5
- * ```ts
5
+ * ```ts tangle:../export/tabs-to-spaces.ts
6
6
  * import { tabsToSpaces } from "@thi.ng/strings";
7
7
  *
8
8
  * console.log(
@@ -23,7 +23,7 @@
23
23
  export declare const tabsToSpaces: (src: string, tabSize?: number) => string;
24
24
  /**
25
25
  * Takes a single line string and converts all tab characters to spaces, using
26
- * given `tabSize`.
26
+ * given `tabSize` (default: 4).
27
27
  *
28
28
  * @param line -
29
29
  * @param tabSize -
package/tabs.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { repeat } from "./repeat.js";
2
- const nextTab = (x, tabSize) => Math.floor((x + tabSize) / tabSize) * tabSize;
2
+ const __nextTab = (x, tabSize) => Math.floor((x + tabSize) / tabSize) * tabSize;
3
3
  const tabsToSpaces = (src, tabSize = 4) => src.split(/\r?\n/g).map((line) => tabsToSpacesLine(line, tabSize)).join("\n");
4
4
  const tabsToSpacesLine = (line, tabSize = 4) => {
5
5
  let res = "";
@@ -8,7 +8,7 @@ const tabsToSpacesLine = (line, tabSize = 4) => {
8
8
  for (let i = 0; i < n; i++) {
9
9
  const w = words[i];
10
10
  res += w;
11
- res += repeat(" ", nextTab(res.length, tabSize) - res.length);
11
+ res += repeat(" ", __nextTab(res.length, tabSize) - res.length);
12
12
  }
13
13
  res += words[n];
14
14
  return res;
@@ -25,7 +25,7 @@ const spacesToTabsLine = (line, tabSize = 4) => {
25
25
  i = m.index;
26
26
  const end = m.index + numSpaces;
27
27
  while (i < end) {
28
- const j = nextTab(i, tabSize);
28
+ const j = __nextTab(i, tabSize);
29
29
  if (j <= end) {
30
30
  res += " ";
31
31
  i = j;
package/trim.d.ts CHANGED
@@ -4,13 +4,17 @@ import type { Stringer } from "./api.js";
4
4
  * trimmable characters (default: whitespace only).
5
5
  *
6
6
  * @example
7
- * ```ts
7
+ * ```ts tangle:../export/trim.ts
8
8
  * import { trim } from "@thi.ng/strings";
9
9
  *
10
- * trim()(" Hello ")
10
+ * console.log(
11
+ * trim()(" Hello ")
12
+ * );
11
13
  * // "Hello"
12
14
  *
13
- * trim(" -+")("-+-+- Hello -+-+-")
15
+ * console.log(
16
+ * trim(" -+")("-+-+- Hello -+-+-")
17
+ * );
14
18
  * // "Hello"
15
19
  * ```
16
20
  *
package/utf8.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  /**
3
2
  * Returns the number of bytes required to encode the given string as UTF-8.
4
3
  *
@@ -45,10 +44,10 @@ export declare const UTF8Error: {
45
44
  origMessage: string;
46
45
  name: string;
47
46
  message: string;
48
- stack?: string | undefined;
47
+ stack?: string;
49
48
  cause?: unknown;
50
49
  };
51
- captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void;
50
+ captureStackTrace(targetObject: object, constructorOpt?: Function): void;
52
51
  prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
53
52
  stackTraceLimit: number;
54
53
  };
package/utf8.js CHANGED
@@ -27,7 +27,7 @@ const utf8Decode = (buf, start, num) => {
27
27
  c = (c & 15) << 12 | (buf[i++] & 63) << 6 | buf[i++] & 63;
28
28
  } else if (c >= 240 && c < 248) {
29
29
  c = (c & 7) << 18 | (buf[i++] & 63) << 12 | (buf[i++] & 63) << 6 | buf[i++] & 63;
30
- } else utf8Error();
30
+ } else __utf8Error();
31
31
  result += fromUtf8CodePoint(c);
32
32
  }
33
33
  }
@@ -64,10 +64,10 @@ const fromUtf8CodePoint = (x) => {
64
64
  x -= 65536;
65
65
  return String.fromCharCode(55296 | x >>> 10, 56320 | x & 1023);
66
66
  }
67
- return utf8Error(`invalid codepoint 0x${x.toString(16)}`);
67
+ return __utf8Error(`invalid codepoint 0x${x.toString(16)}`);
68
68
  };
69
69
  const UTF8Error = defError(() => "UTF-8 error");
70
- const utf8Error = (msg) => {
70
+ const __utf8Error = (msg) => {
71
71
  throw new UTF8Error(msg);
72
72
  };
73
73
  export {
package/uuid.d.ts CHANGED
@@ -11,5 +11,5 @@
11
11
  * @param id -
12
12
  * @param i -
13
13
  */
14
- export declare const uuid: (id: ArrayLike<number>, i?: number | undefined) => string;
14
+ export declare const uuid: (id: ArrayLike<number>, i?: number) => string;
15
15
  //# sourceMappingURL=uuid.d.ts.map
package/word-wrap.js CHANGED
@@ -34,11 +34,11 @@ const SPLIT_ANSI = {
34
34
  return i;
35
35
  }
36
36
  };
37
- const append = (acc, word, wordLen, width) => {
37
+ const __append = (acc, word, wordLen, width) => {
38
38
  const curr = acc[acc.length - 1];
39
39
  curr && width - curr.n > wordLen ? curr.add(word, wordLen) : acc.push(new Line(word, wordLen));
40
40
  };
41
- const wrapWord = (word, { width, min, hard, splitter }, offset = 0, acc = []) => {
41
+ const __wrapWord = (word, { width, min, hard, splitter }, offset = 0, acc = []) => {
42
42
  let len = splitter.length(word);
43
43
  let free = width - offset;
44
44
  if (free < min && free < len) {
@@ -47,12 +47,12 @@ const wrapWord = (word, { width, min, hard, splitter }, offset = 0, acc = []) =>
47
47
  while (hard && len > free) {
48
48
  const split2 = splitter.split(word, free);
49
49
  const chunk = word.substring(0, split2);
50
- append(acc, chunk, free, width);
50
+ __append(acc, chunk, free, width);
51
51
  word = word.substring(split2);
52
52
  free = width;
53
53
  len = splitter.length(word);
54
54
  }
55
- append(acc, word, len, width);
55
+ __append(acc, word, len, width);
56
56
  return acc;
57
57
  };
58
58
  const wordWrapLine = (line, opts, acc = []) => {
@@ -69,7 +69,7 @@ const wordWrapLine = (line, opts, acc = []) => {
69
69
  };
70
70
  for (let word of split(line, opts.delimWord || /\s/g)) {
71
71
  const curr = acc[acc.length - 1];
72
- wrapWord(word, $opts, curr && curr.n > 0 ? curr.n + 1 : 0, acc);
72
+ __wrapWord(word, $opts, curr && curr.n > 0 ? curr.n + 1 : 0, acc);
73
73
  }
74
74
  return acc;
75
75
  };