Comparing version 4.0.8 to 4.0.9
@@ -1,3 +0,1 @@ | ||
{ | ||
"wio": 0 | ||
} | ||
{} |
@@ -0,2 +1,4 @@ | ||
import { table } from "./table"; | ||
declare class db { | ||
static table: typeof table; | ||
static fetch(userData: string): any; | ||
@@ -18,5 +20,6 @@ static set(userData: string, value: any): void; | ||
static filter(callback: any): any; | ||
static backupLoad(file: string): any; | ||
static find(callback: any): any; | ||
static backupLoad(file: string): void; | ||
static substr(userData: string, value: number): void; | ||
} | ||
export = db; | ||
export { db }; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.db = void 0; | ||
const fs_1 = require("fs"); | ||
const table_1 = require("./table"); | ||
const oku = () => JSON.parse(fs_1.readFileSync('./database.json', 'utf8')); | ||
@@ -155,14 +158,15 @@ const yazdir = (data) => fs_1.writeFileSync('./database.json', JSON.stringify(data, null, 2)); | ||
static filter(callback) { | ||
let allData = this.fetchAll(); | ||
let data = Object.values(allData); | ||
data = data.filter(callback); | ||
const res = []; | ||
data.forEach((d) => { | ||
for (var i in allData) { | ||
if (allData[i] == d) | ||
res.push(allData[i]); | ||
} | ||
}); | ||
return res; | ||
const arr = []; | ||
const all = this.fetchAll(); | ||
for (var i in all) { | ||
if (callback(all[i])) | ||
arr.push(all[i]); | ||
} | ||
; | ||
return arr; | ||
} | ||
static find(callback) { | ||
return this.filter(callback)[0]; | ||
} | ||
; | ||
static backupLoad(file) { | ||
@@ -198,2 +202,3 @@ if (!file) | ||
} | ||
module.exports = db; | ||
exports.db = db; | ||
db.table = table_1.table; |
{ | ||
"name": "wio.db", | ||
"version": "4.0.8", | ||
"version": "4.0.9", | ||
"description": "Gözle okunabilir database modülü.", | ||
"main": "./lib/main.js", | ||
"main": "./lib/index.js", | ||
"author": "", | ||
"types": "./lib/main.d.ts", | ||
"types": "./lib/index.d.ts", | ||
"license": "ISC", | ||
@@ -9,0 +9,0 @@ "repository": { |
@@ -50,2 +50,13 @@ ![Image](https://img.shields.io/npm/v/wio.db?color=%2351F9C0&label=Wio.db) | ||
db.backupLoad("backup.json") | ||
db.find(a = a > 10 ) //performs a search and returns the first value | ||
const table = new db.table() | ||
table.createTable("Table1") | ||
table.set("Table1",{ | ||
username:"wioenena", | ||
money:100 | ||
}) | ||
const filterExample = table.filter("Table1",(a) => a.money > 60 ); | ||
console.log(filterExample); // ---> Filter the table | ||
const findExample = table.find("Table1",(a) => a.money > 60) | ||
console.log(findExample); // ---> find the table | ||
@@ -52,0 +63,0 @@ }) |
@@ -7,3 +7,3 @@ { | ||
"target": "es6", | ||
"noImplicitAny": true, | ||
"noImplicitAny": false, | ||
"sourceMap": false, | ||
@@ -10,0 +10,0 @@ "outDir": "./lib", |
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
23877
11
289
75