Object.hx 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Copyright (C)2005-2017 Haxe Foundation
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  20. * DEALINGS IN THE SOFTWARE.
  21. */
  22. package js;
  23. import haxe.extern.Rest;
  24. import haxe.DynamicAccess;
  25. @:native("Object")
  26. extern class Object {
  27. static function assign<T:{}>(target:T, sources:Rest<{}>):T;
  28. @:pure static function create<T>(proto:{}, ?propertiesObject:DynamicAccess<ObjectPropertyDescriptor>):T;
  29. static function defineProperties<T:{}>(obj:T, props:DynamicAccess<ObjectPropertyDescriptor>):T;
  30. static function defineProperty<T:{}>(obj:T, prop:String, descriptor:ObjectPropertyDescriptor):T;
  31. static function freeze<T:{}>(obj:T):T;
  32. @:pure static function getOwnPropertyDescriptor(obj:{}, prop:String):Null<ObjectPropertyDescriptor>;
  33. @:pure static function getOwnPropertyNames(obj:{}):Array<String>;
  34. @:pure static function getOwnPropertySymbols(obj:{}):Array<Symbol>;
  35. @:pure static function getPrototypeOf<TProto:{}>(obj:{}):Null<TProto>;
  36. @:pure static function is<T>(value1:T, value2:T):Bool;
  37. @:pure static function isExtensible(obj:{}):Bool;
  38. @:pure static function isFrozen(obj:{}):Bool;
  39. @:pure static function isSealed(obj:{}):Bool;
  40. @:pure static function keys(obj:{}):Array<String>;
  41. static function preventExtensions<T:{}>(obj:T):T;
  42. static function seal<T:{}>(obj:T):T;
  43. static function setPrototypeOf<T:{}>(obj:T, prototype:Null<{}>):T;
  44. static var prototype(default,never):ObjectPrototype;
  45. @:pure function new(?value:Any);
  46. }
  47. typedef ObjectPrototype = {
  48. var hasOwnProperty(default,never):Function;
  49. var isPrototypeOf(default,never):Function;
  50. var propertyIsEnumerable(default,never):Function;
  51. var toLocaleString(default,never):Function;
  52. var toString(default,never):Function;
  53. var valueOf(default,never):Function;
  54. }
  55. typedef ObjectPropertyDescriptor = {
  56. @:optional var configurable:Bool;
  57. @:optional var enumerable:Bool;
  58. @:optional var value:Any;
  59. @:optional var writable:Bool;
  60. @:optional var get:Void->Any;
  61. @:optional var set:Any->Void;
  62. }