swiftwasm / JavaScriptKit

Swift framework to interact with JavaScript through WebAssembly.
https://swiftpackageindex.com/swiftwasm/JavaScriptKit/main/documentation/javascriptkit
MIT License
670 stars 44 forks source link

Re-add support for Symbol objects via JSSymbol #183

Closed j-f1 closed 2 years ago

j-f1 commented 2 years ago

This re-adds the functionality removed by #180.

(I accidentally pushed this change to main first, sorry about that!)

The Reflect namespace is mainly intended for use with Proxy objects, with each function on that namespace matching the signature of the corresponding proxy trap. For most use cases, normal access is preferable.

The test failure was occurring because Reflect.* functions check that their parameter is really an object. While this is the case for objects, symbols aren’t objects; the [] syntax automatically converts to an object where necessary.

github-actions[bot] commented 2 years ago

Time Change: +603.75ms (7%) 🔍

Total Time: 8,585.75ms

Test name Duration Change
Serialization/Write JavaScript number directly 203.5ms +34.25ms (16%) ⚠️
Serialization/Write JavaScript string directly 197ms +22.25ms (11%) ⚠️
Serialization/Swift Int to JavaScript 2,670ms +250.25ms (9%) 🔍
Serialization/Swift String to JavaScript 2,666.25ms +207.25ms (7%) 🔍
ℹ️ View Unchanged | Test name | Duration | Change | | :--- | :---: | :---: | | Object heap/Increment and decrement RC | 2,849ms | +89.75ms (3%) |

performance-action

kateinoigakukun commented 2 years ago

For the record: https://tc39.es/ecma262/#sec-reflect.get

28.1.5 Reflect.get ( target, propertyKey [ , receiver ] ) When the get function is called with arguments target, propertyKey, and receiver, the following steps are taken:

  1. If Type(target) is not Object, throw a TypeError exception.