Skip to content

Commit

Permalink
get-write-flag: don't test invariants
Browse files Browse the repository at this point in the history
If we're not on windows, or don't have fmap support,
then just make this be a function that always returns 'w'.

If it is windows, and has fmap support, only test the size.
  • Loading branch information
isaacs committed Sep 26, 2019
1 parent 14dc6f4 commit 82cb0f1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/get-write-flag.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ const { O_CREAT, O_TRUNC, O_WRONLY, UV_FS_O_FILEMAP = 0 } = fs.constants
const fMapEnabled = isWindows && !!UV_FS_O_FILEMAP
const fMapLimit = 512 * 1024
const fMapFlag = UV_FS_O_FILEMAP | O_TRUNC | O_CREAT | O_WRONLY
module.exports = size => (fMapEnabled && size < fMapLimit) ? fMapFlag : 'w'
module.exports = !fMapEnabled ? () => 'w'
: size => size < fMapLimit ? fMapFlag : 'w'

0 comments on commit 82cb0f1

Please sign in to comment.