{"id":25158169,"url":"https://github.com/agjs/ipeesee","last_synced_at":"2025-07-22T21:04:13.049Z","repository":{"id":33885731,"uuid":"163304087","full_name":"agjs/iPeeSee","owner":"agjs","description":"Electron IPC on steroids.  💪Simplified async communication and proper error and response handling.","archived":false,"fork":false,"pushed_at":"2023-04-30T03:33:15.000Z","size":153,"stargazers_count":7,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-11T21:30:58.895Z","etag":null,"topics":["electron","inter-process-communication","ipc","javascript","typescript"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/agjs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"license","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-12-27T14:34:42.000Z","updated_at":"2023-06-25T15:33:41.000Z","dependencies_parsed_at":"2024-11-15T05:30:33.061Z","dependency_job_id":null,"html_url":"https://github.com/agjs/iPeeSee","commit_stats":{"total_commits":16,"total_committers":4,"mean_commits":4.0,"dds":0.4375,"last_synced_commit":"4a8a88ed37627e02c76cf9719384899e3e93a804"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/agjs/iPeeSee","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agjs%2FiPeeSee","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agjs%2FiPeeSee/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agjs%2FiPeeSee/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agjs%2FiPeeSee/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/agjs","download_url":"https://codeload.github.com/agjs/iPeeSee/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agjs%2FiPeeSee/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266572293,"owners_count":23949994,"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","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["electron","inter-process-communication","ipc","javascript","typescript"],"created_at":"2025-02-09T01:49:16.930Z","updated_at":"2025-07-22T21:04:13.010Z","avatar_url":"https://github.com/agjs.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# IPeeSee (Inter-process communication)\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"./ipeesee-logo.png\"\u003e\n\u003c/p\u003e\n\nIPeeSee is a JS module built for the sake of easing the pain while working with native IPC\nimplementation in Electron.\n\nIPeeSee is written in Typescript, is fully documented and provides all the necessary types.\n\nCompared to some other modules, IPeeSee preserves the interfaces on both main and renderer process\nand tries to accomplish one-way / two-way communication in the simplest way possible.\n\nBesides communication, IPeeSee implements custom IPCError and IPCResponse. Those are implemented for\nthe sole sake of seperating errors/responses from other communication protocols.\n\n# Install\n\n\u003e npm i ipeesee --save\n\n## API\n\n### `.send(channel, data, options)`\n\nSends a message to a channel.\n\n#### Parameters\n\n- channel _(string)_ - A channel to send a message to\n- data _(any)_ - Data to send _(optional)_\n- options _(object)_ - _(optional)_\n\n  - **window** _(BrowserWindow)_ - An instance of browserWindow to send a message to. _Only required\n    when using with ipcMain_\n\n  - **reply** _(boolean)_ - By default, we always wait for the response. Setting this to false will\n    make the communication one-way only. In simple words, we send a message and don't care about the\n    response\n\n  - **timeout** _(number)_ - Time (seconds) to wait before we manually resolve the reply\n\nResolves either an IPCError or IPCResponse with the following statusCodes:\n\n- 204 - Resolved with no data in the response\n- 200 - Resolved with the data in the response\n- 408 - Resoled by manually timing out. This IPCResponse will also come with a message indicating\n  the timeout and the channel we timed out at\n\nKeep in mind that reply and timeout are mutually exclusive, meaning that setting timeout only makes\nsense when we are actually waiting for the reply. If we aren't (if reply is set to false or not\npassed at all), timeout will take no effect.\n\n---\n\n### `.reply(channel, callback)`\n\nAdds a listener that replies to the provided channel\n\n#### Parameters\n\n- channel _(string)_ - A channel to reply to\n\n- callback(data) _(Function)_ - Receives a message with optional data and responds back to the\n  channel. In order to reply back, it's mandatory to return from this function\n\n# Usage\n\nIPeeSee interfaces are unified. This means that regardless if you are working with main or renderer\nprocess, methods and arguments are the same.\n\n## Constructor\n\nIPeeSee constructor takes the process type (ipcMain, ipcRenderer) and an optional browserWindow that\nyou want to send a message to.\n\nIf you don't pass the window (browserWindow) to the constructor, you will have to pass it to .send()\neach time you want to send a message from main to renderer process.\n\nIf your application only uses a single window, it's a good idea in that case to simply pass a window\nto the constructor and not worry about passing it while using .send().\n\n```js\n\nconst IPeeSee = require('ipeesee').default;\n// or\nimport IPeeSee from 'ipeesee';\n\nconst ipc = new IPeeSee(ipcMain, yourWindow);\nipc.send('foo', { foo: 'bar' }).then(...).catch(...);\n```\n\nOr if you don't pass the window to the constructor, you will have to specify it in each .send _(only\nwhen sending messages from main to renderer)_\n\n```js\nipc.send('foo', { foo: 'bar' }, { window: yourBrowserWindow }).then(...).catch(...);\n```\n\n### Send a message that expects no reply\n\n```js\nipc.send('foo', { foo: 'bar' }, { reply: false });\n```\n\n### Manually timeout the reply after N number of seconds\n\n```js\nipc.send('foo', { foo: 'bar' }, { timeout: 30 }).then(...).catch(...);\n```\n\n### Renderer\n\n```js\nimport { ipcRenderer } from 'electron';\nimport IPeeSee from 'ipeesee';\n\nconst ipc = new IPeeSee(ipcRenderer);\n\nipc\n  .send('foo', { foo: 'bar' })\n  .then(response =\u003e {\n    console.log(response);\n  })\n  .catch(error =\u003e console.error(error)); // { message: 'Cabooom! }\n```\n\n### Main\n\n```js\nimport { ipcMain } from 'electron';\nimport IPeeSee from 'ipeesee';\n\nconst ipc = new IPeeSee(ipcMain);\n\nipc.reply('foo', data =\u003e {\n  return new Promise(resolve =\u003e {\n    console.log(data); // data from sender\n    resolve({ response: 'Foo is so Barish!' }); // respond back to sender\n  });\n});\n```\n\n_Communicating from main to renderer is done exactly the same way._\n\n### Working with errors\n\nIPC .send(channel, response) doesn't provide way to return node-like response e.g. (error,\nresponse). For that reason, we have to work with a single object and make the best out of it.\n\nTo work around this limitation, IPeeSee will check if your response object has .error property on it\nand if so, will reject it as IPCError. This means that no matter what, you will always resolve,\neither an error or a valid response.\n\n### Example with returning an IPCError\n\n```js\n\nipc\n  .send('get-todos', { id: 1 })\n  .then(todo =\u003e {\n    console.log(todo);\n  })\n  .catch(error =\u003e {\n    console.log(error);\n  });\n\n\nipc.reply('get-todos', data =\u003e {\n  return new Promise(resolve =\u003e {\n    request(`https://jsonplaceholder.typicode.com/todos/${data.id}`, (error, response, body) {\n      if(error) {\n        resolve({ error })\n      } else {\n        resolve(response);\n      }\n    });\n  });\n});\n```\n\nIn case of an error, it's imperative that your response object has a property called .error. The\nerror object itself can have any custom properties.\n\nIPCError response object looks like this:\n\n```js\n{\n  type: 'IPC_ERROR',\n  error: {} // error you previously resolved\n}\n```\n\n# TODO\n\n- Add CI server and how to build section\n- Unit tests\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagjs%2Fipeesee","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fagjs%2Fipeesee","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagjs%2Fipeesee/lists"}