{"library":"msgpackr-extract","title":"MessagePack Native String Extractor for Node.js","description":"msgpackr-extract is a Node.js native addon designed for highly optimized, C-level extraction of strings from MessagePack binary data. It acts as an optional native acceleration component for the `msgpackr` package, significantly speeding up string deserialization. The current stable version is 3.0.3, with releases often coinciding with updates to its parent project, `msgpackr`, or new Node.js ABI versions. Its key differentiator is its ability to perform partial MessagePack parsing to quickly locate and extract string data, especially leveraging V8's Latin-1 string optimizations by returning contiguous multi-string buffers. This low-level approach offers superior performance for applications heavily processing MessagePack data streams in Node.js environments. It's not a standalone MessagePack parser but a specialized utility for improving string extraction performance.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install msgpackr-extract"],"cli":null},"imports":["import { extractStrings } from 'msgpackr-extract';","const extractStrings = require('msgpackr-extract').extractStrings;"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { pack } from 'msgpackr';\nimport { extractStrings } from 'msgpackr-extract';\n\nasync function runExtraction() {\n  const dataToPack = {\n    name: 'Alice',\n    city: 'New York',\n    country: 'USA',\n    tags: ['developer', 'typescript', 'nodejs'],\n    description: 'A long string that might contain some non-latin characters like é or ö for testing purposes.'\n  };\n\n  // Pack the data into a MessagePack buffer\n  const packedBuffer = pack(dataToPack);\n  console.log('Original packed buffer length:', packedBuffer.length);\n\n  // Extract strings from the entire buffer. start and end are optional.\n  const extracted = extractStrings(packedBuffer, 0, packedBuffer.length);\n\n  console.log('Extracted strings:');\n  extracted.forEach(str => console.log(`- ${str}`));\n\n  // Example with a subset of the buffer (if you knew string offsets)\n  // This module is usually used internally by msgpackr, but this shows direct usage.\n  const partialExtracted = extractStrings(packedBuffer, 20, 50); // Arbitrary range\n  if (partialExtracted.length > 0) {\n    console.log('\\nPartial extracted strings (from offset 20 to 50):');\n    partialExtracted.forEach(str => console.log(`- ${str}`));\n  } else {\n    console.log('\\nNo strings found in the partial range (offset 20 to 50).');\n  }\n}\n\nrunExtraction().catch(console.error);\n","lang":"typescript","description":"This example demonstrates how to use `msgpackr-extract` to extract strings from a MessagePack-encoded buffer. It first uses `msgpackr` to create a sample buffer, then calls `extractStrings` to get all strings within a specified range, highlighting its core functionality.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}