jeroen / V8

Embedded JavaScript Engine for R
https://cran.r-project.org/package=V8
Other
201 stars 29 forks source link

Object function ArrayBuffer() { [native code] } has no method 'isView #29

Closed bhaskarvk closed 8 years ago

bhaskarvk commented 8 years ago

I'm trying to use https://github.com/mapbox/geobuf in V8 and getting the following error.

> fName <- 'https://rawgit.com/benbalter/dc-maps/master/maps/ward-2012.geojson'

> geoJson <- readr::read_file(fName)

> ct <- v8()
> ct$source('inst/htmlwidgets/lib/geobuf/geobuf.js')
[1] "true"

> ct$get(JS('Object.keys(global)'))
 [1] "console"      "print"        "global"       "ArrayBuffer"  "Int8Array"    "Uint8Array"  
 [7] "Int16Array"   "Uint16Array"  "Int32Array"   "Uint32Array"  "Float32Array" "Float64Array"
[13] "DataView"     "geobuf"      

> ct$source('inst/htmlwidgets/lib/geobuf/pbf.js')
[1] "true"

> ct$get(JS('Object.keys(global)'))
 [1] "console"      "print"        "global"       "ArrayBuffer"  "Int8Array"    "Uint8Array"  
 [7] "Int16Array"   "Uint16Array"  "Int32Array"   "Uint32Array"  "Float32Array" "Float64Array"
[13] "DataView"     "geobuf"       "Pbf"  

> ct$assign('geojson',geoJson)
> ct$console()
This is V8 version 3.15.11.18. Press ESC or CTRL+C to exit.
~ var gj = JSON.parse(geojson)
~ gj
[object Object]
~ var buf = geobuf.encode(gj,new Pbf())
TypeError: Object function ArrayBuffer() { [native code] } has no method 'isView'
 sessionInfo()
R version 3.3.2 (2016-10-31)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: OS X El Capitan 10.11.6

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] V8_1.1                  magrittr_1.5            leaflet.extras_0.1.9002
[4] leaflet_1.0.2.9008     

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.8     XML_3.98-1.5    digest_0.6.10   withr_1.0.2     assertthat_0.1 
 [6] bitops_1.0-6    jsonlite_1.1    curl_2.2        devtools_1.12.0 rjson_0.2.15   
[11] tools_3.3.2     RSelenium_1.4.5 readr_1.0.0     htmlwidgets_0.8 RCurl_1.95-4.8 
[16] caTools_1.17.1  memoise_1.0.0   htmltools_0.3.5 tibble_1.2   
jeroen commented 8 years ago

Are you aware that the protolite package supports geobuf?

bhaskarvk commented 8 years ago

I was not. Thanks for the pointer, protolite will suite my needs perfectly.

binarykitchen commented 7 years ago

Having this issue too sometimes for an AngularJS based app of mine and couldn't find a polyfill for it. Any hints?