{"id":22753579,"url":"https://github.com/starryinternet/fringe","last_synced_at":"2025-04-14T15:31:01.004Z","repository":{"id":21359615,"uuid":"92511872","full_name":"StarryInternet/fringe","owner":"StarryInternet","description":"Fast, lightweight, and extensible message framing over streams","archived":false,"fork":false,"pushed_at":"2023-09-28T22:27:37.000Z","size":55,"stargazers_count":6,"open_issues_count":3,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-10T11:34:51.373Z","etag":null,"topics":["buffer","javascript","message-framing","stream","streaming"],"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/StarryInternet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2017-05-26T13:11:34.000Z","updated_at":"2024-02-27T14:59:59.000Z","dependencies_parsed_at":"2024-11-10T22:33:17.578Z","dependency_job_id":"b0c33168-76ea-4224-abfe-9fbe8371932f","html_url":"https://github.com/StarryInternet/fringe","commit_stats":{"total_commits":30,"total_committers":4,"mean_commits":7.5,"dds":0.5,"last_synced_commit":"96fed82fe76f38f3b8a7451cc78639364090f05a"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StarryInternet%2Ffringe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StarryInternet%2Ffringe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StarryInternet%2Ffringe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StarryInternet%2Ffringe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/StarryInternet","download_url":"https://codeload.github.com/StarryInternet/fringe/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248906397,"owners_count":21181171,"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":["buffer","javascript","message-framing","stream","streaming"],"created_at":"2024-12-11T06:11:44.986Z","updated_at":"2025-04-14T15:31:00.984Z","avatar_url":"https://github.com/StarryInternet.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Fringe\n===\n\n[![Build Status](https://travis-ci.org/StarryInternet/fringe.svg?branch=master)](https://travis-ci.org/StarryInternet/fringe)\n\nFast, lightweight, and extensible message framing over streams.\n\n### Installing\n\n```\nnpm install --save fringe\n```\n\n### Usage\n\nBy default, `fringe` encodes your input buffer with the string `FRINGE`\nplus the byte length of the input buffer encoded as `UInt32BE`.\n\n#### Hello world:\n\n```js\nconst { Encoder, Parser } = require('fringe');\n\nconst encoder = new Encoder();\nconst parser  = new Parser();\n\nencoder.pipe( parser );\n\nparser.on( 'message', buffer =\u003e console.log( buffer.toString('utf8') ) );\n\nencoder.write('hello');\nencoder.write('world');\n```\n\n### Events\n\nWhen a complete message is received, `Parser` will emit two events:\n\n#### data\n\nThe standard Node.js `data` events for streams. The argument passed to your\ncallback will be a Buffer of the original message payload.\n\n#### message\n\nThe argument passed to the `message` event will be the return value of the\n`Parser` instance's `translate` method (see below).\n\nBy default, this value will be identical to the Buffer passed to the `data`\ncallback – but is useful for situations where `translate` may return a parsed\nobject.\n\n### Configuration\n\n`Encoder` and `Parser` each accept two arguments:\n\n#### format\n\nAn object containing formatting options for the message\n\n###### prefix\n\nA string that will be prepended to each message (may be an empty string).\nDefaults to `FRINGE`.\n\n###### lengthFormat\n\nThe binary format that the payload length will be stored as. Options are\n`UInt8`, `UInt16BE`, `UInt16LE`, `UInt32BE`, and `UInt32LE`. Defaults to\n`UInt32BE`.\n\n###### maxSize\n\nThe maximum acceptable payload length in bytes. Defaults to 100 MB\n(1024 * 1024 * 100).\n\n#### options\n\nOptions to be passed directly to the underlying `Transform` stream.\n\n### Extending\n\n`Encoder` and `Parser` may each be sub-classes with custom `translate` methods.\n\n#### Encoder translate\n\nAccepts any value and must return a string or Buffer.\n\nAn example `translate` function to accept an object and output a JSON string:\n\n```js\ntranslate( obj ) {\n  return JSON.stringify( obj );\n}\n```\n\n#### Parser translate\n\nAccepts a string or Buffer and may return any value.\n\nAn example `translate` function to accept a Buffer and output an object:\n\n```js\ntranslate( buffer ) {\n  return JSON.parse( buffer.toString('utf8') );\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstarryinternet%2Ffringe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstarryinternet%2Ffringe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstarryinternet%2Ffringe/lists"}