Преглед изворни кода

[js] Add missing built-in APIs (#8358)

* [js] add missing methods to js.lib.Object

* [js] add js.lib.Math

* [js] add js.lib.WeakMap and js.lib.WeakSet

* [js] add js.lib.Reflect and js.lib.Proxy

* [js] add js.lib.Intl

* [js] add js.lib.WebAssembly

* [js] Rewrite to `final`
terurou пре 6 година
родитељ
комит
a8132fd5ee

+ 39 - 0
std/js/lib/Intl.hx

@@ -0,0 +1,39 @@
+/*
+ * Copyright (C)2005-2019 Haxe Foundation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+package js.lib;
+
+/**
+	The `Intl` object is the namespace for the ECMAScript Internationalization API,
+	which provides language sensitive string comparison, number formatting,and date and time formatting.
+	The INTL object provides access to several constructors as well as functionality common to
+	the internationalization constructors and other language sensitive functions.
+
+	Documentation [Intl](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl) by [Mozilla Contributors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object$history), licensed under [CC-BY-SA 2.5](https://creativecommons.org/licenses/by-sa/2.5/).
+**/
+@:native("Intl")
+extern class Intl {
+	/**
+		Returns canonical locale names.
+	**/
+	@:overload(function(locales:Array<String>):Array<String> {})
+	@:pure static function getCanonicalLocales(locales:String):Array<String>;
+}

+ 251 - 0
std/js/lib/Math.hx

@@ -0,0 +1,251 @@
+/*
+ * Copyright (C)2005-2019 Haxe Foundation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+package js.lib;
+
+import haxe.extern.Rest;
+
+/**
+	Math is a built-in object that has properties and methods for mathematical constants and functions.
+	Not a function object.
+
+	Documentation [Math](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math) by [Mozilla Contributors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map$history), licensed under [CC-BY-SA 2.5](https://creativecommons.org/licenses/by-sa/2.5/).
+**/
+@:native("Math")
+extern class Math {
+	/**
+		Euler's constant and the base of natural logarithms, approximately 2.718.
+	**/
+	static var E(default,never):Float;
+
+	/**
+		Natural logarithm of 2, approximately 0.693.
+	**/
+	static var LN2(default,never):Float;
+	
+	/**
+		Natural logarithm of 10, approximately 2.303.
+	**/
+	static var LN10(default,never):Float;
+	
+	/**
+		Base 2 logarithm of E, approximately 1.443.
+	**/
+	static var LOG2E(default,never):Float;
+	
+	/**
+		Base 10 logarithm of E, approximately 0.434.
+	**/
+	static var LOG10E(default,never):Float;
+
+	/**
+		Ratio of the circumference of a circle to its diameter, approximately 3.14159.
+	**/
+	static var PI(default,never):Float;
+	
+	/**
+		Square root of 1/2; equivalently, 1 over the square root of 2, approximately 0.707.
+	**/
+	static var SQRT1_2(default,never):Float;
+	
+	/**
+		Square root of 2, approximately 1.414.
+	**/
+	static var SQRT2(default,never):Float;
+
+	/**
+		Returns the absolute value of a number.
+	**/
+	@:overload(function(x:Float):Float {})
+	@:pure static function abs(x:Int):Int;
+
+	/**
+		Returns the arccosine of a number.
+	**/
+	@:pure static function acos(x:Float):Float;
+
+	/**
+		Returns the hyperbolic arccosine of a number.
+	**/
+	@:pure static function acosh(x:Float):Float;
+
+	/**
+		Returns the arcsine of a number.
+	**/
+	@:pure static function asin(x:Float):Float;
+
+	/**
+		Returns the hyperbolic arcsine of a number.
+	**/
+	@:pure static function asinh(x:Float):Float;
+
+	/**
+		Returns the arctangent of a number.
+	**/
+	@:pure static function atan(x:Float):Float;
+
+	/**
+		Returns the hyperbolic arctangent of a number.
+	**/
+	@:pure static function atanh(x:Float):Float;
+
+	/**
+		Returns the arctangent of the quotient of its arguments.
+	**/
+	@:pure static function atan2(y:Float, x:Float):Float;
+
+	/**
+		Returns the cube root of a number.
+	**/
+	@:pure static function cbrt(x:Float):Float;
+
+	/**
+		Returns the smallest integer greater than or equal to a number.
+	**/
+	@:pure static function ceil(x:Float):Int;
+
+	/**
+		Returns the number of leading zeroes of a 32-bit integer.
+	**/
+	@:pure static function clz32(x:Int):Int;
+
+	/**
+		Returns the cosine of a number.
+	**/
+	@:pure static function cos(x:Float):Float;
+
+	/**
+		Returns the hyperbolic cosine of a number.
+	**/
+	@:pure static function cosh(x:Float):Float;
+
+	/**
+		Returns Ex, where x is the argument, and E is Euler's constant (2.718…), the base of the natural logarithm.
+	**/
+	@:pure static function exp(x:Float):Float;
+
+	/**
+		Returns subtracting 1 from exp(x).
+	**/
+	@:pure static function expm1(x:Float):Float;
+
+	/**
+		Returns the largest integer less than or equal to a number.
+	**/
+	@:pure static function floor(x:Float):Int;
+
+	/**
+		Returns the nearest single precision float representation of a number.
+	**/
+	@:pure static function fround(x:Float):Float;
+
+	/**
+		Returns the square root of the sum of squares of its arguments.
+	**/
+	@:pure static function hypot(args:Rest<Float>):Float;
+
+	/**
+		Returns the result of a 32-bit integer multiplication.
+	**/
+	@:pure static function imul(x:Int, y:Int):Int;
+
+	/**
+		Returns the natural logarithm (loge, also ln) of a number.
+	**/
+	@:pure static function log(x:Float):Float;
+
+	/**
+		Returns the natural logarithm (loge, also ln) of 1 + x for a number x.
+	**/
+	@:pure static function log1p(x:Float):Float;
+
+	/**
+		Returns the base 10 logarithm of a number.
+	**/
+	@:pure static function log10(x:Float):Float;
+
+	/**
+		Returns the base 2 logarithm of a number.
+	**/
+	@:pure static function log2(x:Float):Float;
+
+	/**
+		Returns the largest of zero or more numbers.
+	**/
+	@:overload(function(args:Rest<Float>):Float {})
+	@:pure static function max(args:Rest<Int>):Int;
+
+	/**
+		Returns the smallest of zero or more numbers.
+	**/
+	@:overload(function(args:Rest<Float>):Float {})
+	@:pure static function min(args:Rest<Int>):Int;
+
+	/**
+		Returns base to the exponent power, that is, baseexponent.
+	**/
+	@:pure static function pow(x:Float, y:Float):Float;
+
+	/**
+		Returns a pseudo-random number between 0 and 1.
+	**/
+	@:pure static function random():Float;
+
+	/**
+		Returns the value of a number rounded to the nearest integer.
+	**/
+	@:pure static function round(x:Float):Int;
+
+	/**
+		Returns the sign of the x, indicating whether x is positive, negative or zero.
+	**/
+	@:pure static function sign(x:Float):Int;
+
+	/**
+		Returns the sine of a number.
+	**/
+	@:pure static function sin(x:Float):Float;
+
+	/**
+		Returns the hyperbolic sine of a number.
+	**/
+	@:pure static function sinh(x:Float):Float;
+
+	/**
+		Returns the positive square root of a number.
+	**/
+	@:pure static function sqrt(x:Float):Float;
+
+	/**
+		Returns the tangent of a number.
+	**/
+	@:pure static function tan(x:Float):Float;
+
+	/**
+		Returns the hyperbolic tangent of a number.
+	**/
+	@:pure static function tanh(x:Float):Float;
+
+	/**
+		Returns the integer part of the number x, removing any fractional digits. 
+	**/
+	@:pure static function trunc(x:Float):Int;
+}

+ 29 - 1
std/js/lib/Object.hx

@@ -51,11 +51,23 @@ extern class Object {
 	**/
 	static function defineProperty<T:{}>(obj:T, prop:String, descriptor:ObjectPropertyDescriptor):T;
 
+	/**
+		Returns an array containing all of the [key, value] pairs of a given
+		object's own enumerable string properties.
+	**/
+	@:pure static function entries(obj:{}):Array<ObjectEntry>;
+
 	/**
 		Freezes an object: other code can't delete or change any properties.
 	**/
 	static function freeze<T:{}>(obj:T):T;
 
+	/**
+		Returns a new object from an iterable of key-value pairs
+		(reverses Object.entries).
+	**/
+	@:pure static function fromEntries<T:{}>(iterable:Any):T; 
+
 	/**
 		Returns a property descriptor for a named property on an object.
 	**/
@@ -120,6 +132,12 @@ extern class Object {
 	**/
 	static function setPrototypeOf<T:{}>(obj:T, prototype:Null<{}>):T;
 
+	/**
+		Returns an array containing the values that correspond to all of
+		a given object's own enumerable string properties.
+	**/
+	@:pure static function values(obj:{}):Array<Any>;
+
 	/**
 		Allows the addition of properties to all objects of type Object.
 	**/
@@ -221,4 +239,14 @@ typedef ObjectPropertyDescriptor = {
 		and with `this` set to the object through which the property is assigned.
 	**/
 	var ?set:Any->Void;
-}
+}
+
+/**
+	Key/value access helper for `js.lib.Object.entries()`.
+**/
+abstract ObjectEntry(Array<Any>) {
+	public var key(get,never):String;
+	public var value(get,never):Any;
+	inline function get_key():String return this[0];
+	inline function get_value():Any return this[1];
+}

+ 119 - 0
std/js/lib/Proxy.hx

@@ -0,0 +1,119 @@
+/*
+ * Copyright (C)2005-2019 Haxe Foundation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+package js.lib;
+
+import js.lib.Object;
+
+/**
+	The `Proxy` object is used to define custom behavior for fundamental operations
+	(e.g. property lookup, assignment, enumeration, function invocation, etc).
+
+	Documentation [Proxy](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy) by [Mozilla Contributors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object$history), licensed under [CC-BY-SA 2.5](https://creativecommons.org/licenses/by-sa/2.5/).
+**/
+@:native("Proxy")
+extern class Proxy<T:{}> {
+	@:pure function new(target:T, handler:ProxyHandler<T>);
+
+	/**
+		Creates a revocable `Proxy` object.
+	**/
+	@:pure static function revocable<T:{}>(target:T, handler:ProxyHandler<T>):RevocableProxy<T>;
+}
+
+typedef ProxyHandler<T:{}> = {
+	/**
+		A trap for `Object.getPrototypeOf`.
+	**/
+	var ?getPrototypeOf:(target:T)->Null<{}>;
+
+	/**
+		A trap for `Object.setPrototypeOf`.
+	**/
+	var ?setPrototypeOf:(target:T, prototype:Null<{}>)->Bool;
+
+	/**
+		A trap for `Object.isExtensible`.
+	**/
+	var ?isExtensible:(target:T)->Bool;
+
+	/**
+		A trap for `Object.preventExtensions`.
+	**/
+	var ?preventExtensions:(target:T)->Bool;
+
+	/**
+		A trap for `Object.getOwnPropertyDescriptor`.
+	**/
+	var ?getOwnPropertyDescriptor:(target:T, prop:String)->Null<ObjectPropertyDescriptor>;
+
+	/**
+		A trap for `Object.defineProperty`.
+	**/
+	var ?defineProperty:(target:T, property:String, descriptor:ObjectPropertyDescriptor)->Bool;
+
+	/**
+		A trap for the `in` operator.
+	**/
+	var ?has:(target:T, prop:String)->Bool;
+
+	/**
+		A trap for getting property values.
+	**/
+	var ?get:(target:T, property:String, receiver:Null<{}>)->Any;
+
+	/**
+		A trap for setting property values.
+	**/
+	var ?set:(target:T, property:String, value:Any, receiver:Null<{}>)->Bool;
+
+	/**
+		A trap for the `delete` operator.
+	**/
+	var ?deleteProperty:(target:T, property:String)->Bool;
+
+	/**
+		A trap for `Object.getOwnPropertyNames` and `Object.getOwnPropertySymbols`.
+	**/
+	var ?ownKeys:(target:T)->Array<String>;
+
+	/**
+		A trap a function call.
+	**/
+	var ?apply:(target:T, thisArg:{}, argumentsList:Array<Any>)->Any;
+
+	/**
+		A trap for the `new` operator.
+	**/
+	var ?construct:(target:Class<T>, argumentsList:Array<Any>, newTarget:Class<Any>)->Void;
+}
+
+typedef RevocableProxy<T:{}> = {
+	/**
+		A Proxy object created with `new Proxy(target, handler)` call.
+	**/
+	final proxy:Proxy<T>;
+	
+	/**
+		A function with no argument to invalidate (switch off) the `proxy`.
+	**/
+	function revoke():Void;
+}

+ 109 - 0
std/js/lib/Reflect.hx

@@ -0,0 +1,109 @@
+/*
+ * Copyright (C)2005-2019 Haxe Foundation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+package js.lib;
+
+import haxe.Constraints.Function;
+import js.lib.Object;
+
+/**
+	`Reflect` is a built-in object that provides methods for interceptable JavaScript operations.
+	The methods are the same as those of [proxy handlers](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler).
+	Reflect is not a function object, so it's not constructible.
+
+	Documentation [Reflect](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect) by [Mozilla Contributors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object$history), licensed under [CC-BY-SA 2.5](https://creativecommons.org/licenses/by-sa/2.5/).
+**/
+@:native("Reflect")
+extern class Reflect {
+	/**
+		Calls a target function with arguments as specified by the args parameter.
+		See also `Function.prototype.apply()`.
+	*/
+	static function apply<T>(target:Function, thisArgument:{}, argumentsList:Array<Any>):T;
+
+	/**
+		The `new` operator as a function. Equivalent to calling `new target(...args)`.
+		Provides also the optional possibility to specify a different prototype.
+	*/
+	static function construct<T,S:T>(target:Class<T>, argumentsList:Array<Any>, ?newTarget:Class<S>):T;
+
+	/**
+		Similar to `Object.defineProperty()`. Returns a Bool.
+	*/
+	static function defineProperty(target:{}, propertyKey:String, attributes:ObjectPropertyDescriptor):Bool;
+
+	/**
+		The `delete` operator as a function. Equivalent to calling `delete target[name]`.
+	*/
+	@:overload(function<T>(target:Array<T>, propertyKey:Int):Bool {})
+	static function deleteProperty(target:{}, propertyKey:String):Bool;
+
+	/**
+		A function that returns the value of properties.
+	*/
+	@:overload(function<T>(target:Array<T>, propertyKey:Int, ?receiver:{}):Null<T> {})
+	@:pure static function get<T>(target:{}, propertyKey:String, ?receiver:{}):Null<T>;
+
+	/**
+		Similar to `Object.getOwnPropertyDescriptor()`.
+		Returns a property descriptor of the given property if it exists on the object,
+		`undefined` otherwise.
+	*/
+	@:pure static function getOwnPropertyDescriptor(target:{}, propertyKey:String):Null<ObjectPropertyDescriptor>;
+
+	/**
+		Same as `Object.getPrototypeOf()`.
+	*/
+	@:pure static function getPrototypeOf<TProto:{}>(target:{}):Null<TProto>;
+
+	/**
+		The `in` operator as function. Returns a boolean indicating whether an own
+		or inherited property exists.
+	*/
+	@:pure static function has(target:{}, propertyKey:String):Bool;
+
+	/**
+		Same as `Object.isExtensible()`.
+	*/
+	@:pure static function isExtensible(target:{}):Bool;
+
+	/**
+		Returns an array of the target object's own (not inherited) property keys.
+	*/
+	@:pure static function ownKeys(target:{}):Array<String>;
+
+	/**
+		Similar to `Object.preventExtensions()`. Returns a Bool.
+	*/
+	static function preventExtensions(obj:{}):Bool;
+
+	/**
+		A function that assigns values to properties. Returns a Bool that is true
+		if the update was successful.
+	*/
+	@:overload(function<T>(target:Array<T>, propertyKey:Int, value:T, ?receiver:{}):Bool {})
+	static function set<T>(target:{}, propertyKey:String, value:T, ?receiver:{}):Bool;
+
+	/**
+		A function that sets the prototype of an object. 
+	*/
+	static function setPrototypeOf<TProto:{}>(target:{}, prototype:TProto):Bool;
+}

+ 65 - 0
std/js/lib/WeakMap.hx

@@ -0,0 +1,65 @@
+/*
+ * Copyright (C)2005-2019 Haxe Foundation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+package js.lib;
+
+/**
+	The `WeakMap` object is a collection of key/value pairs in which the keys are weakly referenced.
+	The keys must be objects and the values can be arbitrary values.
+
+	You can learn more about WeakMaps in the section [WeakMap object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Keyed_collections#WeakMap_object)
+	in [Keyed collections](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Keyed_collections).
+
+	Documentation [WeakMap](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap) by [Mozilla Contributors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object$history), licensed under [CC-BY-SA 2.5](https://creativecommons.org/licenses/by-sa/2.5/).
+**/
+@:native("WeakMap")
+extern class WeakMap<T> {
+	/**
+		The value of the `length` property is 0.
+	**/
+	static final length:Int;
+
+	/**
+		If an iterable object is passed, all of its elements will be added to the new WeakSet.
+		null is treated as undefined.
+	**/
+	@:pure function new(?iterable:Any);
+
+	/**
+		Removes any value associated to the `key`. `has(key)` will return `false` afterwards.
+	**/
+	function delete(key:{}):Bool;
+
+	/**
+		Returns the value associated to the `key`, or `undefined` if there is none.
+	**/
+	@:pure function get(key:{}):T;
+
+	/**
+		Returns a Boolean asserting whether a value has been associated to the `key` in the `WeakMap` object or not.
+	**/
+	@:pure function has(key:{}):Bool;
+
+	/**
+		Sets the value for the `key` in the `WeakMap` object. Returns the `WeakMap` object.
+	**/
+	function set(key:{}, value:T):WeakMap<T>;
+}

+ 58 - 0
std/js/lib/WeakSet.hx

@@ -0,0 +1,58 @@
+/*
+ * Copyright (C)2005-2019 Haxe Foundation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+package js.lib;
+
+/**
+	The `WeakSet` object lets you store weakly held objects in a collection.
+
+	Documentation [WeakSet](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet) by [Mozilla Contributors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object$history), licensed under [CC-BY-SA 2.5](https://creativecommons.org/licenses/by-sa/2.5/).
+**/
+@:native("WeakSet")
+extern class WeakSet {
+	/**
+		The value of the `length` property is 0.
+	**/
+	static final length:Int;
+
+	/**
+		If an iterable object is passed, all of its elements will be added to the new WeakSet.
+		null is treated as undefined.
+	**/
+	@:pure function new(?iterable:Any);
+
+	/**
+		Appends a new object with the given value to the `WeakSet` object.
+	**/
+	function add(value:{}):WeakSet;
+
+	/**
+		Removes the element associated to the `value`.
+		`has(value)` will return `false` afterwards.
+	**/
+	function delete(value:{}):Bool;
+
+	/**
+		Returns a boolean asserting whether an element is present with the given value
+		in the `WeakSet` object or not.
+	**/
+	@:pure function has(value:{}):Bool;
+}

+ 106 - 0
std/js/lib/WebAssembly.hx

@@ -0,0 +1,106 @@
+/*
+ * Copyright (C)2005-2019 Haxe Foundation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+package js.lib;
+
+import js.lib.webassembly.Module;
+import js.lib.webassembly.Instance;
+import js.html.Response;
+
+/**
+	The WebAssembly JavaScript object acts as the namespace for all WebAssembly-related functionality.
+
+	Documentation [WebAssembly](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly) by [Mozilla Contributors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object$history), licensed under [CC-BY-SA 2.5](https://creativecommons.org/licenses/by-sa/2.5/).
+**/
+@:native("WebAssembly")
+extern class WebAssembly {
+	/**
+		The `WebAssembly.instantiate()` function allows you to compile and instantiate WebAssembly code.
+		This function has two overloads:
+
+		- The primary overload takes the WebAssembly binary code, in the form of a typed array or ArrayBuffer,
+		  and performs both compilation and instantiation in one step. The returned Promise resolves to both
+		  a compiled WebAssembly.Module and its first WebAssembly.Instance.
+    	- The secondary overload takes an already-compiled WebAssembly.Module and returns a Promise that resolves
+		  to an Instance of that Module. This overload is useful if the Module has already been compiled.
+	**/
+
+	@:overload(function(bufferSource:Int8Array, importObject:{}):Promise<WebAssemblyInstantiatedSource> {})
+	@:overload(function(bufferSource:Uint8Array, importObject:{}):Promise<WebAssemblyInstantiatedSource> {})
+	@:overload(function(bufferSource:Uint8ClampedArray, importObject:{}):Promise<WebAssemblyInstantiatedSource> {})
+	@:overload(function(bufferSource:Int16Array, importObject:{}):Promise<WebAssemblyInstantiatedSource> {})
+	@:overload(function(bufferSource:Uint16Array, importObject:{}):Promise<WebAssemblyInstantiatedSource> {})
+	@:overload(function(bufferSource:Int32Array, importObject:{}):Promise<WebAssemblyInstantiatedSource> {})
+	@:overload(function(bufferSource:Uint32Array, importObject:{}):Promise<WebAssemblyInstantiatedSource> {})
+	@:overload(function(bufferSource:Float32Array, importObject:{}):Promise<WebAssemblyInstantiatedSource> {})
+	@:overload(function(bufferSource:Float64Array, importObject:{}):Promise<WebAssemblyInstantiatedSource> {})
+	@:overload(function(module:Module, importObject:{}):Promise<Instance> {})
+	@:pure static function instantiate(bufferSource:ArrayBuffer, importObject:{}):Promise<WebAssemblyInstantiatedSource>;
+
+	/**
+		The `WebAssembly.instantiateStreaming()` function compiles and instantiates a WebAssembly module
+		directly from a streamed underlying source. This is the most efficient, optimized way to load wasm code.
+	**/
+	@:pure static function instantiateStreaming(source:Response, importObject:{}):Promise<WebAssemblyInstantiatedSource>;
+
+	/**
+		The `WebAssembly.compile()` function compiles a WebAssembly `Module` from WebAssembly binary code.
+		This function is useful if it is necessary to a compile a module before it can be instantiated
+		(otherwise, the `WebAssembly.instantiate()` function should be used).
+	**/
+	@:overload(function(bufferSource:Int8Array):Promise<Module> {})
+	@:overload(function(bufferSource:Uint8Array):Promise<Module> {})
+	@:overload(function(bufferSource:Uint8ClampedArray):Promise<Module> {})
+	@:overload(function(bufferSource:Int16Array):Promise<Module> {})
+	@:overload(function(bufferSource:Uint16Array):Promise<Module> {})
+	@:overload(function(bufferSource:Int32Array):Promise<Module> {})
+	@:overload(function(bufferSource:Uint32Array):Promise<Module> {})
+	@:overload(function(bufferSource:Float32Array):Promise<Module> {})
+	@:overload(function(bufferSource:Float64Array):Promise<Module> {})
+	@:pure static function compile(bufferSource:ArrayBuffer):Promise<Module>;
+
+	/**
+		The `WebAssembly.compileStreaming()` function compiles a WebAssembly `Module` directly from a streamed
+		underlying source. This function is useful if it is necessary to a compile a module before it can
+		be instantiated (otherwise, the `WebAssembly.instantiateStreaming()` function should be used).
+	**/
+	@:pure static function compileStreaming(source:Response):Promise<Module>;
+
+	/**
+		The `WebAssembly.validate()` function validates a given typed array of WebAssembly binary code,
+		returning whether the bytes form a valid wasm module (`true`) or not (`false`).
+	**/
+	@:overload(function(bufferSource:Int8Array):Bool {})
+	@:overload(function(bufferSource:Uint8Array):Bool {})
+	@:overload(function(bufferSource:Uint8ClampedArray):Bool {})
+	@:overload(function(bufferSource:Int16Array):Bool {})
+	@:overload(function(bufferSource:Uint16Array):Bool {})
+	@:overload(function(bufferSource:Int32Array):Bool {})
+	@:overload(function(bufferSource:Uint32Array):Bool {})
+	@:overload(function(bufferSource:Float32Array):Bool {})
+	@:overload(function(bufferSource:Float64Array):Bool {})
+	@:pure static function validate(bufferSource:ArrayBuffer):Bool;
+}
+
+typedef WebAssemblyInstantiatedSource = {
+	final module:Module;
+	final instance:Instance;
+}

+ 183 - 0
std/js/lib/intl/Collator.hx

@@ -0,0 +1,183 @@
+/*
+ * Copyright (C)2005-2019 Haxe Foundation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+package js.lib.intl;
+
+/**
+	The `Collator` object is a constructor for collators, objects that enable language
+	sensitive string comparison.
+
+	Documentation [Collator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator) by [Mozilla Contributors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object$history), licensed under [CC-BY-SA 2.5](https://creativecommons.org/licenses/by-sa/2.5/).
+**/
+@:native("Intl.Collator")
+extern class Collator {
+	@:overload(function(?locales:Array<String>, ?options:CollatorOptions):Void {})
+	@:pure function new(?locales:String, ?options:CollatorOptions);
+
+	/**
+		Getter function that compares two strings according to the sort order of this `Collator` object.
+	 */
+	@:pure function compare(string1:String, string2:String):Int;
+
+	/**
+		Returns a new object with properties reflecting the locale and collation options computed
+		during initialization of the object.
+	 */
+	@:pure function resolvedOptions():CollatorResolvedOptions;
+
+	/**
+		Returns an array containing those of the provided locales that are supported
+		without having to fall back to the runtime's default locale.
+		@param locales A string with a BCP 47 language tag, or an array of such strings.
+	**/
+	@:overload(function(locales:Array<String>, ?options:CollatorSupportedLocalesOfOptions):Array<String> {})
+	@:pure static function supportedLocalesOf(locales:String, ?options:CollatorSupportedLocalesOfOptions):Array<String>;
+}
+
+typedef CollatorOptions = {
+	/**
+		The locale matching algorithm to use.
+		The default is `BestFit`.
+		For information about this option, see the [Intl page](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_negotiation).
+	**/
+	var ?localeMatcher:LocaleMatcher;
+
+	/**
+		Whether the comparison is for sorting or for searching for matching strings.
+		The default is `Sort`.
+	**/
+	var ?usage:Usage;
+
+	/**
+		Which differences in the strings should lead to non-zero result values.
+		The default is `Variant` for usage `Sort`; it's locale dependent for usage `Search`.
+	**/
+	var ?sensitivity:Sensitivity;
+
+	/**
+		Whether punctuation should be ignored.
+		The default is `false`.
+	**/
+	var ?ignorePunctuation:Bool;
+
+	/**
+		Whether numeric collation should be used, such that "1" < "2" < "10".
+		The default is `false`.
+		This option can be set through an `options` property or through a Unicode extension key;
+		if both are provided, the `options` property takes precedence.
+		Implementations are not required to support this property.
+	**/
+	var ?numeric:Bool;
+
+	/**
+		Whether upper case or lower case should sort first.
+		The default is "false".
+		This option can be set through an options property or through a Unicode extension key;
+		if both are provided, the `options` property takes precedence.
+		Implementations are not required to support this property.
+	**/
+	var ?caseFirst:String;
+}
+
+typedef CollatorResolvedOptions = {
+	/**
+		The BCP 47 language tag for the locale actually used.
+		If any Unicode extension values were requested in the input BCP 47 language tag
+		that led to this locale, the key-value pairs that were requested and are supported
+		for this locale are included in `locale`.
+	**/
+	final locale:String;
+
+	final usage:Usage;
+
+	final sensitivity:Sensitivity;
+
+	/**
+		The values provided for these properties in the `options` argument or filled in as defaults.
+	**/
+	final ignorePunctuation:Bool;
+
+	/**
+		he value requested using the Unicode extension key `"co"`, if it is supported for `Locale`,
+		or `Default`.
+	**/
+	final collation:Collation;
+
+	final numeric:Bool;
+
+	/**
+		The values requested for these properties in the options argument or using the
+		Unicode extension keys `"kn"` and `"kf"` or filled in as defaults.
+		If the implementation does not support these properties, they are omitted.
+	**/
+	final caseFirst:CaseFirst;
+}
+
+enum abstract Usage(String) {
+	var Sort = "sort";
+	var Search = "search";
+}
+
+enum abstract Sensitivity(String) {
+	/**
+		Only strings that differ in base letters compare as unequal.
+		Examples: a ≠ b, a = á, a = A.
+	**/
+	var Base = "base";
+	
+	/**
+		Only strings that differ in base letters or accents and other diacritic marks compare as unequal.
+		Examples: a ≠ b, a ≠ á, a = A.
+	**/
+	var Accent = "accent";
+
+	/**
+		Only strings that differ in base letters or case compare as unequal.
+		Examples: a ≠ b, a = á, a ≠ A.
+	**/
+	var Case = "case";
+
+	/**
+		Strings that differ in base letters, accents and other diacritic marks, or case compare as unequal.
+		Other differences may also be taken into consideration.
+		Examples: a ≠ b, a ≠ á, a ≠ A.
+	**/
+	var Variant = "variant";
+}
+
+enum abstract CaseFirst(String) {
+	var Upper = "upper";
+	var Lower = "lower";
+	var False = "false";
+}
+
+enum abstract Collation(String) {
+	var Locale = "locale";
+	var Default = "default";
+}
+
+typedef CollatorSupportedLocalesOfOptions = {
+	/**
+		The locale matching algorithm to use.
+		The default is `BestFit`.
+	 */
+	var ?localeMatcher:LocaleMatcher;
+}

+ 392 - 0
std/js/lib/intl/DateTimeFormat.hx

@@ -0,0 +1,392 @@
+/*
+ * Copyright (C)2005-2019 Haxe Foundation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+package js.lib.intl;
+
+/**
+	The `DateTimeFormat` object is a constructor for objects that enable language-sensitive
+	date and time formatting.
+
+	Documentation [DateTimeFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat) by [Mozilla Contributors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object$history), licensed under [CC-BY-SA 2.5](https://creativecommons.org/licenses/by-sa/2.5/).
+**/
+@:native("Intl.DateTimeFormat")
+extern class DateTimeFormat {
+	@:overload(function(?locales:Array<String>, ?options:DateTimeFormatOptions):Void {})
+	@:pure function new(?locales:String, ?options:DateTimeFormatOptions);
+
+	/**
+		Getter function that formats a date according to the locale and formatting options
+		of this `DateTimeFormat` object.
+	**/
+	@:overload(function(date:js.lib.Date):String {})
+	@:pure function format(date:Date):String;
+
+	/**
+		Returns an `Array` of objects representing the date string in parts that can be used
+		for custom locale-aware formatting.
+	**/
+	@:overload(function(date:js.lib.Date):Array<DateTimeFormatPart> {})
+	@:pure function formatToParts(date:Date):Array<DateTimeFormatPart>; 
+
+	/**
+		Returns a new object with properties reflecting the locale and formatting options
+		computed during initialization of the object.
+	**/
+	@:pure function resolvedOptions():DateTimeFormatResolvedOptions;
+
+	/**
+		Returns an array containing those of the provided locales that are supported
+		without having to fall back to the runtime's default locale.
+	**/
+	@:overload(function(locales:Array<String>, ?options:DateTimeFormatSupportedLocalesOfOptions):Array<String> {})
+	@:pure static function supportedLocalesOf(locales:String, ?options:DateTimeFormatSupportedLocalesOfOptions):Array<String>;
+}
+
+typedef DateTimeFormatOptions = {
+	/**
+		The locale matching algorithm to use.
+		The default is `BestFit`.
+	**/
+	var ?localeMatcher:LocaleMatcher;
+
+	/**
+		The time zone to use. The only value implementations must recognize is `"UTC"`;
+		the default is the runtime's default time zone. Implementations may also recognize
+		the time zone names of the [IANA time zone database](https://www.iana.org/time-zones),
+		such as `"Asia/Shanghai"`, `"Asia/Kolkata"`, `"America/New_York"`.
+	**/
+	var ?timeZone:String;
+
+	/**
+		Whether to use 12-hour time (as opposed to 24-hour time).
+		The default is locale dependent.
+		This option overrides the hc language tag and/or the `hourCycle` option in case both are present.
+	**/
+	var ?hour12:Bool;
+
+	/**
+		The hour cycle to use. This option overrides the `hc` language tag, if both are present,
+		and the `Hour12` option takes precedence in case both options have been specified.
+	**/
+	var ?hourCycle:HourCycle;
+
+	/**
+		The format matching algorithm to use.
+		The default is `BestFit`.
+		See the following paragraphs for information about the use of this property.
+	**/
+	var ?formatMatcher:FormatMatcher;
+
+	/**
+		The representation of the weekday.
+	**/
+	var ?weekday:WeekdayRepresentation;
+
+	/**
+		The representation of the era.
+	**/
+	var ?era:EraRepresentation;
+
+	/**
+		The representation of the year.
+	**/
+	var ?year:YearRepresentation;
+
+	/**
+		The representation of the month.
+	**/
+	var ?month:MonthRepresentation;
+
+	/**
+		The representation of the day.
+	**/
+	var ?day:DayRepresentation;
+
+	/**
+		The representation of the hour. 
+	**/
+	var ?hour:HourRepresentation;
+
+	/**
+		The representation of the minute.
+	**/
+	var ?minute:MinuteRepresentation;
+
+	/**
+		The representation of the second.
+	**/
+	var ?second:SecondRepresentation;
+
+	/**
+		The representation of the time zone name. 
+	**/
+	var ?timeZoneName:TimeZoneName;
+}
+
+typedef DateTimeFormatResolvedOptions = {
+	/**
+		The BCP 47 language tag for the locale actually used.
+		If any Unicode extension values were requested in the input BCP 47 language tag that led to this locale,
+		the key-value pairs that were requested and are supported for this locale are included in `locale`.
+	**/
+	final locale:String;
+
+	/**
+		E.g. "gregory"
+	**/
+	final calendar:String;
+
+	/**
+		The values requested using the Unicode extension keys "ca" and "nu" or filled in as default values.
+	**/
+	final numberingSystem:String;
+
+	/**
+		The value provided for this property in the options argument; `undefined` (representing the runtime's
+		default time zone) if none was provided.
+		Warning: Applications should not rely on `undefined` being returned, as future versions may return
+		a String value identifying the runtime’s default time zone instead.
+	**/
+	final timeZone:Null<String>;
+
+	/**
+		The value provided for this property in the `options` argument or filled in as a default.
+	**/
+	final hour12:Bool;
+
+	final weekday:WeekdayRepresentation;
+
+	final era:EraRepresentation;
+
+	final year:YearRepresentation;
+
+	final month:MonthRepresentation;
+
+	final day:DayRepresentation;
+
+	final hour:HourRepresentation;
+
+	final minute:MinuteRepresentation;
+
+	final second:SecondRepresentation;
+
+	/**
+		The values resulting from format matching between the corresponding properties in the `options` argument
+		and the available combinations and representations for date-time formatting in the selected locale.
+		Some of these properties may not be present, indicating that the corresponding components will not be
+		represented in formatted output.
+	**/
+	final timeZoneName:TimeZoneName;
+}
+
+enum abstract HourCycle(String) {
+	var H11 = "h11";
+	var H12 = "h12";
+	var H23 = "h23";
+	var H24 = "h24";
+}
+
+enum abstract FormatMatcher(String) {
+	var Basic = "basic";
+	var BestFit = "best fit";
+}
+
+enum abstract WeekdayRepresentation(String) {
+	/**
+		(e.g., Thursday)
+	 */
+    var Long = "long";
+
+	/**
+		(e.g., Thu)
+	 */
+    var Short = "short";
+
+	/**
+		(e.g., T). Two weekdays may have the same narrow style for some locales (e.g. Tuesday's narrow style is also T).
+	 */
+    var Narrow = "narrow";
+}
+
+enum abstract EraRepresentation(String) {
+	/**
+		(e.g., Anno Domini)
+	 */
+	var Long = "long";
+
+	/**
+		(e.g., AD)
+	 */
+	var Short = "short";
+
+	/**
+		(e.g., A)
+	 */
+	var Narrow = "narrow";
+}
+
+enum abstract YearRepresentation(String) {
+	/**
+		(e.g., 2012)
+	**/
+	var Numeric = "numeric";
+
+	/**
+		(e.g., 12)
+	**/
+	var TwoDigit = "2-digit";
+}
+
+enum abstract MonthRepresentation(String) {
+	/**
+		(e.g., 2)
+	**/
+    var Numeric = "numeric";
+
+	/**
+		(e.g., 02)
+	**/
+    var TwoDigit = "2-digit";
+
+	/**
+		(e.g., March)
+	**/
+    var Long = "long";
+
+	/**
+		(e.g., Mar)
+	**/
+    var Short = "short";
+
+	/**
+		(e.g., M). Two months may have the same narrow style for some locales (e.g. May's narrow style is also M).
+	**/
+    var Narrow = "narrow";
+}
+
+enum abstract DayRepresentation(String) {
+	/**
+		(e.g., 1)
+	**/
+	var Numeric = "numeric";
+
+	/**
+		(e.g., 01)
+	**/
+	var TwoDigit = "2-digit";
+}
+
+enum abstract HourRepresentation(String) {
+	var Numeric = "numeric";
+	var TwoDigit = "2-digit";
+}
+
+enum abstract MinuteRepresentation(String) {
+	var Numeric = "numeric";
+	var TwoDigit = "2-digit";
+}
+
+enum abstract SecondRepresentation(String) {
+	var Numeric = "numeric";
+	var TwoDigit = "2-digit";
+}
+
+enum abstract TimeZoneName(String) {
+	/**
+		(e.g., British Summer Time)
+	**/
+    var Long = "long";
+
+	/**
+		(e.g., GMT+1)
+	**/
+    var Short = "short";
+}
+
+typedef DateTimeFormatPart = {
+	var type(default,never):DateTimeFormatPartType;
+	var value(default,never):String;
+}
+
+enum abstract DateTimeFormatPartType(String) {
+	/**
+		The string used for the day, for example "17".
+	**/
+	var Day = "day";
+
+	/**
+		The string used for the day period, for example, "AM" or "PM".
+	**/
+	var DayPeriod = "dayPeriod";
+
+	/**
+		The string used for the era, for example "BC" or "AD".
+	**/
+	var Era = "era";
+
+	/**
+		The string used for the hour, for example "3" or "03".
+	**/
+	var Hour = "hour";
+
+	/**
+		The string used for separating date and time values, for example "/", ",", "o'clock", "de", etc.
+	**/
+	var Literal = "literal";
+
+	/**
+		The string used for the minute, for example "00".
+	**/
+	var Minute = "minute";
+
+	/**
+		The string used for the month, for example "12".
+	**/
+	var Month = "month";
+
+	/**
+		The string used for the second, for example "07" or "42".
+	**/
+	var Second = "second";
+
+	/**
+		The string used for the name of the time zone, for example "UTC".
+	**/
+	var TimeZoneName = "timeZoneName";
+
+	/**
+		The string used for the weekday, for example "M", "Monday", or "Montag".
+	**/
+	var Weekday = "weekday";
+
+	/**
+		The string used for the year, for example "2012" or "96". 
+	**/
+	var Year = "year";
+}
+
+typedef DateTimeFormatSupportedLocalesOfOptions = {
+	/**
+		The locale matching algorithm to use.
+		The default is `BestFit`.
+	 */
+	var ?localeMatcher:LocaleMatcher;
+}

+ 27 - 0
std/js/lib/intl/LocaleMatcher.hx

@@ -0,0 +1,27 @@
+/*
+ * Copyright (C)2005-2019 Haxe Foundation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+package js.lib.intl;
+
+enum abstract LocaleMatcher(String) {
+    var Lookup = "lookup";
+    var BestFit = "best fit";
+}

+ 283 - 0
std/js/lib/intl/NumberFormat.hx

@@ -0,0 +1,283 @@
+/*
+ * Copyright (C)2005-2019 Haxe Foundation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+package js.lib.intl;
+
+/**
+	The `NumberFormat` object is a constructor for objects that enable language sensitive number formatting.
+
+	Documentation [NumberFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat) by [Mozilla Contributors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object$history), licensed under [CC-BY-SA 2.5](https://creativecommons.org/licenses/by-sa/2.5/).
+**/
+@:native("Intl.NumberFormat")
+extern class NumberFormat {
+	@:overload(function(?locales:Array<String>, ?options:NumberFormatOptions):Void {})
+	@:pure function new(?locales:String, ?options:NumberFormatOptions);
+
+	/**
+		Getter function that formats a number according to the locale
+		and formatting options of this `NumberFormat` object.
+	**/
+	@:pure function format(number:Float):String;
+
+	/**
+		Returns an `Array` of objects representing the number string in parts
+		that can be used for custom locale-aware formatting.
+	**/
+	@:pure function formatToParts(?number:Float):Array<NumberFormatPart>;
+
+	/**
+		Returns a new object with properties reflecting the locale and collation options
+		computed during initialization of the object. 
+	**/
+	@:pure function resolvedOptions():NumberFormatResolvedOption;
+
+	/**
+		Returns an array containing those of the provided locales that are supported
+		without having to fall back to the runtime's default locale.
+	**/
+	@:overload(function(locales:Array<String>, ?options:NumberFormatSupportedLocalesOfOptions):Array<String> {})
+	@:pure static function supportedLocalesOf(locales:String, ?options:NumberFormatSupportedLocalesOfOptions):Array<String>;
+}
+
+typedef NumberFormatOptions = {
+	/**
+		The locale matching algorithm to use.
+		The default is `BestFit`.
+		For information about this option, see the [Intl page](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_negotiation).
+	**/
+	var ?localeMatcher:LocaleMatcher;
+
+	/**
+		The formatting style to use.
+		The default is `Decimal`.
+	**/
+	var ?style:NumberFormatStyle;
+
+	/**
+		The currency to use in currency formatting. Possible values are the ISO 4217 currency codes,
+		such as "USD" for the US dollar, "EUR" for the euro, or "CNY" for the Chinese RMB — see the
+		[Current currency & funds code list](https://www.currency-iso.org/en/home/tables/table-a1.html).
+		There is no default value; if the style is "currency", the currency property must be provided.
+	**/
+	var ?currency:String;
+
+	/**
+		How to display the currency in currency formatting.
+		The default is `Symbol`.
+	**/
+	var ?currencyDisplay:CurrencyDisplay;
+
+	/**
+		Whether to use grouping separators, such as thousands separators or thousand/lakh/crore separators.
+		The default is `true`.
+	**/
+	var ?useGrouping:Bool;
+
+	/**
+		The minimum number of integer digits to use.
+		Possible values are from 1 to 21; the default is 1.
+	**/
+	var ?minimumIntegerDigits:Int;
+
+	/**
+		The minimum number of fraction digits to use.
+		Possible values are from 0 to 20; the default for plain number and percent formatting is 0;
+		the default for currency formatting is the number of minor unit digits provided by the
+		[ISO 4217 currency code list](http://www.currency-iso.org/en/home/tables/table-a1.html)
+		(2 if the list doesn't provide that information).
+	**/
+	var ?minimumFractionDigits:Int;
+
+	/**
+		The maximum number of fraction digits to use.
+		Possible values are from 0 to 20; the default for plain number formatting is the larger of
+		minimumFractionDigits and 3; the default for currency formatting is the larger of minimumFractionDigits
+		and the number of minor unit digits provided by the [ISO 4217 currency code list](http://www.currency-iso.org/en/home/tables/table-a1.html)
+		(2 if the list doesn't provide that information); the default for percent formatting is the larger of
+		minimumFractionDigits and 0.
+	**/
+	var ?maximumFractionDigits:Int;
+
+	/**
+		The minimum number of significant digits to use.
+		Possible values are from 1 to 21; the default is 1.
+	**/
+	var ?minimumSignificantDigits:Int;
+	
+	/**
+		The maximum number of significant digits to use.
+		Possible values are from 1 to 21; the default is 21.
+	**/
+	var ?maximumSignificantDigits:Int;
+}
+
+typedef NumberFormatResolvedOption = {
+	/**
+		The BCP 47 language tag for the locale actually used. If any Unicode extension values were
+		requested in the input BCP 47 language tag that led to this locale, the key-value pairs that
+		were requested and are supported for this locale are included in `locale`.
+	**/
+	final locale:String;
+
+	/**
+		The value requested using the Unicode extension key `"nu"` or filled in as a default.
+	**/
+	final numberingSystem:String;
+
+	final style:NumberFormatStyle;
+
+	/**
+		The values provided for these properties in the `options` argument or filled in as defaults.
+	**/
+	final useGrouping:String;
+
+	final currency:String;
+
+	/**
+		The values provided for these properties in the `options` argument or filled in as defaults.
+		These properties are only present if `style` is `"currency"`.
+	**/
+	final currencyDisplay:String;
+
+	final minimumIntegerDigits:Int;
+
+	final minimumFractionDigits:Int;
+
+	/**
+		The values provided for these properties in the `options` argument or filled in as defaults.
+		These properties are present only if neither m`inimumSignificantDigits` nor `maximumSignificantDigits`
+		was provided in the `options` argument.
+	**/
+	final maximumFractionDigits:Int;
+
+	final minimumSignificantDigits:Int;
+
+	/**
+		The values provided for these properties in the `options` argument or filled in as defaults.
+		These properties are present only if at least one of them was provided in the `options` argument.
+	**/
+	final maximumSignificantDigits:Int;
+}
+
+enum abstract NumberFormatStyle(String) {
+	/**
+		plain number formatting
+	**/
+	var Decimal = "decimal";
+
+	/**
+		currency formatting
+	**/
+	var Currency = "currency";
+
+	/**
+		percent formatting
+	**/
+	var Percent = "percent";
+}
+
+enum abstract CurrencyDisplay(String) {
+	/**
+		To use a localized currency symbol such as €.
+	**/
+	var Symbol = "symbol";
+	
+	/**
+		To use the ISO currency code.
+	**/
+	var Code = "code";
+	
+	/**
+		To use a localized currency name such as "dollar".
+	**/
+	var Name = "name";
+}
+
+typedef NumberFormatPart = {
+	final type:NumberFormatPartType;
+	final value:String;
+}
+
+enum abstract NumberFormatPartType(String) {
+	/**
+		The currency string, such as the symbols "$" and "€" or the name "Dollar", "Euro" depending
+		on how currencyDisplay is specified.
+	**/
+	var Currency = "currency";
+
+	/**
+		The decimal separator string (".").
+	**/
+	var Decimal = "decimal";
+
+	/**
+		The fraction number.
+	**/
+	var Fraction = "fraction";
+
+	/**
+		The group separator string (",").
+	**/
+	var group = "group";
+
+	/**
+		The Infinity string ("∞").
+	**/
+	var infinity = "infinity";
+
+	/**
+		The integer number.
+	**/
+	var integer = "integer";
+
+	/**
+		Any literal strings or whitespace in the formatted number.
+	**/
+	var literal = "literal";
+
+	/**
+		The minus sign string ("-").
+	**/
+	var minusSign = "minusSign";
+
+	/**
+		The NaN string ("NaN").
+	**/
+	var nan = "nan";
+
+	/**
+		The plus sign string ("+").
+	**/
+	var plusSign = "plusSign";
+
+	/**
+		The percent sign string ("%"). 
+	**/
+	var percentSign = "percentSign";
+}
+
+typedef NumberFormatSupportedLocalesOfOptions = {
+	/**
+		The locale matching algorithm to use.
+		The default is `BestFit`.
+	 */
+	var ?localeMatcher:LocaleMatcher;
+}

+ 122 - 0
std/js/lib/intl/PluralRules.hx

@@ -0,0 +1,122 @@
+/*
+ * Copyright (C)2005-2019 Haxe Foundation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+package js.lib.intl;
+
+/**
+	The `PluralRules` object is a constructor for objects that enable plural sensitive formatting
+	and plural language rules.
+
+	Documentation [PluralRules](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/PluralRules) by [Mozilla Contributors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object$history), licensed under [CC-BY-SA 2.5](https://creativecommons.org/licenses/by-sa/2.5/).
+**/
+@:native("Intl.PluralRules")
+extern class PluralRules {
+	@:overload(function(?locales:Array<String>, ?options:PluralRulesOptions):Void {})
+	@:pure function new(?locales:String, ?options:PluralRulesOptions);
+
+	/**
+		Returns a new object with properties reflecting the locale and collation options computed during initialization of the object.
+	**/
+	@:pure function resolvedOptions():PluralRulesResolvedOptions;
+
+	/**
+		Returns a String indicating which plurar rule to use for locale-aware formatting. 
+	**/
+	@:pure function select(number:Int):String;
+
+	/**
+		Returns an array containing those of the provided locales that are supported
+		without having to fall back to the runtime's default locale.
+	**/
+	@:overload(function(locales:Array<String>, ?options:PluralRulesSupportedLocalesOfOptions):Array<String> {})
+	@:pure static function supportedLocalesOf(locales:String, ?options:PluralRulesSupportedLocalesOfOptions):Array<String>;
+}
+
+typedef PluralRulesOptions = {
+	/**
+		The locale matching algorithm to use.
+		The default is "best fit".
+		For information about this option, see the [Intl page](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_negotiation).
+	 */
+	var ?localeMatcher:LocaleMatcher;
+	/**
+		The type to use.
+		The default is `Cardinal`.
+	 */
+	var ?type:PluralRulesType;
+}
+
+typedef PluralRulesResolvedOptions = {
+	/**
+		The BCP 47 language tag for the locale actually used. If any Unicode extension values were requested in
+		the input BCP 47 language tag that led to this locale, the key-value pairs that were requested and are
+		supported for this locale are included in `locale`.
+	 */
+	final locale:String;
+
+	/**
+		An `Array` of plural rules used by the given language.
+	**/
+	final pluralCategories:Array<String>;
+
+	/**
+		The type used (cardinal or ordinal).
+	**/
+	final type:PluralRulesType;
+
+	final minimumIntegerDigits:Int;
+
+	final minimumFractionDigits:Int;
+
+	/**
+		The values provided for these properties in the `options` argument or filled in as defaults.
+		These properties are present only if neither `minimumSignificantDigits` nor `maximumSignificantDigits`
+		was provided in the options argument.
+	**/
+	final maximumFractionDigits:Int;
+
+	final minimumSignificantDigits:Int;
+
+	/**
+		The values provided for these properties in the `options` argument or filled in as defaults.
+		These properties are present only if at least one of them was provided in the `options` argument.
+	**/
+	final maximumSignificantDigits:Int;
+}
+
+enum abstract PluralRulesType(String) {
+    /**
+		For cardinal numbers (refering to the quantity of things). 
+     */
+    var Cardinal = "cardinal";
+    /**
+		For ordinal number (refering to the ordering or ranking of things, e.g. "1st", "2nd", "3rd" in English).
+     */
+    var Ordinal = "ordinal";
+}
+
+typedef PluralRulesSupportedLocalesOfOptions = {
+	/**
+		The locale matching algorithm to use.
+		The default is `BestFit`.
+	 */
+	var ?localeMatcher:LocaleMatcher;
+}

+ 162 - 0
std/js/lib/intl/RelativeTimeFormat.hx

@@ -0,0 +1,162 @@
+/*
+ * Copyright (C)2005-2019 Haxe Foundation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+package js.lib.intl;
+
+/**
+	The `RelativeTimeFormat` object is a constructor for objects that enable language-sensitive
+	relative time formatting.
+
+	Documentation [RelativeTimeFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RelativeTimeFormat) by [Mozilla Contributors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object$history), licensed under [CC-BY-SA 2.5](https://creativecommons.org/licenses/by-sa/2.5/).
+**/
+@:native("Intl.RelativeTimeFormat")
+extern class RelativeTimeFormat {
+	@:overload(function(?locales:Array<String>, ?options:RelativeTimeFormatOptions):Void {})
+	@:pure function new(?locales:String, ?options:RelativeTimeFormatOptions);
+
+	/**
+		Formats a value and a unit according to the locale and formatting options
+		of the given Intl.RelativeTimeFormat object.
+	**/
+	@:pure function format(value:Float, unit:RelativeTimeUnit):String;
+
+	/**
+		Returns an Array of objects representing the relative time format in parts
+		that can be used for custom locale-aware formatting.
+	**/
+	@:pure function formatToParts(value:Float, unit:RelativeTimeUnit):Array<RelativeTimeFormatPart>;
+
+	/**
+		Returns a new object with properties reflecting the locale and formatting options
+		computed during initialization of the object. 
+	**/
+	@:pure function resolvedOptions():RelativeTimeFormatResolvedOptions;
+
+	/**
+		Returns an array containing those of the provided locales that are supported
+		without having to fall back to the runtime's default locale.
+	**/
+	@:overload(function(locales:Array<String>, ?options:RelativeTimeFormatSupportedLocalesOfOptions):Array<String> {})
+	@:pure static function supportedLocalesOf(locales:String, ?options:RelativeTimeFormatSupportedLocalesOfOptions):Array<String>;
+}
+
+typedef RelativeTimeFormatOptions = {
+	/**
+		The locale matching algorithm to use.
+		The default is `BestFit`.
+		For information about this option, see [Intl](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_negotiation).
+	**/
+	var ?localeMatcher:LocaleMatcher;
+
+	/**
+		The format of output message.
+		The default value is `Always`.
+		The `Auto` value allows to not always have to use numeric values in the output.
+	**/
+	var ?numeric:RelativeTimeNumeric;
+	
+	/**
+		The length of the internationalized message.
+		The default value is `Long`.
+		The `Narrow` style could be similar to the short style for some locales.
+	**/
+	var ?style:RelativeTimeFormatStyle;
+}
+
+typedef RelativeTimeFormatResolvedOptions = {
+	/**
+		The BCP 47 language tag for the locale actually used. If any Unicode extension values were requested in
+		the input BCP 47 language tag that led to this locale, the key-value pairs that were requested and are
+		supported for this locale are included in `locale`.
+	**/
+	final locale:String;
+
+	/**
+		The length of the internationalized message.
+	**/
+	final style:RelativeTimeFormatStyle;
+
+	/**
+		The format of output message.
+	**/
+	final numeric:RelativeTimeNumeric;
+
+	/**
+		The value requested using the Unicode extension key `"nu"` or filled in as a default.
+	**/
+	final numberingSystem:String;
+}
+
+enum abstract RelativeTimeNumeric(String) {
+	/**
+		(e.g., 1 day ago),
+	**/
+	var Always = "always";
+
+	/**
+		(e.g., yesterday).
+	**/
+	var Auto = "auto";
+}
+
+enum abstract RelativeTimeFormatStyle(String) {
+	/**
+		(e.g., in 1 month)
+	 */
+	var Long = "long";
+
+	/**
+		(e.g., in 1 mo.)
+	 */
+	var Short = "short";
+
+	/**
+		(e.g., in 1 mo.)
+	 */
+	var Narrow = "narrow";
+}
+
+enum abstract RelativeTimeUnit(String) from String to String {
+	var Year = "year";
+	var Quarter = "quarter";
+	var Month = "month";
+	var Week = "week";
+	var Day = "day";
+	var Hour = "hour";
+	var Minute = "minute";
+	var Second = "second";
+}
+
+typedef RelativeTimeFormatPart = {
+	final type:RelativeTimeFormatPartType;
+	final value:String;
+	final ?unit:RelativeTimeUnit;
+}
+
+typedef RelativeTimeFormatPartType = NumberFormat.NumberFormatPartType;
+
+typedef RelativeTimeFormatSupportedLocalesOfOptions = {
+	/**
+		The locale matching algorithm to use.
+		The default is `BestFit`.
+	 */
+	var ?localeMatcher:LocaleMatcher;
+}

+ 33 - 0
std/js/lib/webassembly/CompileError.hx

@@ -0,0 +1,33 @@
+/*
+ * Copyright (C)2005-2019 Haxe Foundation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+package js.lib.webassembly;
+
+/**
+	A WebAssembly `CompileError` object indicates an error during WebAssembly
+	decoding or validation.
+
+	Documentation [CompileError](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/CompileError) by [Mozilla Contributors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object$history), licensed under [CC-BY-SA 2.5](https://creativecommons.org/licenses/by-sa/2.5/).
+**/
+@:native("WebAssembly.CompileError")
+extern class CompileError extends js.lib.Error {
+	function new(?message:String):Void;
+}

+ 61 - 0
std/js/lib/webassembly/Global.hx

@@ -0,0 +1,61 @@
+/*
+ * Copyright (C)2005-2019 Haxe Foundation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+package js.lib.webassembly;
+
+/**
+	A WebAssembly `Global` object represents a global variable instance, accessible from
+	both JavaScript and importable/exportable across one or more WebAssembly `Module` instances.
+	This allows dynamic linking of multiple modules.
+
+	Documentation [Global](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Global) by [Mozilla Contributors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object$history), licensed under [CC-BY-SA 2.5](https://creativecommons.org/licenses/by-sa/2.5/).
+**/
+@:native("WebAssembly.Global")
+extern class Global {
+	/**
+		The value contained inside the global variable — this can be used to directly set
+		and get the global's value.
+	**/
+	var value:Any;
+
+	@:pure function new(descriptor:GlobalDescriptor, value:Any):Void;
+
+	/**
+		Old-style method that returns the value contained inside the global variable.
+	 */
+	@:pure function valueOf():Any;
+}
+
+typedef GlobalDescriptor = {
+	var value:ValueType;
+
+	/**
+		By default, this is false.
+	 */
+	var ?mutable:Bool;
+}
+
+enum abstract ValueType(String) {
+	var I32 = "i32";
+	var I64 = "i64";
+	var F32 = "f32";
+	var F64 = "f64";
+}

+ 42 - 0
std/js/lib/webassembly/Instance.hx

@@ -0,0 +1,42 @@
+/*
+ * Copyright (C)2005-2019 Haxe Foundation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+package js.lib.webassembly;
+
+import haxe.Constraints.Function;
+
+/**
+	A WebAssembly `Instance` object is a stateful, executable instance of a WebAssembly `Module`.
+	Instance objects contain all the [Exported WebAssembly functions](https://developer.mozilla.org/en-US/docs/WebAssembly/Exported_functions)
+	that allow calling into WebAssembly code from JavaScript.
+
+	Documentation [Instance](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance) by [Mozilla Contributors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object$history), licensed under [CC-BY-SA 2.5](https://creativecommons.org/licenses/by-sa/2.5/).
+**/
+@:native("WebAssembly.Instance")
+extern class Instance {
+	/**
+		Returns an object containing as its members all the functions exported from
+		the WebAssembly module instance, to allow them to be accessed and used by JavaScript.
+	**/
+	var exports(default,never):Dynamic<Function>;
+
+	@:pure function new(module:Module, ?importObject:{}):Void;
+}

+ 33 - 0
std/js/lib/webassembly/LinkError.hx

@@ -0,0 +1,33 @@
+/*
+ * Copyright (C)2005-2019 Haxe Foundation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+package js.lib.webassembly;
+
+/**
+	A WebAssembly `LinkError` object indicates an error during module instantiation
+	(besides [traps](http://webassembly.org/docs/semantics/#traps) from the start function).
+
+	Documentation [LinkError](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/LinkError) by [Mozilla Contributors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object$history), licensed under [CC-BY-SA 2.5](https://creativecommons.org/licenses/by-sa/2.5/).
+**/
+@:native("WebAssembly.LinkError")
+extern class LinkError extends js.lib.Error {
+	function new(?message : String):Void;
+}

+ 62 - 0
std/js/lib/webassembly/Memory.hx

@@ -0,0 +1,62 @@
+/*
+ * Copyright (C)2005-2019 Haxe Foundation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+package js.lib.webassembly;
+
+/**
+	A new WebAssembly `Memory` object which is a resizable ArrayBuffer that holds the raw bytes of memory
+	accessed by a WebAssembly WebAssembly `Instance`.
+
+	A memory created by JavaScript or in WebAssembly code will be accessible and mutable from
+	both JavaScript and WebAssembly.
+
+	Documentation [Memory](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory) by [Mozilla Contributors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object$history), licensed under [CC-BY-SA 2.5](https://creativecommons.org/licenses/by-sa/2.5/).
+**/
+@:native("WebAssembly.Memory")
+extern class Memory {
+	/**
+		An accessor property that returns the buffer contained in the memory.
+	**/
+	final buffer:js.lib.ArrayBuffer;
+
+	@:pure function new(memoryDescriptor:MemoryDescriptor):Void;
+
+	/**
+		Increases the size of the memory instance by a specified number of WebAssembly pages
+		(each one is 64KB in size).
+	**/
+	function grow(number:Int):Int;
+}
+
+typedef MemoryDescriptor = {
+	/**
+		The initial size of the WebAssembly Memory, in units of WebAssembly pages.
+	**/
+	var initial:Int;
+
+	/**
+		The maximum size the WebAssembly Memory is allowed to grow to, in units of WebAssembly pages.
+		When present, the `maximum` parameter acts as a hint to the engine to reserve memory up front.
+		However, the engine may ignore or clamp this reservation request.
+		In general, most WebAssembly modules shouldn't need to set a `maximum`.
+	 */
+	var ?maximum:Int;
+}

+ 89 - 0
std/js/lib/webassembly/Module.hx

@@ -0,0 +1,89 @@
+/*
+ * Copyright (C)2005-2019 Haxe Foundation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+package js.lib.webassembly;
+
+import js.lib.ArrayBuffer;
+import js.lib.Int8Array;
+import js.lib.Uint8Array;
+import js.lib.Uint8ClampedArray;
+import js.lib.Int16Array;
+import js.lib.Uint16Array;
+import js.lib.Int32Array;
+import js.lib.Uint32Array;
+import js.lib.Float32Array;
+import js.lib.Float64Array;
+
+/**
+	A WebAssembly `Module` object contains stateless WebAssembly code that has already
+	been compiled by the browser and can be efficiently [shared with Workers](https://developer.mozilla.org/en-US/docs/Web/API/Worker/postMessage),
+	and instantiated multiple times. To instantiate the module, call
+	[the secondary overload of `WebAssembly.instantiate()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiate#Secondary_overload_%E2%80%94_taking_a_module_object_instance).
+
+	Documentation [Module](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Module) by [Mozilla Contributors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object$history), licensed under [CC-BY-SA 2.5](https://creativecommons.org/licenses/by-sa/2.5/).
+**/
+@:native("WebAssembly.Module")
+extern class Module {
+	@:overload(function(bufferSource:Int8Array):Void {})
+	@:overload(function(bufferSource:Uint8Array):Void {})
+	@:overload(function(bufferSource:Uint8ClampedArray):Void {})
+	@:overload(function(bufferSource:Int16Array):Void {})
+	@:overload(function(bufferSource:Uint16Array):Void {})
+	@:overload(function(bufferSource:Int32Array):Void {})
+	@:overload(function(bufferSource:Uint32Array):Void {})
+	@:overload(function(bufferSource:Float32Array):Void {})
+	@:overload(function(bufferSource:Float64Array):Void {})
+	@:pure function new(bufferSource:ArrayBuffer):Void;
+
+	/**
+		Given a `Module` and string, returns a copy of the contents of all custom sections
+		in the module with the given string name.
+	**/
+	@:pure static function customSections(module:Module, sectionName:String):Array<ArrayBuffer>;
+
+	/**
+		Given a `Module`, returns an array containing descriptions of all the declared exports.
+	**/
+	@:pure static function exports(module:Module):Array<ModuleExportDescriptor>;
+
+	/**
+		Given a `Module`, returns an array containing descriptions of all the declared imports. 
+	**/
+	@:pure static function imports(module:Module):Array<ModuleImportDescriptor>;
+}
+
+typedef ModuleExportDescriptor = {
+	var name:String;
+	var kind:ImportExportKind;
+}
+
+typedef ModuleImportDescriptor = {
+	var module:String;
+	var name:String;
+	var kind:ImportExportKind;
+}
+
+enum abstract ImportExportKind(String) {
+	var Function = "function";
+	var Table = "table";
+	var Memory = "memory";
+	var Global = "global";
+}

+ 33 - 0
std/js/lib/webassembly/RuntimeError.hx

@@ -0,0 +1,33 @@
+/*
+ * Copyright (C)2005-2019 Haxe Foundation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+package js.lib.webassembly;
+
+/**
+	A WebAssembly `RuntimeError` object is thrown whenever WebAssembly specifies a
+	[trap](http://webassembly.org/docs/semantics/#traps).
+
+	Documentation [RuntimeError](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/RuntimeError) by [Mozilla Contributors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object$history), licensed under [CC-BY-SA 2.5](https://creativecommons.org/licenses/by-sa/2.5/).
+**/
+@:native("WebAssembly.RuntimeError")
+extern class RuntimeError extends js.lib.Error {
+	function new(?message:String):Void;
+}

+ 80 - 0
std/js/lib/webassembly/Table.hx

@@ -0,0 +1,80 @@
+/*
+ * Copyright (C)2005-2019 Haxe Foundation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+package js.lib.webassembly;
+
+import haxe.Constraints.Function;
+
+/**
+	A Table object of the given size and element type.
+
+	This is a JavaScript wrapper object — an array-like structure representing a WebAssembly Table,
+	which stores function references. A table created by JavaScript or in WebAssembly code will be
+	accessible and mutable from both JavaScript and WebAssembly.
+
+	Documentation [Table](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Table) by [Mozilla Contributors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object$history), licensed under [CC-BY-SA 2.5](https://creativecommons.org/licenses/by-sa/2.5/).
+**/
+@:native("WebAssembly.Table")
+extern class Table {
+	/**
+		Returns the length of the table, i.e. the number of elements.
+	**/
+	var length:Int;
+
+	@:pure function new(tableDescriptor:TableDescriptor):Void;
+
+	/**
+		Accessor function — gets the element stored at a given index.
+	**/
+	@:pure function get(index:Int):Function;
+
+	/**
+		Increases the size of the Table instance by a specified number of elements.
+	**/
+	function grow(number:Int):Int;
+
+	/**
+		Sets an element stored at a given index to a given value. 
+	**/
+	function set(index:Int, value:Function):Void;
+}
+
+typedef TableDescriptor = {
+	/**
+		A string representing the type of value to be stored in the table.
+		At the moment this can only have a value of `Anyfunc` (functions).
+	**/
+	var element:TableKind;
+
+	/**
+		The initial number of elements of the WebAssembly Table.
+	**/
+	var initial:Int;
+
+	/**
+		The maximum number of elements the WebAssembly Table is allowed to grow to. 
+	**/
+	var ?maximum:Int;
+}
+
+enum abstract TableKind(String) {
+	var Anyfunc = "anyfunc";
+}