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

a-toolbox

Package Overview
Dependencies
Maintainers
1
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

a-toolbox - npm Package Compare versions

Comparing version 1.6.2 to 1.7.0

68

fs.js

@@ -12,12 +12,4 @@ const nativeFs = require('fs')

* @method tools.fs.exists
* @param {string} path (filePath) file path
* @param {string} path path
* @return {Promise.<boolean>} true if file/folder exists
* https://nodejs.org/api/fs.html#fs_fs_exists_path_callback
* @test.arrange async function(input, sandbox) {
* const fs = require('../../src/fs')
* return fs.touch('/tmp/file')
* }
* @test.case '/tmp/file' > true
* @test.case '/tmp/none' > false
* @test.case '/tmp' > false
*/

@@ -45,11 +37,2 @@ fs.exists = function (path) {

* @return {Promise.<void>}
* @test.case '/tmp/touch-me'
* @test.case '/none' ! new tollo.Error({code: 'EACCES'})
* @test.assert async (result, input, output, sandbox) => {
* if(result) {
* return result.code === output.code
* }
* const fs = require('../../src/fs')
* return fs.exists(input[0])
* }
*/

@@ -77,11 +60,4 @@ fs.touch = function (path, mode = 0o666) {

* @param {string} path (filePath) file path
* @param {boolean} [safe=true] if safe do not throw exception
* @param {boolean} [safe=false] if safe do not throw exception
* @return {Promise.<void>}
* @test.arrange async function(input, sandbox) {
* const fs = require('../../src/fs')
* return fs.touch('/tmp/file')
* }
* @test.case '/tmp/file'
* @test.case '/tmp/none', false ! new tollo.Error({code: 'ENOENT'})
* @test.case '/tmp/none', true
*/

@@ -100,2 +76,42 @@ fs.unlink = function (path, safe) {

/**
* check if `path` exists and is a file
* @param {string} path path
* @return {Promise.<boolean>} true if file exists and it's a file
*/
fs.isFile = function (path) {
return new Promise(function (resolve) {
nativeFs.stat(path, function (err, stats) {
if (err || !stats) {
resolve(false)
return
} else if (stats.isFile()) {
resolve(true)
return
}
resolve(false)
})
})
}
/**
* check if `path` exists and is a directory
* @param {string} path path
* @return {Promise.<boolean>} true if file exists and it's a directory
*/
fs.isDirectory = function (path) {
return new Promise(function (resolve) {
nativeFs.stat(path, function (err, stats) {
if (err || !stats) {
resolve(false)
return
} else if (stats.isDirectory()) {
resolve(true)
return
}
resolve(false)
})
})
}
module.exports = fs
{
"name": "a-toolbox",
"version": "1.6.2",
"version": "1.7.0",
"description": "javascript lightweight basic tools for node.js and browser",
"main": "index.js",
"dependencies": {
"hash.js": "^1.1.5",
"tollo": "0.0.7-dev"
"hash.js": "^1.1.5"
},
"devDependencies": {
"natives": "^1.1.6",
"babel": "^6.23.0",

@@ -29,8 +29,5 @@ "babel-core": "^6.26.3",

"pre-commit": [
"test",
"build"
],
"scripts": {
"test": "standard && tap test/tdd.js",
"test-cov": "standard && tap test/tdd.js --cov",
"build": "gulp",

@@ -37,0 +34,0 @@ "clear": "gulp clear"

@@ -12,12 +12,4 @@ const nativeFs = require('fs')

* @method tools.fs.exists
* @param {string} path (filePath) file path
* @return {Promise.<boolean>} true if file exists - and it's a file
* https://nodejs.org/api/fs.html#fs_fs_exists_path_callback
* @test.arrange async function(input, sandbox) {
* const fs = require('../../src/fs')
* return fs.touch('/tmp/file')
* }
* @test.case '/tmp/file' > true
* @test.case '/tmp/none' > false
* @test.case '/tmp' > false
* @param {string} path path
* @return {Promise.<boolean>} true if file/folder exists
*/

@@ -30,3 +22,3 @@ fs.exists = function (path) {

return
} else if (stats.isFile()) {
} else if (stats.isFile() || stats.isDirectory()) {
resolve(true)

@@ -46,11 +38,2 @@ return

* @return {Promise.<void>}
* @test.case '/tmp/touch-me'
* @test.case '/none' ! new tollo.Error({code: 'EACCES'})
* @test.assert async (result, input, output, sandbox) => {
* if(result) {
* return result.code === output.code
* }
* const fs = require('../../src/fs')
* return fs.exists(input[0])
* }
*/

@@ -78,11 +61,4 @@ fs.touch = function (path, mode = 0o666) {

* @param {string} path (filePath) file path
* @param {boolean} [safe=true] if safe do not throw exception
* @param {boolean} [safe=false] if safe do not throw exception
* @return {Promise.<void>}
* @test.arrange async function(input, sandbox) {
* const fs = require('../../src/fs')
* return fs.touch('/tmp/file')
* }
* @test.case '/tmp/file'
* @test.case '/tmp/none', false ! new tollo.Error({code: 'ENOENT'})
* @test.case '/tmp/none', true
*/

@@ -101,2 +77,42 @@ fs.unlink = function (path, safe) {

/**
* check if `path` exists and is a file
* @param {string} path path
* @return {Promise.<boolean>} true if file exists and it's a file
*/
fs.isFile = function (path) {
return new Promise(function (resolve) {
nativeFs.stat(path, function (err, stats) {
if (err || !stats) {
resolve(false)
return
} else if (stats.isFile()) {
resolve(true)
return
}
resolve(false)
})
})
}
/**
* check if `path` exists and is a directory
* @param {string} path path
* @return {Promise.<boolean>} true if file exists and it's a directory
*/
fs.isDirectory = function (path) {
return new Promise(function (resolve) {
nativeFs.stat(path, function (err, stats) {
if (err || !stats) {
resolve(false)
return
} else if (stats.isDirectory()) {
resolve(true)
return
}
resolve(false)
})
})
}
module.exports = fs
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