This provides a modularized version of the standard library.
module "@std" // standard constants and functions NaN Infinity undefined eval parseInt parseFloat isNaN isFinite decodeURI encodeURI decodeURIComponent encodeURIComponent // standard constructors Object Function Array String Boolean Number Date RegExp Error EvalError RangeError ReferenceError SyntaxError TypeError URIError Proxy // standard pseudo-modules Math JSON Symbol // === (module "@symbol").Symbol Iterator // === (module "@iter").Iterator
module "@math" E === (module "@std").Math.E LN10 === (module "@std").Math.LN10 LN2 === (module "@std").Math.LN2 LOG2E === (module "@std").Math.LOG2E LOG10E === (module "@std").Math.LOG10E PI === (module "@std").Math.PI SQRT1_2 === (module "@std").Math.SQRT1_2 SQRT2 === (module "@std").Math.SQRT2 abs === (module "@std").Math.abs acos === (module "@std").Math.acos asin === (module "@std").Math.asin atan === (module "@std").Math.atan atan2 === (module "@std").Math.atan2 ceil === (module "@std").Math.ceil cos === (module "@std").Math.cos exp === (module "@std").Math.exp floor === (module "@std").Math.floor log === (module "@std").Math.log max === (module "@std").Math.max min === (module "@std").Math.min pow === (module "@std").Math.pow random === (module "@std").Math.random round === (module "@std").Math.round sin === (module "@std").Math.sin sqrt === (module "@std").Math.sqrt tan === (module "@std").Math.tan
module "@date" parse === (module "@std").Date.parse UTC === (module "@std").Date.UTC now === (module "@std").Date.now
module "@number" MAX_VALUE === (module "@std").Number.MAX_VALUE MIN_VALUE === (module "@std").Number.MIN_VALUE NEGATIVE_INFINITY === (module "@std").Number.NEGATIVE_INFINITY POSITIVE_INFINITY === (module "@std").Number.POSITIVE_INFINITY
module "@array" isArray === (module "@std").Array.isArray
module "@object" getPrototypeOf === (module "@std").Object.getPrototypeOf getOwnPropertyDescriptor === (module "@std").Object.getOwnPropertyDescriptor getOwnPropertyNames === (module "@std").Object.getOwnPropertyNames create === (module "@std").Object.create defineProperty === (module "@std").Object.defineProperty defineProperties === (module "@std").Object.defineProperties seal === (module "@std").Object.seal freeze === (module "@std").Object.freeze preventExtensions === (module "@std").Object.preventExtensions isSealed === (module "@std").Object.isSealed isFrozen === (module "@std").Object.isFrozen isExtensible === (module "@std").Object.isExtensible keys === (module "@std").Object.keys hasOwnProperty // non-method version of Object.prototype.hasOwnProperty isPrototypeOf // non-method version of Object.prototype.isPrototypeOf propertyIsEnumerable // non-method version of Object.prototype.propertyIsEnumerable
module "@function" call // non-method version of Function.prototype.call apply // non-method version of Function.prototype.apply bind // non-method version of Function.prototype.bind
module "@json" parse === (module "@std").JSON.parse stringify === (module "@std").JSON.stringify
module "@symbol"
Symbol
isSymbol
module "@iter"
zip
unzip
Iterator
module "@dict" // standard iterators keys values entries dict
The dict() function creates a new dictionary object, which is a prototype-less object with no properties. If the optional single argument is provided, its own enumerable properties are copied into the result.
function dict(init) { var d = Object.create(null); if (init) { for (var key in init) { if ({}.hasOwnProperty.call(init, key)) { d[key] = init[key]; } } } return d; }
“@meta” library instead of “@object”?“@iter”? don’t both with “@iter” module? (make sure to allow multiply-importing same binding if we duplicate the bindings)Proxy by default? or a separate “@proxy” module?Name or name?Math be the “@math” module instance object (and hence immutable) – better perf, possible migration hazard (There are a lots of mutations to Math out there.)Name be a mutable object akin to Math and JSON