node-nk-base
Advanced tools
Comparing version 1.0.1 to 1.0.2
247
index.js
function NKB(basefile) { | ||
/* | ||
section: ⟦⸨⸩⸨⸩⟧ | ||
part: ❰❲❳⦃ ⥏ ⦄❱ | ||
var types: ± ň క | ||
var value: 『』 | ||
new string: | ||
// ⟦⸨⸩⸨⸩⟧ ❰❲❳⦃⥏⦄❱ ± ň క 『』 ⥌⍖⥍ | ||
*/ | ||
const fs = require('fs'); | ||
@@ -17,3 +24,3 @@ var bt; | ||
} catch { | ||
console.error(`nkbv3 updateBaseText: can't read file with this path(${basefile})!`); | ||
console.error(`node-nk-base updateBaseText: can't read file with this path(${basefile})!`); | ||
return false; | ||
@@ -31,3 +38,3 @@ } | ||
} catch { | ||
console.error(`nkbv3 writeBase: can't write file with this path(${basefile})!`); | ||
console.error(`node-nk-base writeBase: can't write file with this path(${basefile})!`); | ||
return false; | ||
@@ -49,3 +56,3 @@ } | ||
if((bt.indexOf(`⟦⸨${section}⸩`) != -1 && bt.indexOf(`⸨${section}⸩⟧`) != -1)) return true; else return false; | ||
if((bt.indexOf(`⟦⸨${section}⸩`) != -1 && bt.indexOf(`⸨${section}⸩⟧`) != -1)) return true; else return false; | ||
@@ -59,5 +66,5 @@ } | ||
if((bt.indexOf(`⟦⸨${section}⸩`) != -1 && bt.indexOf(`⸨${section}⸩⟧`) != -1)) { | ||
if((bt.indexOf(`⟦⸨${section}⸩`) != -1 && bt.indexOf(`⸨${section}⸩⟧`) != -1)) { | ||
if(bt.split(`⟦⸨${section}⸩`)[1].split(`⸨${section}⸩⟧`)[0].indexOf(`❰❲${id}❳⦃⥏`) != -1) return true; else return false; | ||
if(bt.split(`⟦⸨${section}⸩`)[1].split(`⸨${section}⸩⟧`)[0].indexOf(`❰❲${id}❳⦃ ⥏ `) != -1) return true; else return false; | ||
@@ -73,7 +80,7 @@ } else return false; | ||
if((bt.indexOf(`⟦⸨${section}⸩`) != -1 && bt.indexOf(`⸨${section}⸩⟧`) != -1)) { | ||
if((bt.indexOf(`⟦⸨${section}⸩`) != -1 && bt.indexOf(`⸨${section}⸩⟧`) != -1)) { | ||
if(bt.indexOf(`❰❲${id}❳⦃⥏`) != -1) { | ||
if(bt.indexOf(`❰❲${id}❳⦃ ⥏ `) != -1) { | ||
if(bt.split(`⟦⸨${section}⸩`)[1].split(`⸨${section}⸩⟧`)[0].split(`❰❲${id}❳⦃`)[1].split(`⥏⦄❱`)[0].indexOf(`⥏${variable}=`) != -1) return true; else return false; | ||
if(bt.split(`⟦⸨${section}⸩`)[1].split(`⸨${section}⸩⟧`)[0].split(`❰❲${id}❳⦃`)[1].split(` ⥏ ⦄❱`)[0].indexOf(` ⥏ ${variable}=`) != -1) return true; else return false; | ||
@@ -91,10 +98,10 @@ } else return false; | ||
let v = bt.split(`⟦⸨${section}⸩`)[1].split(`⸨${section}⸩⟧`)[0].split(`❰❲${id}❳⦃`)[1].split(`⦄❱`)[0].split(`⥏${variable}=`)[1].split(`』⥏`)[0]; | ||
let v = bt.split(`⟦⸨${section}⸩`)[1].split(`⸨${section}⸩⟧`)[0].split(`❰❲${id}❳⦃`)[1].split(`⦄❱`)[0].split(` ⥏ ${variable}=`)[1].split(`』 ⥏ `)[0]; | ||
if(v.startsWith(`ň『`)) return Number(v.split(`ň『`)[1]); | ||
if(v.startsWith(`ň『`)) return Number(v.split(`ň『`)[1]); | ||
if(v.startsWith(`క『`)) return v.split(`క『`)[1].replace(/⥌⍖⥍/g, '\n').replace(/⋞∰⋟/g, '』⥏'); | ||
if(v.startsWith(`క『`)) return v.split(`క『`)[1].replace(//g, '\n').replace(/』 ⥑ /g, `』 ⥏ `); | ||
if(v.startsWith(`±『`)) { | ||
v = v.split(`±『`)[1]; | ||
if(v.startsWith(`±『`)) { | ||
v = v.split(`±『`)[1]; | ||
if(v == '0') return false; | ||
@@ -106,3 +113,3 @@ if(v == '1') return true; | ||
console.error(`nkbv3 get: Can't read value this variable(${variable})!`); | ||
console.error(`node-nk-base get: Can't read value of this variable(${variable})!`); | ||
return false; | ||
@@ -117,23 +124,25 @@ | ||
let v = bt.split(`⟦⸨${section}⸩`)[1].split(`⸨${section}⸩⟧`)[0].split(`❰❲${id}❳⦃`)[1].split(`⦄❱`)[0].split(`⥏${variable}=`)[1].split(`』⥏`)[0]; | ||
let v = bt.split(`⟦⸨${section}⸩`)[1].split(`⸨${section}⸩⟧`)[0].split(`❰❲${id}❳⦃`)[1].split(`⦄❱`)[0].split(` ⥏ ${variable}=`)[1].split(`』 ⥏ `)[0]; | ||
let t; | ||
if(v.startsWith(`ň『`)) t = 'ň'; | ||
if(v.startsWith(`ň『`)) t = 'ň'; | ||
if(v.startsWith(`క『`)) { | ||
if(v.startsWith(`క『`)) { | ||
t = 'క'; | ||
value = String(value).replace(/\n/g, '⥌⍖⥍').replace(/』⥏/g, '⋞∰⋟'); | ||
value = String(value).replace(/\n/g, '').replace(/』 ⥏ /g, '』 ⥑ '); | ||
} | ||
if(v.startsWith(`±『`)) t = '±'; | ||
if(v.startsWith(`±『`)) t = '±'; | ||
if(t == undefined) { | ||
console.error(`nkbv3 get: Can't read value this variable(${variable})!`); | ||
console.error(`node-nk-base get: Can't read value of this variable(${variable})!`); | ||
return false; | ||
} | ||
wb(`${bt.split(`⟦⸨${section}⸩`)[0]}⟦⸨${section}⸩${bt.split(`⟦⸨${section}⸩`)[1].split(`⸨${section}⸩⟧`)[0].replace(`❰❲${id}❳⦃${bt.split(`⟦⸨${section}⸩`)[1].split(`⸨${section}⸩⟧`)[0].split(`❰❲${id}❳⦃`)[1].split(`⥏⦄❱`)[0]}⥏⦄❱`, `❰❲${id}❳⦃${bt.split(`⟦⸨${section}⸩`)[1].split(`⸨${section}⸩⟧`)[0].split(`❰❲${id}❳⦃`)[1].split(`⥏⦄❱`)[0].split(`⥏${variable}=`)[0]}⥏${variable}=${t}『${value}』${bt.split(`⟦⸨${section}⸩`)[1].split(`⸨${section}⸩⟧`)[0].split(`❰❲${id}❳⦃`)[1].split(`⥏⦄❱`)[0].split(`⥏${variable}=${v}』`)[1].split(`⥏⦄❱`)[0]}⥏⦄❱`)}⸨${section}⸩⟧${bt.split(`⸨${section}⸩⟧`)[1]}`); | ||
wb(`${bt.split(`⟦⸨${section}⸩`)[0]}⟦⸨${section}⸩${bt.split(`⟦⸨${section}⸩`)[1].split(`⸨${section}⸩⟧`)[0].replace(`❰❲${id}❳⦃${bt.split(`⟦⸨${section}⸩`)[1].split(`⸨${section}⸩⟧`)[0].split(`❰❲${id}❳⦃`)[1].split(` ⥏ ⦄❱`)[0]} ⥏ ⦄❱`, `❰❲${id}❳⦃${bt.split(`⟦⸨${section}⸩`)[1].split(`⸨${section}⸩⟧`)[0].split(`❰❲${id}❳⦃`)[1].split(` ⥏ ⦄❱`)[0].split(` ⥏ ${variable}=`)[0]} ⥏ ${variable}=${t}『${value}』${bt.split(`⟦⸨${section}⸩`)[1].split(`⸨${section}⸩⟧`)[0].split(`❰❲${id}❳⦃`)[1].split(` ⥏ ⦄❱`)[0].split(` ⥏ ${variable}=${v}』`)[1].split(` ⥏ ⦄❱`)[0]} ⥏ ⦄❱`)}⸨${section}⸩⟧${bt.split(`⸨${section}⸩⟧`)[1]}`); | ||
v = null; | ||
return true; | ||
@@ -148,3 +157,3 @@ } | ||
if(!is_section(section)) { | ||
console.error(`nkbv3 add(section): This section(${section}) doesn't exists!`); | ||
console.error(`node-nk-base add(section): This section(${section}) doesn't exists!`); | ||
return false; | ||
@@ -154,3 +163,3 @@ } | ||
if(!is_part(section, id)) { | ||
console.error(`nkbv3 add(id): Part with this id(${id}) doesn't exists!`); | ||
console.error(`node-nk-base add(id): Part with this id(${id}) doesn't exists!`); | ||
return false; | ||
@@ -160,3 +169,3 @@ } | ||
if(!is_variable(section, id, variable)) { | ||
console.error(`nkbv3 add(variable): This variable(${variable}) doesn't exists!`); | ||
console.error(`node-nk-base add(variable): This variable(${variable}) doesn't exists!`); | ||
return false; | ||
@@ -166,10 +175,10 @@ } | ||
let v = bt.split(`⟦⸨${section}⸩`)[1].split(`⸨${section}⸩⟧`)[0].split(`❰❲${id}❳⦃`)[1].split(`⦄❱`)[0].split(`⥏${variable}=`)[1].split(`』⥏`)[0]; | ||
let v = bt.split(`⟦⸨${section}⸩`)[1].split(`⸨${section}⸩⟧`)[0].split(`❰❲${id}❳⦃`)[1].split(`⦄❱`)[0].split(` ⥏ ${variable}=`)[1].split(`』 ⥏ `)[0]; | ||
let t = false; | ||
if(v.startsWith(`ň『`)) t = 'num'; | ||
if(v.startsWith(`ň『`)) t = 'num'; | ||
if(!t) { | ||
console.error(`nkbv3 add(variable): Function "add" can be used only with number variables!`); | ||
console.error(`node-nk-base add(variable): Function "add" can be used only with number variables!`); | ||
return false; | ||
@@ -179,3 +188,3 @@ } | ||
if(!Number(value) && Number(value) != 0) { | ||
console.error(`nkbv3 add(value): Add value for this variable(${variable}) isn't number!`); | ||
console.error(`node-nk-base add(value): Add value for this variable(${variable}) isn't number!`); | ||
return false; | ||
@@ -185,6 +194,8 @@ } | ||
set(section, id, variable, get(section, id, variable) + Number(value)); | ||
if(!set(section, id, variable, get(section, id, variable) + Number(value))) return false; | ||
v = null; | ||
return true; | ||
} | ||
@@ -198,3 +209,3 @@ | ||
if(!is_section(section)) { | ||
console.error(`nkbv3 append(section): This section(${section}) doesn't exists!`); | ||
console.error(`node-nk-base append(section): This section(${section}) doesn't exists!`); | ||
return false; | ||
@@ -204,3 +215,3 @@ } | ||
if(!is_part(section, id)) { | ||
console.error(`nkbv3 append(id): Part with this id(${id}) doesn't exists!`); | ||
console.error(`node-nk-base append(id): Part with this id(${id}) doesn't exists!`); | ||
return false; | ||
@@ -210,3 +221,3 @@ } | ||
if(!is_variable(section, id, variable)) { | ||
console.error(`nkbv3 append(variable): This variable(${variable}) doesn't exists!`); | ||
console.error(`node-nk-base append(variable): This variable(${variable}) doesn't exists!`); | ||
return false; | ||
@@ -216,10 +227,10 @@ } | ||
let v = bt.split(`⟦⸨${section}⸩`)[1].split(`⸨${section}⸩⟧`)[0].split(`❰❲${id}❳⦃`)[1].split(`⦄❱`)[0].split(`⥏${variable}=`)[1].split(`』⥏`)[0]; | ||
let v = bt.split(`⟦⸨${section}⸩`)[1].split(`⸨${section}⸩⟧`)[0].split(`❰❲${id}❳⦃`)[1].split(`⦄❱`)[0].split(` ⥏ ${variable}=`)[1].split(`』 ⥏ `)[0]; | ||
let t = false; | ||
if(v.startsWith(`క『`) ) t = 'str'; | ||
if(v.startsWith(`క『`) ) t = 'str'; | ||
if(!t) { | ||
console.error(`nkbv3 append(variable): Function "append" can be used only with string variables!`); | ||
console.error(`node-nk-base append(variable): Function "append" can be used only with string variables!`); | ||
return false; | ||
@@ -229,3 +240,3 @@ } | ||
if(!String(value) && value != '') { | ||
console.error(`nkbv3 append(value): Append value for this variable(${variable}) isn't string!`); | ||
console.error(`node-nk-base append(value): Append value for this variable(${variable}) isn't string!`); | ||
return false; | ||
@@ -235,5 +246,7 @@ } | ||
set(section, id, variable, String(get(section, id, variable)) + String(value)); | ||
if(!set(section, id, variable, get(section, id, variable) + String(value))) return false; | ||
v = null; | ||
return true; | ||
@@ -246,8 +259,18 @@ } | ||
if(!is_section(section)) { | ||
console.error(`nkbv3 getAllCount(section): This section(${section}) don't exists!`); | ||
console.error(`node-nk-base getAllCount(section): This section(${section}) don't exists!`); | ||
return; | ||
} | ||
return bt.split(`⟦⸨${section}⸩`)[1].split(`⸨${section}⸩⟧`)[0].split(`❳⦃⥏`).length-1; | ||
let c = [ | ||
bt.split(`⟦⸨${section}⸩`)[1].split(`⸨${section}⸩⟧`)[0].split(`❰❲`).length-1, | ||
bt.split(`⟦⸨${section}⸩`)[1].split(`⸨${section}⸩⟧`)[0].split(`❳⦃ ⥏ `).length-1, | ||
bt.split(`⟦⸨${section}⸩`)[1].split(`⸨${section}⸩⟧`)[0].split(` ⥏ ⦄❱`).length-1 | ||
] | ||
if(c[0] == c[1] == c[2]) return bt.split(`⟦⸨${section}⸩`)[1].split(`⸨${section}⸩⟧`)[0].split(`❳⦃ ⥏ `).length-1; | ||
c.sort( (a, b) => { return a = b } ); | ||
return c[0]; | ||
} | ||
@@ -266,3 +289,3 @@ | ||
if(!is_section(section)) { | ||
console.error(`nkbv3 get(section): This section(${section}) doesn't exists!`); | ||
console.error(`node-nk-base get(section): This section(${section}) doesn't exists!`); | ||
return false; | ||
@@ -272,3 +295,3 @@ } | ||
if(!is_part(section, id)) { | ||
console.error(`nkbv3 get(id): Part with this id(${id}) doesn't exists!`); | ||
console.error(`node-nk-base get(id): Part with this id(${id}) doesn't exists!`); | ||
return false; | ||
@@ -278,3 +301,3 @@ } | ||
if(!is_variable(section, id, variable)) { | ||
console.error(`nkbv3 get(variable): This variable(${variable}) doesn't exists!`); | ||
console.error(`node-nk-base get(variable): This variable(${variable}) doesn't exists!`); | ||
return false; | ||
@@ -293,3 +316,3 @@ } | ||
if(!is_section(section)) { | ||
console.error(`nkbv3 set(section): This section(${section}) doesn't exists!`); | ||
console.error(`node-nk-base set(section): This section(${section}) doesn't exists!`); | ||
return false; | ||
@@ -299,3 +322,3 @@ } | ||
if(!is_part(section, id)) { | ||
console.error(`nkbv3 set(id): Part with this id(${id}) doesn't exists!`); | ||
console.error(`node-nk-base set(id): Part with this id(${id}) doesn't exists!`); | ||
return false; | ||
@@ -305,3 +328,3 @@ } | ||
if(!is_variable(section, id, variable)) { | ||
console.error(`nkbv3 set(variable): This variable(${variable}) doesn't exists!`); | ||
console.error(`node-nk-base set(variable): This variable(${variable}) doesn't exists!`); | ||
return false; | ||
@@ -311,11 +334,11 @@ } | ||
let v = bt.split(`⟦⸨${section}⸩`)[1].split(`⸨${section}⸩⟧`)[0].split(`❰❲${id}❳⦃`)[1].split(`⦄❱`)[0].split(`⥏${variable}=`)[1].split(`』⥏`)[0]; | ||
let v = bt.split(`⟦⸨${section}⸩`)[1].split(`⸨${section}⸩⟧`)[0].split(`❰❲${id}❳⦃`)[1].split(`⦄❱`)[0].split(` ⥏ ${variable}=`)[1].split(`』 ⥏ `)[0]; | ||
let t = false; | ||
if(v.startsWith(`ň『`) && (Number(value) || Number(value) == 0)) t = 'num'; | ||
if(v.startsWith(`ň『`) && (Number(value) || Number(value) == 0)) t = 'num'; | ||
if(v.startsWith(`క『`) && (String(value) || value == '')) t = 'str'; | ||
if(v.startsWith(`క『`) && (String(value) || value == '')) t = 'str'; | ||
if(v.startsWith(`±『`) && (value == true || value == false)) { | ||
if(v.startsWith(`±『`) && (value == true || value == false)) { | ||
t = 'bool'; | ||
@@ -327,3 +350,3 @@ if(value == true) value = '1'; | ||
if(!t) { | ||
console.error(`nkbv3 set(value): Type of value(${value}) doesn't match with type of variable(${variable})!`); | ||
console.error(`node-nk-base set(value): Type of value(${value}) doesn't match with type of variable(${variable})!`); | ||
return false; | ||
@@ -337,2 +360,4 @@ } | ||
return true; | ||
} | ||
@@ -350,8 +375,10 @@ | ||
if(is_section(section)) { | ||
console.error(`nkbv3 createSection: Section "${section}" already exists!`); | ||
console.error(`node-nk-base createSection: Section "${section}" already exists!`); | ||
return false; | ||
} | ||
wb(bt + `⟦⸨${section}⸩⸨${section}⸩⟧`); | ||
wb(bt + `⟦⸨${section}⸩⸨${section}⸩⟧`); | ||
return true; | ||
} | ||
@@ -365,8 +392,10 @@ | ||
if(!is_section(section)) { | ||
console.error(`nkbv3 createSection: Section "${section}" doesn't exists!`); | ||
console.error(`node-nk-base createSection: Section "${section}" doesn't exists!`); | ||
return false; | ||
} | ||
wb(bt.replace(`⟦⸨${section}⸩${bt.split(`⟦⸨${section}⸩`)[1].split(`⸨${section}⸩⟧`)[0]}⸨${section}⸩⟧`, '')); | ||
wb(bt.replace(`⟦⸨${section}⸩${bt.split(`⟦⸨${section}⸩`)[1].split(`⸨${section}⸩⟧`)[0]}⸨${section}⸩⟧`, '')); | ||
return true; | ||
} | ||
@@ -380,3 +409,3 @@ | ||
if(!is_section(section)) { | ||
console.error(`nkbv3 findSection(section): This section(${section}) doesn't exists!`); | ||
console.error(`node-nk-base findSection(section): This section(${section}) doesn't exists!`); | ||
return false; | ||
@@ -391,15 +420,16 @@ } | ||
if(is_part(section, id)) { | ||
console.error(`nkbv3 createPart(id): Part with this id(${id}) already exists!`); | ||
console.error(`node-nk-base createPart(id): Part with this id(${id}) already exists!`); | ||
return false; | ||
} | ||
let newbt = bt.split(`⸨${section}⸩⟧`)[0] + `❰❲${id}❳⦃`; | ||
let err = false; | ||
let newbt = bt.split(`⸨${section}⸩⟧`)[0] + `❰❲${id}❳⦃`; | ||
vars.map( (x) => { | ||
if(x[1] == '±' || x[1] == 'ň' || x[1] == 'క') { | ||
if(x[1] == Number || x[1] == String || x[1] == Boolean) { | ||
if(x[1] == 'ň' && !Number(x[2]) && Number(x[2]) != 0) { | ||
console.error(`nkbv3 createPart(variables): Number value is wrong [${x[0]} = ${x[2]}]`); | ||
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; | ||
@@ -409,8 +439,8 @@ return false; | ||
if(x[1] == 'క' && (String(x[2]) || x[2] == '')) { | ||
x[2] = String(x[2]).replace(/\n/g, '⥌⍖⥍'); | ||
if(x[1] == String && (String(x[2]) || x[2] == '')) { | ||
x[2] = String(x[2]).replace(/\n/g, ''); | ||
} | ||
if(x[1] == '±' && !(x[2] == true || x[2] == false)) { | ||
console.error(`nkbv3 createPart(variables): Bool value is wrong [${x[0]} = ${x[2]}]`); | ||
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; | ||
@@ -420,3 +450,3 @@ return false; | ||
if(x[1] == `±` && (x[2] == true || x[2] == false)) { | ||
if(x[1] == Boolean && (x[2] == true || x[2] == false)) { | ||
if(x[2] == true) x[2] = '1'; | ||
@@ -426,4 +456,7 @@ if(x[2] == false) x[2] = '0'; | ||
newbt += `⥏${x[0]}=${x[1]}『${x[2]}』`; | ||
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(${variable}) is wrong!`); | ||
return false; | ||
} | ||
@@ -433,6 +466,8 @@ | ||
newbt += `⥏⦄❱⸨${section}⸩⟧` + bt.split(`⸨${section}⸩⟧`)[1]; | ||
newbt += ` ⥏ ⦄❱⸨${section}⸩⟧` + bt.split(`⸨${section}⸩⟧`)[1]; | ||
if(!err) wb(newbt); else return false; | ||
newbt = null; | ||
return true; | ||
} | ||
@@ -446,8 +481,10 @@ | ||
if(!is_part(section, id)) { | ||
console.error(`nkbv3 deletePart(id): Part with this id(${id}) doesn't exists!`); | ||
console.error(`node-nk-base deletePart(id): Part with this id(${id}) doesn't exists!`); | ||
return false; | ||
} | ||
wb(`${bt.split(`⟦⸨${section}⸩`)[0]}⟦⸨${section}⸩${bt.split(`⟦⸨${section}⸩`)[1].split(`⸨${section}⸩⟧`)[0].replace(`❰❲${id}❳⦃${bt.split(`⟦⸨${section}⸩`)[1].split(`⸨${section}⸩⟧`)[0].split(`❰❲${id}❳⦃`)[1].split(`⥏⦄❱`)[0]}⥏⦄❱`, '')}⸨${section}⸩⟧${bt.split(`⸨${section}⸩⟧`)[1]}`); | ||
wb(`${bt.split(`⟦⸨${section}⸩`)[0]}⟦⸨${section}⸩${bt.split(`⟦⸨${section}⸩`)[1].split(`⸨${section}⸩⟧`)[0].replace(`❰❲${id}❳⦃${bt.split(`⟦⸨${section}⸩`)[1].split(`⸨${section}⸩⟧`)[0].split(`❰❲${id}❳⦃`)[1].split(` ⥏ ⦄❱`)[0]} ⥏ ⦄❱`, '')}⸨${section}⸩⟧${bt.split(`⸨${section}⸩⟧`)[1]}`); | ||
return true; | ||
} | ||
@@ -462,3 +499,3 @@ | ||
if(!is_part(section, id)) { | ||
console.error(`nkbv3 findPart(id): Part with this id(${id}) doesn't exists!`); | ||
console.error(`node-nk-base findPart(id): Part with this id(${id}) doesn't exists!`); | ||
return; | ||
@@ -473,3 +510,3 @@ } | ||
if(!is_section(section)) { | ||
console.error(`nkbv3 get(section): This section(${section}) doesn't exists!`); | ||
console.error(`node-nk-base get(section): This section(${section}) doesn't exists!`); | ||
return false; | ||
@@ -479,3 +516,3 @@ } | ||
if(!is_part(section, id)) { | ||
console.error(`nkbv3 get(id): Part with this id(${id}) doesn't exists!`); | ||
console.error(`node-nk-base get(id): Part with this id(${id}) doesn't exists!`); | ||
return false; | ||
@@ -485,3 +522,3 @@ } | ||
if(!is_variable(section, id, variable)) { | ||
console.error(`nkbv3 get(variable): This variable(${variable}) doesn't exists!`); | ||
console.error(`node-nk-base get(variable): This variable(${variable}) doesn't exists!`); | ||
return false; | ||
@@ -500,3 +537,3 @@ } | ||
if(!is_section(section)) { | ||
console.error(`nkbv3 set(section): This section(${section}) doesn't exists!`); | ||
console.error(`node-nk-base set(section): This section(${section}) doesn't exists!`); | ||
return false; | ||
@@ -506,3 +543,3 @@ } | ||
if(!is_part(section, id)) { | ||
console.error(`nkbv3 set(id): Part with this id(${id}) doesn't exists!`); | ||
console.error(`node-nk-base set(id): Part with this id(${id}) doesn't exists!`); | ||
return false; | ||
@@ -512,3 +549,3 @@ } | ||
if(!is_variable(section, id, variable)) { | ||
console.error(`nkbv3 set(variable): This variable(${variable}) doesn't exists!`); | ||
console.error(`node-nk-base set(variable): This variable(${variable}) doesn't exists!`); | ||
return false; | ||
@@ -518,11 +555,11 @@ } | ||
let v = bt.split(`⟦⸨${section}⸩`)[1].split(`⸨${section}⸩⟧`)[0].split(`❰❲${id}❳⦃`)[1].split(`⦄❱`)[0].split(`⥏${variable}=`)[1].split(`』⥏`)[0]; | ||
let v = bt.split(`⟦⸨${section}⸩`)[1].split(`⸨${section}⸩⟧`)[0].split(`❰❲${id}❳⦃`)[1].split(`⦄❱`)[0].split(` ⥏ ${variable}=`)[1].split(`』 ⥏ `)[0]; | ||
let t = false; | ||
if(v.startsWith(`ň『`) && (Number(value) || Number(value) == 0)) t = 'num'; | ||
if(v.startsWith(`ň『`) && (Number(value) || Number(value) == 0)) t = 'num'; | ||
if(v.startsWith(`క『`) && (String(value) || value == '')) t = 'str'; | ||
if(v.startsWith(`క『`) && (String(value) || value == '')) t = 'str'; | ||
if(v.startsWith(`±『`) && (value == true || value == false)) { | ||
if(v.startsWith(`±『`) && (value == true || value == false)) { | ||
t = 'bool'; | ||
@@ -534,3 +571,3 @@ if(value == true) value = '1'; | ||
if(!t) { | ||
console.error(`nkbv3 set(value): Type of value(${value}) doesn't match with type of variable(${variable})!`); | ||
console.error(`node-nk-base set(value): Type of value(${value}) doesn't match with type of this variable(${variable})!`); | ||
return false; | ||
@@ -540,6 +577,8 @@ } | ||
set(section, id, variable, value); | ||
if(!set(section, id, variable, value)) return false; | ||
v = null; | ||
return true; | ||
} | ||
@@ -568,3 +607,3 @@ | ||
if(is_variable(section, id, variable)) { | ||
console.error(`nkbv3 createVariable(variable): This variable(${variable}) already exists!`); | ||
console.error(`node-nk-base createVariable(variable): This variable(${variable}) already exists!`); | ||
return; | ||
@@ -576,13 +615,13 @@ } | ||
if(type == `ň` || type == `క` || type == `±`) t = true; | ||
if(type == Number || type == String || type == Boolean) t = true; | ||
if(type == `ň` && Number(value) && Number(value) != 0) vt = 'num'; | ||
if(type == Number && Number(value) && Number(value) != 0) vt = Number; | ||
if(type == `క` && (String(value) || value == '')) { | ||
vt = 'str'; | ||
if(type == String && (String(value) || value == '')) { | ||
vt = String; | ||
value = value.replace(/\n/g, '⥌⍖⥍'); | ||
} | ||
if(type == `±` && (value == true || value == false)) { | ||
vt = 'bool'; | ||
if(type == Boolean && (value == true || value == false)) { | ||
vt = Boolean; | ||
if(value == true) value = '1'; | ||
@@ -594,3 +633,3 @@ if(value == false) value = '0'; | ||
if(!t) { | ||
console.error(`nkbv3 createVariable(type): Type of this variable(${variable}) is wrong!`); | ||
console.error(`node-nk-base createVariable(type): Type of this variable(${variable}) is wrong!`); | ||
return false; | ||
@@ -600,3 +639,3 @@ } | ||
if(!vt) { | ||
console.error(`nkbv3 createVariable(value): Value for this variable(${variable}) doesn't match with type of this variable!`); | ||
console.error(`node-nk-base createVariable(value): Value for this variable(${variable}) doesn't match with type of this variable!`); | ||
return false; | ||
@@ -606,4 +645,6 @@ } | ||
wb(`${bt.split(`⟦⸨${section}⸩`)[0]}⟦⸨${section}⸩${bt.split(`⟦⸨${section}⸩`)[1].split(`⸨${section}⸩⟧`)[0].replace(`❰❲${id}❳⦃${bt.split(`⟦⸨${section}⸩`)[1].split(`⸨${section}⸩⟧`)[0].split(`❰❲${id}❳⦃`)[1].split(`⥏⦄❱`)[0]}⥏⦄❱`, `❰❲${id}❳⦃${bt.split(`⟦⸨${section}⸩`)[1].split(`⸨${section}⸩⟧`)[0].split(`❰❲${id}❳⦃`)[1].split(`⥏⦄❱`)[0]}⥏${variable}=${type}『${value}』⥏⦄❱`)}⸨${section}⸩⟧${bt.split(`⸨${section}⸩⟧`)[1]}`); | ||
wb(`${bt.split(`⟦⸨${section}⸩`)[0]}⟦⸨${section}⸩${bt.split(`⟦⸨${section}⸩`)[1].split(`⸨${section}⸩⟧`)[0].replace(`❰❲${id}❳⦃${bt.split(`⟦⸨${section}⸩`)[1].split(`⸨${section}⸩⟧`)[0].split(`❰❲${id}❳⦃`)[1].split(` ⥏ ⦄❱`)[0]} ⥏ ⦄❱`, `❰❲${id}❳⦃${bt.split(`⟦⸨${section}⸩`)[1].split(`⸨${section}⸩⟧`)[0].split(`❰❲${id}❳⦃`)[1].split(` ⥏ ⦄❱`)[0]} ⥏ ${variable}=${(type == Number ? 'ň' : "") + (type == String ? 'క' : "") + (type == Boolean ? '±' : "")}『${value}』 ⥏ ⦄❱`)}⸨${section}⸩⟧${bt.split(`⸨${section}⸩⟧`)[1]}`); | ||
return true; | ||
} | ||
@@ -617,11 +658,14 @@ | ||
if(!is_variable(section, id, variable)) { | ||
console.error(`nkbv3 deleteVariable(variable): This variable(${variable}) doesn't exists!`); | ||
console.error(`node-nk-base deleteVariable(variable): This variable(${variable}) doesn't exists!`); | ||
return false; | ||
} | ||
let v = bt.split(`⟦⸨${section}⸩`)[1].split(`⸨${section}⸩⟧`)[0].split(`❰❲${id}❳⦃`)[1].split(`⦄❱`)[0].split(`⥏${variable}=`)[1].split(`』⥏`)[0]; | ||
let v = bt.split(`⟦⸨${section}⸩`)[1].split(`⸨${section}⸩⟧`)[0].split(`❰❲${id}❳⦃`)[1].split(`⦄❱`)[0].split(` ⥏ ${variable}=`)[1].split(`』 ⥏ `)[0]; | ||
wb(`${bt.split(`⟦⸨${section}⸩`)[0]}⟦⸨${section}⸩${bt.split(`⟦⸨${section}⸩`)[1].split(`⸨${section}⸩⟧`)[0].replace(`❰❲${id}❳⦃${bt.split(`⟦⸨${section}⸩`)[1].split(`⸨${section}⸩⟧`)[0].split(`❰❲${id}❳⦃`)[1].split(`⥏⦄❱`)[0]}⥏⦄❱`, `❰❲${id}❳⦃${bt.split(`⟦⸨${section}⸩`)[1].split(`⸨${section}⸩⟧`)[0].split(`❰❲${id}❳⦃`)[1].split(`⥏⦄❱`)[0]}⥏⦄❱`.replace(`⥏${variable}=${v}』`,''))}⸨${section}⸩⟧${bt.split(`⸨${section}⸩⟧`)[1]}`); | ||
wb(`${bt.split(`⟦⸨${section}⸩`)[0]}⟦⸨${section}⸩${bt.split(`⟦⸨${section}⸩`)[1].split(`⸨${section}⸩⟧`)[0].replace(`❰❲${id}❳⦃${bt.split(`⟦⸨${section}⸩`)[1].split(`⸨${section}⸩⟧`)[0].split(`❰❲${id}❳⦃`)[1].split(` ⥏ ⦄❱`)[0]} ⥏ ⦄❱`, `❰❲${id}❳⦃${bt.split(`⟦⸨${section}⸩`)[1].split(`⸨${section}⸩⟧`)[0].split(`❰❲${id}❳⦃`)[1].split(` ⥏ ⦄❱`)[0]} ⥏ ⦄❱`.replace(` ⥏ ${variable}=${v}』`,''))}⸨${section}⸩⟧${bt.split(`⸨${section}⸩⟧`)[1]}`); | ||
v = null; | ||
return true; | ||
} | ||
@@ -634,4 +678,7 @@ | ||
this.getAllCount = function() { | ||
if(!u_bt()) return false; | ||
return get_all_count(section); | ||
} | ||
@@ -649,7 +696,7 @@ | ||
for(var i = 1; i < count+1; i++) { | ||
parts.push(bt.split(`⟦⸨${section}⸩`)[1].split(`⸨${section}⸩⟧`)[0].split(`❰❲`)[i].split(`❳⦃`)[0]); | ||
parts.push(bt.split(`⟦⸨${section}⸩`)[1].split(`⸨${section}⸩⟧`)[0].split(`❰❲`)[i].split(`❳⦃ ⥏ `)[0]); | ||
} | ||
return parts; | ||
} | ||
@@ -656,0 +703,0 @@ |
{ | ||
"name": "node-nk-base", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"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
23126
402