node-nk-base
Advanced tools
Comparing version 1.1.0 to 1.1.1
1565
index.js
function NKB(basefile) { | ||
/* | ||
section: | ||
part: id | ||
var types: ± ň క | ||
var value: | ||
new string: | ||
section: namename | ||
part: idvar1=±0var2=ň1024var3=క test text | ||
var types: | ||
Boolean: ± (in value: 0 for false, 1 for true) | ||
Number: ň | ||
String: క | ||
variable value: ±1 | ň255 | కtext | ||
in string value '\n' replacing to '' | ||
*/ | ||
const fs = require('fs'); | ||
var bt; | ||
const fs = require('fs'); | ||
var bt; | ||
fs.writeFileSync(basefile, fs.readFileSync(basefile, 'utf-8'), 'utf-8'); | ||
fs.writeFileSync(basefile, fs.readFileSync(basefile, 'utf-8'), 'utf-8'); | ||
function rb() { | ||
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; | ||
} | ||
} | ||
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; | ||
} | ||
} | ||
rb(); | ||
rb(); | ||
function wb(newtx) { | ||
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; | ||
} | ||
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) { | ||
function is_section(section) { | ||
if((bt.indexOf(`${section}`) != -1 && bt.indexOf(`${section}`) != -1)) return true; else return false; | ||
let ss = bt.indexOf(`${section}`); | ||
if(ss === -1) return false; | ||
let se = bt.indexOf(`${section}`, ss) | ||
if(se !== -1) return true; else return false; | ||
} | ||
} | ||
function is_part(section, id) { | ||
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; | ||
let ss = bt.indexOf(`${section}`); | ||
if(ss === -1) return false; | ||
let se = bt.indexOf(`${section}`, ss); | ||
if(se === -1) return false; | ||
let ps = bt.indexOf(`${id}`, ss); | ||
if(ps !== -1 && ps < se) return true; else return false; | ||
} | ||
} | ||
function is_variable(section, id, variable) { | ||
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; | ||
} | ||
let ss = bt.indexOf(`${section}`); | ||
if(ss === -1) return false; | ||
let se = bt.indexOf(`${section}`, ss); | ||
if(se === -1) return false; | ||
let ps = bt.indexOf(`${id}`, ss); | ||
if(ps === -1 || ps > se) return false; | ||
let pe = bt.indexOf(``, ps); | ||
if(pe === -1) return false; | ||
let vs = bt.substring(ps+String(id).length+4, pe+1).indexOf((`${variable}=`), ps); | ||
if(vs !== -1) 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); | ||
function get(section, id, variable, fromMethod) { | ||
let v = bt.substring(vs+variable.length+2, ve); | ||
if(v.startsWith(`ň`)) return Number(v.substring(2, v.length)); | ||
id = String(id); | ||
if(v.startsWith(`క`)) return v.substring(2, v.length).replace(//g, '\n').replace(/ /g, ``); | ||
let ss = bt.indexOf(`${section}`); | ||
if(ss === -1) { | ||
console.error(`node-nk-base ${fromMethod}(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
let se = bt.indexOf(`${section}`, ss); | ||
if(se === -1) { | ||
console.error(`node-nk-base ${fromMethod}(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
let ps = bt.indexOf(`${id}`, ss); | ||
if(ps === -1 || ps > se) { | ||
console.error(`node-nk-base ${fromMethod}(id): Part with this id(${id}) doesn't exists!`); | ||
return null; | ||
} | ||
let pe = bt.indexOf(``, ps); | ||
if(pe === -1 || pe > se) { | ||
console.error(`node-nk-base ${fromMethod}(id): Part with this id(${id}) doesn't exists!`); | ||
return null; | ||
} | ||
let part = bt.substring(ps+id.length+4, pe+1); | ||
if(v.startsWith(`±`)) { | ||
v = v.substring(2, v.length); | ||
if(v == '0') return false; | ||
if(v == '1') return true; | ||
} | ||
console.error(`node-nk-base get: Can't read value of this variable(${variable})!`); | ||
if(Array.isArray(variable)) { | ||
return null; | ||
let values = []; | ||
} | ||
function set(section, id, variable, value) { | ||
for(var i = 0; i < variable.length; i++) { | ||
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 vs = part.indexOf((`${variable[i]}=`)); | ||
if(vs === -1) { | ||
console.error(`node-nk-base ${fromMethod}(variable): This variable(${variable[i]}) doesn't exists!`); | ||
return null; | ||
} | ||
let ve = part.indexOf(``, vs); | ||
let v = bt.substring(vs+variable.length+2, ve); | ||
let v = part.substring(vs+variable[i].length+2, ve); | ||
if(v.startsWith(`ň`)) values.push(Number(v.substring(2, v.length))); else | ||
let t = false; | ||
if(v.startsWith(`క`)) values.push(v.substring(2, v.length).replace(//g, '\n').replace(/ /g, ``)); else | ||
if(v.startsWith(`ň`) && (Number(value) || Number(value) == 0)) t = 'num'; | ||
if(v.startsWith(`±`)) { | ||
v = v.substring(2, v.length); | ||
if(v === '0') values.push(false); | ||
if(v === '1') values.push(true); | ||
} else { | ||
if(v.startsWith(`క`) && (String(value) || value == '')) t = 'str'; | ||
console.error(`node-nk-base ${fromMethod}: Can't read type of value of this variable(${variable[i]})!`); | ||
values.push(null); | ||
if(v.startsWith(`±`) && (value == true || value == false)) { | ||
t = 'bool'; | ||
if(value == true) value = '1'; | ||
if(value == false) value = '0'; | ||
} | ||
} | ||
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 = 'ň'; | ||
return values; | ||
if(v.startsWith(`క`)) { | ||
t = 'క'; | ||
value = String(value).replace(/\n/g, '').replace(//g, ' '); | ||
} | ||
} else { | ||
if(v.startsWith(`±`)) t = '±'; | ||
let vs = part.indexOf((`${variable}=`)); | ||
if(vs === -1) { | ||
console.error(`node-nk-base ${fromMethod}(variable): This variable(${variable}) doesn't exists!`); | ||
return null; | ||
} | ||
let ve = part.indexOf(``, vs); | ||
if(t == undefined) { | ||
console.error(`node-nk-base get: Can't read value of this variable(${variable})!`); | ||
return null; | ||
} | ||
let v = part.substring(vs+variable.length+2, ve); | ||
if(v.startsWith(`ň`)) return Number(v.substring(2, v.length)); | ||
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(v.startsWith(`క`)) return v.substring(2, v.length).replace(//g, '\n').replace(/ /g, ``); | ||
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(`±`)) { | ||
v = v.substring(2, v.length); | ||
if(v === '0') return false; | ||
if(v === '1') return true; | ||
} | ||
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; | ||
} | ||
console.error(`node-nk-base ${fromMethod}: Can't read type of value of this variable(${variable})!`); | ||
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 set(section, id, variable, value, fromMethod) { | ||
id = String(id); | ||
} | ||
let ss = bt.indexOf(`${section}`); | ||
if(ss === -1) { | ||
console.error(`node-nk-base ${fromMethod}(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
let se = bt.indexOf(`${section}`, ss); | ||
if(se === -1) { | ||
console.error(`node-nk-base ${fromMethod}(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
let ps = bt.indexOf(`${id}`, ss); | ||
if(ps === -1 || ps > se) { | ||
console.error(`node-nk-base ${fromMethod}(id): Part with this id(${id}) doesn't exists!`); | ||
return null; | ||
} | ||
let pe = bt.indexOf(``, ps); | ||
if(pe === -1 || pe > se) { | ||
console.error(`node-nk-base ${fromMethod}(id): Part with this id(${id}) doesn't exists!`); | ||
return null; | ||
} | ||
let part = bt.substring(ps+id.length+4, pe+1); | ||
let vs = part.indexOf((`${variable}=`)); | ||
if(vs === -1) { | ||
console.error(`node-nk-base ${fromMethod}(variable): This variable(${variable}) doesn't exists!`); | ||
return null; | ||
} | ||
let ve = part.indexOf(``, vs); | ||
let v = part.substring(vs+variable.length+2, ve); | ||
function append(section, id, variable, value) { | ||
let t = false; | ||
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(`ň`) && (Number(value) || Number(value) === 0)) { | ||
t = 'ň'; | ||
} | ||
let v = bt.substring(vs+variable.length+2, ve); | ||
if(v.startsWith(`క`) && (String(value) || value === '')) { | ||
t = 'క'; | ||
value = String(value).replace(/\n/g, '').replace(//g, ' '); | ||
} | ||
if(!v.startsWith(`క`)) { | ||
console.error(`node-nk-base append(variable): Function "append" can be used only with string variables!`); | ||
return null; | ||
} | ||
if(v.startsWith(`±`) && (value === true || value === false)) { | ||
t = '±'; | ||
if(value === true) value = '1'; | ||
if(value === false) value = '0'; | ||
} | ||
if(!String(value) && value != '') { | ||
console.error(`node-nk-base append(value): Append value for this variable(${variable}) isn't string!`); | ||
return null; | ||
} | ||
if(!t) { | ||
console.error(`node-nk-base set(value): Type of value(${value}) doesn't match with type of variable(${variable})!`); | ||
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; | ||
if(wb(`${bt.substring(0, ps)}${id}${part.substring(0, vs)}${variable}=${t}${value}${part.substring(ve+1, part.length)}${bt.substring(pe+3, bt.length)}`)) return true; else return null; | ||
} | ||
} | ||
function get_all_count(section) { | ||
function add(section, id, variable, value, fromMethod) { | ||
let ss = bt.indexOf(`${section}`); | ||
if(ss == -1) return null; | ||
let se = bt.indexOf(`${section}`, ss); | ||
id = String(id); | ||
let ss = bt.indexOf(`${section}`); | ||
if(ss === -1) { | ||
console.error(`node-nk-base ${fromMethod}(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
let se = bt.indexOf(`${section}`, ss); | ||
if(se === -1) { | ||
console.error(`node-nk-base ${fromMethod}(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
let ps = bt.indexOf(`${id}`, ss); | ||
if(ps === -1 || ps > se) { | ||
console.error(`node-nk-base ${fromMethod}(id): Part with this id(${id}) doesn't exists!`); | ||
return null; | ||
} | ||
let pe = bt.indexOf(``, ps); | ||
if(pe === -1 || pe > se) { | ||
console.error(`node-nk-base ${fromMethod}(id): Part with this id(${id}) doesn't exists!`); | ||
return null; | ||
} | ||
let part = bt.substring(ps+id.length+4, pe+1); | ||
let vs = part.indexOf((`${variable}=`)); | ||
if(vs === -1) { | ||
console.error(`node-nk-base ${fromMethod}(variable): This variable(${variable}) doesn't exists!`); | ||
return null; | ||
} | ||
let ve = part.indexOf(``, vs); | ||
let c = 0; | ||
let v = part.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; | ||
} | ||
for(var lastIndex = ss; lastIndex != -1;) { | ||
lastIndex = bt.indexOf(``, lastIndex+1); | ||
if(lastIndex < se && lastIndex != -1) c++; else break; | ||
} | ||
if(!Number(value) && Number(value) !== 0) { | ||
console.error(`node-nk-base add(value): Add value for this variable(${variable}) isn't number!`); | ||
return null; | ||
} | ||
return c; | ||
if(wb(`${bt.substring(0, ss)}${section}${bt.substring(ss+section.length+2, ps)}${id}${part.substring(0, vs)}${variable}=ň${Number(v.substring(2, v.length))+value}${part.substring(ve+1, part.length)}${bt.substring(pe+3, bt.length)}`)) return true; else return null; | ||
} | ||
} | ||
this.isSection = function(section) { | ||
function append(section, id, variable, value, fromMethod) { | ||
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.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; | ||
if(!is_section(section)) { | ||
console.error(`node-nk-base get(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
id = String(id); | ||
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; | ||
} | ||
let ss = bt.indexOf(`${section}`); | ||
if(ss === -1) { | ||
console.error(`node-nk-base ${fromMethod}(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
let se = bt.indexOf(`${section}`, ss); | ||
if(se === -1) { | ||
console.error(`node-nk-base ${fromMethod}(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
let ps = bt.indexOf(`${id}`, ss); | ||
if(ps === -1 || ps > se) { | ||
console.error(`node-nk-base ${fromMethod}(id): Part with this id(${id}) doesn't exists!`); | ||
return null; | ||
} | ||
let pe = bt.indexOf(``, ps); | ||
if(pe === -1 || pe > se) { | ||
console.error(`node-nk-base ${fromMethod}(id): Part with this id(${id}) doesn't exists!`); | ||
return null; | ||
} | ||
let part = bt.substring(ps+id.length+4, pe+1); | ||
let vs = part.indexOf((`${variable}=`)); | ||
if(vs === -1) { | ||
console.error(`node-nk-base ${fromMethod}(variable): This variable(${variable}) doesn't exists!`); | ||
return null; | ||
} | ||
let ve = part.indexOf(``, vs); | ||
return get(section, id, variable); | ||
let v = part.substring(vs+variable.length+2, ve); | ||
} | ||
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; | ||
} | ||
this.set = function(section, id, variable, value) { | ||
if(!rb()) return null; | ||
if(wb(`${bt.substring(0, ss)}${section}${bt.substring(ss+section.length+2, ps)}${id}${part.substring(0, vs)}${variable}=ň${v.substring(2, v.length)+String(value).replace(/\n/g, '').replace(//g, ' ')}${part.substring(ve+1, part.length)}${bt.substring(pe+3, 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); | ||
let c = 0; | ||
for(var lastIndex = ss; lastIndex !== -1;) { | ||
lastIndex = bt.indexOf(``, lastIndex+1); | ||
if(lastIndex < se && lastIndex !== -1) c++; else break; | ||
} | ||
return c; | ||
} | ||
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; | ||
} | ||
this.isSection = function(section) { | ||
if(!rb()) return null; | ||
return is_section(section); | ||
} | ||
if(!is_variable(section, id, variable)) { | ||
console.error(`node-nk-base set(variable): This variable(${variable}) doesn't exists!`); | ||
return null; | ||
} | ||
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) { | ||
return set(section, id, variable, value); | ||
if(!rb()) return null; | ||
if(!is_section(section)) return null; | ||
if(!is_part(section, id)) return null | ||
return is_variable(section, id, variable); | ||
} | ||
this.add = function(section, id, variable, value) { | ||
} | ||
if(!rb()) return null; | ||
if(!is_section(section)) { | ||
console.error(`node-nk-base add(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
this.get = function(section, id, variable) { | ||
if(!is_part(section, id)) { | ||
console.error(`node-nk-base add(id): Part with this id(${id}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!rb()) return null; | ||
if(!is_variable(section, id, variable)) { | ||
console.error(`node-nk-base add(variable): This variable(${variable}) doesn't exists!`); | ||
return null; | ||
} | ||
return get(section, id, variable, 'get'); | ||
return add(section, id, variable, value); | ||
} | ||
} | ||
this.append = function(section, id, variable, value) { | ||
this.set = function(section, id, variable, value) { | ||
if(!rb()) return null; | ||
if(!rb()) return null; | ||
if(!is_section(section)) { | ||
console.error(`node-nk-base append(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
return set(section, id, variable, value, 'set'); | ||
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.createSection = function(section) { | ||
this.add = function(section, id, variable, value) { | ||
if(!rb()) return null; | ||
if(!rb()) return null; | ||
if(is_section(section)) { | ||
console.error(`node-nk-base createSection: Section "${section}" already exists!`); | ||
return null; | ||
} | ||
return add(section, id, variable, value, 'add'); | ||
wb(bt + `${section}${section}`); | ||
} | ||
return true; | ||
this.append = function(section, id, variable, value) { | ||
} | ||
if(!rb()) return null; | ||
return append(section, id, variable, value, 'append'); | ||
this.deleteSection = function(section) { | ||
} | ||
this.createSection = function(section) { | ||
if(!rb()) return null; | ||
if(!rb()) return null; | ||
if(!is_section(section)) { | ||
console.error(`node-nk-base createSection: Section "${section}" doesn't exists!`); | ||
return null; | ||
} | ||
if(is_section(section)) { | ||
console.error(`node-nk-base createSection: Section "${section}" already exists!`); | ||
return null; | ||
} | ||
let ss = bt.indexOf(`${section}`); | ||
let se = bt.indexOf(`${section}`, ss); | ||
wb(bt + `${section}${section}`); | ||
if(wb(bt.substring(0, ss) + bt.substring(se+section.length+2, bt.length))) return true; else return false; | ||
return true; | ||
} | ||
} | ||
this.findSection = function(section) { | ||
this.deleteSection = function(section) { | ||
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; | ||
} | ||
let ss = bt.indexOf(`${section}`); | ||
if(ss === -1) { | ||
console.error(`node-nk-base deleteSection: Section "${section}" doesn't exists!`); | ||
return null; | ||
} | ||
let se = bt.indexOf(`${section}`, ss); | ||
if(se === -1) { | ||
console.error(`node-nk-base deleteSection: 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 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.createPart = function(id, vars) { | ||
this.findSection = function(section) { | ||
if(!rb()) return null; | ||
if(!rb()) return null; | ||
if(!is_section(section)) { | ||
console.error(`node-nk-base createPart(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 createPart(id): Part with this id(${id}) already exists!`); | ||
return null; | ||
} | ||
let ss = bt.indexOf(`${section}`); | ||
let se = bt.indexOf(`${section}`, ss); | ||
this.isPart = function(id) { | ||
let err = false; | ||
if(!rb()) return null; | ||
return is_part(section, id); | ||
} | ||
this.isVariable = function(id, variable) { | ||
if(!rb()) return null; | ||
return is_variable(section, id, variable); | ||
} | ||
let newbt = bt.substring(0, se) + `${id}`; | ||
this.createPart = function(id, vars) { | ||
vars.map( (x) => { | ||
if(!rb()) return null; | ||
if(x[1] == Number || x[1] == String || x[1] == Boolean) { | ||
let ss = bt.indexOf(`${section}`); | ||
if(ss === -1) { | ||
console.error(`node-nk-base createPart(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
let se = bt.indexOf(`${section}`, ss); | ||
if(se === -1) { | ||
console.error(`node-nk-base createPart(section): This section(${section}) doesn't exists!`); | ||
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, ''); | ||
} | ||
let err = false; | ||
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; | ||
} | ||
let newbt = bt.substring(0, se) + `${id}`; | ||
if(x[1] == Boolean && (x[2] == true || x[2] == false)) { | ||
if(x[2] == true) x[2] = '1'; | ||
if(x[2] == false) x[2] = '0'; | ||
} | ||
for(var i = 0; i < vars.length; i++) { | ||
newbt += `${x[0]}=${(x[1] == Number ? 'ň' : "") + (x[1] == String ? 'క' : "") + (x[1] == Boolean ? '±' : "")}${x[2]}`; | ||
let x = vars[i]; | ||
} else { | ||
console.error(`node-nk-base createPart(variables): Type of this variable(${x[0]}) is wrong!`); | ||
return null; | ||
} | ||
if(x[1] === Number || x[1] === String || x[1] === Boolean) { | ||
}); | ||
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; | ||
continue; | ||
} | ||
if(x[1] === String && (String(x[2]) || x[2] === '')) { | ||
x[2] = String(x[2]).replace(/\n/g, ''); | ||
} | ||
newbt += `` + bt.substring(se, bt.length); | ||
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; | ||
continue; | ||
} | ||
if(!err) { | ||
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(wb(newbt)) { | ||
newbt = null; | ||
return true; | ||
} else return null; | ||
newbt += `${x[0]}=${(x[1] === Number ? 'ň' : "") + (x[1] === String ? 'క' : "") + (x[1] === Boolean ? '±' : "")}${x[2]}`; | ||
} else return null; | ||
} | ||
} else { | ||
console.error(`node-nk-base createPart(variables): Type of this variable(${x[0]}) is wrong!`); | ||
continue; | ||
} | ||
} | ||
this.deletePart = function(id) { | ||
newbt += `` + bt.substring(se, bt.length); | ||
if(!rb()) return null; | ||
if(!err) { | ||
if(!is_section(section)) { | ||
console.error(`node-nk-base findSection(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
if(wb(newbt)) { | ||
newbt = null; | ||
return true; | ||
} else return null; | ||
if(!is_part(section, id)) { | ||
console.error(`node-nk-base deletePart(id): Part with this id(${id}) doesn't exists!`); | ||
return null; | ||
} | ||
} 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.deletePart = function(id) { | ||
} | ||
if(!rb()) return null; | ||
let ss = bt.indexOf(`${section}`); | ||
if(ss === -1) { | ||
console.error(`node-nk-base deletePart(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
let se = bt.indexOf(`${section}`, ss); | ||
if(se === -1) { | ||
console.error(`node-nk-base deletePart(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
let ps = bt.indexOf(`${id}`, ss); | ||
if(ps === -1 || ps > se) { | ||
console.error(`node-nk-base deletePart(id): Part with this id(${id}) doesn't exists!`); | ||
return null; | ||
} | ||
let pe = bt.indexOf(``, ps); | ||
if(pe === -1 || pe > se) { | ||
console.error(`node-nk-base deletePart(id): Part with this id(${id}) doesn't exists!`); | ||
return null; | ||
} | ||
this.get = function(id, variable) { | ||
if(wb(bt.substring(0, ps) + bt.substring(pe+2, bt.length))) return true; else return null; | ||
if(!rb()) return null; | ||
} | ||
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.get = function(id, variable) { | ||
} | ||
if(!rb()) return null; | ||
return get(section, id, variable, 'section.get'); | ||
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); | ||
return set(section, id, variable, value, 'section.get'); | ||
} | ||
} | ||
this.add = function(id, variable, value) { | ||
this.add = function(id, variable, value) { | ||
if(!rb()) return null; | ||
return add(section, id, variable, value, 'section.get'); | ||
} | ||
if(!rb()) return null; | ||
this.append = 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); | ||
} | ||
return append(section, id, variable, value, 'section.get'); | ||
} | ||
this.findPart = function(id) { | ||
this.append = function(id, variable, value) { | ||
if(!rb()) return null; | ||
if(!rb()) return null; | ||
id = String(id); | ||
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(!is_section(section)) { | ||
console.error(`node-nk-base findPart(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 append(section, id, variable, value); | ||
} | ||
this.isVariable = function(variable) { | ||
this.findPart = function(id) { | ||
if(!rb()) return null; | ||
return is_variable(section, id, variable); | ||
} | ||
if(!rb()) return null; | ||
this.get = function(variable) { | ||
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; | ||
return get(section, id, variable, 'part.get'); | ||
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.set = function(variable, value) { | ||
this.get = function(variable) { | ||
if(!rb()) return null; | ||
if(!rb()) return null; | ||
return set(section, id, variable, value, 'part.get'); | ||
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.add = function(variable, value) { | ||
} | ||
if(!rb()) return null; | ||
return add(section, id, variable, value, 'part.get'); | ||
} | ||
this.append = function(variable, value) { | ||
if(!rb()) return null; | ||
return append(section, id, variable, value, 'part.get'); | ||
} | ||
this.set = function(variable, value) { | ||
this.createVariable = function(variable, type, value) { | ||
if(!rb()) return null; | ||
if(!rb()) return null; | ||
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; | ||
} | ||
let ss = bt.indexOf(`${section}`); | ||
if(ss === -1) { | ||
console.error(`node-nk-base part.createVariable(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
let se = bt.indexOf(`${section}`, ss); | ||
if(se === -1) { | ||
console.error(`node-nk-base part.createVariable(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
let ps = bt.indexOf(`${id}`, ss); | ||
if(ps === -1 || ps > se) { | ||
console.error(`node-nk-base part.createVariable(id): Part with this id(${id}) doesn't exists!`); | ||
return; | ||
} | ||
let pe = bt.indexOf(``, ps); | ||
if(pe === -1 || pe > se) { | ||
console.error(`node-nk-base part.createVariable(id): Part with this id(${id}) doesn't exists!`); | ||
return; | ||
} | ||
let part = bt.substring(ps+id.length+4, pe+1); | ||
let vs = part.indexOf((`${variable}=`)); | ||
if(vs !== -1) { | ||
console.error(`node-nk-base part.createVariable(variable): This variable(${variable}) already exists!`); | ||
return; | ||
} | ||
return set(section, id, variable, value); | ||
if(!(type === Number || type === String || type === Boolean)) { | ||
console.error(`node-nk-base createVariable(type): Type of this variable(${variable}) is wrong!`); | ||
return null; | ||
} | ||
} | ||
let t = false; | ||
if(type === Number && (Number(value) || Number(value) === 0)) t = Number; | ||
this.add = function(variable, value) { | ||
if(type === String && (String(value) || value === '')) { | ||
t = String; | ||
value = value.replace(/\n/g, '⥌⍖⥍'); | ||
} | ||
if(!rb()) return null; | ||
if(type === Boolean && (value === true || value === false)) { | ||
t = Boolean; | ||
if(value === true) value = '1'; | ||
if(value === false) value = '0'; | ||
} | ||
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(!t) { | ||
console.error(`node-nk-base createVariable(value): Value for this variable(${variable}) doesn't match with type of this variable!`); | ||
return null; | ||
} | ||
return add(section, id, variable, value); | ||
} | ||
this.append = function(variable, value) { | ||
if(wb(bt.substring(0, pe) + `${variable}=${(type === Number ? 'ň' : "") + (type === String ? 'క' : "") + (type === Boolean ? '±' : "")}${value}` + bt.substring(pe, bt.length))) return true; else return null; | ||
if(!rb()) return null; | ||
} | ||
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; | ||
} | ||
this.deleteVariable = function(variable) { | ||
return append(section, id, variable, value); | ||
} | ||
if(!rb()) return null; | ||
let ss = bt.indexOf(`${section}`); | ||
if(ss === -1) { | ||
console.error(`node-nk-base part.deleteVariable(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
let se = bt.indexOf(`${section}`, ss); | ||
if(se === -1) { | ||
console.error(`node-nk-base part.deleteVariable(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
let ps = bt.indexOf(`${id}`, ss); | ||
if(ps === -1 || ps > se) { | ||
console.error(`node-nk-base part.deleteVariable(id): Part with this id(${id}) doesn't exists!`); | ||
return; | ||
} | ||
let pe = bt.indexOf(``, ps); | ||
if(pe === -1 || pe > se) { | ||
console.error(`node-nk-base part.deleteVariable(id): Part with this id(${id}) doesn't exists!`); | ||
return; | ||
} | ||
let part = bt.substring(ps+id.length+4, pe+1); | ||
let vs = part.indexOf((`${variable}=`)); | ||
if(vs === -1) { | ||
console.error(`node-nk-base part.deleteVariable(variable): This variable(${variable}) doesn't exists!`); | ||
return; | ||
} | ||
let ve = part.indexOf(``, vs); | ||
this.createVariable = function(variable, type, value) { | ||
if(`${bt.substring(0, ps)}${id}${part.substring(0, vs)}${part.substring(ve+2, part.length)}${bt.substring(pe+3, bt.length)}`) return true; | ||
} | ||
if(!rb()) return null; | ||
this.getVariableCount = function() { | ||
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; | ||
} | ||
let c = 0; | ||
if(is_variable(section, id, variable)) { | ||
console.error(`node-nk-base createVariable(variable): This variable(${variable}) already exists!`); | ||
return; | ||
} | ||
let ss = bt.indexOf(`${section}`); | ||
if(ss === -1) { | ||
console.error(`node-nk-base getVariableCount(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
let se = bt.indexOf(`${section}`, ss); | ||
if(se === -1) { | ||
console.error(`node-nk-base getVariableCount(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
let ps = bt.indexOf(`${id}`, ss); | ||
if(ps === -1 || ps > se) { | ||
console.error(`node-nk-base getVariableCount(id): Part with this id(${id}) doesn't exists!`); | ||
return null; | ||
} | ||
let pe = bt.indexOf(``, ps); | ||
if(pe === -1 || pe > se) { | ||
console.error(`node-nk-base getVariableCount(id): Part with this id(${id}) doesn't exists!`); | ||
return null; | ||
} | ||
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; | ||
} | ||
let t = false; | ||
let vt = false; | ||
return c; | ||
} | ||
this.getVariables = function() { | ||
if(type == Number || type == String || type == Boolean) t = true; | ||
if(!rb()) return null; | ||
if(type == Number && (Number(value) || Number(value) == 0)) vt = Number; | ||
let variables = []; | ||
if(type == String && (String(value) || value == '')) { | ||
vt = String; | ||
value = value.replace(/\n/g, '⥌⍖⥍'); | ||
} | ||
let ss = bt.indexOf(`${section}`); | ||
if(ss === -1) { | ||
console.error(`node-nk-base getVariables(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
let se = bt.indexOf(`${section}`, ss); | ||
if(se === -1) { | ||
console.error(`node-nk-base getVariables(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
let ps = bt.indexOf(`${id}`, ss); | ||
if(ps === -1 || ps > se) { | ||
console.error(`node-nk-base getVariableCount(id): Part with this id(${id}) doesn't exists!`); | ||
return null; | ||
} | ||
if(ps === -1 || ps > se) { | ||
console.error(`node-nk-base getVariableCount(id): Part with this id(${id}) doesn't exists!`); | ||
return null; | ||
} | ||
let pe = bt.indexOf(``, ps); | ||
if(pe === -1 || pe > se) { | ||
console.error(`node-nk-base getVariableCount(id): Part with this id(${id}) doesn't exists!`); | ||
return null; | ||
} | ||
let part = bt.substring(ps+id.length+4); | ||
for(var vs = -1, vs1 = -1, ve = -1;;) { | ||
vs = part.indexOf(``, ve+1); | ||
vs1 = part.indexOf(``, vs+1); | ||
ve = part.indexOf(``, vs1+1); | ||
if((vs !== -1 && vs1 !== -1 && ve !== -1) && (ve < pe)) { | ||
variables.push(part.substring(vs+1, vs1-2)); | ||
} else break; | ||
} | ||
if(type == Boolean && (value == true || value == false)) { | ||
vt = Boolean; | ||
if(value == true) value = '1'; | ||
if(value == false) value = '0'; | ||
} | ||
return variables; | ||
} | ||
} | ||
if(!t) { | ||
console.error(`node-nk-base createVariable(type): Type of this variable(${variable}) is wrong!`); | ||
return null; | ||
} | ||
this.getAllCount = function() { | ||
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(!rb()) 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(!is_section(section)) { | ||
console.error(`node-nk-base findSection(section): This section(${section}) doesn't exists!`); | ||
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; | ||
return get_all_count(section); | ||
} | ||
} | ||
this.getAll = function() { | ||
if(!rb()) return null; | ||
this.deleteVariable = function(variable) { | ||
let ss = bt.indexOf(`${section}`); | ||
if(ss === -1) { | ||
console.error(`node-nk-base getAll(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
let se = bt.indexOf(`${section}`, ss); | ||
if(se === -1) { | ||
console.error(`node-nk-base getAll(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
if(!rb()) return null; | ||
let parts = []; | ||
if(!is_section(section)) { | ||
console.error(`node-nk-base findSection(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
for(var lastIndex = ss;;) { | ||
if(!is_part(section, id)) { | ||
console.error(`node-nk-base findPart(id): Part with this id(${id}) doesn't exists!`); | ||
return; | ||
} | ||
lastIndex = bt.indexOf(``, lastIndex+1); | ||
if(lastIndex > se || lastIndex === -1) break; | ||
parts.push(bt.substring(lastIndex+2, bt.indexOf(``, lastIndex+2))); | ||
if(!is_variable(section, id, variable)) { | ||
console.error(`node-nk-base deleteVariable(variable): This variable(${variable}) 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); | ||
let vs = bt.indexOf((`${variable}=`), ps); | ||
if(vs > pe) return null; | ||
let ve = bt.indexOf(``, vs); | ||
return parts; | ||
if(wb(bt.substring(0, vs+1) + bt.substring(ve+2, bt.length))) return true; | ||
} | ||
} | ||
this.getVariableCount = function() { | ||
this.getOfAll = function(variable) { | ||
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; | ||
} | ||
let ss = bt.indexOf(`${section}`); | ||
if(ss === -1) { | ||
console.error(`node-nk-base getAll(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
let se = bt.indexOf(`${section}`, ss); | ||
if(se === -1) { | ||
console.error(`node-nk-base getAll(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; | ||
} | ||
let values = []; | ||
let c = 0; | ||
if(Array.isArray(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); | ||
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; | ||
} | ||
for(var ps = ss;;) { | ||
ps = bt.indexOf(``, ps+1); | ||
if(ps > se || ps === -1) break; | ||
let id = bt.substring(ps+2, bt.indexOf(``, ps+2)); | ||
let part = bt.substring(ps+id.length+4, bt.indexOf(``, ps)); | ||
return c; | ||
} | ||
this.getVariables = function() { | ||
let v = []; | ||
if(!rb()) return null; | ||
for(var i = 0; i < variable.length; i++) { | ||
let vs = part.indexOf((`${variable[i]}=`)); | ||
if(vs === -1) { | ||
v.push(null); | ||
continue; | ||
} | ||
let ve = part.indexOf(``, vs); | ||
let value = part.substring(vs+variable[i].length+2, ve); | ||
if(value.startsWith(`ň`)) v.push(Number(v.substring(2, value.length))); else | ||
if(value.startsWith(`క`)) v.push(value.substring(2, value.length).replace(//g, '\n').replace(/ /g, ``)); else | ||
if(value.startsWith(`±`)) { | ||
value = value.substring(2, v.length); | ||
if(value === '0') v.push(false); | ||
if(value === '1') v.push(true); | ||
} else { | ||
v.push(null); | ||
continue; | ||
} | ||
if(!is_section(section)) { | ||
console.error(`node-nk-base findSection(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
} | ||
values.push( { id: id, value: v } ); | ||
} | ||
if(!is_part(section, id)) { | ||
console.error(`node-nk-base findPart(id): Part with this id(${id}) doesn't exists!`); | ||
return; | ||
} | ||
} else { | ||
let variables = []; | ||
for(var ps = ss;;) { | ||
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; | ||
} | ||
ps = bt.indexOf(``, ps+1); | ||
if(ps > se || ps === -1) break; | ||
return variables; | ||
} | ||
let id = bt.substring(ps+2, bt.indexOf(``, ps+2)); | ||
let part = bt.substring(ps+id.length+4, bt.indexOf(``, ps)); | ||
let v; | ||
} | ||
let vs = part.indexOf((`${variable}=`)); | ||
if(vs === -1) { | ||
values.push( { id: id, value: null } ); | ||
continue; | ||
} | ||
let ve = part.indexOf(``, vs); | ||
let value = part.substring(vs+variable.length+2, ve); | ||
if(value.startsWith(`ň`)) v = Number(v1.substring(2, value.length)); else | ||
this.getAllCount = function() { | ||
if(value.startsWith(`క`)) v = value.substring(2, value.length).replace(//g, '\n').replace(/ /g, ``); else | ||
if(!rb()) return null; | ||
if(value.startsWith(`±`)) { | ||
value = value.substring(2, value.length); | ||
if(value === '0') v = false; | ||
if(value === '1') v = true; | ||
} else { | ||
values.push( { id: id, value: null } ); | ||
continue; | ||
} | ||
if(!is_section(section)) { | ||
console.error(`node-nk-base findSection(section): This section(${section}) doesn't exists!`); | ||
return null; | ||
} | ||
values.push( { id: id, value: v } ); | ||
return get_all_count(section); | ||
} | ||
} | ||
} | ||
return values; | ||
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; | ||
} | ||
this.getSectionCount = function() { | ||
let ss = bt.indexOf(`${section}`); | ||
let se = bt.indexOf(`${section}`, ss); | ||
if(!rb()) return null; | ||
let parts = []; | ||
let c = 0; | ||
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))); | ||
} | ||
for(var ss = -1, ss1 = -1, se = -1;;) { | ||
return parts; | ||
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; | ||
} | ||
this.getSectionCount = function() { | ||
return c; | ||
if(!rb()) return null; | ||
} | ||
let c = 0; | ||
for(var ss = -1, ss1 = -1, se = -1;;) { | ||
this.getSections = function() { | ||
ss = bt.indexOf(``, se+1); | ||
ss1 = bt.indexOf(``, ss+1); | ||
if(!rb()) return null; | ||
let section = bt.substring(ss+1, ss1); | ||
let sections = []; | ||
se = bt.indexOf(`${section}`, ss1); | ||
for(var ss = -1, ss1 = -1, se = -1;;) { | ||
if(ss !== -1 && ss1 !==-1 && se !== -1) { | ||
c++; | ||
se += (section.length + 1); | ||
} else break; | ||
ss = bt.indexOf(``, se+1); | ||
ss1 = bt.indexOf(``, ss+1); | ||
} | ||
let section = bt.substring(ss+1, ss1); | ||
return c; | ||
se = bt.indexOf(`${section}`, ss1); | ||
} | ||
if(ss !== -1 && ss1 !==-1 && se !== -1) { | ||
sections.push(section); | ||
se += (section.length + 1); | ||
} else break; | ||
} | ||
this.getSections = function() { | ||
return sections; | ||
if(!rb()) return null; | ||
} | ||
let sections = []; | ||
for(var ss = -1, ss1 = -1, se = -1;;) { | ||
console.log(`node-nk-base started on file "${basefile}"`); | ||
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.1.0", | ||
"version": "1.1.1", | ||
"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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
AI-detected possible typosquat
Supply chain riskAI has identified this package as a potential typosquat of a more popular package. This suggests that the package may be intentionally mimicking another package's name, description, or other metadata.
Found 1 instance in 1 package
36160
736