New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

fsgod

Package Overview
Dependencies
Maintainers
1
Versions
85
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fsgod - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

services/file-transfer-service.js

11

index.js

@@ -5,9 +5,6 @@ const

path = require('path'),
bdos = require('./services/virtual-directory-object-service');
vdos = require('./services/virtual-directory-object-service'),
fts = require('./services/file-transfer-service');
exports.VirtualDirectoryTree = bdos.VirtualDirectoryTree;
exports.VDT = bdos.VDT;
// var TestTree = bdos.VDT('./tests/test_dir', (vdt) => {
// console.log(JSON.stringify(vdt));
// });
exports.VirtualDirectoryTree = vdos.VirtualDirectoryTree;
exports.VDT = vdos.VirtualDirectoryTree;
{
"name": "fsgod",
"version": "0.0.4",
"version": "0.0.5",
"description": "Secure file sharing, hosting, and transfer",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -1,4 +0,41 @@

#FSGOD
##FSGOD (Alpha)
A service for securely managing, transfering, collaborating, and hosting content on your local network
The only component thus far (v 0.0.5) is the Virtual Directory Tree (VDT).
The purpose of this library is to make dynamic managing of any size of file system easy and quick.
##API Example
```
const fsgod = require('fsgod');
// fsgod.VDT and fsgod.VirtualDirectoryTree are aliases of the same function.
fsgod.VDT('./', (vdt) => {
var myDirectoryTree = vdt;
for ( var i = 0; i < myDirectory.content.length; i++ ){
console.log(myDirectory.content[i].name);
}
});
```
The above code should log the names of all the items in the directory it's currently in
##More Info
| Function | Arguments | Usage |
|:---:|:---:|:---:|
| `VDT or VirtualDirectoryTree` | `url: the path to the directory you'd like to operate, done: to be called when VDT is done getting the directory` | ```fsgod.VDT(urlToFolder, function(vdt){ })``` |
The `vdt` object that gets passed to the callback in ```fsgod.VDT``` is the Virtual Directory Tree. ```fsgod.VDT``` recursively walks through a specified folder and builds each item into a JavaScript object and passes it back to the user in the callback. For the meantime (v0.0.5), ```fsgod.VDT``` can only be used to read data. If you'd like to help, email me at maui.wowie@tuta.io.
| VDT object keys | Usage | Type |
|:---:|:---:|:---:|
| `content` | `The content of the item, if it's a directory it will be an array of other items. If it's a file it will be it's file content` | `Array or String` |
| `name` | `The name of the file or directory` | `String` |
| `type` | `Will let you know if its a directory or file` | `String` |
| `fullPath` | `The full path to the item` | `String` |

@@ -1,100 +0,95 @@

const
fs = require('fs'),
path = require('path');
(function () {
'use strict';
const
fs = require('fs'),
path = require('path');
exports.VirtualDirectoryTree = VirtualDirectoryTree;
exports.VDT = VirtualDirectoryTree;
exports.VirtualDirectoryTree = VirtualDirectoryTree;
function VirtualDirectoryTree($dir, $done) {
function VirtualDirectoryTree($dir, $done) {
var $VDT = new VDTCompiler($dir),
scansStarted = 0,
scansFinished = 0;
var VDT = new VirtualDirectory($dir),
scansStarted = 0,
scansFinished = 0;
function FileObject($fullPath){
function FileObject($fullPath) {
var fo = this;
fo.__type = 'file';
fo.__name = $fullPath.split(/[\\\/]/gi).reverse()[0];
fo.__fullPath = $fullPath;
fo.__content = '';
fo.__send = function(){
console.log('send func called on file');
};
fo.__getContentFromSrcAsync = function(done){
fs.readFile(fo.__fullPath, 'utf-8', (err, data) => {
if (err) throw err;
fo.__updateFOContentAsync(data);
});
};
fo.__getContentFromSrc = function(done){
fs.readFile(fo.__fullPath, 'utf-8', (err, data) => {
if (err) throw err;
fo.__updateFOContent(data, () => {
done();
var fo = this;
fo.type = 'file';
fo.name = $fullPath.split(/[\\\/]/gi).reverse()[0];
fo.fullPath = $fullPath;
fo.content = '';
fo.__getContentFromSrcAsync = function (done) {
fs.readFile(fo.fullPath, 'utf-8', (err, data) => {
if (err) throw err;
fo.__updateFOContentAsync(data);
});
});
};
fo.__updateFileSrc = function(newContent, done){
fs.writeFile(fo.__fullPath, newContent, (err) => {
if (err) throw err;
fo.__updateFOContent(newContent, () => {
done();
};
fo.__getContentFromSrc = function (done) {
fs.readFile(fo.fullPath, 'utf-8', (err, data) => {
if (err) throw err;
fo.__updateFOContent(data, () => {
done();
});
});
});
};
fo.__updateFOContent = function(newContent, done){
fo.__content = newContent;
done();
};
fo.__updateFOContentAsync = function(newContent){
fo.__content = newContent;
};
(function(){
scansStarted++;
fo.__getContentFromSrc(() => {
scansFinished++;
if (scansStarted === scansFinished) end();
});
})();
}
};
fo.__updateFileSrc = function (newContent, done) {
fs.writeFile(fo.fullPath, newContent, (err) => {
if (err) throw err;
fo.__updateFOContent(newContent, () => {
done();
});
});
};
fo.__updateFOContent = function (newContent, done) {
fo.content = newContent;
done();
};
fo.__updateFOContentAsync = function (newContent) {
fo.content = newContent;
};
function VDTCompiler($fullPath){
(function () {
scansStarted++;
fo.__getContentFromSrc(() => {
scansFinished++;
if (scansStarted === scansFinished) end();
});
})();
}
var dir = this;
dir.__type = 'directory';
dir.__name = $fullPath.split(/[\\\/]/gi).reverse()[0];
dir.__fullPath = $fullPath;
dir.__content = [];
(function(){
scansStarted++;
fs.readdir(dir.__fullPath, (err, items) => {
if (err) throw err;
items.forEach((item, index) => {
item = path.resolve(dir.__fullPath, item);
fs.stat(item, (err, stat) => {
if (stat && stat.isDirectory()){
dir.__content.push(new VDTCompiler(item));
} else {
dir.__content.push(new FileObject(item));
}
function VirtualDirectory($fullPath) {
var dir = this;
dir.type = 'directory';
dir.name = $fullPath.split(/[\\\/]/gi).reverse()[0];
dir.fullPath = $fullPath;
dir.content = [];
(function () {
scansStarted++;
fs.readdir(dir.fullPath, (err, items) => {
if (err) throw err;
items.forEach((item, index) => {
item = path.resolve(dir.fullPath, item);
fs.stat(item, (err, stat) => {
if (stat && stat.isDirectory()) {
dir.content.push(new VirtualDirectory(item));
} else {
dir.content.push(new FileObject(item));
}
});
});
scansFinished++;
if (scansStarted === scansFinished) end();
});
scansFinished++;
if (scansStarted === scansFinished) end();
});
})();
})();
}
function end() {
$done(VDT);
}
}
function end(){
$done($VDT);
}
}
})();
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