Skip to content

Commit

Permalink
types
Browse files Browse the repository at this point in the history
  • Loading branch information
pyramation committed May 17, 2024
1 parent 5992d4d commit e29be9e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 9 deletions.
40 changes: 31 additions & 9 deletions types/js.d.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,44 @@
export interface JSStringifySetterOptions<ObjType, RootType> {
currentKey: string;
currentPath: string;
value: any;
obj: ObjType;
root: RootType;
defaultValuesMap: {
[path: string]: any;
};
}
export interface JSStringifyPropertyReplacerOptions<ObjType, RootType> {
currentKey: string;
currentPath: string;
propertyRenameMap: {
[pattern: string]: string;
};
obj: ObjType;
root: RootType;
value?: any;
}
export type JSStringifySetter = (options: JSStringifySetterOptions<any, any>) => any;
export type JSStringifyReplacer = (options: JSStringifyPropertyReplacerOptions<any, any>) => any;
export interface JSStringifyOptions {
space?: number;
replacer?: (key: string, value: any) => any | null;
propertyReplacer?: (currentKey: string, currentPath: string, propertyRenameMap: {
[pattern: string]: string;
}) => string;
propertyReplacer?: (options: JSStringifyPropertyReplacerOptions<any, any>) => string;
valueReplacer?: Record<string, (options: JSStringifyPropertyReplacerOptions<any, any>) => any>;
quotes?: 'single' | 'double' | 'backtick';
inlineArrayLimit?: number;
camelCase?: boolean;
camelCaseFn?: (str: string) => string;
propertyRenameMap?: {
[key: string]: string;
};
include?: string[];
exclude?: string[];
defaultValuesMap?: {
[path: string]: any;
};
defaultValuesSetter?: {
[path: string]: (currentKey: string, currentPath: string, value: any, obj?: any) => any;
propertyRenameMap?: {
[path: string]: any;
};
defaultValuesSetter?: {
[path: string]: JSStringifySetter;
} | JSStringifySetter;
json?: boolean;
}
export declare function chooseQuotes(str: string, preferred: 'single' | 'double' | 'backtick'): string;
Expand Down
8 changes: 8 additions & 0 deletions types/utils.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
export declare function camelCaseTransform(key: string): string;
export declare function isSimpleKey(key: string): boolean;
export declare function dirname(path: string): string;
export declare function escapeStringForSingleQuotes(str: string): string;
export declare function escapeStringForDoubleQuotes(str: string): string;
export declare function escapeStringForBacktickQuotes(str: string): string;
interface ShouldIncludeOptions {
include: string[];
exclude: string[];
}
export declare function expandPaths(paths: string[]): string[];
export declare const shouldInclude: (type: string, options: ShouldIncludeOptions) => boolean;
export {};

0 comments on commit e29be9e

Please sign in to comment.