@punks/backend-core 0.0.76 → 0.0.78
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/dist/cjs/index.js +207 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/utils/encoding.d.ts +5 -0
- package/dist/cjs/types/utils/html.d.ts +61 -0
- package/dist/cjs/types/utils/index.d.ts +2 -0
- package/dist/cjs/types/utils/uid.d.ts +1 -0
- package/dist/esm/index.js +202 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/utils/encoding.d.ts +5 -0
- package/dist/esm/types/utils/html.d.ts +61 -0
- package/dist/esm/types/utils/index.d.ts +2 -0
- package/dist/esm/types/utils/uid.d.ts +1 -0
- package/dist/index.d.ts +15 -1
- package/package.json +1 -1
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
export declare const encodeUtf8: (value: Uint8Array) => string;
|
|
3
|
+
export declare const decodeUtf8: (value: string) => Buffer;
|
|
4
|
+
export declare const encodeBase64: (value: Uint8Array) => string;
|
|
5
|
+
export declare const decodeBase64: (value: string) => Buffer;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
type QuoteCharacter = '"' | "'";
|
|
2
|
+
export interface StateMachineOptions {
|
|
3
|
+
readonly allowedTags?: Set<string>;
|
|
4
|
+
readonly disallowedTags?: Set<string>;
|
|
5
|
+
readonly tagReplacementText: string;
|
|
6
|
+
readonly encodePlaintextTagDelimiters: boolean;
|
|
7
|
+
}
|
|
8
|
+
export type StateTransitionFunction = (next: State) => void;
|
|
9
|
+
export interface State {
|
|
10
|
+
consume(character: string, transition: StateTransitionFunction): string;
|
|
11
|
+
}
|
|
12
|
+
type InPlaintextStateTransitionFunction = (next: InTagNameState) => void;
|
|
13
|
+
export declare class InPlaintextState implements State {
|
|
14
|
+
private readonly options;
|
|
15
|
+
constructor(options: StateMachineOptions);
|
|
16
|
+
consume(character: string, transition: InPlaintextStateTransitionFunction): string;
|
|
17
|
+
}
|
|
18
|
+
export declare const enum TagMode {
|
|
19
|
+
Allowed = 0,
|
|
20
|
+
Disallowed = 1
|
|
21
|
+
}
|
|
22
|
+
type InTagNameStateTransitionFunction = (next: InPlaintextState | InTagState<TagMode.Allowed> | InTagState<TagMode.Disallowed> | InCommentState) => void;
|
|
23
|
+
export declare class InTagNameState implements State {
|
|
24
|
+
private readonly options;
|
|
25
|
+
private nameBuffer;
|
|
26
|
+
private isClosingTag;
|
|
27
|
+
constructor(options: StateMachineOptions);
|
|
28
|
+
consume(character: string, transition: InTagNameStateTransitionFunction): string;
|
|
29
|
+
private isNameBufferAnAllowedTag;
|
|
30
|
+
}
|
|
31
|
+
type InTagStateTransitionFunction<T extends TagMode> = (next: InPlaintextState | InQuotedStringInTagState<T>) => void;
|
|
32
|
+
export declare class InTagState<T extends TagMode> implements State {
|
|
33
|
+
readonly mode: T;
|
|
34
|
+
private readonly options;
|
|
35
|
+
constructor(mode: T, options: StateMachineOptions);
|
|
36
|
+
consume(character: string, transition: InTagStateTransitionFunction<T>): string;
|
|
37
|
+
}
|
|
38
|
+
type InQuotedStringInTagStateTransitionFunction<T extends TagMode> = (next: InTagState<T>) => void;
|
|
39
|
+
export declare class InQuotedStringInTagState<T extends TagMode> implements State {
|
|
40
|
+
readonly mode: T;
|
|
41
|
+
readonly quoteCharacter: QuoteCharacter;
|
|
42
|
+
private readonly options;
|
|
43
|
+
constructor(mode: T, quoteCharacter: QuoteCharacter, options: StateMachineOptions);
|
|
44
|
+
consume(character: string, transition: InQuotedStringInTagStateTransitionFunction<T>): string;
|
|
45
|
+
}
|
|
46
|
+
type InCommentStateTransitionFunction = (next: InPlaintextState) => void;
|
|
47
|
+
export declare class InCommentState implements State {
|
|
48
|
+
private readonly options;
|
|
49
|
+
private consecutiveHyphens;
|
|
50
|
+
constructor(options: StateMachineOptions);
|
|
51
|
+
consume(character: string, transition: InCommentStateTransitionFunction): string;
|
|
52
|
+
}
|
|
53
|
+
export declare const DefaultStateMachineOptions: StateMachineOptions;
|
|
54
|
+
export declare class StateMachine {
|
|
55
|
+
private state;
|
|
56
|
+
private transitionFunction;
|
|
57
|
+
constructor(partialOptions?: Partial<StateMachineOptions>);
|
|
58
|
+
consume(text: string): string;
|
|
59
|
+
}
|
|
60
|
+
export declare function stripTags(text: string, options?: Partial<StateMachineOptions>): string;
|
|
61
|
+
export {};
|
|
@@ -6,6 +6,8 @@ export { getDirectoryFilePaths } from "./files";
|
|
|
6
6
|
export { joinPath, splitPath, ensureDirectory, getDirectoryPath, createDayPath, } from "./paths";
|
|
7
7
|
export * from "./strings";
|
|
8
8
|
export * from "./objects";
|
|
9
|
+
export * from "./encoding";
|
|
10
|
+
export { stripTags } from "./html";
|
|
9
11
|
export { maskVariable } from "./variables";
|
|
10
12
|
export * from "./text";
|
|
11
13
|
export * from "./threading";
|
package/dist/index.d.ts
CHANGED
|
@@ -251,6 +251,19 @@ declare const jsonSerialize: (obj: any, options?: {
|
|
|
251
251
|
prettify?: boolean;
|
|
252
252
|
}) => string;
|
|
253
253
|
|
|
254
|
+
declare const encodeUtf8: (value: Uint8Array) => string;
|
|
255
|
+
declare const decodeUtf8: (value: string) => Buffer;
|
|
256
|
+
declare const encodeBase64: (value: Uint8Array) => string;
|
|
257
|
+
declare const decodeBase64: (value: string) => Buffer;
|
|
258
|
+
|
|
259
|
+
interface StateMachineOptions {
|
|
260
|
+
readonly allowedTags?: Set<string>;
|
|
261
|
+
readonly disallowedTags?: Set<string>;
|
|
262
|
+
readonly tagReplacementText: string;
|
|
263
|
+
readonly encodePlaintextTagDelimiters: boolean;
|
|
264
|
+
}
|
|
265
|
+
declare function stripTags(text: string, options?: Partial<StateMachineOptions>): string;
|
|
266
|
+
|
|
254
267
|
declare const maskVariable: (value: string | undefined, unmaskedLength?: number) => string;
|
|
255
268
|
|
|
256
269
|
declare const pluralize: (word: string) => string;
|
|
@@ -271,6 +284,7 @@ declare const mapOrThrow: <T>({ mapper, throw: throwFn, }: {
|
|
|
271
284
|
}) => T;
|
|
272
285
|
|
|
273
286
|
declare const newUuid: () => string;
|
|
287
|
+
declare const generateHash: (length: number) => string;
|
|
274
288
|
|
|
275
289
|
declare function serializeQueryString(obj: {
|
|
276
290
|
[key: string]: any;
|
|
@@ -315,4 +329,4 @@ type ExcelParseOptions = {
|
|
|
315
329
|
};
|
|
316
330
|
declare const excelParse: (file: string | ArrayBuffer, options?: ExcelParseOptions) => any;
|
|
317
331
|
|
|
318
|
-
export { AppServiceReference, ConsoleLogger, CsvBuildOptions, CsvColumnDefinition, DatadogLogger, Dict, ExcelColumnDefinition, ExcelKeyTransform, ExcelParseOptions, ExcelSheetDefinition, FileLogger, ILogger, ILoggerProvider, IResolveServiceOptions, IServiceLocator, ITree, ITreeNode, LocalizedField, Log, LogLevel, MetaSerializationType, Optional, RichText, TimeUnit, TreeNodeBuilder, addTime, buildObject, buildTree, buildUrl, byField, byFieldDesc, camelToKebabCase, camelToSnakeCase, createDayPath, csvBuild, csvParse, deserializeQueryString, distinct, distinctElements, ensureDirectory, ensureStartSlash, ensureTailingSlash, excelBuild, excelParse, first, flatten, floorDateToSecond, getDirectoryFilePaths, getDirectoryPath, getQueryParameter, groupBy, indexes, isNullOrUndefined, iterate, joinPath, joinUrl, jsonDistinct, jsonSerialize, last, logMemoryUsage, mapAsync, mapOrThrow, maskVariable, mergeDeep, multipleSplit, newUuid, notNull, notUndefined, pluralize, processArrayDifferences, processArrayItemMove, range, removeUndefinedProps, selectMany, serializeQueryString, sleep, sort, splitPath, subArrays, subtractTime, testInternetConnection, toArrayDict, toCamelCase, toDict, toItemsDict, toItemsMap, toMap, toTitleCase, trim, trimEnd, trimStart, updateQueryParameters };
|
|
332
|
+
export { AppServiceReference, ConsoleLogger, CsvBuildOptions, CsvColumnDefinition, DatadogLogger, Dict, ExcelColumnDefinition, ExcelKeyTransform, ExcelParseOptions, ExcelSheetDefinition, FileLogger, ILogger, ILoggerProvider, IResolveServiceOptions, IServiceLocator, ITree, ITreeNode, LocalizedField, Log, LogLevel, MetaSerializationType, Optional, RichText, TimeUnit, TreeNodeBuilder, addTime, buildObject, buildTree, buildUrl, byField, byFieldDesc, camelToKebabCase, camelToSnakeCase, createDayPath, csvBuild, csvParse, decodeBase64, decodeUtf8, deserializeQueryString, distinct, distinctElements, encodeBase64, encodeUtf8, ensureDirectory, ensureStartSlash, ensureTailingSlash, excelBuild, excelParse, first, flatten, floorDateToSecond, generateHash, getDirectoryFilePaths, getDirectoryPath, getQueryParameter, groupBy, indexes, isNullOrUndefined, iterate, joinPath, joinUrl, jsonDistinct, jsonSerialize, last, logMemoryUsage, mapAsync, mapOrThrow, maskVariable, mergeDeep, multipleSplit, newUuid, notNull, notUndefined, pluralize, processArrayDifferences, processArrayItemMove, range, removeUndefinedProps, selectMany, serializeQueryString, sleep, sort, splitPath, stripTags, subArrays, subtractTime, testInternetConnection, toArrayDict, toCamelCase, toDict, toItemsDict, toItemsMap, toMap, toTitleCase, trim, trimEnd, trimStart, updateQueryParameters };
|