Skip to content

Crayon 3.0.0

Compare
Choose a tag to compare
@Im-Beast Im-Beast released this 17 May 14:05
· 164 commits to main since this release
22d9f63

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 🥳