Skip to content

Commit c4329aa

Browse files
thefourtheyervagg
authored andcommitted
fs: move mkdtemp* functions near static functions
PR-URL: #6828 Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent c068880 commit c4329aa

File tree

1 file changed

+41
-39
lines changed

1 file changed

+41
-39
lines changed

lib/fs.js

Lines changed: 41 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,6 +1590,47 @@ fs.realpath = function realpath(path, options, callback) {
15901590
};
15911591

15921592

1593+
fs.mkdtemp = function(prefix, options, callback_) {
1594+
var callback = maybeCallback(callback_);
1595+
if (!prefix || typeof prefix !== 'string')
1596+
throw new TypeError('filename prefix is required');
1597+
1598+
options = options || {};
1599+
if (typeof options === 'function') {
1600+
callback = options;
1601+
options = {};
1602+
} else if (typeof options === 'string') {
1603+
options = {encoding: options};
1604+
}
1605+
if (typeof options !== 'object')
1606+
throw new TypeError('"options" must be a string or an object');
1607+
1608+
if (!nullCheck(prefix, callback)) {
1609+
return;
1610+
}
1611+
1612+
var req = new FSReqWrap();
1613+
req.oncomplete = callback;
1614+
1615+
binding.mkdtemp(prefix + 'XXXXXX', options.encoding, req);
1616+
};
1617+
1618+
1619+
fs.mkdtempSync = function(prefix, options) {
1620+
if (!prefix || typeof prefix !== 'string')
1621+
throw new TypeError('filename prefix is required');
1622+
1623+
options = options || {};
1624+
if (typeof options === 'string')
1625+
options = {encoding: options};
1626+
if (typeof options !== 'object')
1627+
throw new TypeError('"options" must be a string or an object');
1628+
nullCheck(prefix);
1629+
1630+
return binding.mkdtemp(prefix + 'XXXXXX', options.encoding);
1631+
};
1632+
1633+
15931634
var pool;
15941635

15951636
function allocNewPool(poolSize) {
@@ -1993,42 +2034,3 @@ SyncWriteStream.prototype.destroy = function() {
19932034
};
19942035

19952036
SyncWriteStream.prototype.destroySoon = SyncWriteStream.prototype.destroy;
1996-
1997-
fs.mkdtemp = function(prefix, options, callback_) {
1998-
var callback = maybeCallback(callback_);
1999-
if (!prefix || typeof prefix !== 'string')
2000-
throw new TypeError('filename prefix is required');
2001-
2002-
options = options || {};
2003-
if (typeof options === 'function') {
2004-
callback = options;
2005-
options = {};
2006-
} else if (typeof options === 'string') {
2007-
options = {encoding: options};
2008-
}
2009-
if (typeof options !== 'object')
2010-
throw new TypeError('"options" must be a string or an object');
2011-
2012-
if (!nullCheck(prefix, callback)) {
2013-
return;
2014-
}
2015-
2016-
var req = new FSReqWrap();
2017-
req.oncomplete = callback;
2018-
2019-
binding.mkdtemp(prefix + 'XXXXXX', options.encoding, req);
2020-
};
2021-
2022-
fs.mkdtempSync = function(prefix, options) {
2023-
if (!prefix || typeof prefix !== 'string')
2024-
throw new TypeError('filename prefix is required');
2025-
2026-
options = options || {};
2027-
if (typeof options === 'string')
2028-
options = {encoding: options};
2029-
if (typeof options !== 'object')
2030-
throw new TypeError('"options" must be a string or an object');
2031-
nullCheck(prefix);
2032-
2033-
return binding.mkdtemp(prefix + 'XXXXXX', options.encoding);
2034-
};

0 commit comments

Comments
 (0)