Parses INI files to AST with great performance.
- Extremely fast.
- Offers ES, CJS and UMD modules.
- Includes TypeScript types.
- No dependencies.
- Small size - 4.47 kB minified, 1.95 kB gzipped, 1.79 kB brotlied.
This is currently work in progress.
import { parseText } from 'fast-ini-parser'
const ini = `
scope = global
[database]
user = dbuser
password = dbpassword
database = use_this_database
`
const ast = parseText(ini)
// Result:
//
// {
// "type": "File",
// "body": [...]
// }
See also the TypeScript types.
Parses a text
string with INI file contents to AST.
Parses an array of tokens converted from a text
string with INI file contents to AST.
Converts a text
string with INI file contents to an array of tokens.
Returns a generator yielding tokens from a text
string with INI file contents.
tokens
: if set totrue
, a propertytokes
pointing to an array of tokens will be attached to the AST root (File)comments
: if set totrue
, comments will be included in the extrated tokenswhitespace
: if set totrue
, whitespace will be included in the extrated tokenslocations
: if set totrue
, node locations (line, column) will be included in the ASTranges
: if set totrue
, node ranges (offset, length) will be included in the ASTraw
: if set totrue
, raw names will be included in the AST (names are converted to lower-case)sourceFile
: source file name to use in error messages ("ini" by default)onCreateNode
: a function to be called whenever an AST node has been createdonCreateToken
: a function to be called whenever a token has been extracted
onCreateNode: (node: object): void
onCreateToken: (token: object): void