English | 한국어
set-data is a data storage method. It uses the extension .sd.
set-data consists of key-value pairs as follows.
KEY=VALUE
{ KEY: 'VALUE' }
In set-data, use the # symbol for comments.
# This is a comment.
KEY=VALUE
{ KEY: 'VALUE' }
In set-data, when using spacing in values, use $S as follows.
KEY=spacing$Sexample
{ KEY: 'spacing example' }
Starting from version 1.2.0, you no longer need to use $E when using the = character in values.
In set-data, when storing multiple values, do not use commas. (However, make sure to use line breaks.)
KEY1=VALUE1
KEY2=VALUE2
{ KEY1: 'VALUE1', KEY2: 'VALUE2' }
In set-data, when using arrays, append & to the key and separate elements with commas in the value.
&KEY=VALUE1,VALUE2
{ KEY: ['VALUE1', 'VALUE2'] }
When you want to use commas in elements of an array, use $C as follows.
&KEY=comma$Cexample,VALUE2
{ KEY: ['comma,example', 'VALUE2'] }
In set-data, when using boolean values, append ! to the key.
!KEY=true
{ KEY: true }
To download the library, type npm i set-data
in the console.
To import the library, use require
as follows.
const setData = require('set-data')
parse returns the set-data string as an object.
setData.parse(`
KEY=VALUE
`)
{ KEY: 'VALUE' }
parseFile returns the set-data file as an object.
setData.parseFile('./setting.sd', 'utf-8')
setData.parseFile('./setting.sd') // Encoding can be omitted.
stringfy returns an object as a set-data string as follows.
setData.stringfy({
key: 'value'
})
key=value
stringfyFile writes a set-data file with an object as follows.
setData.stringfyFile('./setting.sd', {
key: 'value'
})
This will write key=value
content to the ./setting.sd
file.
Be careful when passing the path of an existing file as the fileName
parameter, as it will overwrite the file.