style-dictionary-utils
Version:
Utilities to use in your style dictionary config
39 lines (38 loc) • 1.98 kB
TypeScript
import { PreprocessedTokens } from 'style-dictionary';
import { Preprocessor } from 'style-dictionary/types';
/**
* Recursively traverses an object and changes any child object
* with a direct "$type" property matching the specified value,
* replacing it with the provided replacement object.
*
* @param obj - The object to traverse
* @param targetType - The $type value to match
* @param replacement - The replacement object or function
* If a function, receives (currentObj) and returns new object
* @returns A new object with replacements applied
*/
/**
* Recursively traverses an object and changes any child object
* with a direct "$type" property matching the specified value,
* replacing it with the provided replacement object.
*
* @param obj - The object to traverse
* @param targetType - The $type value to match
* @param replacement - The replacement object or function
* If a function, receives (currentObj, parentObj) and returns new object
* @returns A new object with replacements applied
*/
/**
* Recursively traverses an object and changes any child object
* with a direct "$type" property matching the specified value,
* allowing a replacement function to return a MODIFIED PARENT object
* (rather than the matched child) in-place in the parent context.
*
* @param obj - The object to traverse
* @param targetType - The $type value to match
* @param replacement - The replacement function which receives (child, parent, childKey)
* and returns the new parent object, or undefined to skip replacement.
* @returns A new object with replacements applied
*/
export declare function changeTypeInObject(obj: Record<string, unknown>, targetType: string, replacement: (child: PreprocessedTokens, parent: PreprocessedTokens, childKey: string | number) => Record<string, unknown>): Record<string, unknown>;
export declare const extractLetterSpacingPreprocessor: Preprocessor;