Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

wio.db

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wio.db - npm Package Compare versions

Comparing version 4.0.9 to 4.0.10

tslint.json

162

lib/main.d.ts
import { table } from "./table";
/**
*
* db
* @class db
*/
declare class db {
/**
*
* table
* @static
* @memberof db
*/
static table: typeof table;
/**
*
* fetch
* @static
* @param {string} userData
* @returns {*}
* @memberof db
*/
static fetch(userData: string): any;
/**
*
* set
* @static
* @param {string} userData
* @param {*} value
* @memberof db
*/
static set(userData: string, value: any): void;
/**
*
* add
* @static
* @param {string} userData
* @param {number} value
* @returns {void}
* @memberof db
*/
static add(userData: string, value: number): void;
/**
*
* delete
* @static
* @param {*} userData
* @memberof db
*/
static delete(userData: any): void;
/**
*
* fetchAll
* @static
* @returns {object}
* @memberof db
*/
static fetchAll(): object;
/**
*
* has
* @static
* @param {string} userData
* @returns {(true | false)}
* @memberof db
*/
static has(userData: string): true | false;
/**
*
* arrayDeleteVal
* @static
* @param {string} userData
* @param {*} value
* @memberof db
*/
static arrayDeleteVal(userData: string, value: any): void;
/**
*
* arrayHas
* @static
* @param {string} userData
* @param {*} value
* @returns {boolean}
* @memberof db
*/
static arrayHas(userData: string, value: any): boolean;
/**
*
* clearDB
* @static
* @memberof db
*/
static clearDB(): void;
/**
*
* deleteDataEach
* @static
* @param {string} userData
* @memberof db
*/
static deleteDataEach(userData: string): void;
/**
*
* includes
* @static
* @param {string} userData
* @returns {Array<any>}
* @memberof db
*/
static includes(userData: string): Array<any>;
/**
*
* objectDeleteKey
* @static
* @param {string} userData
* @param {*} key
* @memberof db
*/
static objectDeleteKey(userData: string, key: any): void;
/**
*
* push
* @static
* @param {string} userData
* @param {*} value
* @memberof db
*/
static push(userData: string, value: any): void;
/**
*
* startsWith
* @static
* @param {string} userData
* @returns {(Array<any> | null)}
* @memberof db
*/
static startsWith(userData: string): Array<any> | null;
/**
*
* backup
* @static
* @param {string} file
* @memberof db
*/
static backup(file: string): void;
static filter(callback: any): any;
/**
*
* filter
* @static
* @param {*} func
* @returns {*}
* @memberof db
*/
static filter(func: any): any;
/**
*
* find
* @static
* @param {*} callback
* @returns {*}
* @memberof db
*/
static find(callback: any): any;
/**
*
* backupLoad
* @static
* @param {string} file
* @memberof db
*/
static backupLoad(file: string): void;
static substr(userData: string, value: number): void;
/**
*
* substr
* @static
* @param {string} userData
* @param {number} value
* @memberof db
*/
static subbstr(userData: string, value: number): void;
}
export { db };

270

lib/main.js

@@ -6,4 +6,4 @@ "use strict";

const table_1 = require("./table");
const oku = () => JSON.parse(fs_1.readFileSync('./database.json', 'utf8'));
const yazdir = (data) => fs_1.writeFileSync('./database.json', JSON.stringify(data, null, 2));
const oku = () => JSON.parse(fs_1.readFileSync("./database.json", "utf8"));
const yazdir = (data) => fs_1.writeFileSync("./database.json", JSON.stringify(data, null, 2));
const err = (e) => TypeError(e);

