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 1.1.3 to 1.1.4

4

index.js

@@ -9,2 +9,4 @@ const

exports.VirtualDirectoryTree = vdos.VirtualDirectoryTree;
exports.VDT = vdos.VirtualDirectoryTree;
exports.VDT = vdos.VirtualDirectoryTree;
exports.sftp = fts.sftp;
exports.ftp = fts.ftp;
{
"name": "fsgod",
"version": "1.1.3",
"version": "1.1.4",
"description": "Secure file sharing, hosting, and transfer",

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

@@ -198,2 +198,38 @@

### vdt.json
The **json** method only applies to files with the **.json** extension. The **json** method gets the content of the target .json file and returns it as a JavaScript ready object. The following code will create a file named **test.json** and then return it's content into a JSON ready-to-go object
```javascript
fsgod.VDT('./', (vdt) => {
vdt.mkfile('test.json', '{"foo":"bar"}', (err) => {
if (err) throw err;
var file = vdt.get('test.json');
fileJSON = file.json();
console.log(fileJSON.foo); // will log 'bar'
});
});
```
### vdt.writejson
The **writejson** method only applies to files with the **.json** extension. The **writejson** takes a JavaScript object and converts it to a json string and saves it as the content of the target .json file. The following code will create a file named **test.json**, then return it's content into a JSON ready-to-go object, then update the **foo** variable and save it to **test.json**
```javascript
fsgod.VDT('./', (vdt) => {
vdt.mkfile('test.json', '{"foo":"bar"}', (err) => {
if (err) throw err;
var file = vdt.get('test.json');
fileJSON = file.json();
console.log(fileJSON.foo); // will log 'bar'
fileJSON.foo = "updated!";
file.writejson(fileJSON, () => {
console.log(file.json().foo); // wil log 'updated!'
});
});
});
```
## Virtual Directory

@@ -200,0 +236,0 @@

@@ -6,12 +6,12 @@ (function(){

exports.$ftp = $ftp;
exports.$fileTransferProtocol = $ftp;
exports.$sftp = $sftp;
exports.$safeFileTransferProtocol = $sftp;
exports.ftp = ftp;
exports.fileTransferProtocol = ftp;
exports.sftp = sftp;
exports.safeFileTransferProtocol = sftp;
function $ftp($url){
function ftp($url){
}
function $sftp($url){
function sftp($url){

@@ -18,0 +18,0 @@ }

@@ -118,14 +118,33 @@ (function () {

function scrubJSON ($item) {
if (Buffer.isBuffer($item)) $item = $item.toString('utf8');
$item = $item.replace(/^\uFEFF/, '');
return $item;
}
FileObject.prototype.json = function(){
var fo = this;
if (fo.name.split(".").reverse()[0] !== 'json') throw 'The .json() method is only for files with the .json file extension!';
return fs.readFile(fo.name, 'utf8', (err, data) => {
var data = fs.readFileSync(fo.fullPath);
data = scrubJSON(data);
return JSON.parse(data);
};
FileObject.prototype.writejson = function($newJSON, $done){
var fo = this;
if (fo.name.split(".").reverse()[0] !== 'json') throw 'The .writejson() method is only for files with the .json file extension!';
$newJSON = JSON.stringify($newJSON);
$newJSON = scrubJSON($newJSON);
fo.__updateFileSrc($newJSON, (err) => {
if (err) throw err;
return JSON.parse(data);
$done();
});
};
FileObject.prototype.append = function($newContent, $done){
var fo = this;
fo.__updateFileSrc(fo.content + $newContent, (err) => {
if (err) throw err;
$done();

@@ -189,3 +208,3 @@ });

} else {
$cb('File Already Exists');
$cb(null);
}

@@ -217,5 +236,8 @@ });

VirtualDirectory.prototype.mkdir.prototype.then = function($next){
$next();
};
VirtualDirectory.prototype.search = function($term, $options, $cb){
var dir = this;
if(typeof $term !== 'string') throw 'Search Term Must Be A String!';
if (!$cb) { $cb = $options; $options = {}; }

@@ -222,0 +244,0 @@ if ($options.content === undefined) $options.content = true;

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