bare-fs 2.0.0 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -17,6 +17,7 @@ fs.access
17
17
  fs.chmod
18
18
  fs.close
19
19
  fs.chmod
20
+ fs.exists
20
21
  fs.fstat
21
22
  fs.ftruncate
22
23
  fs.lstat
@@ -63,6 +64,7 @@ fs.createWriteStream
63
64
  fs.accessSync
64
65
  fs.chmodSync
65
66
  fs.closeSync
67
+ fs.existsSync
66
68
  fs.fchmodSync
67
69
  fs.fstatSync
68
70
  fs.lstatSync
package/binding.c CHANGED
@@ -809,7 +809,7 @@ bare_fs_readv (js_env_t *env, js_callback_info_t *info) {
809
809
  assert(err == 0);
810
810
 
811
811
  uv_buf_t *buf = &bufs[i];
812
- err = js_get_typedarray_info(env, item, NULL, (void **) &buf->base, &buf->len, NULL, NULL);
812
+ err = js_get_typedarray_info(env, item, NULL, (void **) &buf->base, (size_t *) &buf->len, NULL, NULL);
813
813
  assert(err == 0);
814
814
  }
815
815
 
@@ -967,7 +967,7 @@ bare_fs_writev (js_env_t *env, js_callback_info_t *info) {
967
967
  assert(err == 0);
968
968
 
969
969
  uv_buf_t *buf = &bufs[i];
970
- err = js_get_typedarray_info(env, item, NULL, (void **) &buf->base, &buf->len, NULL, NULL);
970
+ err = js_get_typedarray_info(env, item, NULL, (void **) &buf->base, (size_t *) &buf->len, NULL, NULL);
971
971
  assert(err == 0);
972
972
  }
973
973
 
package/index.js CHANGED
@@ -239,6 +239,31 @@ function accessSync (filepath, mode = constants.F_OK) {
239
239
  binding.accessSync(filepath, mode)
240
240
  }
241
241
 
242
+ function exists (filepath, cb) {
243
+ if (typeof filepath !== 'string') {
244
+ throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof filepath) + ' (' + filepath + ')')
245
+ }
246
+
247
+ if (typeof cb !== 'function') {
248
+ throw typeError('ERR_INVALID_ARG_TYPE', 'Callback must be a function. Received type ' + (typeof cb) + ' (' + cb + ')')
249
+ }
250
+
251
+ return access(filepath, (err) => cb(!!err)) // eslint-disable-line n/no-callback-literal
252
+ }
253
+
254
+ function existsSync (filepath) {
255
+ if (typeof filepath !== 'string') {
256
+ throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof filepath) + ' (' + filepath + ')')
257
+ }
258
+
259
+ try {
260
+ accessSync(filepath)
261
+ return true
262
+ } catch {
263
+ return false
264
+ }
265
+ }
266
+
242
267
  function read (fd, buffer, offset, len, pos, cb) {
243
268
  if (typeof fd !== 'number') {
244
269
  throw typeError('ERR_INVALID_ARG_TYPE', 'File descriptor must be a number. Received type ' + (typeof fd) + ' (' + fd + ')')
@@ -1742,6 +1767,7 @@ function noop () {}
1742
1767
  exports.access = access
1743
1768
  exports.chmod = chmod
1744
1769
  exports.close = close
1770
+ exports.exists = exists
1745
1771
  exports.fchmod = fchmod
1746
1772
  exports.fstat = fstat
1747
1773
  exports.ftruncate = ftruncate
@@ -1769,6 +1795,7 @@ exports.writev = writev
1769
1795
  exports.accessSync = accessSync
1770
1796
  exports.chmodSync = chmodSync
1771
1797
  exports.closeSync = closeSync
1798
+ exports.existsSync = existsSync
1772
1799
  exports.fchmodSync = fchmodSync
1773
1800
  exports.fstatSync = fstatSync
1774
1801
  exports.lstatSync = lstatSync
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bare-fs",
3
- "version": "2.0.0",
3
+ "version": "2.1.1",
4
4
  "description": "Native file system for Javascript",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -11,11 +11,11 @@
11
11
  "CMakeLists.txt",
12
12
  "prebuilds"
13
13
  ],
14
- "imports": {
15
- "events": "bare-events"
14
+ "addon": {
15
+ "target": "bare_fs"
16
16
  },
17
17
  "scripts": {
18
- "test": "standard && bare -m package.json test.js"
18
+ "test": "standard && bare test.js"
19
19
  },
20
20
  "repository": {
21
21
  "type": "git",
Binary file
Binary file