@@ -16,15 +16,36 @@ try {

}
/**
*
* db
* @class db
*/
class db {
/**
*
* fetch
* @static
* @param {string} userData
* @returns {*}
* @memberof db
*/
static fetch(userData) {
if (!userData)
throw err('Çekilicek veri belirtilmedi.');
throw err("Çekilicek veri belirtilmedi.");
const data = oku();
return data[userData] ? data[userData] : null;
}
/**
*
* set
* @static
* @param {string} userData
* @param {*} value
* @memberof db
*/
static set(userData, value) {
if (!userData)
throw err('Tanımlanmayan değer.');
throw err("Tanımlanmayan değer.");
if (isNaN(value))
if (!value)
throw err('Tanımlanmayan değer.');
throw err("Tanımlanmayan değer.");
const data = oku();

@@ -34,2 +55,11 @@ data[userData] = value;

}
/**
*
* add
* @static
* @param {string} userData
* @param {number} value
* @returns {void}
* @memberof db
*/
static add(userData, value) {

@@ -39,6 +69,6 @@ const data = oku();

if (!value)
throw err('Ekliyeceğim şeyi belirtmelisin.');
if (typeof value != 'number')
throw err('Ekliyeceğim şey sayı türünden olmalıdır.');
if (data[userData] == undefined)
throw err("Ekliyeceğim şeyi belirtmelisin.");
if (typeof value != "number")
throw err("Ekliyeceğim şey sayı türünden olmalıdır.");
if (data[userData] === undefined)
return this.set(userData, value);

@@ -48,17 +78,39 @@ data[userData] += value;

}
/**
*
* delete
* @static
* @param {*} userData
* @memberof db
*/
static delete(userData) {
if (isNaN(userData)) {
if (!userData)
throw err('Neyi silmem gerektigini anlamadım.');
throw err("Neyi silmem gerektigini anlamadım.");
}
const data = oku();
if (!data[userData])
throw err('Böyle bir veri yok ki sileyim.');
if (!data[userData] && data[userData] !== 0)
throw err("Böyle bir veri yok ki sileyim.");
delete data[userData];
yazdir(data);
}
/**
*
* fetchAll
* @static
* @returns {object}
* @memberof db
*/
static fetchAll() {
let data = oku();
const data = oku();
return data;
}
/**
*
* has
* @static
* @param {string} userData
* @returns {(true | false)}
* @memberof db
*/
static has(userData) {

@@ -68,33 +120,64 @@ const data = oku();

}
/**
*
* arrayDeleteVal
* @static
* @param {string} userData
* @param {*} value
* @memberof db
*/
static arrayDeleteVal(userData, value) {
if (!userData || !value)
throw err('Parametreleri girin.');
throw err("Parametreleri girin.");
const data = this.fetch(userData);
if (Array.isArray(data) == false)
throw err('Veri Array olmak zorundadır.');
if (this.arrayHas(userData, value) == false)
if (!Array.isArray(data))
throw err("Veri Array olmak zorundadır.");
if (!this.arrayHas(userData, value))
throw err("Array'de böyle veri yok silemiyorum.");
var newArr = [];
data.filter((a) => a != value)
const newArr = [];
data
.filter((a) => a !== value)
.forEach((a) => newArr.push(a));
this.set(userData, newArr);
}
/**
*
* arrayHas
* @static
* @param {string} userData
* @param {*} value
* @returns {boolean}
* @memberof db
*/
static arrayHas(userData, value) {
if (!userData || !value)
throw err('Parametreleri girin.');
throw err("Parametreleri girin.");
const data = this.fetch(userData);
if (Array.isArray(data) == false)
throw err('Veri Array olmak zorundadır.');
if (!Array.isArray(data))
throw err("Veri Array olmak zorundadır.");
return data.indexOf(value) > -1 ? true : false;
}
/**
*
* clearDB
* @static
* @memberof db
*/
static clearDB() {
yazdir({});
}
/**
*
* deleteDataEach
* @static
* @param {string} userData
* @memberof db
*/
static deleteDataEach(userData) {
if (!userData)
throw err('Silmem gereken veriyi tanımlayın.');
throw err("Silmem gereken veriyi tanımlayın.");
const allData = oku();
let keys = Object.keys(allData);
if (keys == '')
throw err('Böyle bir veri yok silemem.');
if (keys == "")
throw err("Böyle bir veri yok silemem.");
keys = keys.filter((a) => a.includes(userData));

@@ -105,43 +188,76 @@ keys.forEach((a) => {

}
/**
*
* includes
* @static
* @param {string} userData
* @returns {Array<any>}
* @memberof db
*/
static includes(userData) {
if (!userData)
throw err('Çekmem gereken veriyi belirtin.');
throw err("Çekmem gereken veriyi belirtin.");
const allData = oku();
let keys = Object.keys(allData);
keys = keys.filter((a) => a.includes(userData));
if (keys == '')
throw err('Databasede böyle veri yok.');
if (keys === "")
throw err("Databasede böyle veri yok.");
return keys;
}
/**
*
* objectDeleteKey
* @static
* @param {string} userData
* @param {*} key
* @memberof db
*/
static objectDeleteKey(userData, key) {
if (!userData)
throw err('Lütfen veriyi belirtin.');
throw err("Lütfen veriyi belirtin.");
if (!key)
throw err('Silinicek veriyi belirtin.');
throw err("Silinicek veriyi belirtin.");
const f = this.has(userData);
if (!f)
throw err('Böyle bir veri yok.');
throw err("Böyle bir veri yok.");
const data = this.fetch(userData);
if (typeof data != 'object' || Array.isArray(data))
throw err('Belirtilen veri object tipinde bir veri değil.');
if (typeof data != "object" || Array.isArray(data))
throw err("Belirtilen veri object tipinde bir veri değil.");
if (!data[key])
throw err('Belirtilen veride böyle bir key yok.');
throw err("Belirtilen veride böyle bir key yok.");
delete data[key];
this.set(userData, data);
}
/**
*
* push
* @static
* @param {string} userData
* @param {*} value
* @memberof db
*/
static push(userData, value) {
const data = oku();
if (Array.isArray(data[userData]) == false)
throw err('Girilen değer Array olmak zorundadır.');
if (!Array.isArray(data[userData]))
throw err("Girilen değer Array olmak zorundadır.");
data[userData].push(value);
yazdir(data);
}
/**
*
* startsWith
* @static
* @param {string} userData
* @returns {(Array<any> | null)}
* @memberof db
*/
static startsWith(userData) {
if (!userData)
throw err('Bulunacak değer belirtilmedi..!');
throw err("Bulunacak değer belirtilmedi..!");
const data = oku();
let arr = [];
const arr = [];
const res = [];
let keys = Object.keys(data);
keys.filter((a) => a.startsWith(userData))
const keys = Object.keys(data);
keys
.filter((a) => a.startsWith(userData))
.forEach((a) => arr.push(a));

@@ -151,3 +267,3 @@ arr.forEach((a) => {

});
if (res.length == 0)
if (res.length === 0)
return null;

@@ -157,39 +273,75 @@ else

}
/**
*
* backup
* @static
* @param {string} file
* @memberof db
*/
static backup(file) {
if (!file)
throw err('Yedekliyecegim dosyanın ismini yaz.');
if (!file.endsWith('.json'))
throw err('Yedekliyecegim dosya json uzantılı olmalı.');
throw err("Yedekliyecegim dosyanın ismini yaz.");
if (!file.endsWith(".json"))
throw err("Yedekliyecegim dosya json uzantılı olmalı.");
const data = oku();
fs_1.writeFileSync("./" + file, JSON.stringify(data, null, 4));
fs_1.writeFileSync(`./${file}`, JSON.stringify(data, null, 4));
}
static filter(callback) {
/**
*
* filter
* @static
* @param {*} func
* @returns {*}
* @memberof db
*/
static filter(func) {
const arr = [];
const all = this.fetchAll();
for (var i in all) {
if (callback(all[i]))
for (const i in all) {
if (func(all[i]))
arr.push(all[i]);
}
;
return arr;
}
/**
*
* find
* @static
* @param {*} callback
* @returns {*}
* @memberof db
*/
static find(callback) {
return this.filter(callback)[0];
}
;
/**
*
* backupLoad
* @static
* @param {string} file
* @memberof db
*/
static backupLoad(file) {
if (!file)
throw err('Yedekliyecegim dosyanın ismini yaz.');
if (!file.endsWith('.json'))
throw err('Yedekliyecegim dosya json uzantılı olmalı.');
throw err("Yedekliyecegim dosyanın ismini yaz.");
if (!file.endsWith(".json"))
throw err("Yedekliyecegim dosya json uzantılı olmalı.");
const data = oku();
try {
oku();
fs_1.writeFileSync('./database.json', JSON.stringify(data, null, 2));
fs_1.writeFileSync("./database.json", JSON.stringify(data, null, 2));
}
catch (_a) {
fs_1.writeFileSync('./database.json', JSON.stringify(data, null, 2));
fs_1.writeFileSync("./database.json", JSON.stringify(data, null, 2));
}
}
static substr(userData, value) {
/**
*
* substr
* @static
* @param {string} userData
* @param {number} value
* @memberof db
*/
static subbstr(userData, value) {
if (!userData || !value)

@@ -211,2 +363,8 @@ throw err("Parametreleri düzgün girin.");

exports.db = db;
/**
*
* table
* @static
* @memberof db
*/
db.table = table_1.table;

@@ -0,7 +1,47 @@

/**
*
* table
* @export
* @class table
*/
export declare class table {
/**
* Creates an instance of table.
* @memberof table
*/
constructor();
/**
*
* createTable
* @param {string} key
* @memberof table
*/
createTable(key: string): void;
/**
*
* set
* @param {*} key
* @param {*} value
* @memberof table
*/
set(key: any, value: any): void;
filter(key: any, callback: any): any[];
/**
*
* filter
* @param {*} key
* @param {*} callback
* @returns
* @memberof table
*/
filter(key: any, callback: any): any;
/**
*
* find
* @param {*} key
* @param {*} callback
* @returns
* @memberof table
*/
find(key: any, callback: any): any;
5: any;
}

@@ -5,13 +5,43 @@ "use strict";

const main_1 = require("./main");
/**
*
* table
* @export
* @class table
*/
class table {
/**
* Creates an instance of table.
* @memberof table
*/
constructor() {
void 0;
}
;
/**
*
* createTable
* @param {string} key
* @memberof table
*/
createTable(key) {
main_1.db.set(key, []);
}
;
/**
*
* set
* @param {*} key
* @param {*} value
* @memberof table
*/
set(key, value) {
main_1.db.push(key, value);
}
/**
*
* filter
* @param {*} key
* @param {*} callback
* @returns
* @memberof table
*/
filter(key, callback) {

@@ -26,2 +56,10 @@ const fetched = main_1.db.fetch(key);

}
/**
*
* find
* @param {*} key
* @param {*} callback
* @returns
* @memberof table
*/
find(key, callback) {

@@ -32,2 +70,1 @@ return this.filter(key, callback)[0];

exports.table = table;
;
{
"name": "wio.db",
"version": "4.0.9",
"version": "4.0.10",
"description": "Gözle okunabilir database modülü.",

@@ -26,9 +26,9 @@ "main": "./lib/index.js",

},
"dependencies": {
"@types/ws": "^7.2.6",
"fs": "0.0.1-security"
},
"devDependencies": {
"@types/node": "^14.6.4"
"@types/node": "^14.6.4",
"eslint": "^5.16.0",
"eslint-config-airbnb-base": "^14.2.0",
"eslint-plugin-import": "^2.22.1",
"tslint": "^6.1.3"
}
}

@@ -0,1 +1,2 @@

# KODLAR ÇALINMA DURUMUNDA GEREKLİ İŞLEMLER YAPILICAKTIR.
![Image](https://img.shields.io/npm/v/wio.db?color=%2351F9C0&label=Wio.db)

@@ -2,0 +3,0 @@ ![Image](https://img.shields.io/npm/dt/wio.db.svg?color=%2351FC0&maxAge=3600)

{
"compilerOptions": {
"module": "commonjs",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"target": "es6",
"noImplicitAny": false,
"sourceMap": false,
"outDir": "./lib",
"baseUrl": ".",
"paths": {
"*": [
"node_modules/*",
"src/types/*"
]
},
"declaration":true
"compilerOptions": {
"module": "commonjs",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"target": "es6",
"noImplicitAny": false,
"sourceMap": false,
"outDir": "./lib",
"baseUrl": ".",
"paths": {
"*": ["node_modules/*", "src/types/*"]
},
"include": [
"src/**/*"
]
}
"declaration": true
},
"include": ["src/**/*"]
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc