Releases: crayon-js/crayon
Releases · crayon-js/crayon
Crayon 3.3.3
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 newDeno.Command
API
Caching speed benchmark
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")
}
});
Crayon 3.3.2
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 makecrayon.js
package prepare & publish normally.
Crayon 3.3.1
Improvements
- Introduced
usesFunc
property toCrayon
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
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 withinsearchIndex
andoffset
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
bgAnsi3
now returns proper colorkeyword()
typings now work as expectedcached-long-chain
bench's label is now properly named
BREAKING CHANGES
keyword()
doesn't returnundefined
anymore and instead throwscompileType
andansi256
fromliteral.ts
andchalk_aliases.ts
respectively 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.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
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
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 🥳
Crayon 2.3.0
Improvements:
- Added way to add multiple style functions at once using
addStyleFunctions