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

ldbjs

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ldbjs - npm Package Compare versions

Comparing version 0.2.0 to 1.0.1

base64.js

1

event.js

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

// event module
const EventEmmiter = require('events');

@@ -2,0 +3,0 @@

31

index.js
const fs = require('fs');
const event = require('./event.js');
const json = require('./json.js');
const base = require('./base64.js');
const ldb = {};
// put the event module in the main module
ldb.event = event;
// put the json module in the main module
ldb.json = json;
// put the base64 module in the main module
ldb.base64 = base;
// get the project dir path
ldb.dir = __dirname;
// criar uma pasta para armazenar os dados
// crieate a folder to place the dbfiles
ldb.createDB = (path, name, callback)=>{

@@ -22,3 +27,3 @@ fs.mkdir(`${path}/${name}`, { recursive: true }, (err)=>{

// criar arquivo
// create dbfiles
ldb.createDBFile = (path, db, file, callback)=>{

@@ -32,3 +37,3 @@ fs.writeFile(`${path}/${db}/${file}.ldb`, '', (err)=>{

// deletar arquivo
// delete files
ldb.deleteDBFile = (path, db, file, callback)=>{

@@ -40,7 +45,7 @@ fs.unlink(`${path}/${db}/${file}.ldb`, ()=>{

// renomear arquivo
// rename files
ldb.renameDBFile = (oldPath, oldDB, oldFile, newFile)=>{
fs.rename(`${oldPath}/${oldDB}/${oldFile}.ldb`, `${oldPath}/${oldDB}/${newFile}.ldb`, (err)=>{
if(err) throw err;
// show the new stats in the console
fs.stat(`${oldPath}/${oldDB}/${newFile}.ldb`, (err, stats)=>{

@@ -54,3 +59,3 @@ if(err) throw err;

// clonar os dados de um arquivos
// clone db file
ldb.cloneDBFile = (path, db, file, toPath, toDB, toFile, callback)=>{

@@ -64,3 +69,3 @@ fs.copyFile(`${path}/${db}/${file}.ldb`, `${toPath}/${toDB}/${toFile}.ldb`, (err)=>{

// sobrescrever dados
// overwrite db file data
ldb.overwriteData = (path, db, file, content, callback)=>{

@@ -74,3 +79,3 @@ fs.writeFile(`${path}/${db}/${file}.ldb`, content, (err)=>{

// enviar dados, gera um erro se o arquivo não existir
// send data to dbfile
ldb.sendData = (path, db, file, content, callback)=>{

@@ -93,3 +98,3 @@

// pegar os dados de um arquivo
// get data from dbfile
ldb.getData = (path, db, file, callback)=>{

@@ -99,9 +104,7 @@ fs.readFile(`${path}/${db}/${file}.ldb`, (err, data)=>{

if(callback) callback(data);
return data;
if(callback) callback(data.toString());
});
}
// listar os arquivos do db
// list the db files in the folder, in a console table
ldb.getDBFiles = (path, db, callback)=>{

@@ -108,0 +111,0 @@ fs.readdir(`${path}/${db}`, (err, files)=>{

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

// json module
const fs = require('fs');

@@ -2,0 +3,0 @@

{
"name": "ldbjs",
"version": "0.2.0",
"version": "1.0.1",
"description": "Create and manage local db files and data",
"main": "./index.js",
"keywords": [
"backend",
"frontend",
"fullstack",
"local",
"electron",
"db",
"database",
"data",
"files",
"json",
"localstorage"
"backend",
"frontend",
"fullstack",
"local",
"electron",
"db",
"database",
"data",
"files",
"json",
"localstorage",
"base64"
],

@@ -23,8 +24,10 @@ "author": "raisess-Danilo_Santana",

"dependencies": {
"file-system": "^2.2.2"
"base-64": "^0.1.0",
"utf8": "^3.0.0"
},
"devDependencies": {
"file-system": "^2.2.2"
"base-64": "^0.1.0",
"utf8": "^3.0.0"
},
"license": "MIT"
}
}

@@ -53,18 +53,11 @@ # ldbjs

```javascript
// electron example
const ldb = require('ldbjs');
let myPTag = document.getElementById('myP');
myPTag.innerHTML = ldb.getData('.', 'myDB', 'myDBFile'); // returns data of the file
console.log(ldb.getData('.', 'myDB', 'myDBFile')); // returns data in buffer format of the file
ldb.getData('.', 'myDB', 'myDBFile', (data)=>{ // optional callback
myPTag.innerHTML = data;
ldb.getData('.', 'myDB', 'myDBFile', (data)=>{ // use callback
console.log(data);
});
```
The returned value is a json with the properties type and data, type is buffer and data is content,
while **on console** prints **array with buffer**, while on **html component returns
exactly the data on the screen**.
The returned value is the **data** of the file.
This function is used only with a callback to get the parameter.

@@ -71,0 +64,0 @@ ### Getting the DB files name

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