@tolki/types 1.11.0 → 1.12.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tolki/types",
3
- "version": "1.11.0",
3
+ "version": "1.12.0",
4
4
  "description": "Utility TypeScript types for @tolki packages and Laravel HTTP responses.",
5
5
  "author": "Abraham Arango <https://github.com/abetwothree>",
6
6
  "license": "MIT",
package/src/objects.d.ts CHANGED
@@ -26,7 +26,7 @@ export type NonObjectItems =
26
26
  /**
27
27
  * `NonObjectItems` without the Map, for an obj helper's empty-result row, so `Map | string[]` is not typed as empty.
28
28
  *
29
- * @remarks A Map keyed by `unknown`, `any` or an object type still fits the `WeakMap` member, so a union
29
+ * @remarks A Map keyed by `any` or an object type still fits the `WeakMap` member, so a union
30
30
  * holding it beside another of these values is typed as empty, though its Map is walked.
31
31
  */
32
32
  export type NonKeyedItems = Exclude<
package/src/strings.d.ts CHANGED
@@ -1,3 +1,29 @@
1
1
  export interface CanBeEscapedWhenCastToString {
2
2
  escapeWhenCastToString(escape: boolean): this;
3
3
  }
4
+
5
+ /**
6
+ * A subject Str's replace() and remove() accept: a string, strings in a list, Map, collection or iterable,
7
+ * or an object of strings.
8
+ */
9
+ export type StringSubject<TSubject> =
10
+ | string
11
+ | Iterable<string>
12
+ | ReadonlyMap<unknown, string>
13
+ | (object & { readonly [K in keyof TSubject]: string });
14
+
15
+ /**
16
+ * What replace() and remove() return for a subject: a string for a string, else the subject's shape holding
17
+ * strings.
18
+ */
19
+ export type StringSubjectResult<TSubject> = TSubject extends string
20
+ ? string
21
+ : TSubject extends ReadonlyMap<infer TKey, unknown>
22
+ ? Map<TKey, string>
23
+ : TSubject extends readonly unknown[]
24
+ ? string[]
25
+ : TSubject extends { all(): infer TItems }
26
+ ? StringSubjectResult<TItems>
27
+ : TSubject extends Iterable<unknown>
28
+ ? string[]
29
+ : { [K in keyof TSubject]: string };