{"id":21521089,"url":"https://github.com/weisjohn/sleepyhollow-phantom","last_synced_at":"2025-04-09T22:21:43.546Z","repository":{"id":17294897,"uuid":"20065282","full_name":"weisjohn/sleepyhollow-phantom","owner":"weisjohn","description":"PhantomJS binder for two-way communication with Node.js","archived":false,"fork":false,"pushed_at":"2015-02-18T07:36:17.000Z","size":201,"stargazers_count":6,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T00:15:01.865Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/weisjohn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-05-22T14:59:38.000Z","updated_at":"2024-06-22T02:56:50.000Z","dependencies_parsed_at":"2022-09-26T21:21:03.659Z","dependency_job_id":null,"html_url":"https://github.com/weisjohn/sleepyhollow-phantom","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weisjohn%2Fsleepyhollow-phantom","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weisjohn%2Fsleepyhollow-phantom/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weisjohn%2Fsleepyhollow-phantom/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weisjohn%2Fsleepyhollow-phantom/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/weisjohn","download_url":"https://codeload.github.com/weisjohn/sleepyhollow-phantom/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247847614,"owners_count":21006100,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-24T01:05:44.372Z","updated_at":"2025-04-09T22:21:43.520Z","avatar_url":"https://github.com/weisjohn.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"sleepyhollow-phantom\n====================\n\nPhantomJS binder for two-way communication with Node.js. An IPC library in two modules, used in conjunction with [sleepyhollow-node](https://github.com/weisjohn/sleepyhollow-node), via `stdin` and `stderr`. No `socket.io` or server-page hacks required.\n\n### usage\n\nTo receive messages from Node.js, require and invoke `sleepyhollow`. This returns an `EventEmitter` instance which allows you to implement your own message passing system.\n\n```\n// this is PhantomJS code, not Node.js code!\n\nvar sleepyhollow = require('../index.js');\nvar mrhyde = sleepyhollow();\n\nmrhyde.on('render', function(url) {\n    var page = require('webpage').create();\n    page.open(url, function(status) {\n        page.render(url.replace(/[\\/:]/g, \"\") + \".png\");\n        mrhyde.emit(\"rendered\");\n        page.close();\n    });\n});\n\nmrhyde.on('end', function() {\n    phantom.exit();\n});\n\n```\n\n[See the usage example for the corresponding Node.js code](https://github.com/weisjohn/sleepyhollow-node#usage).\n\n#### emit(event, [param])\n\nArguments:\n\n1. event - String: name of the event\n2. param - Mixed: optional, any `JSON.stringify()`-able value is supported\n\nReturns: null\n\nExample:\n\n```javascript\nmyhyde.emit(\"payload\", { prop : page.size });\n```\n\n\n#### on(event, listener)\n\nArguments:\n\n1. event - String: name of the event\n2. listener - Function(Mixed): receives a optional `JSON.stringify()`-able value\n\nExample:\n\n```javascript\nmyhyde.on('render', function(obj) {\n    page.render(\"tmp\");\n})\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweisjohn%2Fsleepyhollow-phantom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fweisjohn%2Fsleepyhollow-phantom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweisjohn%2Fsleepyhollow-phantom/lists"}