untable
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

untable Travis CI Build Status

Create an object from a string table of keys and values.

NPM Badge

Install

npm install untable

Usage

const untable = require("untable");

untable(`
Availability                : 3
Caption                     : Internal Battery
Chemistry                   : 6
PowerManagementCapabilities : {1}
PowerManagementSupported    : False
`, { allowNumbers: true, allowBooleans: true, allowArrays: true });
/*
{
	Availability: 3,
	Caption: "Internal Battery",
	Chemistry: 6,
	PowerManagementCapabilities: [ 1 ],
	PowerManagementSupported: false
}
*/

API

untable(input, options?)

input

Type: string

The input string table to parse.

options

Type: object

separator

Type: string
Default: :

The separator between table items.

allowNumbers

Type: boolean
Default: false

Allow parsing values as numbers.

allowArrays

Type: boolean
Default: false

Allow parsing values as arrays. Matches strings with commas and strings surrounded by [] or {}.

allowBooleans

Type: boolean
Default: false

Allow parsing values these values as booleans:

"y", "yes", "true", true, "n", "no", "false", false, "on", "off"

Package Sidebar

Install

npm i untable

Weekly Downloads

2

Version

1.0.0

License

MIT

Unpacked Size

6.02 kB

Total Files

6

Last publish

Collaborators

  • richienb