Skip to content

Releases: crayon-js/crayon

Crayon 3.3.3

03 Dec 13:27
Compare
Choose a tag to compare

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

Caching speed benchmark

Code:

import { crayon as c332, colors, attributes } from "https://deno.land/x/crayon@3.3.2/mod.ts";
import { crayon as c333 } from "https://deno.land/x/crayon@3.3.3/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 3.3.2

12 Jul 20:14
f37bd64
Compare
Choose a tag to compare

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 3.3.1

05 Jul 10:30
Compare
Choose a tag to compare

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 3.3.0

03 Jul 17:36
Compare
Choose a tag to compare

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 3.2.0

29 Jun 07:01
Compare
Choose a tag to compare

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 3.1.3

21 Jun 16:11
4b7ec92
Compare
Choose a tag to compare

Bug fixes

  • Extensions should now be published without issues

Crayon 3.1.1

21 Jun 15:13
b532c0e
Compare
Choose a tag to compare

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 3.1.0

17 May 20:49
47116f8
Compare
Choose a tag to compare

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 3.0.0

17 May 14:05
22d9f63
Compare
Choose a tag to compare

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 2.3.0

03 Aug 15:22
Compare
Choose a tag to compare

Improvements:

  • Added way to add multiple style functions at once using addStyleFunctions