cafe-utility 11.0.2 → 11.1.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/index.d.ts +12 -10
- package/index.js +6 -3124
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
type Indexable = number | string;
|
|
2
|
+
type CafeObject<T = unknown> = Record<string, T>;
|
|
3
3
|
declare function invertPromise<T>(promise: Promise<T>): Promise<unknown>;
|
|
4
4
|
declare function raceFulfilled<T>(promises: Promise<T>[]): Promise<unknown>;
|
|
5
5
|
declare function runInParallelBatches<T>(promises: (() => Promise<T>)[], concurrency?: number): Promise<T[]>;
|
|
@@ -165,7 +165,7 @@ interface BlockExtractionOptions {
|
|
|
165
165
|
declare function extractBlock(string: string, options: BlockExtractionOptions): string | null;
|
|
166
166
|
declare function extractAllBlocks(string: string, options: BlockExtractionOptions): string[];
|
|
167
167
|
declare function replaceBlocks(string: string, replaceFn: (match: string) => string, options: BlockExtractionOptions): string;
|
|
168
|
-
|
|
168
|
+
type StringSegment = {
|
|
169
169
|
symbol: string | null;
|
|
170
170
|
string: string;
|
|
171
171
|
};
|
|
@@ -175,7 +175,7 @@ declare function uint8ArrayToBase64(array: Uint8Array): string;
|
|
|
175
175
|
declare function hexToUint8Array(hex: string): Uint8Array;
|
|
176
176
|
declare function uint8ArrayToHex(array: Uint8Array): string;
|
|
177
177
|
declare function route(pattern: string, actual: string): Record<string, unknown> | null;
|
|
178
|
-
|
|
178
|
+
type VariantGroup = {
|
|
179
179
|
variants: string[];
|
|
180
180
|
avoid: string | null;
|
|
181
181
|
};
|
|
@@ -183,6 +183,7 @@ declare function explodeReplace(string: string, substring: string, variants: str
|
|
|
183
183
|
declare function generateVariants(string: string, groups: VariantGroup[], count: number, generator?: () => number): string[];
|
|
184
184
|
declare function hashCode(string: string): number;
|
|
185
185
|
declare function replaceWord(string: string, search: string, replace: string, whitespaceOnly?: boolean): string;
|
|
186
|
+
declare function replacePascalCaseWords(string: string, replacer: (word: string) => string): string;
|
|
186
187
|
declare function containsWord(string: string, word: string): boolean;
|
|
187
188
|
declare function containsWords(string: string, words: string[], mode: 'any' | 'all'): boolean;
|
|
188
189
|
declare function parseHtmlAttributes(string: string): Record<string, string>;
|
|
@@ -211,7 +212,7 @@ declare function getAgoStructured(dateOrTimestamp: Date | number, now?: number):
|
|
|
211
212
|
value: number;
|
|
212
213
|
unit: string;
|
|
213
214
|
};
|
|
214
|
-
|
|
215
|
+
type CountCyclesOptions = {
|
|
215
216
|
precision?: number;
|
|
216
217
|
now?: number;
|
|
217
218
|
};
|
|
@@ -253,7 +254,7 @@ declare function getPreLine(string: string): string;
|
|
|
253
254
|
declare function getCached<T>(key: string, ttlMillis: number, handler: () => Promise<T>): Promise<T>;
|
|
254
255
|
declare function joinUrl(...parts: unknown[]): string;
|
|
255
256
|
declare function replaceBetweenStrings(string: string, start: string, end: string, replacement: string, keepBoundaries?: boolean): string;
|
|
256
|
-
|
|
257
|
+
type MarkdownDescription = {
|
|
257
258
|
type: 'p' | 'h1' | 'li';
|
|
258
259
|
isCapitalized: boolean;
|
|
259
260
|
hasPunctuation: boolean;
|
|
@@ -343,7 +344,7 @@ export declare class Maybe<T> {
|
|
|
343
344
|
bind<K>(fn: (value: T) => K): Maybe<Awaited<K>>;
|
|
344
345
|
valueOf(): Promise<T | null>;
|
|
345
346
|
}
|
|
346
|
-
|
|
347
|
+
type Playbook<T> = {
|
|
347
348
|
ttl: number;
|
|
348
349
|
ttlMax?: number;
|
|
349
350
|
data: T;
|
|
@@ -359,15 +360,15 @@ declare function requireStringArgument(args: string[], key: string, env?: Record
|
|
|
359
360
|
declare function requireNumberArgument(args: string[], key: string, env?: Record<string, string | undefined>, envKey?: string): number;
|
|
360
361
|
declare function bringToFrontInPlace<T>(array: T[], index: number): void;
|
|
361
362
|
declare function bringToFront<T>(array: T[], index: number): T[];
|
|
362
|
-
|
|
363
|
+
type Point = {
|
|
363
364
|
x: number;
|
|
364
365
|
y: number;
|
|
365
366
|
};
|
|
366
|
-
|
|
367
|
+
type Line = {
|
|
367
368
|
start: Point;
|
|
368
369
|
end: Point;
|
|
369
370
|
};
|
|
370
|
-
|
|
371
|
+
type Truthy = boolean | number;
|
|
371
372
|
declare function addPoint(a: Point, b: Point): Point;
|
|
372
373
|
declare function subtractPoint(a: Point, b: Point): Point;
|
|
373
374
|
declare function multiplyPoint(point: Point, scalar: number): Point;
|
|
@@ -647,6 +648,7 @@ export declare const Strings: {
|
|
|
647
648
|
generateVariants: typeof generateVariants;
|
|
648
649
|
hashCode: typeof hashCode;
|
|
649
650
|
replaceWord: typeof replaceWord;
|
|
651
|
+
replacePascalCaseWords: typeof replacePascalCaseWords;
|
|
650
652
|
};
|
|
651
653
|
export declare const Assertions: {
|
|
652
654
|
asEqual: typeof asEqual;
|