Crayon 3.0.0
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 toprototype
.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 ofcrayon
calledoptimize
, it's majorly improved.clamp
function fromutil.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
andreplaceAll
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 thanchalk
and previous versions of `crayon 🥳