{"id":32565654,"url":"https://github.com/davidcai1111/resper","last_synced_at":"2026-05-14T21:06:25.254Z","repository":{"id":57354768,"uuid":"54263428","full_name":"DavidCai1111/resper","owner":"DavidCai1111","description":":microscope:A parser for RESP (REdis Serialization Protocol)","archived":false,"fork":false,"pushed_at":"2016-04-20T15:06:22.000Z","size":8,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-03-26T11:37:03.594Z","etag":null,"topics":["nodejs","resp"],"latest_commit_sha":null,"homepage":"","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/DavidCai1111.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":"2016-03-19T11:54:20.000Z","updated_at":"2016-03-28T05:32:33.000Z","dependencies_parsed_at":"2022-09-26T16:31:31.495Z","dependency_job_id":null,"html_url":"https://github.com/DavidCai1111/resper","commit_stats":null,"previous_names":["davidcai1993/resper"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/DavidCai1111/resper","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DavidCai1111%2Fresper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DavidCai1111%2Fresper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DavidCai1111%2Fresper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DavidCai1111%2Fresper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DavidCai1111","download_url":"https://codeload.github.com/DavidCai1111/resper/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DavidCai1111%2Fresper/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33043297,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-13T13:14:54.681Z","status":"online","status_checked_at":"2026-05-14T02:00:06.663Z","response_time":57,"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":["nodejs","resp"],"created_at":"2025-10-29T04:51:25.591Z","updated_at":"2026-05-14T21:06:25.237Z","avatar_url":"https://github.com/DavidCai1111.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# resper\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)\n[![Build Status](https://travis-ci.org/DavidCai1993/resper.svg?branch=master)](https://travis-ci.org/DavidCai1993/resper)\n[![Coverage Status](https://coveralls.io/repos/github/DavidCai1993/resper/badge.svg?branch=master)](https://coveralls.io/github/DavidCai1993/resper?branch=master)\n\nA parser for RESP (REdis Serialization Protocol).\n\n## Install\n\n```sh\nnpm install resper\n```\n\n## Usage\n\n```js\n'use strict'\nconst Resper = require('resper')\n\nlet resper = new Resper()\n\nresper\n  .on('error', console.error)\n  .on('data', console.log)\n  .on('drain', () =\u003e {\n    // ...\n    console.log('drain')\n  })\n\nresper.write(Resper.encodeInt(998))\nresper.end(Resper.encodeArray([\n  Resper.encodeInt(1),\n  Resper.encodeString('str'),\n  [\n    Resper.encodeNullArray(),\n    Resper.encodeError(new Error('heheda'))\n  ]\n]))\n```\n\n## API\n\n### Class: Resper\n\n### Class Method: encodeString(str)\n\nEncode `str` to RESP buffer.\n\n### Class Method: encodeError(err)\n\nEncode `err` to RESP buffer.\n\n### Class Method: encodeInt(int)\n\nEncode `int` to RESP buffer.\n\n### Class Method: encodeBulkString(bulk)\n\nEncode `bluk` to RESP buffer, `bluk` could be a String or a Buffer.\n\n### Class Method: encodeNull()\n\nGet the RESP Null buffer.\n\n### Class Method: encodeNullArray()\n\nGet the RESP NullArray buffer.\n\n### Class Method: encodeArray(arr)\n\nEncode `arr` to RESP buffer, each element in `arr` should be an instance of buffer.\n\n### Class Method: encodeRequestArray(requestArr)\n\nEncode `requestArr` to RESP request buffer, each element in `requestArr` should be a string.\n\n```\nresper.encodeRequestArray(['LLEN', 'mylist'])\n```\n\n### Class Method: decode(encodedBuffer)\n\nDecode RESP buffer to real value. The return value is array which first element is the decode result, and the second value is the index after first `CRLF`.\n\n```js\nResper.decode(Resper.encodeInt(998))[0] // 998\n```\n\n### resper.write(buffer)\n\nWrite `buffer` to the resper, resper will emit `data` event when after it parsed the `buffer`.\n\n### resper.end([buffer])\n\nWhen no more data will be writen, you can call this method, and the instance of `Resper` will emit `finish` event.\n\n#### Event: data\n\n`function (parsedData) { }`\n\nEmitted when the instance of `Resper` parsed the written RESP buffer.\n\n#### Event: error\n\n`function (error) { }`\n\nEmitted when an error was occurred.\n\n#### Event: drain\n\n`function () { }`\n\nEmitted when no more data in instance's inner buffer.\n\n#### Event: finish\n\n`function () { }`\n\nEmitted when the `resper.end` was called.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidcai1111%2Fresper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavidcai1111%2Fresper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidcai1111%2Fresper/lists"}