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).

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.
  • ThingName.MethodName -> thingname_MethodName
  • Math.max -> math_max
  • Object.fromEntries -> object_fromEntries
  • Array.isArray -> array_isArray
  • performance.now -> performance_now
  • console.log -> console_log

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:

// unminified iife
const a = (() => 5 * 2)() // a = 10
// minified expression generated by esbuild:
const a = 10

using a combination of the "pure" annotation and the iife evaluatation feature of esbuild, we can create minifiable and tree-shakable aliases:

// unminified iife
const math_constructor = Math
export const math_max = /* @__PURE__ */ (() => math_constructor.max)()
export const math_min = /* @__PURE__ */ (() => math_constructor.min)()
// resulting minified and tree-shakable expression generated by esbuild:
const
a = Math,
b = a.max,
c = a.min
export { b as math_max, c as math_min }

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.

  • from
  • fromAsync
  • isArray
  • of
  • now
  • max
  • min
  • random
  • MAX_VALUE
  • isInteger
  • parseInt
  • assign
  • defineProperty
  • entries
  • getPrototypeOf
  • resolve
  • fromCharCode
  • iterator
  • toStringTag
  • assert
  • error
  • log
  • table
  • now
  • clearInterval
  • clearTimeout
  • decodeURI
  • encodeURI
  • setInterval
  • setTimeout

Variables

math_E
math_LN10
math_LN2
math_LOG10E
math_LOG2E
math_PI
math_SQRT1_2
math_SQRT2
number_EPSILON
number_MAX_SAFE_INTEGER
number_MAX_VALUE
number_MIN_SAFE_INTEGER
number_MIN_VALUE
number_NEGATIVE_INFINITY
number_NaN
number_POSITIVE_INFINITY
symbol_asyncDispose
symbol_asyncIterator
symbol_dispose
symbol_hasInstance
symbol_isConcatSpreadable
symbol_iterator
symbol_match
symbol_matchAll
symbol_metadata
symbol_replace
symbol_search
symbol_species
symbol_split
symbol_toPrimitive
symbol_toStringTag
symbol_unscopables

Functions

noop
array_isEmpty
array_from
array_fromAsync
array_isArray
array_of
bigint_asIntN
bigint_asUintN
date_UTC
date_now
date_parse
json_parse
json_stringify
math_max
math_min
math_sign
math_ceil
math_floor
math_fround
math_round
math_trunc
math_acos
math_acosh
math_asin
math_asinh
math_atan
math_atan2
math_atanh
math_cos
math_cosh
math_sin
math_sinh
math_tan
math_tanh
math_abs
math_cbrt
math_exp
math_expm1
math_log
math_log10
math_log1p
math_log2
math_pow
math_sqrt
math_clz32
math_imul
math_hypot
math_random
number_isFinite
number_isInteger
number_isNaN
number_isSafeInteger
number_parseFloat
number_parseInt
object_assign
object_create
object_defineProperties
object_defineProperty
object_entries
object_freeze
object_fromEntries
object_getOwnPropertyDescriptor
object_getOwnPropertyDescriptors
object_getOwnPropertyNames
object_getOwnPropertySymbols
object_getPrototypeOf
object_groupBy
object_hasOwn
object_is
object_isExtensible
object_isFrozen
object_isSealed
object_keys
object_preventExtensions
object_seal
object_setPrototypeOf
object_values
promise_forever
promise_outside
promise_all
promise_allSettled
promise_any
promise_race
promise_reject
promise_resolve
promise_withResolvers
response_error
response_json
response_redirect
string_toUpperCase
string_toLowerCase
string_fromCharCode
string_fromCodePoint
string_raw
symbol_for
symbol_keyFor
console_assert
console_clear
console_count
console_countReset
console_debug
console_dir
console_dirxml
console_error
console_group
console_groupCollapsed
console_groupEnd
console_info
console_log
console_table
console_time
console_timeEnd
console_timeLog
console_timeStamp
console_trace
console_warn
performance_now
dom_setTimeout
dom_clearTimeout
dom_setInterval
dom_clearInterval
dom_encodeURI
dom_encodeURIComponent
dom_decodeURI
dom_decodeURIComponent