@types/short-css-vars
@types/short-css-vars
npm i @types/short-css-vars
@types/short-css-vars

@types/short-css-vars

The repository for high quality TypeScript type definitions.

by DefinitelyTyped

1.1.1 (see all)License:MITTypeScript:Built-In
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.

Downloads/wk

10

GitHub Stars

41K

LAST COMMIT

7mos ago

MAINTAINERS

1

CONTRIBUTORS

17,572

OPEN ISSUES

636

OPEN PRs

224
VersionTagPublished
1.1.1
latest
1yr ago
1.1.1
ts4.7
1yr ago
1.1.1
ts4.6
1yr ago
1.1.1
ts4.8
1yr ago
No alternatives found
No tutorials found
Add a tutorial

Rate & Review

100
No reviews found
Be the first to rate