a huge collection of aliases for built-in javascript objects and functions.
using the exports from this submodule will let you greatly minify your code,
and also reduce the number of dynamic function dispatches on built-in class's static methods.
Warning
micro-optimization is BAD - people of the old.
micro-optimization might result in poorer JIT performance - some old timer.
micro-optimization is what you do as a bad programmer - linus torvalds (not).
micro-optimization costs millions to revert - linus tech tips (not).
export naming convention
the objects/functions exported by this submodule follow the following naming convention:
the name starts with a lowercase version of the built-in class/object.
so for instance, Math becomes math.
followed by an underscore ("_")
followed by the name of the method/property of that object.
examples
ThingName.MethodName -> thingname_MethodName
Math.max -> math_max
Object.fromEntries -> object_fromEntries
Array.isArray -> array_isArray
performance.now -> performance_now
console.log -> console_log
minifiablility
this submodule needs esbuild's intelligent minifier to shrink it down in it size.
each export is declared separately for two reasons:
using destructuring, such as export const { from, isArray, of } = Array, is not tree-shakable by esbuild,
because destructuring may have property-accessor side effects (even though it isn't the case here).
as such, it is impossible to instruct esbuild that a statement is "pure" (i.e. free of side effects).
and so, we will be left with a ton of unused exported baggage that will end up in the final bundle.
we cannot add documentation comment to destructured variables, and so, our documentation coverage score will drastically drop.
the only way to tell esbuild that an expression is "pure" is when a "@__PURE__" multiline comment is added before a
function call (yes, it has to be a function call). this way, esbuild will tree shake the assigned variable if it is not used.
moreover, esbuild will also evaluate simple iife (immediately invoked function expression), such as the following:
// resulting minified and tree-shakable expression generated by esbuild: const a = Math, b = a.max, c = a.min export { basmath_max, casmath_min }
aliases used by this library (@oazmi/kitchensink)
the following static method aliases are used internally by this library.
so importing any these aliases will likely not add any additional size to your minified scripts.
a huge collection of aliases for built-in javascript objects and functions. using the exports from this submodule will let you greatly minify your code, and also reduce the number of dynamic function dispatches on built-in class's static methods.
micro-optimization is BAD - people of the old.
micro-optimization might result in poorer JIT performance - some old timer.
micro-optimization is what you do as a bad programmer - linus torvalds (not).
micro-optimization costs millions to revert - linus tech tips (not).
export naming convention
the objects/functions exported by this submodule follow the following naming convention:
Math
becomesmath
."_"
)examples
ThingName.MethodName
->thingname_MethodName
Math.max
->math_max
Object.fromEntries
->object_fromEntries
Array.isArray
->array_isArray
performance.now
->performance_now
console.log
->console_log
minifiablility
this submodule needs esbuild's intelligent minifier to shrink it down in it size.
each export is declared separately for two reasons:
export const { from, isArray, of } = Array
, is not tree-shakable by esbuild, because destructuring may have property-accessor side effects (even though it isn't the case here). as such, it is impossible to instruct esbuild that a statement is "pure" (i.e. free of side effects). and so, we will be left with a ton of unused exported baggage that will end up in the final bundle.the only way to tell esbuild that an expression is "pure" is when a
"@__PURE__"
multiline comment is added before a function call (yes, it has to be a function call). this way, esbuild will tree shake the assigned variable if it is not used.moreover, esbuild will also evaluate simple iife (immediately invoked function expression), such as the following:
using a combination of the "pure" annotation and the iife evaluatation feature of esbuild, we can create minifiable and tree-shakable aliases:
aliases used by this library (
@oazmi/kitchensink
)the following static method aliases are used internally by this library. so importing any these aliases will likely not add any additional size to your minified scripts.
Array
from
fromAsync
isArray
of
Date
now
Math
max
min
random
Number
MAX_VALUE
isInteger
parseInt
Object
assign
defineProperty
entries
getPrototypeOf
Promise
resolve
String
fromCharCode
Symbol
iterator
toStringTag
console
assert
error
log
table
performance
now
built-in
window
functionsclearInterval
clearTimeout
decodeURI
encodeURI
setInterval
setTimeout