ES.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. register_simple_module('ES', {
  2. /* types */
  3. Symbol: Types.ES_Symbol,
  4. Object: Types.ES_Object,
  5. Key: Types.ES_Key,
  6. Class: Types.ES_Class,
  7. Function: Types.ES_Function,
  8. Iterable: Types.ES_Iterable,
  9. AsyncIterable: Types.ES_AsyncIterable,
  10. /* empty values */
  11. undefined: undefined,
  12. null: null,
  13. /* tools */
  14. create_symbol: fun (
  15. 'function create_symbol (name: String) -> ES_Symbol',
  16. name => Symbol(name)
  17. ),
  18. new: fun (
  19. 'function new (F: ES_Class) -> ES_Function',
  20. F => {
  21. let C = function constructor (...args) {
  22. return new (
  23. Function.prototype.bind
  24. .apply(F, [null, ...args])
  25. )()
  26. }
  27. return inject_desc(C, 'es_constructor')
  28. }
  29. ),
  30. instance_of: fun (
  31. 'function instance_of (F: ES_Class) -> Type',
  32. F => {
  33. return $(x => x instanceof F)
  34. }
  35. )
  36. })