{"name":"parse-columns","version":"4.0.0","description":"Parse text columns, like the output of Unix commands","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/parse-columns.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":{"types":"./index.d.ts","default":"./index.js"},"sideEffects":false,"engines":{"node":">=20"},"scripts":{"test":"xo && ava && tsd"},"keywords":["parse","parser","columns","column","row","text","string","unix","command","output","csv","shell","sh","term","table"],"dependencies":{"escape-string-regexp":"^5.0.0","execall":"^3.0.0","split-at":"^3.0.0"},"devDependencies":{"ava":"^6.4.1","tsd":"^0.33.0","xo":"^1.2.2"},"_id":"parse-columns@4.0.0","gitHead":"682a2057c903e88cfc29a2a46962a73f35390b41","types":"./index.d.ts","bugs":{"url":"https://github.com/sindresorhus/parse-columns/issues"},"homepage":"https://github.com/sindresorhus/parse-columns#readme","_nodeVersion":"20.19.1","_npmVersion":"10.9.2","dist":{"integrity":"sha512-gDbL5+8ozVxQAqhKWrRcpdZeJJc1N01jIcbJpRb/ajH3TqiJTM+CpE2KhUt1IzIUXwpsYuAL0eNDCh9BnOG4QQ==","shasum":"2cad666161dbab15d8a7a722ffc26135b74db575","tarball":"http://registry-npm.ywwl.com/parse-columns/download/parse-columns-4.0.0.tgz","fileCount":5,"unpackedSize":9215,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCn3h3fLt8B2ZowLZOEoaVu8rhwT8+smrme4RCSEMJJNQIgczxbpzh3FnuIJ+w5BxfAKVi5lCxPWmoSWOK7mXxceGA="}],"size":3866,"noattachment":false,"key":"/parse-columns/-/parse-columns-4.0.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/parse-columns_4.0.0_1757430815324_0.7633240715478955"},"_hasShrinkwrap":false,"readme":"# parse-columns\n\n> Parse text columns, like the output of Unix commands\n\n## Install\n\n```sh\nnpm install parse-columns\n```\n\n## Usage\n\n```\n$ df -kP\nFilesystem 1024-blocks      Used Available Capacity  Mounted on\n/dev/disk1   487350400 467871060  19223340    97%    /\ndevfs              185       185         0   100%    /dev\nmap -hosts           0         0         0   100%    /net\n```\n\n```js\nimport {promisify} from 'node:util';\nimport childProcess from 'node:child_process';\nimport parseColumns from 'parse-columns';\n\nconst execFileP = promisify(childProcess.execFile);\n\nconst {stdout} = await execFileP('df', ['-kP']);\n\nconsole.log(parseColumns(stdout, {\n\ttransform: (item, header, columnIndex) => {\n\t\t// Coerce elements in column index 1 to 3 to a number\n\t\tif (columnIndex >= 1 && columnIndex <= 3) {\n\t\t\treturn Number(item);\n\t\t}\n\n\t\treturn item;\n\t}\n}));\n/*\n[\n\t{\n\t\tFilesystem: '/dev/disk1',\n\t\t'1024-blocks': 487350400,\n\t\tUsed: 467528020,\n\t\tAvailable: 19566380,\n\t\tCapacity: '96%',\n\t\t'Mounted on': '/'\n\t},\n\t…\n]\n*/\n```\n\n## API\n\n### parseColumns(textColumns, options?)\n\n#### textColumns\n\nType: `string`\n\nThe text columns to parse.\n\n#### options\n\nType: `object`\n\n##### separator\n\nType: `string | RegExp`\nDefault: `' '`\n\nSeparator to split columns on.\n\n- `string`: Single character separator (default behavior)\n- `RegExp`: Regular expression pattern for flexible matching\n\n```js\n// Default space separator\nparseColumns(data);\n\n// Tab separator  \nparseColumns(data, {separator: '\\t'});\n\n// Any whitespace (spaces, tabs, etc.)\nparseColumns(data, {separator: /\\s+/});\n\n// Either spaces or tabs  \nparseColumns(data, {separator: /[ \\t]/});\n```\n\n##### headers\n\nType: `string[]`\n\nHeaders to use instead of the existing ones.\n\n##### transform\n\nType: `Function`\n\nTransform elements.\n\nUseful for being able to cleanup or change the type of elements.\n\nThe supplied function gets the following arguments and is expected to return the element:\n\n- `element` *(string)*\n- `header` *(string)*\n- `columnIndex` *(number)*\n- `rowIndex` *(number)*\n\n## Related\n\n- [parse-columns-cli](https://github.com/sindresorhus/parse-columns-cli) - CLI for this module\n","publish_time":1757430815494,"_cnpm_publish_time":1757430815494,"dist-tags":{"latest":"4.0.0"}}