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

nyks

Package Overview
Dependencies
Maintainers
1
Versions
250
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nyks - npm Package Compare versions

Comparing version 0.1.6 to 0.1.7

4

package.json
{
"name": "nyks",
"version": "0.1.6",
"version": "0.1.7",
"description": "nodejs exupery style",

@@ -33,4 +33,4 @@ "keywords": [

},
"_id": "nyks@0.1.2",
"_id": "nyks@0.1.6",
"_from": "nyks@"
}

@@ -17,3 +17,16 @@ nyks provide a set of "missing" stuffs in nodejs basic api.

* require('fs').md5FileSync(file_path)
Return md5 checksum of a file
* require('fs').filesizeSync(path);
Filesize sync
* require('fs').tmppath (ext)
Return a unique file path in OS temp dir
* require('fs').renameCross(src, dest, callback)
Rename src to dest (even on cross devices)
# Natives

@@ -20,0 +33,0 @@ ## Object

var fs = require('fs'),
crypto = require('crypto');
crypto = require('crypto'),
path = require('path'),
os = require('os');
fs.md5FileSync = function(path){
fs.md5FileSync = function(file_path){
var md5 = crypto.createHash('md5');
md5.update(fs.readFileSync(path));
md5.update(fs.readFileSync(file_path));
return md5.digest('hex');
}
fs.filesizeSync = function(file_path){
return fs.statSync(file_path)["size"];
}
fs.deleteFolderRecursive = function(path) {
fs.renameCross = function(src, dst, callback){
var readStream = fs.createReadStream(src)
var writeStream = fs.createWriteStream(dst);
readStream.pipe(writeStream);
writeStream.on('finish', function(){
fs.unlinkSync(src);
callback();
});
}
fs.tmppath = function(ext){
ext = ext || "tmp";
var abc = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
var rand = (abc + abc + abc ).split("").shuffle().slice(0,8).join("");
var fname = ext + "-" + rand + "." + ext;
var file_path = os.tmpdir() + "/" +fname;
if(fs.existsSync(file_path))
return fs.tmppath(ext);
return file_path;
}
fs.mkdirpSync = function(file_path){
if( fs.existsSync(file_path) )
return file_path;
fs.mkdirpSync(path.dirname(file_path));
fs.mkdirSync(file_path);
return file_path;
}
fs.deleteFolderRecursive = function(file_path) {
var files = [];
if( fs.existsSync(path) ) {
files = fs.readdirSync(path);
if( fs.existsSync(file_path) ) {
files = fs.readdirSync(file_path);
files.forEach(function(file,index){
var curPath = path + "/" + file;
if(fs.lstatSync(curPath).isDirectory()) { // recurse
fs.deleteFolderRecursive(curPath);
var curfile_path = file_path + "/" + file;
if(fs.lstatSync(curfile_path).isDirectory()) { // recurse
fs.deleteFolderRecursive(curfile_path);
} else { // delete file
fs.unlinkSync(curPath);
fs.unlinkSync(curfile_path);
}
});
fs.rmdirSync(path);
fs.rmdirSync(file_path);
}
};
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