{"_id":"args-tokenizer","_rev":"3-0f642958707c3a6142855357d440069e","name":"args-tokenizer","dist-tags":{"latest":"0.3.0"},"versions":{"0.1.0":{"name":"args-tokenizer","version":"0.1.0","keywords":[],"author":{"name":"Bogdan Chadkin","email":"opensource@trysound.io"},"license":"MIT","_id":"args-tokenizer@0.1.0","maintainers":[{"name":"trysound","email":"opensource@trysound.io"}],"dist":{"shasum":"e52d46f233961d25ca229fc685a32407444230cc","tarball":"https://registry.npmjs.org/args-tokenizer/-/args-tokenizer-0.1.0.tgz","fileCount":5,"integrity":"sha512-9yDBBeg+2WTmWXJMfdO3efV+VknAL2UlxS7Yxt5e/aYjMW3yDiQhGPuFg+wEuTGN3JxsRL/wjCg0qBDFklyXjw==","signatures":[{"sig":"MEQCIESyqLiPnunh7bO65O9ACTzRid62HL0kDaOUo5n3s/WwAiBNC9sl6ezR3K0OJ9Q3wT+0cEDRnTzHTfn0Ltd9yEaUPQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5199},"type":"module","_from":"file:args-tokenizer-0.1.0.tgz","exports":{".":{"types":"./dist/args-tokenizer.d.ts","import":"./dist/args-tokenizer.js"},"./package.json":"./package.json"},"scripts":{"test":"vitest run","build":"rm -rf dist && esbuild src/args-tokenizer.ts --outdir=dist --bundle --format=esm && tsc && rm dist/*.test.*"},"_npmUser":{"name":"trysound","email":"opensource@trysound.io"},"_resolved":"/private/var/folders/4q/phc2tfv56wxg0819j35vkdt00000gn/T/490b0b4f8fc434b468035038eb1e6ff5/args-tokenizer-0.1.0.tgz","_integrity":"sha512-9yDBBeg+2WTmWXJMfdO3efV+VknAL2UlxS7Yxt5e/aYjMW3yDiQhGPuFg+wEuTGN3JxsRL/wjCg0qBDFklyXjw==","_npmVersion":"10.8.2","description":"Tokenize a shell string into argv array","directories":{},"_nodeVersion":"20.18.0","_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.19.2","vitest":"^2.1.8","esbuild":"^0.24.0","prettier":"^3.4.2","typescript":"^5.7.2","@types/node":"^22.10.2"},"_npmOperationalInternal":{"tmp":"tmp/args-tokenizer_0.1.0_1734711034133_0.9431290093473872","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"args-tokenizer","version":"0.2.0","keywords":[],"author":{"name":"Bogdan Chadkin","email":"opensource@trysound.io"},"license":"MIT","_id":"args-tokenizer@0.2.0","maintainers":[{"name":"trysound","email":"opensource@trysound.io"}],"dist":{"shasum":"cd52203c984621f8fd922c469681c508e71a1969","tarball":"https://registry.npmjs.org/args-tokenizer/-/args-tokenizer-0.2.0.tgz","fileCount":5,"integrity":"sha512-R4HL7zpFdNpaNnqvtkHhFwzQhEFWhmYz4dC6W0CEzjxu4OBjobsrpOoBiiW5UINlzVQuU0inVPRSXRRT9bKV2Q==","signatures":[{"sig":"MEYCIQClcxRPbcTFE7f9VmJns1X6Lf/vH0B5VS/0bRr0x+un7QIhAKU41xBvsu2gJkIthoUozwYO68A3bTVUQyVsr4e4eHgY","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5240},"type":"module","_from":"file:args-tokenizer-0.2.0.tgz","types":"./dist/args-tokenizer.d.ts","exports":{".":{"types":"./dist/args-tokenizer.d.ts","import":"./dist/args-tokenizer.js"},"./package.json":"./package.json"},"scripts":{"test":"vitest run","build":"rm -rf dist && esbuild src/args-tokenizer.ts --outdir=dist --bundle --format=esm && tsc && rm dist/*.test.*"},"_npmUser":{"name":"trysound","email":"opensource@trysound.io"},"_resolved":"/private/var/folders/4q/phc2tfv56wxg0819j35vkdt00000gn/T/a3df9c5f0464a803e2c2f621c70d3106/args-tokenizer-0.2.0.tgz","_integrity":"sha512-R4HL7zpFdNpaNnqvtkHhFwzQhEFWhmYz4dC6W0CEzjxu4OBjobsrpOoBiiW5UINlzVQuU0inVPRSXRRT9bKV2Q==","_npmVersion":"10.8.2","description":"Tokenize a shell string into argv array","directories":{},"_nodeVersion":"20.18.0","_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.19.2","vitest":"^2.1.8","esbuild":"^0.24.0","prettier":"^3.4.2","typescript":"^5.7.2","@types/node":"^22.10.2"},"_npmOperationalInternal":{"tmp":"tmp/args-tokenizer_0.2.0_1734757578238_0.692108585162619","host":"s3://npm-registry-packages-npm-production"}},"0.2.1":{"name":"args-tokenizer","version":"0.2.1","keywords":[],"author":{"name":"Bogdan Chadkin","email":"opensource@trysound.io"},"license":"MIT","_id":"args-tokenizer@0.2.1","maintainers":[{"name":"trysound","email":"opensource@trysound.io"}],"dist":{"shasum":"6eaa5dc2f6c78f785ae72f56dd978b9daa5d7ccb","tarball":"https://registry.npmjs.org/args-tokenizer/-/args-tokenizer-0.2.1.tgz","fileCount":5,"integrity":"sha512-1hd00qLJxfSYLirIJherrIBbLkpYlLttu2lxQvVJWY+ohZgEZ2Sf9Rnsx5C1kQNo22eb9tV8/l8TWpjYKtwNIw==","signatures":[{"sig":"MEUCIHaPWL97w4121llCE0NCLSOuOQgJMv5Rs8vkRauaFz9AAiEAyM9iNw0WCieKuxtw8LVi+yPCpCVe6LOOyumOt4oEQW4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":5285},"type":"module","_from":"file:args-tokenizer-0.2.1.tgz","types":"./dist/args-tokenizer.d.ts","exports":{".":{"types":"./dist/args-tokenizer.d.ts","import":"./dist/args-tokenizer.js","default":"./dist/args-tokenizer.js"},"./package.json":"./package.json"},"scripts":{"test":"vitest run","build":"rm -rf dist && esbuild src/args-tokenizer.ts --outdir=dist --bundle --format=esm && tsc && rm dist/*.test.*"},"_npmUser":{"name":"trysound","email":"opensource@trysound.io"},"_resolved":"/private/var/folders/4q/phc2tfv56wxg0819j35vkdt00000gn/T/a387e5ba49fb0e6e09db1f3465a4bb63/args-tokenizer-0.2.1.tgz","_integrity":"sha512-1hd00qLJxfSYLirIJherrIBbLkpYlLttu2lxQvVJWY+ohZgEZ2Sf9Rnsx5C1kQNo22eb9tV8/l8TWpjYKtwNIw==","_npmVersion":"10.8.2","description":"Tokenize a shell string into argv array","directories":{},"_nodeVersion":"20.18.0","_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.19.2","vitest":"^2.1.8","esbuild":"^0.24.0","prettier":"^3.4.2","typescript":"^5.7.2","@types/node":"^22.10.2"},"_npmOperationalInternal":{"tmp":"tmp/args-tokenizer_0.2.1_1734826926873_0.1311128113438076","host":"s3://npm-registry-packages-npm-production"}},"0.3.0":{"name":"args-tokenizer","version":"0.3.0","description":"Tokenize a shell string into argv array","type":"module","types":"./dist/args-tokenizer.d.ts","exports":{".":{"types":"./dist/args-tokenizer.d.ts","import":"./dist/args-tokenizer.js","default":"./dist/args-tokenizer.js"},"./package.json":"./package.json"},"devDependencies":{"@types/node":"^22.10.2","esbuild":"^0.24.0","prettier":"^3.4.2","tsx":"^4.19.2","typescript":"^5.7.2","vitest":"^2.1.8"},"repository":{"type":"git","url":"git+https://github.com/TrySound/args-tokenizer.git"},"keywords":["args","commands","shell","tokenizer","parser","tinyexec","child_process","spawn"],"author":{"name":"Bogdan Chadkin","email":"opensource@trysound.io"},"license":"MIT","scripts":{"build":"rm -rf dist && esbuild src/args-tokenizer.ts --outdir=dist --bundle --format=esm && tsc && rm dist/*.test.*","test":"vitest run"},"_id":"args-tokenizer@0.3.0","bugs":{"url":"https://github.com/TrySound/args-tokenizer/issues"},"homepage":"https://github.com/TrySound/args-tokenizer#readme","_integrity":"sha512-xXAd7G2Mll5W8uo37GETpQ2VrE84M181Z7ugHFGQnJZ50M2mbOv0osSZ9VsSgPfJQ+LVG0prSi0th+ELMsno7Q==","_resolved":"/private/var/folders/4q/phc2tfv56wxg0819j35vkdt00000gn/T/16b234110f3b8586769ddfebd817825e/args-tokenizer-0.3.0.tgz","_from":"file:args-tokenizer-0.3.0.tgz","_nodeVersion":"20.18.0","_npmVersion":"10.8.2","dist":{"integrity":"sha512-xXAd7G2Mll5W8uo37GETpQ2VrE84M181Z7ugHFGQnJZ50M2mbOv0osSZ9VsSgPfJQ+LVG0prSi0th+ELMsno7Q==","shasum":"4ec0d6af4cd9d78f5992735ebb5ddd2b4426a75a","tarball":"https://registry.npmjs.org/args-tokenizer/-/args-tokenizer-0.3.0.tgz","fileCount":5,"unpackedSize":6176,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEmuP8HLx5Irf7WhDP9Yd+zqRxCrzTU/Vfd4SkR0w7Z3AiB+t2LHYPTr4Cj/V8W1Uu5ghADYDiHJZKAln2Y5Sz7dTA=="}]},"_npmUser":{"name":"trysound","email":"opensource@trysound.io"},"directories":{},"maintainers":[{"name":"trysound","email":"opensource@trysound.io"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/args-tokenizer_0.3.0_1735479039726_0.13998931891200472"},"_hasShrinkwrap":false}},"time":{"created":"2024-12-20T16:10:34.132Z","modified":"2024-12-29T13:30:40.110Z","0.1.0":"2024-12-20T16:10:34.364Z","0.2.0":"2024-12-21T05:06:18.432Z","0.2.1":"2024-12-22T00:22:07.099Z","0.3.0":"2024-12-29T13:30:39.937Z"},"author":{"name":"Bogdan Chadkin","email":"opensource@trysound.io"},"license":"MIT","keywords":["args","commands","shell","tokenizer","parser","tinyexec","child_process","spawn"],"description":"Tokenize a shell string into argv array","maintainers":[{"name":"trysound","email":"opensource@trysound.io"}],"readme":"# args-tokenizer\n\n`args-tokenizer` is a lightweight JavaScript library for parsing shell commands with arguments into an `argv` array. This makes it easy to work with command-line tools and libraries that expect an array format for arguments, such as [`tinyexec`](https://github.com/tinylibs/tinyexec).\n\n## Features\n\n- Simple and intuitive API.\n- Handles quoted strings and escapes correctly.\n- Supports multiline input.\n- Ideal for parsing human-readable shell commands, especially `curl`-style commands.\n\n---\n\n<img src=\"https://raw.githubusercontent.com/webstudio-is/webstudio-design/refs/heads/main/brand/logo-icon-color.svg\" alt=\"\" width=\"28\" height=\"21\" />  Made at <b><a href=\"https://webstudio.is\">Webstudio</a></b>, open source website builder.\n\n---\n\n## Installation\n\nInstall `args-tokenizer`:\n\n```bash\nnpm install args-tokenizer\n```\n\n## Usage\n\nHere's how you can use `args-tokenizer` to parse shell commands:\n\n```js\nimport { tokenizeArgs } from \"args-tokenizer\";\n\nconst args = tokenizeArgs(`ls -la \"./src\"`);\nconsole.log(args); // [\"ls\", \"-la\", \"./src\"]\n```\n\n### Multiline Input Support\n\n`args-tokenizer` also supports multiline commands, such as:\n\n```js\nconst args = tokenizeArgs(`\n  curl \\\\\n    -X POST \\\\\n    \"https://my-url.com\"\n`);\nconsole.log(args); // [\"curl\", \"-X\", \"POST\", \"https://my-url.com\"]\n```\n\n### Example with `tinyexec`\n\nOne common use case is passing more human-readable commands into the [`tinyexec`](https://github.com/tinylibs/tinyexec) library:\n\n```js\nimport { tokenizeArgs } from \"args-tokenizer\";\nimport { x } from \"tinyexec\";\n\nconst [command, ...args] = tokenizeArgs(\"ls -la\");\nconst result = await x(command, args);\nconsole.log(result.stdout);\n```\n\n## API\n\n### `tokenizeArgs(command: string, options: Options): string[]`\n\nParses a shell command string into an array of arguments. Properly handles:\n\n- Quoted strings (e.g., `'\"./path/to/file\"'`).\n- Escaped characters (e.g., `\\\"`).\n- Multiline commands (e.g., lines ending with `\\\\`).\n\n### Options\n\n- `loose`: If `true`, the tokenizer will not throw an error when closing quotes are missing. Default is `false`.\n\n#### Examples\n\n```js\n// Without loose option (default behavior)\n// This will throw an error due to the missing closing quote\ntokenizeArgs('command \"arg1 arg2');\n\n// With loose option enabled\nconst args = tokenizeArgs('command \"arg1 arg2', { loose: true });\n// ['command', 'arg1 arg2']\n```\n\n## License\n\nThis project is licensed under the [MIT License](./LICENSE).\n\n## Contributing\n\nContributions are welcome! Feel free to open issues or submit pull requests to improve the library.\n","readmeFilename":"README.md","homepage":"https://github.com/TrySound/args-tokenizer#readme","repository":{"type":"git","url":"git+https://github.com/TrySound/args-tokenizer.git"},"bugs":{"url":"https://github.com/TrySound/args-tokenizer/issues"}}