{"library":"statsd-parser","title":"Streaming StatsD Protocol Parser","type":"library","description":"statsd-parser is a Node.js library designed for streaming parsing of the StatsD protocol. It provides both a low-level `parser()` object for direct event-driven parsing and a higher-level `createStream()` API for integrating with Node.js streams, allowing for efficient processing of StatsD metrics from various input sources like network streams or files. The library was last updated in September 2013, with its current and only published version being 0.0.4. Due to its age and lack of maintenance for over a decade, it is not recommended for new projects or existing systems requiring modern Node.js compatibility, security updates, or active support. Key differentiators at the time of its release included its focus on streaming capabilities and event-driven parsing, which was beneficial for handling high-volume metric data efficiently in a Node.js environment.","language":"javascript","status":"abandoned","last_verified":"Thu Apr 23","install":{"commands":["npm install statsd-parser"],"cli":null},"imports":["const statsd_parser = require('statsd-parser');","const statsd_parser = require('statsd-parser');\nconst parser = statsd_parser.parser();","const statsd_parser = require('statsd-parser');\nconst stream = statsd_parser.createStream(options);"],"auth":{"required":false,"env_vars":[]},"links":{"homepage":null,"github":"https://github.com/dscape/statsd-parser","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/statsd-parser","openapi_spec":null,"status_page":null,"smithery":null},"quickstart":{"code":"const statsd_parser = require(\"statsd-parser\");\nconst fs = require('fs');\nconst { Readable } = require('stream');\n\n// Basic parser usage\nconst parser = statsd_parser.parser();\n\nparser.onerror = function (e) {\n  console.error(\"Parser Error:\", e.message);\n};\n\nparser.onstat = function (txt, obj) {\n  console.log(`Parsed stat: ${txt} ->`, obj);\n};\n\nparser.onend = function () {\n  console.log(\"Basic parser stream finished.\\n\");\n};\n\nconsole.log(\"--- Using basic parser ---\");\nparser.write('foo.bar:1|c\\nbaz.qux:2.5|g\\n');\nparser.write('timer.event:100|ms\\n');\nparser.close(); // Signal end of input\n\n// Stream usage with a Readable stream\nconst stream = statsd_parser.createStream();\n\nstream.on(\"error\", function (e) {\n  console.error(\"Stream Error:\", e.message); \n  // In a real application, you might need to handle this more robustly,\n  // like clearing the parser error and resuming if it's an internal parser error.\n  this._parser.error = null;\n  this._parser.resume();\n});\n\nstream.on(\"stat\", function (txt, obj) {\n  console.log(`Streamed stat: ${txt} ->`, obj);\n});\n\nstream.on(\"end\", () => {\n  console.log(\"Stream parser finished.\");\n});\n\nconsole.log(\"--- Using stream parser ---\");\nconst inputData = 'metric.one:10|c\\nmetric.two:200|ms\\nmetric.three:3.14|g\\n';\nconst readableStream = Readable.from(inputData);\n\nreadableStream.pipe(stream);\n","lang":"javascript","description":"This quickstart demonstrates both the direct `parser` API and the `createStream` API for processing StatsD metric strings. It shows error handling and how to receive parsed metric objects.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}