@types/short-css-vars

@types/short-css-vars

npm i @types/short-css-vars

Readme

Installation

npm install --save @types/short-css-vars

Summary

This package contains type definitions for short-css-vars (https://github.com/godaddy/short-css-vars/packages/short-css-vars#readme).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/short-css-vars.

index.d.ts

// Type definitions for short-css-vars 1.1
// Project: https://github.com/godaddy/short-css-vars/packages/short-css-vars#readme
// Definitions by: Piotr Błażejewicz <https://github.com/peterblazejewicz>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

/**
 * Each instance keeps track of renamed variables to check for collisions and
 * to provide a mapping of changed names.
 *
 * @classdesc Shorten lengthy CSS variable names
 */
declare class ShortCssVars {
    constructor(options?: ShortCssVars.Options);

    /**
     * Shortens the name part of a variable string
     * @param varName - Variable name including -- prefix
     * @returns short
     */
    replaceName(varName: string): string;

    /**
     * Shortens the names of variables throughout CSS
     * @param css - Text containing CSS variables
     * @returns shortened CSS
     */
    replaceCss(css: string): string;

    /**
     * Get a mapping of original names to shortened names
     *
     * @example
     * {
     *   'long-variable-name-that-defines-a-particular-color': '1vf2dsn'
     * }
     * @returns map
     */
    getMap(): {
        [name: string]: string;
    };
}

declare namespace ShortCssVars {
    /**
     * Optional configurations
     */
    interface Options {
        /**
         * Custom formatter
         */
        formatter?: CustomFormatter | undefined;
        /**
         * Rule to ignore certain variable names
         */
        ignore?: IgnoreType | undefined;
    }

    interface CustomFormatter {
        /**
         * Returns a unique hash for a string name.
         *
         * @param name - Variable name
         * @returns encoded hash
         */
        (name: string): string;
    }

    interface CustomIgnore {
        (name: string): boolean;
    }

    type IgnoreType = RegExp | string | CustomIgnore;
}

export = ShortCssVars;

Additional Details

  • Last updated: Tue, 06 Jul 2021 16:34:44 GMT
  • Dependencies: none
  • Global values: none

Credits

These definitions were written by Piotr Błażejewicz.

Jump To