module JS::Helpers
def native_methods
def native_methods @native_methods ||= %x{ let obj = #{to_n}; const props = new Set(); while (obj !== null) { for (const key of Reflect.ownKeys(obj)) { const stringKey = key.toString() const rubyName = #{to_rb_name(`stringKey`)} if (typeof key !== 'symbol' && stringKey !== rubyName ) { props.add(rubyName); } props.add(stringKey); } obj = Object.getPrototypeOf(obj); } return Array.from(props); } end
def wrap_result(result)
def wrap_result(result) if `result && typeof result.then === 'function'` Promise.new(result) elsif `typeof result === 'object' && result !== null` Proxy.new(result) else result end end