js-ffi: move casting to native code

Putting language-specific casting code in Elm code makes it unportable
in the event that the compiler supports another target in the future. As
elm-d3 is D3 and therefore JavaScript-specific this is unlikely to be an
issue in the future, but it nevertheless a good practice.