
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
config-ini-parser
Advanced tools
JavaScript Configuration file(.ini) content parser, similar to python ConfigParser without I/O operations. Only one JavaScript file without any other dependencies. Compatible with NodeJS, TypeScript and Browsers.
Description JavaScript Configuration file(.ini) content parser, similar to python ConfigParser without I/O operations. Only one JavaScript file without any other dependencies. Compatible with NodeJS, TypeScript and Browsers.
Author Erxin(Edwin) Shang
$ npm install config-ini-parser
or
$ bower install config-ini
optionName0=value0
optionName2=value2
[sectionName0]
optionName0=value0
optionName1=value1
...
[sectionName1]
optionName0=value0
optionName1=value1
optionName2=value2
...
var ConfigIniParser = require("config-ini-parser").ConfigIniParser;
parser = new ConfigIniParser(); //Use default delimiter
parser.parse(iniContent);
var value = parser.get("section", "option");
parser.stringify('\n');
var ConfigIniParser = require("config-ini-parser").ConfigIniParser;
var delimiter = "\r\n"; //or "\n" for *nux
parser = new ConfigIniParser(delimiter); //If don't assign the parameter delimiter then the default value \n will be used
parser.parse(iniContent);
var value = parser.get("section", "option");
value = parser.get(null, "option"); //access the default section
value = parser.getOptionFromDefaultSection("option"); //access the default section
parser.stringify('\n'); //get all the ini file content as a string
var ConfigIniParser = require("config-ini-parser").ConfigIniParser;
parser = new ConfigIniParser(); //Use default delimiter
parser.parse(iniContent);
var value = parser.get("section", "option");
parser.stringify('\r\n');
var delimiter = "\r\n"; //or "\n" for *nux. by default it will use \n
parser = new ConfigIniParser(delimiter); //If don't assign the parameter delimiter then the default value \n will be used
parser.parse(iniContent);
var value = parser.get("section", "option");
value = parser.get(null, "option"); //access the default section
value = parser.getOptionFromDefaultSection("option"); //access the default section
///<reference path="..\\node_modules\\config-ini-parser\\config-ini.d.ts"/>
const ConfigIniParser = require("config-ini-parser").ConfigIniParser;
//or with import statements
//import { ConfigIniParser } from "config-ini-parser";
let p = new ConfigIniParser();
try {
p.addSection("abc");
} catch (e) {
if (e == ConfigIniParser.Errors.ErrorDuplicateSectionError) {
console.error("Duplicated section");
}
}
//create a new config ini parser instance, if the delimiter is ignore then '\n' will be used
ConfigIniParser([delimiter]);
//return parser itself
.addSection(sectionName);
//return the option value
.get(sectionName, optionName[, defaultValue]) ;
//return the option value from default section
.getOptionFromDefaultSection(optionName[, defaultValue]);
//return option value and convert to boolean
.getBoolean(sectionName, optionName);
//return option value and convert to boolean from the default section
.getBooleanFromDefaultSection(optionName);
//return option value and converted to number
.getNumber(sectionName, optionName);
//return value and converted to number from default section
.getNumberFromDefaultSection(optionName);
//return boolean
.isHaveSection(sectionName);
//return boolean
.isHaveOption(sectionName, optionName);
//return boolean
.isHaveOptionInDefaultSection(optionName);
//return all the items in the specify section as [[optionName, optionValue]]
.items(sectionName);
//return all the option names under a specify section into an array
.options(sectionName);
//parse a ini content
.parse(iniContent);
//remove a specify option from the section if it exist and successful removed then return true, if not exist then return false
.removeOption(sectionName, optionName);
//remove a specify option from the default section if it exist and successful removed then return true, if not exist then return false
.removeOptionFromDefaultSection(optionName);
//remove a specify section if it exist and successful removed then return true, if not exist then return false
.removeSection(sectionName);
//return all the section names into an array
.sections();
//set the value of the option in a given section, if the option is not exist then it will be added, if the section is not exist then exception will be raise
.set(sectionName, optionName, value);
//set the option to the given value in the default section. if the option is not exit then it will be added.
.setOptionInDefaultSection(optionName, value);
//convert back the configuration content into delimiter separated string, if delimiter is
//ignore then '\n' will be used
.stringify([delimiter]);
Defined several kinds of built-in error types
ConfigIniParser.Errors.Error;
ConfigIniParser.Errors.ErrorNoSection;
ConfigIniParser.Errors.ErrorNoOption;
ConfigIniParser.Errors.ErrorDuplicateSectionError;
ConfigIniParser.Errors.ErrorCallParseMultipleTimes;
ConfigIniParser.Errors.ErrorIncorrectArgumentType;
GPL-3.0
FAQs
JavaScript Configuration file(.ini) content parser, similar to python ConfigParser without I/O operations. Only one JavaScript file without any other dependencies. Compatible with NodeJS, TypeScript and Browsers.
The npm package config-ini-parser receives a total of 7,640 weekly downloads. As such, config-ini-parser popularity was classified as popular.
We found that config-ini-parser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.