fs-copy-file
Advanced tools
Comparing version 2.1.0 to 2.1.1
@@ -10,5 +10,3 @@ 'use strict'; | ||
module.exports = fs.copyFile ? fs.copyFile : copyFile; | ||
module.exports.constants = { | ||
const constants = { | ||
COPYFILE_EXCL, | ||
@@ -19,6 +17,17 @@ COPYFILE_FICLONE, | ||
const isExcl = (flags) => { | ||
return flags & COPYFILE_EXCL; | ||
}; | ||
module.exports = fs.copyFile ? fs.copyFile : copyFile; | ||
module.exports.constants = constants; | ||
const isNumber = (a) => typeof a === 'number'; | ||
const or = (a, b) => a | b; | ||
const getValue = (obj) => (key) => obj[key]; | ||
const getMaxMask = (obj) => Object | ||
.keys(obj) | ||
.map(getValue(obj)) | ||
.reduce(or); | ||
const MAX_MASK = getMaxMask(constants); | ||
const isExcl = (flags) => flags & COPYFILE_EXCL; | ||
function copyFile(src, dest, flags, callback) { | ||
@@ -59,3 +68,3 @@ if (!callback) { | ||
if (typeof flags === 'number' && flags && flags !== COPYFILE_EXCL) | ||
if (flags && isNumber(flags) && (flags > MAX_MASK || flags < 0)) | ||
throw Error(`EINVAL: invalid argument, copyfile -> '${dest}'`); | ||
@@ -62,0 +71,0 @@ } |
{ | ||
"name": "fs-copy-file", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)", | ||
@@ -5,0 +5,0 @@ "description": "fs.copyFile ponyfill", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8150
60