{"library":"nanotar","title":"nanotar Tar Utilities","description":"nanotar is a compact and efficient utility library designed for creating and parsing Tar archives across various JavaScript environments, including Node.js, browsers, and edge runtimes. It prioritizes performance and a minimal footprint, making it suitable for resource-constrained applications. The current stable version is 0.3.0, with releases occurring as needed for enhancements and fixes, as demonstrated by recent updates to 0.2.0 and 0.3.0. A key differentiator is its universal JavaScript runtime compatibility and the inclusion of TypeScript types, ensuring robust development. It offers core functionalities for both generating `.tar` files and extracting their contents, supporting common Tar specifications. Unlike some alternatives, it aims to be dependency-free and focuses purely on the Tar format without additional compression (like gzip) built-in, allowing users to combine it with other compression libraries as needed.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install nanotar"],"cli":null},"imports":["import { createTar } from 'nanotar'","import { parseTar } from 'nanotar'","import type { TarFileItem } from 'nanotar'"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { createTar, parseTar } from 'nanotar';\n\nasync function main() {\n  const files = [\n    { name: 'file1.txt', data: new TextEncoder().encode('Hello, nanotar!') },\n    { name: 'folder/file2.json', data: new TextEncoder().encode('{\"key\": \"value\"}') }\n  ];\n\n  // Create a tar archive\n  const tarBuffer = await createTar(files);\n  console.log('Created tar archive with size:', tarBuffer.byteLength, 'bytes');\n\n  // Simulate writing to disk and reading back (e.g., using Node.js fs)\n  // For browser/edge, this would be a Blob or similar.\n  // Example: fs.writeFileSync('archive.tar', Buffer.from(tarBuffer));\n  // const readTarBuffer = new Uint8Array(fs.readFileSync('archive.tar'));\n\n  // Parse the tar archive\n  const parsedItems = [];\n  for await (const item of parseTar(tarBuffer)) {\n    parsedItems.push(item);\n    console.log(`Parsed item: ${item.name} (type: ${item.type}, size: ${item.size})`);\n    if (item.data) {\n      console.log('  Content:', new TextDecoder().decode(item.data));\n    }\n  }\n\n  console.log('Total items parsed:', parsedItems.length);\n}\n\nmain().catch(console.error);","lang":"typescript","description":"Demonstrates how to create a Tar archive from an array of files and then parse its contents back into individual items, showing basic file and folder handling.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}