{"action":"created","issue":{"url":"https://api.github.com/repos/ateucher/rmapshaper/issues/2","labels_url":"https://api.github.com/repos/ateucher/rmapshaper/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/ateucher/rmapshaper/issues/2/comments","events_url":"https://api.github.com/repos/ateucher/rmapshaper/issues/2/events","html_url":"https://github.com/ateucher/rmapshaper/issues/2","id":106111495,"number":2,"title":"Use V8","user":{"login":"ateucher","id":2816635,"avatar_url":"https://avatars.githubusercontent.com/u/2816635?v=3","gravatar_id":"","url":"https://api.github.com/users/ateucher","html_url":"https://github.com/ateucher","followers_url":"https://api.github.com/users/ateucher/followers","following_url":"https://api.github.com/users/ateucher/following{/other_user}","gists_url":"https://api.github.com/users/ateucher/gists{/gist_id}","starred_url":"https://api.github.com/users/ateucher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ateucher/subscriptions","organizations_url":"https://api.github.com/users/ateucher/orgs","repos_url":"https://api.github.com/users/ateucher/repos","events_url":"https://api.github.com/users/ateucher/events{/privacy}","received_events_url":"https://api.github.com/users/ateucher/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":16,"created_at":"2015-09-11T23:22:32Z","updated_at":"2015-09-12T19:00:53Z","closed_at":null,"body":"I'd like to include the mapshaper javascript library and use [V8](https://cran.r-project.org/web/packages/V8/index.html), so that users don't have to have `node.js` and the `mapshaper` module installed. Also, using `system()` calls to use mapshaper commands in node is very inefficient due to all of the disk i/o required.\r\n\r\nI've started trying in `test_v8.R` in the [test-v8](https://github.com/ateucher/rmapshaper/tree/test-v8) branch.  Unfortunately I'm a total javascript hack.\r\n\r\nI've got the library imported, and a basic call to `mapshaper.applyCommands` running with no errors (as documented [here](https://github.com/mbloch/mapshaper/wiki/Using-mapshaper-programmatically))- but it doesn't return anything. I've run through most of the javascript call stack with a bunch of `console.log()`'s and I think it dies with the call to [`utils.reduceAsync`](https://github.com/ateucher/rmapshaper/blob/test-v8/inst/mapshaper/mapshaper.js#L15349) [here](https://github.com/ateucher/rmapshaper/blob/test-v8/inst/mapshaper/mapshaper.js#L15311).\r\n\r\nV8 doesn't ship with some things that Node has, such as the timer functions `setImmediate` and `setTimout`, so I was initially getting the errors `ReferenceError: setTimeout is not defined` and `ReferenceError: setImmediate is not defined`. After some googling around, I found some versions of these functions that people had put together, and included them - it stopped the errors, but now `mapshaper.applyCommands` just fails silently.  I have a strong suspicion that the totally hacky way I did this is the source of the problem.\r\n\r\nIf anyone has any ideas - either by telling I'm totally off-track, or by telling me how I might include the timers properly, I would be really grateful.\r\n\r\n@sckott, @timelyportfolio - do you have any ideas?"},"comment":{"url":"https://api.github.com/repos/ateucher/rmapshaper/issues/comments/139809876","html_url":"https://github.com/ateucher/rmapshaper/issues/2#issuecomment-139809876","issue_url":"https://api.github.com/repos/ateucher/rmapshaper/issues/2","id":139809876,"user":{"login":"timelyportfolio","id":837910,"avatar_url":"https://avatars.githubusercontent.com/u/837910?v=3","gravatar_id":"","url":"https://api.github.com/users/timelyportfolio","html_url":"https://github.com/timelyportfolio","followers_url":"https://api.github.com/users/timelyportfolio/followers","following_url":"https://api.github.com/users/timelyportfolio/following{/other_user}","gists_url":"https://api.github.com/users/timelyportfolio/gists{/gist_id}","starred_url":"https://api.github.com/users/timelyportfolio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timelyportfolio/subscriptions","organizations_url":"https://api.github.com/users/timelyportfolio/orgs","repos_url":"https://api.github.com/users/timelyportfolio/repos","events_url":"https://api.github.com/users/timelyportfolio/events{/privacy}","received_events_url":"https://api.github.com/users/timelyportfolio/received_events","type":"User","site_admin":false},"created_at":"2015-09-12T19:00:53Z","updated_at":"2015-09-12T19:00:53Z","body":"Took me a little longer since I've been lazy and using the UI.  I'm not familiar with the command-line options.  Here is what I have for now.  I'll post it up in its ugly state since I have to turn off the computer for the day.\r\n\r\nIt is all in the fork https://github.com/timelyportfolio/rmapshaper/tree/V8 with code [here](https://github.com/timelyportfolio/rmapshaper/blob/V8/inst/examples/experiment_V8.R).  Hope it helps.  I'll be able to get back on it in the morning or tomorrow night."}}