* The ``bind()`` method creates a new function that, when called, has its * ``this`` keyword set to the provided value, with a given sequence of * arguments preceding any provided when the new function is called. See * :js:meth:`Function.bind`. * * If the :js:class:`~pyodide.ffi.PyCal
(thisArg: any, ...jsargs: any)
| 2875 | * @returns |
| 2876 | */ |
| 2877 | bind(thisArg: any, ...jsargs: any) { |
| 2878 | let { shared, props } = _getAttrs(this); |
| 2879 | const { boundArgs: boundArgsOld, boundThis: boundThisOld, isBound } = props; |
| 2880 | let boundThis = thisArg; |
| 2881 | if (isBound) { |
| 2882 | boundThis = boundThisOld; |
| 2883 | } |
| 2884 | let boundArgs = boundArgsOld.concat(jsargs); |
| 2885 | props = Object.assign({}, props, { |
| 2886 | boundArgs, |
| 2887 | isBound: true, |
| 2888 | boundThis, |
| 2889 | }); |
| 2890 | return pyproxy_new(shared.ptr, { |
| 2891 | shared, |
| 2892 | flags: _getFlags(this), |
| 2893 | props, |
| 2894 | }); |
| 2895 | } |
| 2896 | |
| 2897 | /** |
| 2898 | * Returns a :js:class:`~pyodide.ffi.PyProxy` that passes ``this`` as the first argument to the |