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 |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1
330428
17
41
4423
- Removedtollo@0.0.7-dev
- Removed@babel/code-frame@7.26.2(transitive)
- Removed@babel/generator@7.26.3(transitive)
- Removed@babel/helper-string-parser@7.25.9(transitive)
- Removed@babel/helper-validator-identifier@7.25.9(transitive)
- Removed@babel/parser@7.26.3(transitive)
- Removed@babel/template@7.25.9(transitive)
- Removed@babel/traverse@7.26.4(transitive)
- Removed@babel/types@7.26.3(transitive)
- Removed@jridgewell/gen-mapping@0.3.8(transitive)
- Removed@jridgewell/resolve-uri@3.1.2(transitive)
- Removed@jridgewell/set-array@1.2.1(transitive)
- Removed@jridgewell/sourcemap-codec@1.5.0(transitive)
- Removed@jridgewell/trace-mapping@0.3.25(transitive)
- Removedajv@6.12.6(transitive)
- Removedansi-regex@2.1.14.1.1(transitive)
- Removedansi-styles@2.2.13.2.1(transitive)
- Removedappend-transform@1.0.0(transitive)
- Removedarchy@1.0.0(transitive)
- Removedarg@4.1.3(transitive)
- Removedargparse@1.0.10(transitive)
- Removedasn1@0.2.6(transitive)
- Removedassert-plus@1.0.0(transitive)
- Removedasynckit@0.4.0(transitive)
- Removedaws-sign2@0.7.0(transitive)
- Removedaws4@1.13.2(transitive)
- Removedbalanced-match@1.0.2(transitive)
- Removedbcrypt-pbkdf@1.0.2(transitive)
- Removedbind-obj-methods@2.0.2(transitive)
- Removedbluebird@3.7.2(transitive)
- Removedbrace-expansion@1.1.11(transitive)
- Removedbrowser-process-hrtime@1.0.0(transitive)
- Removedbuffer-from@1.1.2(transitive)
- Removedcaching-transform@3.0.2(transitive)
- Removedcall-bind@1.0.8(transitive)
- Removedcall-bind-apply-helpers@1.0.1(transitive)
- Removedcall-bound@1.0.3(transitive)
- Removedcamelcase@5.3.1(transitive)
- Removedcapture-stack-trace@1.0.2(transitive)
- Removedcaseless@0.12.0(transitive)
- Removedchalk@1.1.3(transitive)
- Removedcheckv@0.0.18(transitive)
- Removedclean-yaml-object@0.1.0(transitive)
- Removedcliui@5.0.0(transitive)
- Removedcolor-convert@1.9.3(transitive)
- Removedcolor-name@1.1.3(transitive)
- Removedcolor-support@1.1.3(transitive)
- Removedcombined-stream@1.0.8(transitive)
- Removedcommondir@1.0.1(transitive)
- Removedconcat-map@0.0.1(transitive)
- Removedconvert-source-map@1.9.0(transitive)
- Removedcore-util-is@1.0.21.0.3(transitive)
- Removedcoveralls@3.1.1(transitive)
- Removedcp-file@6.2.0(transitive)
- Removedcross-spawn@4.0.2(transitive)
- Removeddashdash@1.14.1(transitive)
- Removeddebug@2.6.94.4.0(transitive)
- Removeddecamelize@1.2.0(transitive)
- Removeddeep-equal@1.1.2(transitive)
- Removeddefault-require-extensions@2.0.0(transitive)
- Removeddefine-data-property@1.1.4(transitive)
- Removeddefine-properties@1.2.1(transitive)
- Removeddelayed-stream@1.0.0(transitive)
- Removeddiff@1.4.04.0.2(transitive)
- Removeddomain-browser@1.2.0(transitive)
- Removeddunder-proto@1.0.1(transitive)
- Removedecc-jsbn@0.1.2(transitive)
- Removedemoji-regex@7.0.3(transitive)
- Removedend-of-stream@0.1.5(transitive)
- Removederror-ex@1.3.2(transitive)
- Removedes-define-property@1.0.1(transitive)
- Removedes-errors@1.3.0(transitive)
- Removedes-object-atoms@1.0.0(transitive)
- Removedes6-error@4.1.1(transitive)
- Removedescape-string-regexp@1.0.52.0.0(transitive)
- Removedesm@3.2.25(transitive)
- Removedesprima@4.0.1(transitive)
- Removedevents-to-array@1.1.2(transitive)
- Removedextend@3.0.2(transitive)
- Removedextsprintf@1.3.0(transitive)
- Removedfast-deep-equal@3.1.3(transitive)
- Removedfast-json-stable-stringify@2.1.0(transitive)
- Removedfind-cache-dir@2.1.0(transitive)
- Removedfind-up@3.0.0(transitive)
- Removedforeground-child@1.5.6(transitive)
- Removedforever-agent@0.6.1(transitive)
- Removedform-data@2.3.3(transitive)
- Removedfs-exists-cached@1.0.0(transitive)
- Removedfs-extra@3.0.1(transitive)
- Removedfs.realpath@1.0.0(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedfunction-loop@1.0.2(transitive)
- Removedfunctions-have-names@1.2.3(transitive)
- Removedget-caller-file@2.0.5(transitive)
- Removedget-intrinsic@1.2.6(transitive)
- Removedgetpass@0.1.7(transitive)
- Removedglob@7.2.3(transitive)
- Removedglobals@11.12.0(transitive)
- Removedgopd@1.2.0(transitive)
- Removedgraceful-fs@4.2.11(transitive)
- Removedhar-schema@2.0.0(transitive)
- Removedhar-validator@5.1.5(transitive)
- Removedhas-ansi@2.0.0(transitive)
- Removedhas-flag@3.0.0(transitive)
- Removedhas-property-descriptors@1.0.2(transitive)
- Removedhas-symbols@1.1.0(transitive)
- Removedhas-tostringtag@1.0.2(transitive)
- Removedhasha@3.0.0(transitive)
- Removedhasown@2.0.2(transitive)
- Removedhosted-git-info@2.8.9(transitive)
- Removedhtml-escaper@2.0.2(transitive)
- Removedhtml-tags@1.2.0(transitive)
- Removedhttp-signature@1.2.0(transitive)
- Removedimurmurhash@0.1.4(transitive)
- Removedinflight@1.0.6(transitive)
- Removedis-arguments@1.2.0(transitive)
- Removedis-arrayish@0.2.1(transitive)
- Removedis-core-module@2.16.1(transitive)
- Removedis-date-object@1.1.0(transitive)
- Removedis-fullwidth-code-point@2.0.0(transitive)
- Removedis-html@1.1.0(transitive)
- Removedis-regex@1.2.1(transitive)
- Removedis-stream@1.1.0(transitive)
- Removedis-typedarray@1.0.0(transitive)
- Removedisarray@1.0.0(transitive)
- Removedisexe@2.0.0(transitive)
- Removedisstream@0.1.2(transitive)
- Removedistanbul-lib-coverage@2.0.5(transitive)
- Removedistanbul-lib-hook@2.0.7(transitive)
- Removedistanbul-lib-instrument@3.3.0(transitive)
- Removedistanbul-lib-report@2.0.8(transitive)
- Removedistanbul-lib-source-maps@3.0.6(transitive)
- Removedistanbul-reports@2.2.7(transitive)
- Removedjs-tokens@4.0.0(transitive)
- Removedjs-yaml@3.14.1(transitive)
- Removedjsbn@0.1.1(transitive)
- Removedjsesc@3.1.0(transitive)
- Removedjson-parse-better-errors@1.0.2(transitive)
- Removedjson-schema@0.4.0(transitive)
- Removedjson-schema-traverse@0.4.1(transitive)
- Removedjson-stringify-safe@5.0.1(transitive)
- Removedjsonfile@3.0.1(transitive)
- Removedjsprim@1.4.2(transitive)
- Removedlcov-parse@1.0.0(transitive)
- Removedload-json-file@4.0.0(transitive)
- Removedlocate-path@3.0.0(transitive)
- Removedlodash@4.17.21(transitive)
- Removedlodash.flattendeep@4.4.0(transitive)
- Removedlog-driver@1.2.7(transitive)
- Removedlog-segment@1.7.9(transitive)
- Removedlru-cache@4.1.5(transitive)
- Removedmake-dir@2.1.0(transitive)
- Removedmake-error@1.3.6(transitive)
- Removedmath-intrinsics@1.1.0(transitive)
- Removedmerge-source-map@1.1.0(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removedminimatch@3.1.2(transitive)
- Removedminimist@1.2.8(transitive)
- Removedminipass@2.9.0(transitive)
- Removedmkdirp@0.5.6(transitive)
- Removedms@2.0.02.1.3(transitive)
- Removednested-error-stacks@2.1.1(transitive)
- Removednodemailer@4.7.0(transitive)
- Removednormalize-package-data@2.5.0(transitive)
- Removednyc@14.1.1(transitive)
- Removedoauth-sign@0.9.0(transitive)
- Removedobject-is@1.1.6(transitive)
- Removedobject-keys@1.1.1(transitive)
- Removedonce@1.3.3(transitive)
- Removedopener@1.5.2(transitive)
- Removedorchestrator@0.3.8(transitive)
- Removedos-homedir@1.0.2(transitive)
- Removedown-or@1.0.0(transitive)
- Removedown-or-env@1.0.2(transitive)
- Removedp-limit@2.3.0(transitive)
- Removedp-locate@3.0.0(transitive)
- Removedp-try@2.2.0(transitive)
- Removedpackage-hash@3.0.0(transitive)
- Removedparse-json@4.0.0(transitive)
- Removedpath-exists@3.0.0(transitive)
- Removedpath-is-absolute@1.0.1(transitive)
- Removedpath-parse@1.0.7(transitive)
- Removedpath-type@3.0.0(transitive)
- Removedperformance-now@2.1.0(transitive)
- Removedpicocolors@1.1.1(transitive)
- Removedpify@3.0.04.0.1(transitive)
- Removedpkg-dir@3.0.0(transitive)
- Removedprocess-nextick-args@2.0.1(transitive)
- Removedpseudomap@1.0.2(transitive)
- Removedpsl@1.15.0(transitive)
- Removedpunycode@1.4.12.3.1(transitive)
- Removedqs@6.5.3(transitive)
- Removedread-pkg@3.0.0(transitive)
- Removedread-pkg-up@4.0.0(transitive)
- Removedreadable-stream@2.3.8(transitive)
- Removedregexp.prototype.flags@1.5.3(transitive)
- Removedrelease-zalgo@1.0.0(transitive)
- Removedrequest@2.88.2(transitive)
- Removedrequest-promise@4.2.6(transitive)
- Removedrequest-promise-core@1.1.4(transitive)
- Removedrequire-directory@2.1.1(transitive)
- Removedrequire-main-filename@2.0.0(transitive)
- Removedresolve@1.22.10(transitive)
- Removedresolve-from@4.0.0(transitive)
- Removedrimraf@2.7.1(transitive)
- Removedsafe-buffer@5.1.25.2.1(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedsemver@5.7.26.3.1(transitive)
- Removedsequencify@0.0.7(transitive)
- Removedset-blocking@2.0.0(transitive)
- Removedset-function-length@1.2.2(transitive)
- Removedset-function-name@2.0.2(transitive)
- Removedsignal-exit@3.0.7(transitive)
- Removedsource-map@0.6.1(transitive)
- Removedsource-map-support@0.5.21(transitive)
- Removedspawn-wrap@1.4.3(transitive)
- Removedspdx-correct@3.2.0(transitive)
- Removedspdx-exceptions@2.5.0(transitive)
- Removedspdx-expression-parse@3.0.1(transitive)
- Removedspdx-license-ids@3.0.20(transitive)
- Removedsprintf-js@1.0.3(transitive)
- Removedsshpk@1.18.0(transitive)
- Removedstack-utils@1.0.5(transitive)
- Removedstealthy-require@1.1.1(transitive)
- Removedstream-consume@0.1.1(transitive)
- Removedstring-width@3.1.0(transitive)
- Removedstring_decoder@1.1.1(transitive)
- Removedstrip-ansi@3.0.15.2.0(transitive)
- Removedstrip-bom@3.0.0(transitive)
- Removedsupports-color@2.0.06.1.0(transitive)
- Removedsupports-preserve-symlinks-flag@1.0.0(transitive)
- Removedtap@12.7.0(transitive)
- Removedtap-mocha-reporter@3.0.9(transitive)
- Removedtap-parser@5.4.07.0.0(transitive)
- Removedtest-exclude@5.2.3(transitive)
- Removedtmatch@4.0.0(transitive)
- Removedtollo@0.0.7-dev(transitive)
- Removedtough-cookie@2.5.0(transitive)
- Removedtrivial-deferred@1.1.2(transitive)
- Removedts-node@8.10.2(transitive)
- Removedtsame@2.0.1(transitive)
- Removedtunnel-agent@0.6.0(transitive)
- Removedtweetnacl@0.14.5(transitive)
- Removedtypescript@3.9.10(transitive)
- Removedunicode-length@1.0.3(transitive)
- Removeduniversalify@0.1.2(transitive)
- Removeduri-js@4.4.1(transitive)
- Removedutil-deprecate@1.0.2(transitive)
- Removeduuid@3.4.0(transitive)
- Removedvalidate-npm-package-license@3.0.4(transitive)
- Removedverror@1.10.0(transitive)
- Removedwhich@1.3.1(transitive)
- Removedwhich-module@2.0.1(transitive)
- Removedwrap-ansi@5.1.0(transitive)
- Removedwrappy@1.0.2(transitive)
- Removedwrite-file-atomic@2.4.3(transitive)
- Removedy18n@4.0.3(transitive)
- Removedyallist@2.1.23.1.1(transitive)
- Removedyapool@1.0.0(transitive)
- Removedyargs@13.3.2(transitive)
- Removedyargs-parser@13.1.2(transitive)
- Removedyn@3.1.1(transitive)