mcpropertiesparser
Version:
A simple, lightweight and type safe .properties file parser that allow to read/edit .properties minecraft server file
86 lines (51 loc) • 2.71 kB
Markdown
is a lightweight and typesafe set of utilies to parse and modify .properties file of mc servers
```shell
npm install mcpropertiesparser
yarn add mcpropertiesparser
```
| Name | Return | Description |
| ------------------------- | ----------------------- | ------------------------------------------------------------ |
| parsePropertiesFileToJson | Promise<PropertiesFile> | parsePropertiesFileToJson allow you to get the json conversion of a .properties file |
| Parameter | Type | Description | Required |
| -------------- | ------ | ------------------------------------- | -------- |
| propertiesPath | string | path of the .properties file to parse | True |
```typescript
import {parsedPropertiesFile} from "mcpropertiesparser"
const parsedPropertiesFile = await parsePropertiesFileToJson(path)
```
| Name | Return | Description |
| -------------------- | ------- | ------------------------------------------------- |
| propertiesFileHasKey | Boolean | Check if a properties file contain a specific key |
| Parameter | Type | Description | Required |
| -------------- | -------------- | ------------------------------- | -------- |
| propertiesFile | PropertiesFile | properties file object to check | True |
| key | string | key to check if exist | True |
```typescript
import {propertiesFileHasKey} from "mcpropertiesparser"
propertiesFileHasKey(propertiesFile, key)
```
| Name | Return | Description |
| ------------------- | ------------- | ---------------------------------------------------- |
| writePropertiesFile | Promise<void> | Write a properties file object as a .properties file |
| Parameter | Type | Description | Required |
| ------------ | -------------- | ----------------------------------- | -------- |
| *properties* | PropertiesFile | properties file object to check | True |
| path | string | path where the file will be written | True |
```typescript
import {writePropertiesFile} from "mcpropertiesparser"
// it can be the same path from the actual edited file and will replace the old with the new changes
await writePropertiesFile(properties, path)
```
> mcPropertiesParser