crayon

🖍️ Terminal styling done light and fast.

MIT License

Downloads
268
Stars
45
Committers
4

Bot releases are hidden (Show)

crayon - Crayon 3.3.3 Latest Release

Published by Im-Beast almost 2 years ago

Improvements

  • Crayon now uses more efficient way to re-cache styles when colorSupport value changes
    • It makes caching a lot faster (>240x faster) – look benchmark on the bottom
    • This also reduces memory usage by ~33%
  • Updated benchmarks
  • Added test for checking whether changing colorSupport has effect on instance styles
  • color_support extension now uses new Deno.Command API

Code:

import { crayon as c332, colors, attributes } from "https://deno.land/x/[email protected]/mod.ts";
import { crayon as c333 } from "https://deno.land/x/[email protected]/mod.ts";

const styles = [...colors.keys(), ...attributes.keys()]

await Deno.bench({ name: "C 3.3.3", group: "a", baseline: true }, () => {
   for (let i = 0; i < 1000; ++i) {
   	const a = styles[~~(Math.random() * styles.length)];
   	const b = styles[~~(Math.random() * styles.length)];
   	const c = styles[~~(Math.random() * styles.length)];		
   	const d = styles[~~(Math.random() * styles.length)];
   
   	c333[a][b][c][d]("hi")
   }
});

await Deno.bench({ name: "C 3.3.2", group: "a" }, () => {
   for (let i = 0; i < 1000; ++i) {
   	const a = styles[~~(Math.random() * styles.length)];
   	const b = styles[~~(Math.random() * styles.length)];
   	const c = styles[~~(Math.random() * styles.length)];		
   	const d = styles[~~(Math.random() * styles.length)];
   
   	c332[a][b][c][d]("hi")
   }
});

Result on my machine:
image

crayon - Crayon 3.3.2

Published by Im-Beast over 2 years ago

Improvements

  • Crayon now has a new logo, crayon-js organization new profile picture and crayon repository new social preview
  • Improved naming of some variables so that they make more sense
  • Added Chalk 5.0.1 to benchmarks

Bug fixes

  • Added CustomEvent compatibility layer for node which should hopefully make crayon.js package prepare & publish normally.
crayon - Crayon 3.3.1

Published by Im-Beast over 2 years ago

Improvements

  • Introduced usesFunc property to Crayon instance
    • It indicates whether Crayon instance used mapped function, if so - prevent further caching of this instance.

Bug fixes

  • Behaviour improvement described above should fix theoritical cpu overhead and memory leaks that could happen.
crayon - Crayon 3.3.0

Published by Im-Beast over 2 years ago

Improvements

  • Badges should now be correctly displayed on deno.land/x
  • README now contains information about usage and extensions
  • Crayon styles now dynamically respond to prototype.colorSupport changes
  • Chalk Aliases and Css Keywords also apply to above change
  • Css keywords package has been shrunk from 12.61KB to 8.83KB
  • Color support extension has been recoded and moved to this repository (new version is not available for node yet)
  • README for src/extensions directory has been added

Bug fixes

  • replaceAll() function now accounts for word getting moved within searchIndex and offset
crayon - Crayon 3.2.0

Published by Im-Beast over 2 years ago

Improvements

  • Extensions now have their own README's
  • Documented things that weren't
  • Tests have been improved
  • Main repository now has coverage and raw size badges that are stored under badges/
  • hex() error handling has been improved

Bug fixes

  • bgAnsi3 now returns proper color
  • keyword() typings now work as expected
  • cached-long-chain bench's label is now properly named

BREAKING CHANGES

  • keyword() doesn't return undefined anymore and instead throws
  • compileType and ansi256 from literal.ts and chalk_aliases.ts respectively are no longer exported
crayon - Crayon 3.1.3

Published by Im-Beast over 2 years ago

Bug fixes

  • Extensions should now be published without issues
crayon - Crayon 3.1.1

Published by Im-Beast over 2 years ago

Improvements

  • Extensions are finally on npm, they follow versioning on crayon.js no matter the changes.

Bug fixes

  • NO_COLOR environment variable was improperly interpreted inside the code. It has been fixed.
crayon - Crayon 3.1.0

Published by Im-Beast over 2 years ago

Improvements

  • Crayon's overhead when NO_COLOR is present has been minimized.

Bug fixes

  • NO_COLOR environment variable was improperly interpreted inside the code. It has been fixed.
crayon - Crayon 3.0.0

Published by Im-Beast over 2 years ago

Project has switched to use Deno as the main runtime, Node's crayon.js package will still be generated using dnt

New features:

  • hex function can now take number as an argument, e.g.: hex(0x0808ff) as well as lowercase hexadecimal letters: hex("#0808ff")
  • New tests and benchmarks

BREAKING CHANGES:

  • crayonPrototype has been renamed to prototype.
  • clearCache, clone, instance functions were deprecated because of new non-mutating nature of crayon.
  • crayon() doesn't return Crayon instance anymore because of the same reasons, instead it will return "undefined" as calling crayon now requires at least 1 argument.
  • optimizeStyles function is now method of crayon called optimize, it's majorly improved.
  • clamp function from util.ts has been removed.
  • New crayon typings differ from old ones.
  • Extensions aren't released for npm yet, old ones are not compatible.

Enormous performance gain was caused by many micro-optimizations:

  • using custom replace and replaceAll function
  • replacing getter that generates crayon instance with value of built crayon after it was acomplished (memoization)
  • optimizing getting text from arguments given to crayon when only one is given
  • not mutating crayon instance
  • accessing object properties as least as possible, being careful with creating new variables
  • 🎉 This performance gain makes crayon multiple (and in some scenarios tens) times faster than chalk and previous versions of `crayon 🥳
crayon - Crayon 2.3.0

Published by Im-Beast about 3 years ago

Improvements:

  • Added way to add multiple style functions at once using addStyleFunctions
crayon - Crayon 2.2.0

Published by Im-Beast over 3 years ago

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
crayon - Crayon 2.1.1

Published by Im-Beast over 3 years ago

  • Fixed type definiton of adding aliases
  • Updated README for Deno
crayon - Crayon 2.1

Published by Im-Beast over 3 years ago

Added support for 🦕 Deno

crayon - Crayon 2.0

Published by Im-Beast over 3 years ago

Crayon 2.0 ships with many bugfixes and some interesting changes.

Breaking changes

  • CSS Keywords are now shipped as extension in @crayon.js/keywords package, see here and here.
  • Color support detection is now shipped as extension in @crayon.js/color-support package, see here and here.
  • Crayon.js is now ES Module instead of CommonJS
  • - crayon.colorSupport
    + crayon.config.colorSupport
    
  • @crayon.js/lite is deprecated - main crayon.js package is now the same out of the box without using extension packages.

Improvements

  • Fixed style caching
  • Nesting and chaining styles has been improved and fixed (also in literal templates)
  • Added support for chaining and functions for literal templates
  • Cleaned up type definitions
  • Functions and variables are now reusable to user and can be easily extended (look here):
  • Created Wiki
  • Using defineProperty instead of Proxies
  • Hugely improved performance
  • Lower package size (even when combined with @crayon.js/color-support and @crayon.js/keywords)

All changes

crayon - Deno Release 1.0.0

Published by Im-Beast over 3 years ago

Make crayon.js work on deno

crayon - Release 1.1

Published by Im-Beast over 3 years ago

  • Added support for template literals
  • Fixed invalid color conversion
  • Added jest coverage test
Package Rankings
Top 10.28% on Npmjs.org
Top 8.52% on Deno.land
Badges
Extracted from project README's
deno github workflow