MCPcopy Index your code
hub / github.com/pyscript/pyscript / to_js

Function to_js

core/src/stdlib/pyscript/ffi.py:74–99  ·  view source on GitHub ↗

Convert Python objects to JavaScript objects. This ensures a Python `dict` becomes a [proper JavaScript object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) rather a JavaScript [`Map`](https://developer.mozilla.org/en-US/docs/Web/JavaScri

(value, **kw)

Source from the content-addressed store, hash-verified

72
73
74def to_js(value, **kw):
75 """
76 Convert Python objects to JavaScript objects.
77
78 This ensures a Python `dict` becomes a
79 [proper JavaScript object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)
80 rather a JavaScript [`Map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map),
81 which is more intuitive for most use cases.
82
83 Where required, the underlying `to_js` uses `Object.fromEntries` for
84 `dict` conversion.
85
86 ```python
87 from pyscript import ffi
88 import js
89
90
91 note = {
92 "body": "This is a notification",
93 "icon": "icon.png"
94 }
95
96 js.Notification.new("Hello!", ffi.to_js(note))
97 ```
98 """
99 return _to_js_wrapper(value, **kw)
100
101
102def is_none(value):

Callers 8

PyWorkerFunction · 0.90
mountFunction · 0.90
decoratorFunction · 0.90
request_streamMethod · 0.90
assignFunction · 0.85
split_element_styleFunction · 0.85
get_rendererFunction · 0.85

Calls 1

_to_js_wrapperFunction · 0.85

Tested by 1