From 118d4ed5474bef22e9279af87049c764117e454e Mon Sep 17 00:00:00 2001 From: Rudy Ges Date: Sun, 15 Oct 2023 14:32:52 +0200 Subject: [PATCH] Reduce diff --- std/js/lib/Object.hx | 99 +++++++++++++++++++++++--------------------- std/js/lib/Symbol.hx | 5 +-- 2 files changed, 53 insertions(+), 51 deletions(-) diff --git a/std/js/lib/Object.hx b/std/js/lib/Object.hx index 2e7a6db03a7..05d6d14dc7b 100644 --- a/std/js/lib/Object.hx +++ b/std/js/lib/Object.hx @@ -22,8 +22,8 @@ package js.lib; -import haxe.DynamicAccess; import haxe.extern.Rest; +import haxe.DynamicAccess; /** The `js.lib.Object` constructor creates an object wrapper. @@ -32,13 +32,6 @@ import haxe.extern.Rest; **/ @:native("Object") extern class Object { - static var prototype(default,never):ObjectPrototype; - - /** - The Object constructor creates an object wrapper. - **/ - @:pure function new(?value:Any); - /** The Object.assign() method is used to copy the values of all enumerable own properties from one or more source objects to a target object. It @@ -57,25 +50,25 @@ extern class Object { See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create **/ - @:pure static function create(proto:Null<{}>, ?propertiesObject:DynamicAccess>):TObj; + @:pure static function create(proto:Null<{}>, ?propertiesObject:DynamicAccess>):T; /** - The static method Object.defineProperty() defines a new property directly - on an object, or modifies an existing property on an object, and returns - the object. + The Object.defineProperties() method defines new or modifies existing + properties directly on an object, returning the object. - See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty + See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperties **/ - @:overload(function(obj:TObj, prop:Symbol, descriptor:ObjectPropertyDescriptor):TObj {}) - static function defineProperty(obj:TObj, prop:String, descriptor:ObjectPropertyDescriptor):TObj; + static function defineProperties(obj:T, props:DynamicAccess>):T; /** - The Object.defineProperties() method defines new or modifies existing - properties directly on an object, returning the object. + The static method Object.defineProperty() defines a new property directly + on an object, or modifies an existing property on an object, and returns + the object. - See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperties + See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty **/ - static function defineProperties(obj:TObj, props:DynamicAccess>):TObj; + @:overload(function(obj:T, prop:Symbol, descriptor:ObjectPropertyDescriptor):T {}) + static function defineProperty(obj:T, prop:String, descriptor:ObjectPropertyDescriptor):T; /** The Object.entries() method returns an array of a given object's own @@ -87,7 +80,7 @@ extern class Object { See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries **/ - @:pure static function entries(obj:TObj):Array; + @:pure static function entries(obj:T):Array; /** The Object.freeze() method freezes an object: that is, prevents new @@ -99,7 +92,7 @@ extern class Object { See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze **/ - static function freeze(obj:TObj):TObj; + static function freeze(obj:T):T; /** The Object.getOwnPropertyDescriptor() method returns a property @@ -115,8 +108,8 @@ extern class Object { @:overload(function(obj:String, prop:Symbol):Null> {}) @:overload(function(obj:String, prop:String):Null> {}) @:overload(function(target:Array, propertyKey:Int):Null> {}) - @:overload(function(obj:TObj, prop:Symbol):Null> {}) - @:pure static function getOwnPropertyDescriptor(obj:TObj, prop:String):Null>; + @:overload(function(obj:T, prop:Symbol):Null> {}) + @:pure static function getOwnPropertyDescriptor(obj:T, prop:String):Null>; /** The Object.getOwnPropertyDescriptors() method returns all own property @@ -126,7 +119,7 @@ extern class Object { **/ @:overload(function(target:String):DynamicAccess> {}) @:overload(function(target:Array):DynamicAccess> {}) - @:pure static function getOwnPropertyDescriptors(obj:TObj):DynamicAccess>; + @:pure static function getOwnPropertyDescriptors(obj:T):DynamicAccess>; /** The Object.getOwnPropertyNames() method returns an array of all @@ -135,7 +128,7 @@ extern class Object { See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames **/ - @:pure static function getOwnPropertyNames(obj:TObj):Array; + @:pure static function getOwnPropertyNames(obj:T):Array; /** The Object.getOwnPropertySymbols() method returns an array of all symbol @@ -145,7 +138,7 @@ extern class Object { See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertySymbols **/ - @:pure static function getOwnPropertySymbols(obj:TObj):Array; + @:pure static function getOwnPropertySymbols(obj:T):Array; /** The Object.getPrototypeOf() method returns the prototype (i.e. the value @@ -153,7 +146,7 @@ extern class Object { See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getPrototypeOf **/ - @:pure static function getPrototypeOf(obj:TObj):TProto; + @:pure static function getPrototypeOf(obj:T):TProto; /** The Object.is() method determines whether two values are the same value. @@ -162,7 +155,7 @@ extern class Object { See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is **/ - @:pure static function is(obj1:TObj, obj2:TObj):Bool; + @:pure static function is(obj1:T, obj2:T):Bool; /** The Object.isExtensible() method determines if an object is extensible @@ -170,21 +163,21 @@ extern class Object { See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isExtensible **/ - @:pure static function isExtensible(obj:TObj):Bool; + @:pure static function isExtensible(obj:T):Bool; /** The Object.isFrozen() determines if an object is frozen. See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isFrozen **/ - @:pure static function isFrozen(obj:TObj):Bool; + @:pure static function isFrozen(obj:T):Bool; /** The Object.isSealed() method determines if an object is sealed. See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isSealed **/ - @:pure static function isSealed(obj:TObj):Bool; + @:pure static function isSealed(obj:T):Bool; /** The Object.keys() method returns an array of a given object's own @@ -194,7 +187,7 @@ extern class Object { See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys **/ - @:pure static function keys(obj:TObj):Array; + @:pure static function keys(obj:T):Array; /** The Object.preventExtensions() method prevents new properties from ever @@ -202,7 +195,7 @@ extern class Object { See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/preventExtensions **/ - static function preventExtensions(obj:TObj):TObj; + static function preventExtensions(obj:T):T; /** The Object.seal() method seals an object, preventing new properties from @@ -212,7 +205,7 @@ extern class Object { See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/seal **/ - static function seal(obj:TObj):TObj; + static function seal(obj:T):T; /** The Object.setPrototypeOf() method sets the prototype (i.e., the internal @@ -222,7 +215,7 @@ extern class Object { See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf **/ - static function setPrototypeOf(obj:TObj, proto:Null):TObj; + static function setPrototypeOf(obj:T, proto:Null):T; /** The Object.values() method returns an array of a given object's own @@ -234,7 +227,17 @@ extern class Object { See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/values **/ - @:pure static function values(obj:TObj):Array; + @:pure static function values(obj:T):Array; + + /** + Allows the addition of properties to all objects of type Object. + **/ + static var prototype(default, never):ObjectPrototype; + + /** + The Object constructor creates an object wrapper. + **/ + @:pure function new(?value:Any); } /** @@ -247,45 +250,39 @@ typedef ObjectPrototype = { property as a direct property of that object and not inherited through the prototype chain. **/ - var hasOwnProperty(default,never):Function; + var hasOwnProperty(default, never):Function; /** Returns a boolean indicating whether the object this method is called upon is in the prototype chain of the specified object. **/ - var isPrototypeOf(default,never):Function; + var isPrototypeOf(default, never):Function; /** Returns a boolean indicating if the internal enumerable attribute is set. **/ - var propertyIsEnumerable(default,never):Function; + var propertyIsEnumerable(default, never):Function; /** Calls `toString()`. **/ - var toLocaleString(default,never):Function; + var toLocaleString(default, never):Function; /** Returns a string representation of the object. **/ - var toString(default,never):Function; + var toString(default, never):Function; /** Returns the primitive value of the specified object. **/ - var valueOf(default,never):Function; + var valueOf(default, never):Function; } /** @see **/ typedef ObjectPropertyDescriptor = { - /** - The value associated with the property. - Can be any valid JavaScript value (number, object, function, etc). - **/ - var ?value:TProp; - /** `true` if and only if the type of this property descriptor may be changed and if the property may be deleted from the corresponding object. @@ -300,6 +297,12 @@ typedef ObjectPropertyDescriptor = { **/ var ?enumerable:Bool; + /** + The value associated with the property. + Can be any valid JavaScript value (number, object, function, etc). + **/ + var ?value:TProp; + /** `true` if and only if the value associated with the property may be changed with an assignment operator. diff --git a/std/js/lib/Symbol.hx b/std/js/lib/Symbol.hx index 18cde8d8856..ebfd734ab53 100644 --- a/std/js/lib/Symbol.hx +++ b/std/js/lib/Symbol.hx @@ -41,7 +41,7 @@ extern class Symbol { See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/for **/ - @:native('for') static function for_(key:String):Symbol; + @:native("for") static function for_(key:String):Symbol; /** The Symbol.keyFor(sym) method retrieves a shared symbol key from the @@ -49,7 +49,7 @@ extern class Symbol { See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/keyFor **/ - @:pure static function keyFor(symbol:Symbol):Null; + @:pure static function keyFor(sym:Symbol):Null; /** Returns a string containing the description of the Symbol. @@ -128,4 +128,3 @@ extern class Symbol { inline function ofObject(object:{}):Null return (cast object)[cast this]; } -