[Ur] Difficulty determining what functions to "wrap", using JavaScript FFI, for certain existing JavaScript libraries

Stefan Scott Alexander stefanscottalexx at gmail.com
Sat Aug 1 21:45:46 EDT 2015


I understand that it is necessary to use Ur/Web's JavaScript FFI in order
to call an existing JavaScript library, and I have to declare the functions
in a URS file.

The difficulty I have is that when I look at certain JavaScript libraries,
I have difficulty determining what functions are at "top-level" in the JS
file, to declare in the URS file.

For example, here are two JavaScript libraries which implement a DatePicker:

https://github.com/eternicode/bootstrap-datepicker/blob/master/js/bootstrap-datepicker.js

https://github.com/dbushell/Pikaday/blob/master/pikaday.js

They both appear to have a single top-level "factory" function (?),
apparently anonymous (?), enclosed in parentheses.

Then they both return a bunch of things in { ... } - var declarations and
function declarations etc. But these things aren't at "top-level" so I
doubt it would make much sense to refer to such function declarations from
a URS file.

Are these kind of JavaScript libraries (involving a single, anonymous
top-level function) even callable via Ur/Web's FFI?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.impredicative.com/pipermail/ur/attachments/20150801/921f4cf3/attachment.html>


More information about the Ur mailing list