Skip to content

Crayon 2.2.0

Compare
Choose a tag to compare
@Im-Beast Im-Beast released this 15 May 11:42
· 222 commits to main since this release

Breaking changes:

+ const x = crayon as any as Crayon<...>
- const x = crayon as Crayon<...>

Improvements:

  • Fixed issue with overwriting config properties
  • Fixed issues with extending styles
  • Improved rgb -> ansi8 and rgb -> ansi4 color conversion
  • Improved typings, in addition to extending styles it's now possible to extend functions and their typings:
    import crayon from 'crayon.js';
    import { Crayon } from 'crayon.js/lib/types';
    /*
      Styles - Template Literal Type
        example: 'gray' | 'grey'
        default: void
      Functions - Template Literal Type
        example: 'rainbowize' | 'somethingelse'
        default: void
      Object - object
        example: {
            rainbowize: (shift: number) => Crayon<Styles, Functions, Object>
        }
        default: void
     */
   type Styles = 'gray' | 'grey';
   type Functions = 'somethingelse';
   type Object = {
       rainbowize: (shift: number) => Crayon<Styles, Functions, Object>
   };

   const typedCrayon = crayon as any as Crayon<Styles, Functions, Object>;
  // now typedCrayon has autocompletion for gray, grey, somethingelse (no arguments autocompletion) and rainbowize