FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

doc: update fs.watchFile doc by clement-nardi · Pull Request #40134 · nodejs/node · GitHub

/ node Public

doc: update fs.watchFile doc - #40134

Closed
clement-nardi wants to merge 1 commit into
nodejs:masterfrom
clement-nardi:patch-1
Closed

doc: update fs.watchFile doc#40134
clement-nardi wants to merge 1 commit into
nodejs:masterfrom
clement-nardi:patch-1

Conversation

Copy link
Copy Markdown
Contributor

The current wording suggests to compare Date objects, which won't work.

nodejs-github-bot added doc Issues and PRs related to the documentations. fs Issues and PRs related to the fs subsystem / file system. labels Sep 17, 2021

aduh95 commented Sep 17, 2021
edited
Loading

Copy link
Copy Markdown
Contributor

I mean, comparing Date objects does work in JavaScript:

new Date >= new Date; // true
new Date <= new Date; // true
new Date < new Date; // false
new Date > new Date; // false
new Date('1970-01-01') < new Date('2038-01-19'); // true
new Date('1970-01-01') > new Date('2038-01-19'); // false

// Equality on the other hand doesn't work
new Date == new Date // false
new Date('1970-01-01') == new Date('1970-01-01') // false

Copy link
Copy Markdown
Contributor Author

Well, here the idea is to know whether a file has been modified by comparing modified times.
I think most people would use the inequality operator for this:

if (prev.mtime !== curr.mtime) {
    console.log("The file has been modified!")
}

which doesn't work.

Actually that's the root cause of a bug I just fixed.

Copy link
Copy Markdown
Member

Keep in mind that "compare X and Y" does not mean "apply a JS comparison operator between X and Y"; for example, X.getTime() === Y.getTime() is a way to compare X and Y.

In any case, this can be sidestepped by just referring to curr.mtimeMs and prev.mtimeMs instead of curr.mtime and prev.mtime :)

Comment thread doc/api/fs.md Outdated
The current wording suggests to compare Date objects, which won't work.
targos added the commit-queue Add this label to land a pull request using GitHub Actions. label Sep 26, 2021
github-actions Bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Sep 26, 2021

Copy link
Copy Markdown
Contributor

Landed in a2ed30b...2b02d2f

github-actions Bot closed this Sep 26, 2021
nodejs-github-bot pushed a commit that referenced this pull request Sep 26, 2021
The current wording suggests to compare Date objects, which won't work.

PR-URL: #40134
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
targos pushed a commit that referenced this pull request Oct 4, 2021
The current wording suggests to compare Date objects, which won't work.

PR-URL: #40134
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc Issues and PRs related to the documentations. fs Issues and PRs related to the fs subsystem / file system.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants


Back | FazBrowse Home | New Git URL