IniFile
IniFile
allows to create and manage .INI files.
Methods
new IniFile(filename)
filename
string - Path to INI file.
Create a new IniFile instance. If the INI file does not exists a new one will be created at filename
.
deleteKey(section, key)
section
string - Section name.key
string - Key name.
Deletes a key from the INI file.
eraseSection(section)
section
string - Section name.
Deletes a section from the INI file.
sectionExists(section)
section
string - Section name.
Returns Promise<boolean>
- Resolves with true
if section
exists.
keyExists(section, key)
section
string - Section name.key
string - Key name.
Returns Promise<boolean>
- Resolves with true
if key
exists in section
.
readBool(section, key, defaultValue)
section
string - Section name.key
string - Key name.defaultValue
boolean - Default value to be returned if no section, key or data found.
Returns Promise<boolean>
- Resolves with a boolean value.
readDate(section, key, defaultValue)
section
string - Section name.key
string - Key name.defaultValue
Date - Default value to be returned if no section, key or data found.
Returns Promise<Date>
- Resolves with a Date value. Only the date part is returned, the time part defaults to 00:00:00.
readDateTime(section, key, defaultValue)
section
string - Section name.key
string - Key name.defaultValue
Date - Default value to be returned if no section, key or data found.
Returns Promise<Date>
- Resolves with a Date value. Contains both date and time.
readFloat(section, key, defaultValue)
section
string - Section name.key
string - Key name.defaultValue
number - Default value to be returned if no section, key or data found.
Returns Promise<number>
- Resolves with a float number
.
readInteger(section, key, defaultValue)
section
string - Section name.key
string - Key name.defaultValue
number - Default value to be returned if no section, key or data found.
Returns Promise<number>
- Resolves with a number.
readString(section, key, defaultValue)
section
string - Section name.key
string - Key name.defaultValue
string - Default value to be returned if no section, key or data found.
Returns Promise<string>
- Resolves with a string.
readSection(section)
section
string - Section name.
Returns Promise<Array<string>>
- Resolves with an array that contains each key name for the given section.
readSections()
Returns Promise<Array<string>>
- Resolves with an array that contains each section names of the file.
readSectionValues(section)
section
string - Section name.
Returns Promise<Array<string>>
- Resolves with an array of string that contains each key=data pair for a given section.
readSubSections(section, [recurse])
section
string - Section name.recurse
boolean - Recursively read sub sections. Default isfalse
.
Returns Promise<Array<string>>
- Resolves with an array of string that contains the names of all sections.
readTime(section, key, defaultValue)
section
string - Section name.key
string - Key name.defaultValue
Date - Default value to be returned if no section, key or data found.
Returns Promise<Date>
- Resolves with a Date object where the date part defaults to January 01, 1970.
writeBool(section, key, value)
section
string - Section name.key
string - Key name.value
boolean - The boolean value to be written to the INI file.
Writes a boolean value to INI file.
writeDate(section, key, value)
section
string - Section name.key
string - Key name.value
Date - The boolean value to be written to the INI file. Only the date part will be saved. The time part will euqal to 00:00:00.
Writes a Date value to INI file.
writeDateTime(section, key, value)
section
string - Section name.key
string - Key name.value
Date - The boolean value to be written to the INI file. Both date and time parts will be persisted.
Writes a Date value to INI file.
writeFloat(section, key, value)
section
string - Section name.key
string - Key name.value
number - The float value to be written to the INI file.
Writes a floatr value to INI file.
writeInteger(section, key, value)
section
string - Section name.key
string - Key name.value
number - The integer value to be written to the INI file.
Writes an integer value to INI file.
writeString(section, key, value)
section
string - Section name.key
string - Key name.value
string - The string value to be written to the INI file.
Writes an string value to INI file.
writeTime(section, key, value)
section
string - Section name.key
string - Key name.value
Date - The boolean value to be written to the INI file. Only the time part will be saved. The time part will euqal to January 01, 1970.
Writes a Date value to INI file.