{"id":30190810,"url":"https://github.com/fibjs/fib-push","last_synced_at":"2025-08-12T20:08:58.303Z","repository":{"id":57235123,"uuid":"113867908","full_name":"fibjs/fib-push","owner":"fibjs","description":null,"archived":false,"fork":false,"pushed_at":"2020-05-25T13:17:14.000Z","size":41,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-09T06:21:18.024Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/fibjs.png","metadata":{"files":{"readme":"README.md","changelog":"History.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-11T14:20:51.000Z","updated_at":"2020-05-25T13:17:16.000Z","dependencies_parsed_at":"2022-08-23T15:50:45.667Z","dependency_job_id":null,"html_url":"https://github.com/fibjs/fib-push","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/fibjs/fib-push","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fibjs%2Ffib-push","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fibjs%2Ffib-push/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fibjs%2Ffib-push/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fibjs%2Ffib-push/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fibjs","download_url":"https://codeload.github.com/fibjs/fib-push/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fibjs%2Ffib-push/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269706643,"owners_count":24462205,"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-08-10T02:00:08.965Z","response_time":71,"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-08-12T20:08:54.329Z","updated_at":"2025-08-12T20:08:58.266Z","avatar_url":"https://github.com/fibjs.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## fib-push\n\n[![NPM version](https://img.shields.io/npm/v/fib-push.svg)](https://www.npmjs.org/package/fib-push)\n[![Build Status](https://travis-ci.org/fibjs/fib-push.svg)](https://travis-ci.org/fibjs/fib-push)\n[![Build status](https://ci.appveyor.com/api/projects/status/6l4jxtsea63v75rd?svg=true)](https://ci.appveyor.com/project/richardo2016/fib-push)\n\n\n`fib-push` is one global service in a fibjs runtime, which provides duplex communication based on **websocket-like** connection, and manage end-2-end connection \u0026 **message queue** with **Channel**. One global service is enough in most cases, so we **don't** support multiple instances of `fib-push` at now.\n\n`fib-push` has so less code that you could learn about its mechanism and usage just by reading source code :)\n\n### Core Concept\n\n- `Channel` is the pivot structure in `fib-push`.\n- There is one global `idles` variable for recording idle channel, when new idle channel added as tail, the head one would be delete and removed.\n- All message transmission is on json-encoded-format.\n\n### Usage\n\n```javascript\nconst push = require('fib-push');\n\npush.config({\n    idle_limit: 10,\n    msg_limit: 10\n});\nvar r = [];\nvar ws = {\n    send: m =\u003e r.push(m)\n};\n\nfunction filter_data (data) {\n    return data.foo === 'bar';\n}\n// mount one channel named of 'channel_name'\npush.on('channel_name', ws, new Date(), filter_data);\npush.post('channel_name', { foo: '_bar' })\nconsole.log(r.length) // 0\npush.post('channel_name', { foo: 'bar' })\nconsole.log(r.length) // 1\n\nconsole.log(r[0]) // {\"timestamp\":\"2018-05-11T09:18:05.134Z\",\"ch\":\"channel_name\",\"data\":{\"foo\":\"bar\"}}\nconsole.log(JSON.parse(r[0]).data) // {foo: 'bar'}\n```\n\nView more useages in this repo's `test/*.js`\n\n---\n\n### Types\n\nView details in [@types]\n---\n\n[Link]:docs/link.md\n[@types]:@types/index.d.ts\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffibjs%2Ffib-push","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffibjs%2Ffib-push","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffibjs%2Ffib-push/lists"}