{"id":28929104,"url":"https://github.com/flymeth/better-postmessage","last_synced_at":"2025-09-18T09:11:19.488Z","repository":{"id":243676609,"uuid":"813109080","full_name":"Flymeth/better-postmessage","owner":"Flymeth","description":"window.postMessage, but supports Promises, answers and simple typed handling","archived":false,"fork":false,"pushed_at":"2024-06-12T13:22:12.000Z","size":27,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-09T02:28:29.952Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Flymeth.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-10T13:52:29.000Z","updated_at":"2025-03-22T16:37:28.000Z","dependencies_parsed_at":"2024-06-10T16:11:58.124Z","dependency_job_id":null,"html_url":"https://github.com/Flymeth/better-postmessage","commit_stats":null,"previous_names":["flymeth/better-postmessage"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Flymeth/better-postmessage","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flymeth%2Fbetter-postmessage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flymeth%2Fbetter-postmessage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flymeth%2Fbetter-postmessage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flymeth%2Fbetter-postmessage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Flymeth","download_url":"https://codeload.github.com/Flymeth/better-postmessage/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flymeth%2Fbetter-postmessage/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275739911,"owners_count":25519604,"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-09-18T02:00:09.552Z","response_time":77,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","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":[],"created_at":"2025-06-22T14:15:22.521Z","updated_at":"2025-09-18T09:11:19.478Z","avatar_url":"https://github.com/Flymeth.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Better postMessage\n\nTired of the `window.postMessage()` method ? Need fresh new API that support Promises, answers and simple typed handling ?\nBetterPostMessage will resolve all of that !\n\n## Installation\n\n```terminal\n# NPM\nnpm i --save better-postmessage\n\n# YARN\nyarn i --save better-postmessage\n\n# BUN\nbun i --save better-postmessage\n```\n\n## Usage\n\n### First context\n\n```ts\nimport BetterPostMessage from \"better-postmessage\";\n\nconst messenger = new BetterPostMessage\u003cstring\u003e(window);\nmessenger\n .post({ message: \"ping\" })\n .answer.then((answer) =\u003e {\n  if (answer === \"pong\") console.log(\"Second context is online !\");\n })\n .catch(() =\u003e {\n  console.log(\"Second context has not responded\");\n });\n```\n\n### Second context\n\n```ts\nimport BetterPostMessage from \"better-postmessage\";\n\nconst messenger = new BetterPostMessage\u003cstring\u003e(window);\nmessenger.onReceive(({ message }) =\u003e {\n if (message === \"ping\") return \"pong\";\n});\n```\n\n### Parameters\n\n#### Constructor arguments\n\n```js\nnew BetterPostMessage(context, options?)\n```\n\n##### Context\n\nThe Window-based context where to emit/receive messages\n\n##### Options?\n\n\u003e Not required\n\nThe object containing all behavior options of the messenger.\nHere are the different options :\n\n| KEY           | DESCRIPTION                                                                                          | TYPE      | DEFAULT VALUE |\n| ------------- | ---------------------------------------------------------------------------------------------------- | --------- | ------------- |\n| tunnel        | Specify the custom tunnel of the proxy. Handler and message will be only receive/send to this tunnel | `string`  | `\"\"`          |\n| answerTimeout | In milliseconds, the maximum amount of time a message can wait for its answer                        | `number`  | `15_000`      |\n| debug         | If you want to view what's appening behind the process                                               | `boolean` | `false`       |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflymeth%2Fbetter-postmessage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflymeth%2Fbetter-postmessage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflymeth%2Fbetter-postmessage/lists"}