{"id":16349514,"url":"https://github.com/jednano/ini-parser","last_synced_at":"2025-03-23T00:33:27.549Z","repository":{"id":49727470,"uuid":"108021273","full_name":"jednano/ini-parser","owner":"jednano","description":"A highly forgiving and configurable INI parser for the informal INI file format.","archived":false,"fork":false,"pushed_at":"2023-01-04T21:58:20.000Z","size":540,"stargazers_count":7,"open_issues_count":9,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-18T04:14:11.078Z","etag":null,"topics":["browser","configurable","format","ini","parse","parser","read","write"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jednano.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-23T18:17:55.000Z","updated_at":"2023-12-29T22:24:53.000Z","dependencies_parsed_at":"2023-02-02T21:16:38.665Z","dependency_job_id":null,"html_url":"https://github.com/jednano/ini-parser","commit_stats":null,"previous_names":["jedmao/ini-parser"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jednano%2Fini-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jednano%2Fini-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jednano%2Fini-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jednano%2Fini-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jednano","download_url":"https://codeload.github.com/jednano/ini-parser/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221841534,"owners_count":16890019,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["browser","configurable","format","ini","parse","parser","read","write"],"created_at":"2024-10-11T01:00:07.235Z","updated_at":"2024-10-28T14:38:46.893Z","avatar_url":"https://github.com/jednano.png","language":"TypeScript","readme":"# @jedmao/ini-parser\n\n[![NPM version](http://img.shields.io/npm/v/@jedmao/ini-parser.svg?style=flat)](https://www.npmjs.com/package/@jedmao/ini-parser)\n[![npm license](http://img.shields.io/npm/l/@jedmao/ini-parser.svg?style=flat-square)](https://www.npmjs.com/package/@jedmao/ini-parser)\n[![Travis Build Status](https://img.shields.io/travis/jedmao/ini-parser.svg)](https://travis-ci.org/jedmao/ini-parser)\n[![codecov](https://codecov.io/gh/jedmao/ini-parser/branch/master/graph/badge.svg)](https://codecov.io/gh/jedmao/ini-parser)\n[![Dependency Status](https://gemnasium.com/badges/github.com/jedmao/ini-parser.svg)](https://gemnasium.com/github.com/jedmao/ini-parser)\n\n[![npm](https://nodei.co/npm/@jedmao/ini-parser.svg?downloads=true)](https://nodei.co/npm/@jedmao/ini-parser/)\n\nA highly forgiving and configurable INI parser for the [informal INI file format](https://en.wikipedia.org/wiki/INI_file).\n\n## Introduction\n\nThe INI file format is informal. Different parsers behave differently, in that they support different features. This parser aims to be a bit more flexible and [configurable](#options) to suite your needs, whatever they may be. Also, it assumes INI files out there in the wild could have some pretty crazy things in them. This parser does its best to understand whatever crazy you throw at it.\n\nNo dependencies on Node.js here, so you should be able to use it in the browser.\n\n## Usage\n\n```ini\n; example.ini\n\na=b\n\n[c]\nd:e\n\n[c]\nf=g\n```\n\n```ts\nimport { readFileSync } from \"fs\";\nimport Parser from \"@jedmao/ini-parser\";\n\nconst { configure, parse } = new Parser(/* config */);\n\nparse(fs.readFileSync(\"./example.ini\"));\n```\n\nSee [`Parser#parse`](#parserparse-contents-string-) API.\n\n### Result\n\n```json\n[\n  {\n    \"a\": \"b\"\n  },\n  [\n    [\n      \"c\",\n      {\n        \"d\": \"e\"\n      }\n    ],\n    [\n      \"c\",\n      {\n        \"f\": \"g\"\n      }\n    ]\n  ]\n]\n```\n\n## API\n\n```ts\nimport Parser from \"@jedmao/ini-parser\";\n```\n\n### `new Parser( options?: ParseOptions )`\n\nClass constructor. Accepts [`ParseOptions`](#interface-parseoptions) for initial configuration.\n\n### `Parser#configure( options?: ParseOptions )`\n\nSets configuration options, preserving existing configuration and overriding only the new keys you provide.\n\n### `Parser#resetConfiguration()`\n\nResets configuration to default settings as if you created a `new Parser()`.\n\n### `Parser#parse( contents?: string )`\n\nParses INI file contents as a string. The result will be an array:\n\n- Index `0` will have any/all root properties.\n- Index `1` will have an array of any/all sections that follow.\n\n_Note: repeated sections will also be repeated in the array._\n\nSee [`Usage`](#usage) for an example.\n\n### `interface ParseOptions`\n\n```ts\ninterface ParseOptions {\n  /**\n   * Indicates accepted comment chars. Only works if you specify single-char\n   * comment values in RegExp form. A setting of `false` turns off comments\n   * completely, treating comment chars as normal string values.\n   * @default {RegExp} /[#;]/\n   */\n  comment?: RegExp | false;\n  /**\n   * Accepts comment chars in a property key or value. If a space\n   * follows the comment char, it is considered an actual comment.\n   * Example: \"#k;=#v; #z\" -\u003e { \"#k;\": \"#v;\" }\n   * @default {false} false\n   */\n  isCommentCharInProp?: boolean;\n  /**\n   * Indicates accepted delimiter chars. Only works if you specify\n   * single-char delimiter values in RegExp form.\n   * @default {RegExp} /[=:]/\n   */\n  delimiter?: RegExp;\n  /**\n   * Indicates accepted newline sequences in the form of a RegExp.\n   * @default {RegExp} /\\r?\\n/\n   */\n  newline?: RegExp;\n  /**\n   * By default, attempts to parse property values with `JSON.parse`.\n   * If unsuccessful, returns property value as a string. You may also\n   * provide your own resolve function here for custom property value\n   * resolution.\n   * @default {true} true\n   */\n  resolve?: boolean | ResolveCallback;\n}\n```\n\n### `interface ResolveCallback`\n\n```ts\ninterface ResolveCallback {\n  (value: string, key?: string, fallback?: typeof parseValue): any;\n}\n```\n\n### `parseValue( value: string )`\n\nAttempts to parse a string value with `JSON.parse`. If unsuccessful, returns input string untouched.\n\n## Testing\n\nRun the following command:\n\n```\n$ npm test\n```\n\nThis will build scripts, run tests and generate a code coverage report. Anything less than 100% coverage will throw an error.\n\n### Watching\n\nFor much faster development cycles, run the following commands in 2 separate processes:\n\n```\nnpm run build:watch\n```\n\nCompiles TypeScript source into the `./dist` folder and watches for changes.\n\n```\n$ npm run watch\n```\n\nRuns the tests in the `./dist` folder and watches for changes.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjednano%2Fini-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjednano%2Fini-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjednano%2Fini-parser/lists"}