summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLucas Holmquist <lholmqui@redhat.com>2019-10-09 08:40:30 -0400
committerRich Trott <rtrott@gmail.com>2019-10-12 19:56:07 -0700
commit7eacb7438960da98eaf210e232ea93a98e247b72 (patch)
treebea0591ab3e77b12c2c0dd7e0f601efaf06a403d /lib
parent40ef537d6949f723d2d4af841d95bd9d4b28ea81 (diff)
downloadandroid-node-v8-7eacb7438960da98eaf210e232ea93a98e247b72.tar.gz
android-node-v8-7eacb7438960da98eaf210e232ea93a98e247b72.tar.bz2
android-node-v8-7eacb7438960da98eaf210e232ea93a98e247b72.zip
fs: make FSWatcher.start private
* This is a semver-major change to rename the FSWatcher.start function to FSWatcher._start to make it private The motivation here is that it serves no purpose to the end user. An instance of FSWatcher is returned when a user calls fs.watch, which will call the start method. A user can't create an instance of a FSWatcher directly. If the start method is called by a user it is a noop since the watcher has already started. Calling start after a watcher has closed is also a noop PR-URL: https://github.com/nodejs/node/pull/29905 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/fs.js8
-rw-r--r--lib/internal/fs/watchers.js19
2 files changed, 14 insertions, 13 deletions
diff --git a/lib/fs.js b/lib/fs.js
index d5c7ea70d8..1b3df1119f 100644
--- a/lib/fs.js
+++ b/lib/fs.js
@@ -1342,10 +1342,10 @@ function watch(filename, options, listener) {
if (!watchers)
watchers = require('internal/fs/watchers');
const watcher = new watchers.FSWatcher();
- watcher.start(filename,
- options.persistent,
- options.recursive,
- options.encoding);
+ watcher[watchers.kFSWatchStart](filename,
+ options.persistent,
+ options.recursive,
+ options.encoding);
if (listener) {
watcher.addListener('change', listener);
diff --git a/lib/internal/fs/watchers.js b/lib/internal/fs/watchers.js
index bde07cfdc5..4dfa83c3b2 100644
--- a/lib/internal/fs/watchers.js
+++ b/lib/internal/fs/watchers.js
@@ -25,6 +25,8 @@ const assert = require('internal/assert');
const kOldStatus = Symbol('kOldStatus');
const kUseBigint = Symbol('kUseBigint');
+const kFSWatchStart = Symbol('kFSWatchStart');
+
function emitStop(self) {
self.emit('stop');
}
@@ -135,18 +137,16 @@ function FSWatcher() {
Object.setPrototypeOf(FSWatcher.prototype, EventEmitter.prototype);
Object.setPrototypeOf(FSWatcher, EventEmitter);
-
-// FIXME(joyeecheung): this method is not documented.
// At the moment if filename is undefined, we
-// 1. Throw an Error if it's the first time .start() is called
-// 2. Return silently if .start() has already been called
+// 1. Throw an Error if it's the first time Symbol('kFSWatchStart') is called
+// 2. Return silently if Symbol('kFSWatchStart') has already been called
// on a valid filename and the wrap has been initialized
// 3. Return silently if the watcher has already been closed
// This method is a noop if the watcher has already been started.
-FSWatcher.prototype.start = function(filename,
- persistent,
- recursive,
- encoding) {
+FSWatcher.prototype[kFSWatchStart] = function(filename,
+ persistent,
+ recursive,
+ encoding) {
if (this._handle === null) { // closed
return;
}
@@ -202,5 +202,6 @@ Object.defineProperty(FSEvent.prototype, 'owner', {
module.exports = {
FSWatcher,
- StatWatcher
+ StatWatcher,
+ kFSWatchStart
};