Releases: crayon-js/crayon
Releases · crayon-js/crayon
Crayon 3.3.3
Improvements
- Crayon now uses more efficient way to re-cache styles when
colorSupportvalue 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
colorSupporthas effect on instance styles color_supportextension now uses newDeno.CommandAPI
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")
}
});Crayon 3.3.2
Improvements
- Crayon now has a new logo,
crayon-jsorganization 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
CustomEventcompatibility layer for node which should hopefully makecrayon.jspackage prepare & publish normally.
Crayon 3.3.1
Improvements
- Introduced
usesFuncproperty toCrayoninstance- 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
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.colorSupportchanges - 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/extensionsdirectory has been added
Bug fixes
replaceAll()function now accounts for word getting moved withinsearchIndexandoffset
Crayon 3.2.0
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
bgAnsi3now returns proper colorkeyword()typings now work as expectedcached-long-chainbench's label is now properly named
BREAKING CHANGES
keyword()doesn't returnundefinedanymore and instead throwscompileTypeandansi256fromliteral.tsandchalk_aliases.tsrespectively are no longer exported
Crayon 3.1.3
Bug fixes
- Extensions should now be published without issues
Crayon 3.1.1
Improvements
- Extensions are finally on npm, they follow versioning on
crayon.jsno matter the changes.
Bug fixes
NO_COLORenvironment variable was improperly interpreted inside the code. It has been fixed.
Crayon 3.1.0
Improvements
- Crayon's overhead when
NO_COLORis present has been minimized.
Bug fixes
NO_COLORenvironment variable was improperly interpreted inside the code. It has been fixed.
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:
hexfunction 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:
crayonPrototypehas been renamed toprototype.clearCache,clone,instancefunctions 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.optimizeStylesfunction is now method ofcrayoncalledoptimize, it's majorly improved.clampfunction fromutil.tshas 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
replaceandreplaceAllfunction - 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
crayonmultiple (and in some scenarios tens) times faster thanchalkand previous versions of `crayon 🥳
Crayon 2.3.0
Improvements:
- Added way to add multiple style functions at once using
addStyleFunctions
