优化exists

master
宇天 2020-10-07 00:07:12 +08:00
parent de6182576d
commit 11d37d5d9b
3 changed files with 12 additions and 12 deletions

View File

@ -21,10 +21,7 @@ class Stats {
} }
} }
const VERSION = +process.versions.node const VERSION = +process.versions.node.split('.').slice(0, 2).join('.')
.split('.')
.slice(0, 2)
.join('.')
const EMPTY_STAT = new Stats() const EMPTY_STAT = new Stats()
@ -288,7 +285,7 @@ const Iofs = {
* @param {String} file [目标路径] * @param {String} file [目标路径]
*/ */
exists(file) { exists(file) {
return this.is(file, FS.constants.R_OK) return this.is(file, FS.constants.F_OK)
}, },
// 是否可读写 // 是否可读写

View File

@ -21,10 +21,7 @@ class STATS {
} }
} }
const VERSION = +process.versions.node const VERSION = +process.versions.node.split('.').slice(0, 2).join('.')
.split('.')
.slice(0, 2)
.join('.')
const EMPTY_STAT = new STATS() const EMPTY_STAT = new STATS()
@ -288,7 +285,7 @@ export default {
* @param {String} file [目标路径] * @param {String} file [目标路径]
*/ */
exists(file) { exists(file) {
return this.is(file, FS.constants.R_OK) return this.is(file, FS.constants.F_OK)
}, },
// 是否可读写 // 是否可读写

View File

@ -1,13 +1,19 @@
{ {
"name": "iofs", "name": "iofs",
"version": "1.5.0", "version": "1.5.1",
"description": "iofs是一个基于原生fs模块封装的工具, 旨在提供更加方便实用一些常用的API方法(同步), API习惯参考了bash shell。", "description": "iofs是一个基于原生fs模块封装的工具, 旨在提供更加方便实用一些常用的API方法(同步), API习惯参考了bash shell。",
"main": "index.js", "main": "index.js",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/bytedo/iofs.git" "url": "https://github.com/bytedo/iofs.git"
}, },
"keywords": ["fivejs", "fs", "iofs", "fs.io", "file"], "keywords": [
"fivejs",
"fs",
"iofs",
"fs.io",
"file"
],
"author": "yutent", "author": "yutent",
"license": "MIT" "license": "MIT"
} }