node-nk-base
Advanced tools
Comparing version 1.0.9 to 1.1.0
1416
index.js
function NKB(basefile) { | ||
/* | ||
section: | ||
part: id | ||
var types: ± ň క | ||
var value: | ||
new string: | ||
*/ | ||
/* | ||
const fs = require('fs'); | ||
var bt; | ||
section: | ||
part: id | ||
var types: ± ň క | ||
var value: | ||
new string: | ||
fs.writeFileSync(basefile, fs.readFileSync(basefile, 'utf-8'), 'utf-8'); | ||
*/ | ||
const fs = require('fs'); | ||
var bt; | ||
fs.writeFileSync(basefile, fs.readFileSync(basefile, 'utf-8'), 'utf-8'); | ||
function rb() { | ||
try { | ||
bt = `${fs.readFileSync(basefile, 'utf-8')}`; | ||
return true; | ||
} catch { | ||
console.error(`node-nk-base updateBaseText: can't read file with this path(${basefile})!`); | ||
return null; | ||
} | ||
} | ||
function rb() { | ||
rb(); | ||
try { | ||
bt = `${fs.readFileSync(basefile, 'utf-8')}`; | ||
return true; | ||
} catch { | ||
console.error(`node-nk-base updateBaseText: can't read file with this path(${basefile})!`); | ||
return null; | ||
} | ||
} | ||
function wb(newtx) { | ||
rb(); | ||
try { | ||
fs.writeFileSync(basefile, newtx, 'utf-8'); | ||
return true; | ||
} catch { | ||
console.error(`node-nk-base writeBase: can't write file with this path(${basefile})!`); | ||
return null; | ||
} | ||
function wb(newtx) { | ||
} | ||
try { | ||
fs.writeFileSync(basefile, newtx, 'utf-8'); | ||
return true; | ||
} catch { | ||
console.error(`node-nk-base writeBase: can't write file with this path(${basefile})!`); | ||
return null; | ||
} | ||
} | ||
this.bool = '±'; | ||
this.num = 'ň'; | ||
this.str = 'క'; | ||
this.bool = '±'; | ||
this.num = 'ň'; | ||
this.str = 'క'; | ||
function is_section(section) { | ||
if((bt.indexOf(`${section}`) != -1 && bt.indexOf(`${section}`) != -1)) return true; else return false; | ||
function is_section(section) { | ||
} | ||
if((bt.indexOf(`${section}`) != -1 && bt.indexOf(`${section}`) != -1)) return true; else return false; | ||
} | ||
function is_part(section, id) { | ||
let ss = bt.indexOf(`${section}`); | ||
let se = bt.indexOf(`${section}`, ss); | ||
let pi = bt.indexOf(`${id}`, ss); | ||
if(pi != -1 && pi < se) return true; else return false; | ||
function is_part(section, id) { | ||
} | ||
let ss = bt.indexOf(`${section}`); | ||
let se = bt.indexOf(`${section}`, ss); | ||
let pi = bt.indexOf(`${id}`, ss); | ||
if(pi != -1 && pi < se) return true; else return false; | ||
} | ||
function is_variable(section, id, variable) { | ||
let ss = bt.indexOf(`${section}`); | ||
let se = bt.indexOf(`${section}`, ss); | ||
let ps = bt.indexOf(`${id}`, ss); | ||
let pe = bt.indexOf(``, ps); | ||
let vi = bt.indexOf((`${variable}=`), ps); | ||
if(vi != -1 && (vi < pe && pe < se)) return true; else return false; | ||
} | ||
function is_variable(section, id, variable) { | ||
let ss = bt.indexOf(`${section}`); | ||
let se = bt.indexOf(`${section}`, ss); | ||
let ps = bt.indexOf(`${id}`, ss); | ||
let pe = bt.indexOf(``, ps); | ||
let vi = bt.indexOf((`${variable}=`), ps); | ||
if(vi != -1 && (vi < pe && pe < se)) return true; else return false; | ||
} | ||
function get(section, id, variable) { | ||
let ss = bt.indexOf(`${section}`); | ||
if(ss == -1) return null; | ||
let se = bt.indexOf(`${section}`, ss); | ||
let ps = bt.indexOf(`${id}`, ss); | ||
if(ps > se) return null; | ||
let pe = bt.indexOf(``, ps); | ||
let vs = bt.indexOf((`${variable}=`), ps); | ||
if(vs > pe) return null; | ||
let ve = bt.indexOf(``, vs); | ||
let v = bt.substring(vs+variable.length+2, ve); | ||
if(v.startsWith(`ň`)) return Number(v.substring(2, v.length)); | ||
function get(section, id, variable) { | ||
let ss = bt.indexOf(`${section}`); | ||
if(ss == -1) return null; | ||
let se = bt.indexOf(`${section}`, ss); | ||
let ps = bt.indexOf(`${id}`, ss); | ||
if(ps > se) return null; | ||
let pe = bt.indexOf(``, ps); | ||
let vs = bt.indexOf((`${variable}=`), ps); | ||
if(vs > pe) return null; | ||
let ve = bt.indexOf(``, vs); | ||
if(v.startsWith(`క`)) return v.substring(2, v.length).replace(//g, '\n').replace(/ /g, ``); | ||
let v = bt.substring(vs+variable.length+2, ve); | ||
if(v.startsWith(`ň`)) return Number(v.substring(2, v.length)); | ||
if(v.startsWith(`±`)) { | ||
v = v.substring(2, v.length); | ||
if(v == '0') return false; | ||
if(v == '1') return true; | ||
} | ||
if(v.startsWith(`క`)) return v.substring(2, v.length).replace(//g, '\n').replace(/ /g, ``); | ||
console.error(`node-nk-base get: Can't read value of this variable(${variable})!`); | ||
if(v.startsWith(`±`)) { | ||
v = v.substring(2, v.length); | ||
if(v == '0') return false; | ||
if(v == '1') return true; | ||
} | ||
return null; | ||
console.error(`node-nk-base get: Can't read value of this variable(${variable})!`); | ||
} | ||
function set(section, id, variable, value) { | ||
return null; | ||
let ss = bt.indexOf(`${section}`); | ||
if(ss == -1) return null; | ||
let se = bt.indexOf(`${section}`, ss); | ||
let ps = bt.indexOf(`${id}`, ss); | ||
if(ps > se) return null; | ||
let pe = bt.indexOf(``, ps); | ||
let vs = bt.indexOf((`${variable}=`), ps); | ||
if(vs > pe) return null; | ||
let ve = bt.indexOf(``, vs); | ||
} | ||
function set(section, id, variable, value) { | ||
let v = bt.substring(vs+variable.length+2, ve); | ||
let ss = bt.indexOf(`${section}`); | ||
if(ss == -1) return null; | ||
let se = bt.indexOf(`${section}`, ss); | ||
let ps = bt.indexOf(`${id}`, ss); | ||
if(ps > se) return null; | ||
let pe = bt.indexOf(``, ps); | ||
let vs = bt.indexOf((`${variable}=`), ps); | ||
if(vs > pe) return null; | ||
let ve = bt.indexOf(``, vs); | ||
let t = false; | ||
let v = bt.substring(vs+variable.length+2, ve); | ||
if(v.startsWith(`ň`) && (Number(value) || Number(value) == 0)) t = 'num'; | ||
let t = false; | ||
if(v.startsWith(`క`) && (String(value) || value == '')) t = 'str'; | ||
if(v.startsWith(`ň`) && (Number(value) || Number(value) == 0)) t = 'num'; | ||
if(v.startsWith(`±`) && (value == true || value == false)) { | ||
t = 'bool'; | ||
if(value == true) value = '1'; | ||
if(value == false) value = '0'; | ||
} | ||
if(v.startsWith(`క`) && (String(value) || value == '')) t = 'str'; | ||
if(!t) { | ||
console.error(`node-nk-base set(value): Type of value(${value}) doesn't match with type of variable(${variable})!`); | ||
return null; | ||
} | ||
if(v.startsWith(`±`) && (value == true || value == false)) { | ||
t = 'bool'; | ||
if(value == true) value = '1'; | ||
if(value == false) value = '0'; | ||
} | ||
if(v.startsWith(`ň`)) t = 'ň'; | ||
if(!t) { | ||
console.error(`node-nk-base set(value): Type of value(${value}) doesn't match with type of variable(${variable})!`); | ||
return null; | ||
} | ||
if(v.startsWith(`క`)) { | ||
t = 'క'; | ||
value = String(value).replace(/\n/g, '').replace(//g, ' '); | ||
} | ||
if(v.startsWith(`ň`)) t = 'ň'; | ||
if(v.startsWith(`±`)) t = '±'; | ||
if(v.startsWith(`క`)) { | ||
t = 'క'; | ||
value = String(value).replace(/\n/g, '').replace(//g, ' '); | ||
} | ||
if(t == undefined) { | ||
console.error(`node-nk-base get: Can't read value of this variable(${variable})!`); | ||
return null; | ||
} | ||
if(v.startsWith(`±`)) t = '±'; | ||
if(wb(`${bt.substring(0, ss)}${section}${bt.substring(ss+section.length+2, vs+1)}${variable}=${t}${value}${bt.substring(ve+2, bt.length)}`)) return true; else return null; | ||
} | ||
function add(section, id, variable, value) { | ||
if(t == undefined) { | ||
console.error(`node-nk-base get: Can't read value of this variable(${variable})!`); | ||
return null; | ||
} | ||
let ss = bt.indexOf(`${section}`); | ||
if(ss == -1) return null; | ||
let se = bt.indexOf(`${section}`, ss); | ||
let ps = bt.indexOf(`${id}`, ss); | ||
if(ps > se) return null; | ||
let pe = bt.indexOf(``, ps); | ||
let vs = bt.indexOf((`${variable}=`), ps); | ||
if(vs > pe) return null; | ||
let ve = bt.indexOf(``, vs); | ||
if(wb(`${bt.substring(0, ss)}${section}${bt.substring(ss+section.length+2, vs+1)}${variable}=${t}${value}${bt.substring(ve+2, bt.length)}`)) return true; else return null; | ||
} | ||
function add(section, id, variable, value) { | ||
let v = bt.substring(vs+variable.length+2, ve); | ||
if(!v.startsWith(`ň`)) { | ||
console.error(`node-nk-base add(variable): Function "add" can be used only with number variables!`); | ||
return null; | ||
} | ||
let ss = bt.indexOf(`${section}`); | ||
if(ss == -1) return null; | ||
let se = bt.indexOf(`${section}`, ss); | ||
let ps = bt.indexOf(`${id}`, ss); | ||
if(ps > se) return null; | ||
let pe = bt.indexOf(``, ps); | ||
let vs = bt.indexOf((`${variable}=`), ps); | ||
if(vs > pe) return null; | ||
let ve = bt.indexOf(``, vs); | ||
if(!Number(value) && Number(value) != 0) { | ||
console.error(`node-nk-base add(value): Add value for this variable(${variable}) isn't number!`); | ||
return null; | ||
} | ||
let v = bt.substring(vs+variable.length+2, ve); | ||
if(!v.startsWith(`ň`)) { | ||
console.error(`node-nk-base add(variable): Function "add" can be used only with number variables!`); | ||
return null; | ||
} | ||
if(wb(`${bt.substring(0, ss)}${section}${bt.substring(ss+section.length+2, vs+1)}${variable}=ň${Number(v.substring(2, v.length)) + value}${bt.substring(ve+2, bt.length)}`)) return true; else return null; | ||
} | ||
if(!Number(value) && Number(value) != 0) { | ||
console.error(`node-nk-base add(value): Add value for this variable(${variable}) isn't number!`); | ||
return null; | ||
} | ||
if(wb(`${bt.substring(0, ss)}${section}${bt.substring(ss+section.length+2, vs+1)}${variable}=ň${Number(v.substring(2, v.length)) + value}${bt.substring(ve+2, bt.length)}`)) return true; else return null; | ||
} | ||
function append(section, id, variable, value) { | ||
let ss = bt.indexOf(`${section}`); | ||
if(ss == -1) return null; | ||
let se = bt.indexOf(`${section}`, ss); | ||
let ps = bt.indexOf(`${id}`, ss); | ||
if(ps > se) return null; | ||
let pe = bt.indexOf(``, ps); | ||
let vs = bt.indexOf((`${variable}=`), ps); | ||
if(vs > pe) return null; | ||
let ve = bt.indexOf(``, vs); | ||
function append(section, id, variable, value) { | ||
let v = bt.substring(vs+variable.length+2, ve); | ||
let ss = bt.indexOf(`${section}`); | ||
if(ss == -1) return null; | ||
let se = bt.indexOf(`${section}`, ss); | ||
let ps = bt.indexOf(`${id}`, ss); | ||
if(ps > se) return null; | ||
let pe = bt.indexOf(``, ps); | ||
let vs = bt.indexOf((`${variable}=`), ps); | ||
if(vs > pe) return null; | ||
let ve = bt.indexOf(``, vs); | ||
if(!v.startsWith(`క`)) { | ||
console.error(`node-nk-base append(variable): Function "append" can be used only with string variables!`); | ||
return null; | ||
} | ||
let v = bt.substring(vs+variable.length+2, ve); | ||
if(!String(value) && value != '') { | ||
console.error(`node-nk-base append(value): Append value for this variable(${variable}) isn't string!`); | ||
return null; | ||
} | ||
if(!v.startsWith(`క`)) { | ||
console.error(`node-nk-base append(variable): Function "append" can be used only with string variables!`); | ||
return null; | ||
} | ||
if(!String(value) && value != '') { | ||
console.error(`node-nk-base append(value): Append value for this variable(${variable}) isn't string!`); | ||
return null; | ||
} | ||
if(wb(`${bt.substring(0, ss)}${section}${bt.substring(ss+section.length+2, vs+1)}${variable}=క${v.substring(2, v.length) + value.replace(/\n/g, '').replace(//g, ' ')}${bt.substring(ve+2, bt.length)}`)) return true; else return null; | ||
} | ||
function get_all_count(section) { | ||
let ss = bt.indexOf(`${section}`); | ||
if(ss == -1) return null; | ||
let se = bt.indexOf(`${section}`, ss); | ||
if(wb(`${bt.substring(0, ss)}${section}${bt.substring(ss+section.length+2, vs+1)}${variable}=క${v.substring(2, v.length) + value.replace(/\n/g, '').replace(//g, ' ')}${bt.substring(ve+2, bt.length)}`)) return true; else return null; | ||
} | ||
function get_all_count(section) { | ||
let c = 0; | ||
let ss = bt.indexOf(`${section}`); | ||
if(ss == -1) return null; | ||
let se = bt.indexOf(`${section}`, ss); | ||
for(var lastIndex = ss; lastIndex != -1;) { | ||
lastIndex = bt.indexOf(``, lastIndex+1); | ||
if(lastIndex < se && lastIndex != -1) c++; else break; | ||
} | ||
let c = 0; | ||
return c; | ||
for(var lastIndex = ss; lastIndex != -1;) { | ||
lastIndex = bt.indexOf(``, lastIndex+1); | ||
if(lastIndex < se && lastIndex != -1) c++; else break; | ||
} | ||
} | ||
return c; | ||
} | ||
this.isSection = function(section) { | ||
if(!rb()) return null; | ||
return is_section(section); | ||
this.isSection = function(section) { | ||
} | ||
if(!rb()) return null; | ||
return is_section(section); | ||
this.isPart = function(section, id) { | ||
} | ||
if(!rb()) return null; | ||
if(!is_section(section)) return null; | ||
return is_part(section, id); | ||
this.isPart = function(section, id) { | ||
} | ||
if(!rb()) return null; | ||
if(!is_section(section)) return null; | ||
return is_part(section, id); | ||
this.isVariable = function(section, id, variable) { | ||
} | ||
if(!rb()) return null; | ||
if(!is_section(section)) return null; | ||
if(!is_part(section, id)) return null | ||
return is_variable(section, id, variable); | ||
this.isVariable = function(section, id, variable) { | ||
} | ||
if(!rb()) return null; | ||
if(!is_section(section)) return null; | ||
if(!is_part(section, id)) return null | ||
return is_variable(section, id, variable); | ||
} | ||
this.get = function(section, id, variable) { | ||
if(!rb()) return null; | ||
this.get = function(section, id, variable) { | ||
if(!is_section(section)) { | ||
console.error(`node-nk-base get(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!is_part(section, id)) { | ||
console.error(`node-nk-base get(id): Part with this id(${id}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!is_variable(section, id, variable)) { | ||
console.error(`node-nk-base get(variable): This variable(${variable}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!rb()) return null; | ||
return get(section, id, variable); | ||
if(!is_section(section)) { | ||
console.error(`node-nk-base get(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!is_part(section, id)) { | ||
console.error(`node-nk-base get(id): Part with this id(${id}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!is_variable(section, id, variable)) { | ||
console.error(`node-nk-base get(variable): This variable(${variable}) doesn't exists!`); | ||
return null; | ||
} | ||
} | ||
return get(section, id, variable); | ||
} | ||
this.set = function(section, id, variable, value) { | ||
if(!rb()) return null; | ||
this.set = function(section, id, variable, value) { | ||
if(!is_section(section)) { | ||
console.error(`node-nk-base set(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!rb()) return null; | ||
if(!is_part(section, id)) { | ||
console.error(`node-nk-base set(id): Part with this id(${id}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!is_section(section)) { | ||
console.error(`node-nk-base set(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!is_variable(section, id, variable)) { | ||
console.error(`node-nk-base set(variable): This variable(${variable}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!is_part(section, id)) { | ||
console.error(`node-nk-base set(id): Part with this id(${id}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!is_variable(section, id, variable)) { | ||
console.error(`node-nk-base set(variable): This variable(${variable}) doesn't exists!`); | ||
return null; | ||
} | ||
return set(section, id, variable, value); | ||
} | ||
this.add = function(section, id, variable, value) { | ||
return set(section, id, variable, value); | ||
if(!rb()) return null; | ||
} | ||
this.add = function(section, id, variable, value) { | ||
if(!is_section(section)) { | ||
console.error(`node-nk-base add(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!rb()) return null; | ||
if(!is_part(section, id)) { | ||
console.error(`node-nk-base add(id): Part with this id(${id}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!is_section(section)) { | ||
console.error(`node-nk-base add(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!is_variable(section, id, variable)) { | ||
console.error(`node-nk-base add(variable): This variable(${variable}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!is_part(section, id)) { | ||
console.error(`node-nk-base add(id): Part with this id(${id}) doesn't exists!`); | ||
return null; | ||
} | ||
return add(section, id, variable, value); | ||
if(!is_variable(section, id, variable)) { | ||
console.error(`node-nk-base add(variable): This variable(${variable}) doesn't exists!`); | ||
return null; | ||
} | ||
} | ||
return add(section, id, variable, value); | ||
this.append = function(section, id, variable, value) { | ||
} | ||
if(!rb()) return null; | ||
this.append = function(section, id, variable, value) { | ||
if(!is_section(section)) { | ||
console.error(`node-nk-base append(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!rb()) return null; | ||
if(!is_part(section, id)) { | ||
console.error(`node-nk-base append(id): Part with this id(${id}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!is_section(section)) { | ||
console.error(`node-nk-base append(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!is_variable(section, id, variable)) { | ||
console.error(`node-nk-base append(variable): This variable(${variable}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!is_part(section, id)) { | ||
console.error(`node-nk-base append(id): Part with this id(${id}) doesn't exists!`); | ||
return null; | ||
} | ||
return append(section, id, variable, value); | ||
if(!is_variable(section, id, variable)) { | ||
console.error(`node-nk-base append(variable): This variable(${variable}) doesn't exists!`); | ||
return null; | ||
} | ||
} | ||
this.createSection = function(section) { | ||
return append(section, id, variable, value); | ||
if(!rb()) return null; | ||
} | ||
this.createSection = function(section) { | ||
if(is_section(section)) { | ||
console.error(`node-nk-base createSection: Section "${section}" already exists!`); | ||
return null; | ||
} | ||
if(!rb()) return null; | ||
wb(bt + `${section}${section}`); | ||
if(is_section(section)) { | ||
console.error(`node-nk-base createSection: Section "${section}" already exists!`); | ||
return null; | ||
} | ||
return true; | ||
wb(bt + `${section}${section}`); | ||
} | ||
return true; | ||
} | ||
this.deleteSection = function(section) { | ||
if(!rb()) return null; | ||
this.deleteSection = function(section) { | ||
if(!is_section(section)) { | ||
console.error(`node-nk-base createSection: Section "${section}" doesn't exists!`); | ||
return null; | ||
} | ||
if(!rb()) return null; | ||
let ss = bt.indexOf(`${section}`); | ||
let se = bt.indexOf(`${section}`, ss); | ||
if(!is_section(section)) { | ||
console.error(`node-nk-base createSection: Section "${section}" doesn't exists!`); | ||
return null; | ||
} | ||
if(wb(bt.substring(0, ss) + bt.substring(se+section.length+2, bt.length))) return true; else return false; | ||
let ss = bt.indexOf(`${section}`); | ||
let se = bt.indexOf(`${section}`, ss); | ||
} | ||
if(wb(bt.substring(0, ss) + bt.substring(se+section.length+2, bt.length))) return true; else return false; | ||
} | ||
this.findSection = function(section) { | ||
if(!rb()) return null; | ||
this.findSection = function(section) { | ||
if(!is_section(section)) { | ||
console.error(`node-nk-base findSection(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!rb()) return null; | ||
if(!is_section(section)) { | ||
console.error(`node-nk-base findSection(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
this.isPart = function(id) { | ||
if(!rb()) return null; | ||
if(!is_section(section)) return null; | ||
return is_part(section, id); | ||
} | ||
this.isVariable = function(id, variable) { | ||
if(!rb()) return null; | ||
if(!is_section(section)) return null; | ||
if(!is_part(section, id)) return null | ||
return is_variable(section, id, variable); | ||
} | ||
this.isPart = function(id) { | ||
this.createPart = function(id, vars) { | ||
if(!rb()) return null; | ||
if(!is_section(section)) return null; | ||
return is_part(section, id); | ||
} | ||
this.isVariable = function(id, variable) { | ||
if(!rb()) return null; | ||
if(!is_section(section)) return null; | ||
if(!is_part(section, id)) return null | ||
return is_variable(section, id, variable); | ||
} | ||
if(!rb()) return null; | ||
this.createPart = function(id, vars) { | ||
if(!is_section(section)) { | ||
console.error(`node-nk-base createPart(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!rb()) return null; | ||
if(is_part(section, id)) { | ||
console.error(`node-nk-base createPart(id): Part with this id(${id}) already exists!`); | ||
return null; | ||
} | ||
if(!is_section(section)) { | ||
console.error(`node-nk-base createPart(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
let ss = bt.indexOf(`${section}`); | ||
let se = bt.indexOf(`${section}`, ss); | ||
if(is_part(section, id)) { | ||
console.error(`node-nk-base createPart(id): Part with this id(${id}) already exists!`); | ||
return null; | ||
} | ||
let err = false; | ||
let ss = bt.indexOf(`${section}`); | ||
let se = bt.indexOf(`${section}`, ss); | ||
let newbt = bt.substring(0, se) + `${id}`; | ||
let err = false; | ||
vars.map( (x) => { | ||
let newbt = bt.substring(0, se) + `${id}`; | ||
if(x[1] == Number || x[1] == String || x[1] == Boolean) { | ||
vars.map( (x) => { | ||
if(x[1] == Number && !Number(x[2]) && Number(x[2]) != 0) { | ||
console.error(`node-nk-base createPart(variables): Number value is wrong([${x[0]} = ${x[2]}])`); | ||
err = true; | ||
return null; | ||
} | ||
if(x[1] == String && (String(x[2]) || x[2] == '')) { | ||
x[2] = String(x[2]).replace(/\n/g, ''); | ||
} | ||
if(x[1] == Number || x[1] == String || x[1] == Boolean) { | ||
if(x[1] == Boolean && !(x[2] == true || x[2] == false)) { | ||
console.error(`node-nk-base createPart(variables): Bool value is wrong([${x[0]} = ${x[2]}])`); | ||
err = true; | ||
return null; | ||
} | ||
if(x[1] == Number && !Number(x[2]) && Number(x[2]) != 0) { | ||
console.error(`node-nk-base createPart(variables): Number value is wrong([${x[0]} = ${x[2]}])`); | ||
err = true; | ||
return null; | ||
} | ||
if(x[1] == String && (String(x[2]) || x[2] == '')) { | ||
x[2] = String(x[2]).replace(/\n/g, ''); | ||
} | ||
if(x[1] == Boolean && (x[2] == true || x[2] == false)) { | ||
if(x[2] == true) x[2] = '1'; | ||
if(x[2] == false) x[2] = '0'; | ||
} | ||
if(x[1] == Boolean && !(x[2] == true || x[2] == false)) { | ||
console.error(`node-nk-base createPart(variables): Bool value is wrong([${x[0]} = ${x[2]}])`); | ||
err = true; | ||
return null; | ||
} | ||
newbt += `${x[0]}=${(x[1] == Number ? 'ň' : "") + (x[1] == String ? 'క' : "") + (x[1] == Boolean ? '±' : "")}${x[2]}`; | ||
if(x[1] == Boolean && (x[2] == true || x[2] == false)) { | ||
if(x[2] == true) x[2] = '1'; | ||
if(x[2] == false) x[2] = '0'; | ||
} | ||
} else { | ||
console.error(`node-nk-base createPart(variables): Type of this variable(${x[0]}) is wrong!`); | ||
return null; | ||
} | ||
newbt += `${x[0]}=${(x[1] == Number ? 'ň' : "") + (x[1] == String ? 'క' : "") + (x[1] == Boolean ? '±' : "")}${x[2]}`; | ||
}); | ||
} else { | ||
console.error(`node-nk-base createPart(variables): Type of this variable(${x[0]}) is wrong!`); | ||
return null; | ||
} | ||
newbt += `` + bt.substring(se, bt.length); | ||
}); | ||
if(!err) { | ||
newbt += `` + bt.substring(se, bt.length); | ||
if(wb(newbt)) { | ||
newbt = null; | ||
return true; | ||
} else return null; | ||
if(!err) { | ||
} else return null; | ||
} | ||
if(wb(newbt)) { | ||
newbt = null; | ||
return true; | ||
} else return null; | ||
} else return null; | ||
} | ||
this.deletePart = function(id) { | ||
if(!rb()) return null; | ||
this.deletePart = function(id) { | ||
if(!is_section(section)) { | ||
console.error(`node-nk-base findSection(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!rb()) return null; | ||
if(!is_part(section, id)) { | ||
console.error(`node-nk-base deletePart(id): Part with this id(${id}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!is_section(section)) { | ||
console.error(`node-nk-base findSection(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
let ss = bt.indexOf(`${section}`); | ||
if(ss == -1) return null; | ||
let se = bt.indexOf(`${section}`, ss); | ||
let ps = bt.indexOf(`${id}`, ss); | ||
if(ps > se) return null; | ||
let pe = bt.indexOf(``, ps); | ||
if(!is_part(section, id)) { | ||
console.error(`node-nk-base deletePart(id): Part with this id(${id}) doesn't exists!`); | ||
return null; | ||
} | ||
if(wb(bt.substring(0, ps) + bt.substring(pe+2, bt.length))) return true; else return null; | ||
let ss = bt.indexOf(`${section}`); | ||
if(ss == -1) return null; | ||
let se = bt.indexOf(`${section}`, ss); | ||
let ps = bt.indexOf(`${id}`, ss); | ||
if(ps > se) return null; | ||
let pe = bt.indexOf(``, ps); | ||
} | ||
if(wb(bt.substring(0, ps) + bt.substring(pe+2, bt.length))) return true; else return null; | ||
} | ||
this.get = function(id, variable) { | ||
if(!rb()) return null; | ||
this.get = function(id, variable) { | ||
if(!is_section(section)) { | ||
console.error(`node-nk-base get(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!is_part(section, id)) { | ||
console.error(`node-nk-base get(id): Part with this id(${id}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!is_variable(section, id, variable)) { | ||
console.error(`node-nk-base get(variable): This variable(${variable}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!rb()) return null; | ||
return get(section, id, variable); | ||
if(!is_section(section)) { | ||
console.error(`node-nk-base get(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!is_part(section, id)) { | ||
console.error(`node-nk-base get(id): Part with this id(${id}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!is_variable(section, id, variable)) { | ||
console.error(`node-nk-base get(variable): This variable(${variable}) doesn't exists!`); | ||
return null; | ||
} | ||
} | ||
return get(section, id, variable); | ||
} | ||
this.set = function(id, variable, value) { | ||
if(!rb()) return null; | ||
this.set = function(id, variable, value) { | ||
if(!is_section(section)) { | ||
console.error(`node-nk-base set(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!is_part(section, id)) { | ||
console.error(`node-nk-base set(id): Part with this id(${id}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!is_variable(section, id, variable)) { | ||
console.error(`node-nk-base set(variable): This variable(${variable}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!rb()) return null; | ||
return set(section, id, variable, value); | ||
if(!is_section(section)) { | ||
console.error(`node-nk-base set(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!is_part(section, id)) { | ||
console.error(`node-nk-base set(id): Part with this id(${id}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!is_variable(section, id, variable)) { | ||
console.error(`node-nk-base set(variable): This variable(${variable}) doesn't exists!`); | ||
return null; | ||
} | ||
} | ||
return set(section, id, variable, value); | ||
} | ||
this.add = function(id, variable, value) { | ||
if(!rb()) return null; | ||
this.add = function(id, variable, value) { | ||
if(!is_section(section)) { | ||
console.error(`node-nk-base add(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!is_part(section, id)) { | ||
console.error(`node-nk-base add(id): Part with this id(${id}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!is_variable(section, id, variable)) { | ||
console.error(`node-nk-base add(variable): This variable(${variable}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!rb()) return null; | ||
return add(section, id, variable, value); | ||
} | ||
if(!is_section(section)) { | ||
console.error(`node-nk-base add(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!is_part(section, id)) { | ||
console.error(`node-nk-base add(id): Part with this id(${id}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!is_variable(section, id, variable)) { | ||
console.error(`node-nk-base add(variable): This variable(${variable}) doesn't exists!`); | ||
return null; | ||
} | ||
return add(section, id, variable, value); | ||
} | ||
this.append = function(id, variable, value) { | ||
if(!rb()) return null; | ||
this.append = function(id, variable, value) { | ||
if(!is_section(section)) { | ||
console.error(`node-nk-base append(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!is_part(section, id)) { | ||
console.error(`node-nk-base append(id): Part with this id(${id}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!is_variable(section, id, variable)) { | ||
console.error(`node-nk-base append(variable): This variable(${variable}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!rb()) return null; | ||
return append(section, id, variable, value); | ||
} | ||
if(!is_section(section)) { | ||
console.error(`node-nk-base append(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!is_part(section, id)) { | ||
console.error(`node-nk-base append(id): Part with this id(${id}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!is_variable(section, id, variable)) { | ||
console.error(`node-nk-base append(variable): This variable(${variable}) doesn't exists!`); | ||
return null; | ||
} | ||
return append(section, id, variable, value); | ||
} | ||
this.findPart = function(id) { | ||
this.findPart = function(id) { | ||
if(!rb()) return null; | ||
if(!is_section(section)) { | ||
console.error(`node-nk-base findSection(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!is_part(section, id)) { | ||
console.error(`node-nk-base findPart(id): Part with this id(${id}) doesn't exists!`); | ||
return; | ||
} | ||
if(!rb()) return null; | ||
if(!is_section(section)) { | ||
console.error(`node-nk-base findSection(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!is_part(section, id)) { | ||
console.error(`node-nk-base findPart(id): Part with this id(${id}) doesn't exists!`); | ||
return; | ||
} | ||
this.isVariable = function(variable) { | ||
if(!rb()) return null; | ||
if(!is_section(section)) return null; | ||
if(!is_part(section, id)) return null | ||
return is_variable(section, id, variable); | ||
} | ||
this.isVariable = function(variable) { | ||
if(!rb()) return null; | ||
if(!is_section(section)) return null; | ||
if(!is_part(section, id)) return null | ||
return is_variable(section, id, variable); | ||
} | ||
this.get = function(variable) { | ||
if(!rb()) return null; | ||
this.get = function(variable) { | ||
if(!is_section(section)) { | ||
console.error(`node-nk-base get(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!is_part(section, id)) { | ||
console.error(`node-nk-base get(id): Part with this id(${id}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!is_variable(section, id, variable)) { | ||
console.error(`node-nk-base get(variable): This variable(${variable}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!rb()) return null; | ||
return get(section, id, variable); | ||
if(!is_section(section)) { | ||
console.error(`node-nk-base get(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!is_part(section, id)) { | ||
console.error(`node-nk-base get(id): Part with this id(${id}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!is_variable(section, id, variable)) { | ||
console.error(`node-nk-base get(variable): This variable(${variable}) doesn't exists!`); | ||
return null; | ||
} | ||
} | ||
return get(section, id, variable); | ||
} | ||
this.set = function(variable, value) { | ||
if(!rb()) return null; | ||
this.set = function(variable, value) { | ||
if(!is_section(section)) { | ||
console.error(`node-nk-base set(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!is_part(section, id)) { | ||
console.error(`node-nk-base set(id): Part with this id(${id}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!is_variable(section, id, variable)) { | ||
console.error(`node-nk-base set(variable): This variable(${variable}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!rb()) return null; | ||
return set(section, id, variable, value); | ||
if(!is_section(section)) { | ||
console.error(`node-nk-base set(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!is_part(section, id)) { | ||
console.error(`node-nk-base set(id): Part with this id(${id}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!is_variable(section, id, variable)) { | ||
console.error(`node-nk-base set(variable): This variable(${variable}) doesn't exists!`); | ||
return null; | ||
} | ||
} | ||
return set(section, id, variable, value); | ||
} | ||
this.add = function(variable, value) { | ||
if(!rb()) return null; | ||
this.add = function(variable, value) { | ||
if(!is_section(section)) { | ||
console.error(`node-nk-base add(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!is_part(section, id)) { | ||
console.error(`node-nk-base add(id): Part with this id(${id}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!is_variable(section, id, variable)) { | ||
console.error(`node-nk-base add(variable): This variable(${variable}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!rb()) return null; | ||
return add(section, id, variable, value); | ||
} | ||
this.append = function(variable, value) { | ||
if(!is_section(section)) { | ||
console.error(`node-nk-base add(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!is_part(section, id)) { | ||
console.error(`node-nk-base add(id): Part with this id(${id}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!is_variable(section, id, variable)) { | ||
console.error(`node-nk-base add(variable): This variable(${variable}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!rb()) return null; | ||
return add(section, id, variable, value); | ||
} | ||
this.append = function(variable, value) { | ||
if(!is_section(section)) { | ||
console.error(`node-nk-base append(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!is_part(section, id)) { | ||
console.error(`node-nk-base append(id): Part with this id(${id}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!is_variable(section, id, variable)) { | ||
console.error(`node-nk-base append(variable): This variable(${variable}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!rb()) return null; | ||
return append(section, id, variable, value); | ||
} | ||
if(!is_section(section)) { | ||
console.error(`node-nk-base append(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!is_part(section, id)) { | ||
console.error(`node-nk-base append(id): Part with this id(${id}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!is_variable(section, id, variable)) { | ||
console.error(`node-nk-base append(variable): This variable(${variable}) doesn't exists!`); | ||
return null; | ||
} | ||
return append(section, id, variable, value); | ||
} | ||
this.createVariable = function(variable, type, value) { | ||
if(!rb()) return null; | ||
this.createVariable = function(variable, type, value) { | ||
if(!is_section(section)) { | ||
console.error(`node-nk-base findSection(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!rb()) return null; | ||
if(!is_part(section, id)) { | ||
console.error(`node-nk-base findPart(id): Part with this id(${id}) doesn't exists!`); | ||
return; | ||
} | ||
if(!is_section(section)) { | ||
console.error(`node-nk-base findSection(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
if(is_variable(section, id, variable)) { | ||
console.error(`node-nk-base createVariable(variable): This variable(${variable}) already exists!`); | ||
return; | ||
} | ||
if(!is_part(section, id)) { | ||
console.error(`node-nk-base findPart(id): Part with this id(${id}) doesn't exists!`); | ||
return; | ||
} | ||
let t = false; | ||
let vt = false; | ||
if(is_variable(section, id, variable)) { | ||
console.error(`node-nk-base createVariable(variable): This variable(${variable}) already exists!`); | ||
return; | ||
} | ||
if(type == Number || type == String || type == Boolean) t = true; | ||
let t = false; | ||
let vt = false; | ||
if(type == Number && (Number(value) || Number(value) == 0)) vt = Number; | ||
if(type == Number || type == String || type == Boolean) t = true; | ||
if(type == String && (String(value) || value == '')) { | ||
vt = String; | ||
value = value.replace(/\n/g, '⥌⍖⥍'); | ||
} | ||
if(type == Number && (Number(value) || Number(value) == 0)) vt = Number; | ||
if(type == Boolean && (value == true || value == false)) { | ||
vt = Boolean; | ||
if(value == true) value = '1'; | ||
if(value == false) value = '0'; | ||
} | ||
if(type == String && (String(value) || value == '')) { | ||
vt = String; | ||
value = value.replace(/\n/g, '⥌⍖⥍'); | ||
} | ||
if(type == Boolean && (value == true || value == false)) { | ||
vt = Boolean; | ||
if(value == true) value = '1'; | ||
if(value == false) value = '0'; | ||
} | ||
if(!t) { | ||
console.error(`node-nk-base createVariable(type): Type of this variable(${variable}) is wrong!`); | ||
return null; | ||
} | ||
if(!vt) { | ||
console.error(`node-nk-base createVariable(value): Value for this variable(${variable}) doesn't match with type of this variable!`); | ||
return null; | ||
} | ||
if(!t) { | ||
console.error(`node-nk-base createVariable(type): Type of this variable(${variable}) is wrong!`); | ||
return null; | ||
} | ||
let ss = bt.indexOf(`${section}`); | ||
if(ss == -1) return null; | ||
let se = bt.indexOf(`${section}`, ss); | ||
let ps = bt.indexOf(`${id}`, ss); | ||
if(ps > se) return null; | ||
let pe = bt.indexOf(``, ps); | ||
let vs = bt.indexOf((`${variable}=`), ps); | ||
if(vs > pe) return null; | ||
let ve = bt.indexOf(``, vs); | ||
if(!vt) { | ||
console.error(`node-nk-base createVariable(value): Value for this variable(${variable}) doesn't match with type of this variable!`); | ||
return null; | ||
} | ||
if(wb(bt.substring(0, pe) + `${variable}=${(type == Number ? 'ň' : "") + (type == String ? 'క' : "") + (type == Boolean ? '±' : "")}${value}` + bt.substring(pe, bt.length))) return true; else return null; | ||
let ss = bt.indexOf(`${section}`); | ||
if(ss == -1) return null; | ||
let se = bt.indexOf(`${section}`, ss); | ||
let ps = bt.indexOf(`${id}`, ss); | ||
if(ps > se) return null; | ||
let pe = bt.indexOf(``, ps); | ||
let vs = bt.indexOf((`${variable}=`), ps); | ||
if(vs > pe) return null; | ||
let ve = bt.indexOf(``, vs); | ||
} | ||
if(wb(bt.substring(0, pe) + `${variable}=${(type == Number ? 'ň' : "") + (type == String ? 'క' : "") + (type == Boolean ? '±' : "")}${value}` + bt.substring(pe, bt.length))) return true; else return null; | ||
} | ||
this.deleteVariable = function(variable) { | ||
if(!rb()) return null; | ||
this.deleteVariable = function(variable) { | ||
if(!is_section(section)) { | ||
console.error(`node-nk-base findSection(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!rb()) return null; | ||
if(!is_part(section, id)) { | ||
console.error(`node-nk-base findPart(id): Part with this id(${id}) doesn't exists!`); | ||
return; | ||
} | ||
if(!is_section(section)) { | ||
console.error(`node-nk-base findSection(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!is_variable(section, id, variable)) { | ||
console.error(`node-nk-base deleteVariable(variable): This variable(${variable}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!is_part(section, id)) { | ||
console.error(`node-nk-base findPart(id): Part with this id(${id}) doesn't exists!`); | ||
return; | ||
} | ||
let ss = bt.indexOf(`${section}`); | ||
if(ss == -1) return null; | ||
let se = bt.indexOf(`${section}`, ss); | ||
let ps = bt.indexOf(`${id}`, ss); | ||
if(ps > se) return null; | ||
let pe = bt.indexOf(``, ps); | ||
let vs = bt.indexOf((`${variable}=`), ps); | ||
if(vs > pe) return null; | ||
let ve = bt.indexOf(``, vs); | ||
if(!is_variable(section, id, variable)) { | ||
console.error(`node-nk-base deleteVariable(variable): This variable(${variable}) doesn't exists!`); | ||
return null; | ||
} | ||
if(wb(bt.substring(0, vs+1) + bt.substring(ve+2, bt.length))) return true; | ||
} | ||
let ss = bt.indexOf(`${section}`); | ||
if(ss == -1) return null; | ||
let se = bt.indexOf(`${section}`, ss); | ||
let ps = bt.indexOf(`${id}`, ss); | ||
if(ps > se) return null; | ||
let pe = bt.indexOf(``, ps); | ||
let vs = bt.indexOf((`${variable}=`), ps); | ||
if(vs > pe) return null; | ||
let ve = bt.indexOf(``, vs); | ||
if(wb(bt.substring(0, vs+1) + bt.substring(ve+2, bt.length))) return true; | ||
} | ||
} | ||
this.getVariableCount = function() { | ||
this.getAllCount = function() { | ||
if(!rb()) return null; | ||
if(!rb()) return null; | ||
if(!is_section(section)) { | ||
console.error(`node-nk-base findSection(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!is_section(section)) { | ||
console.error(`node-nk-base findSection(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!is_part(section, id)) { | ||
console.error(`node-nk-base findPart(id): Part with this id(${id}) doesn't exists!`); | ||
return; | ||
} | ||
return get_all_count(section); | ||
} | ||
let c = 0; | ||
let ss = bt.indexOf(`${section}`); | ||
if(ss == -1) return null; | ||
let se = bt.indexOf(`${section}`, ss); | ||
let ps = bt.indexOf(`${id}`, ss); | ||
if(ps > se) return null; | ||
let pe = bt.indexOf(``, ps); | ||
for(var vs = -1, vs1 = -1, ve = ps;;) { | ||
vs = bt.indexOf(``, ve); | ||
vs1 = bt.indexOf(``, vs); | ||
ve = bt.indexOf(``, vs1); | ||
if((vs !== -1 && vs1 !== -1 && ve !== -1) && ve < pe) c++; else break; | ||
} | ||
this.getAll = function() { | ||
return c; | ||
} | ||
this.getVariables = function() { | ||
if(!rb()) return null; | ||
if(!rb()) return null; | ||
if(!is_section(section)) { | ||
console.error(`node-nk-base findSection(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!is_section(section)) { | ||
console.error(`node-nk-base findSection(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
let ss = bt.indexOf(`${section}`); | ||
let se = bt.indexOf(`${section}`, ss); | ||
if(!is_part(section, id)) { | ||
console.error(`node-nk-base findPart(id): Part with this id(${id}) doesn't exists!`); | ||
return; | ||
} | ||
let parts = []; | ||
let variables = []; | ||
for(var lastIndex = ss;;) { | ||
lastIndex = bt.indexOf(``, lastIndex+1); | ||
if(lastIndex > se || lastIndex == -1) break; | ||
parts.push(bt.substring(lastIndex+2, bt.indexOf(``, lastIndex+2))); | ||
} | ||
let ss = bt.indexOf(`${section}`); | ||
if(ss == -1) return null; | ||
let se = bt.indexOf(`${section}`, ss); | ||
let ps = bt.indexOf(`${id}`, ss); | ||
if(ps > se) return null; | ||
let pe = bt.indexOf(``, ps); | ||
for(var vs = -1, vs1 = -1, ve = ps;;) { | ||
vs = bt.indexOf(``, ve+1); | ||
vs1 = bt.indexOf(``, vs+1); | ||
ve = bt.indexOf(``, vs1+1); | ||
if((vs !== -1 && vs1 !== -1 && ve !== -1) && (ve < pe)) { | ||
variables.push(bt.substring(vs+1, vs1-2)); | ||
} else break; | ||
} | ||
return parts; | ||
return variables; | ||
} | ||
} | ||
} | ||
} | ||
this.getAllCount = function() { | ||
console.log(`node-nk-base started on file "${basefile}"!`); | ||
if(!rb()) return null; | ||
if(!is_section(section)) { | ||
console.error(`node-nk-base findSection(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
return get_all_count(section); | ||
} | ||
this.getAll = function() { | ||
if(!rb()) return null; | ||
if(!is_section(section)) { | ||
console.error(`node-nk-base findSection(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
let ss = bt.indexOf(`${section}`); | ||
let se = bt.indexOf(`${section}`, ss); | ||
let parts = []; | ||
for(var lastIndex = ss;;) { | ||
lastIndex = bt.indexOf(``, lastIndex+1); | ||
if(lastIndex > se || lastIndex == -1) break; | ||
parts.push(bt.substring(lastIndex+2, bt.indexOf(``, lastIndex+2))); | ||
} | ||
return parts; | ||
} | ||
} | ||
this.getSectionCount = function() { | ||
if(!rb()) return null; | ||
let c = 0; | ||
for(var ss = -1, ss1 = -1, se = -1;;) { | ||
ss = bt.indexOf(``, se+1); | ||
ss1 = bt.indexOf(``, ss+1); | ||
let section = bt.substring(ss+1, ss1); | ||
se = bt.indexOf(`${section}`, ss1); | ||
if(ss !== -1 && ss1 !==-1 && se !== -1) { | ||
c++; | ||
se += (section.length + 1); | ||
} else break; | ||
} | ||
return c; | ||
} | ||
this.getSections = function() { | ||
if(!rb()) return null; | ||
let sections = []; | ||
for(var ss = -1, ss1 = -1, se = -1;;) { | ||
ss = bt.indexOf(``, se+1); | ||
ss1 = bt.indexOf(``, ss+1); | ||
let section = bt.substring(ss+1, ss1); | ||
se = bt.indexOf(`${section}`, ss1); | ||
if(ss !== -1 && ss1 !==-1 && se !== -1) { | ||
sections.push(section); | ||
se += (section.length + 1); | ||
} else break; | ||
} | ||
return sections; | ||
} | ||
console.log(`node-nk-base started on file "${basefile}"!`); | ||
} | ||
module.exports = NKB; |
{ | ||
"name": "node-nk-base", | ||
"version": "1.0.9", | ||
"version": "1.1.0", | ||
"description": "database for nodejs by NK", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
31294
664