mirror of
https://github.com/Sevichecc/Urara-Blog.git
synced 2025-05-03 06:59:31 +08:00
24 lines
No EOL
431 B
Text
24 lines
No EOL
431 B
Text
import * as fs from 'graceful-fs';
|
|
|
|
export function asyncFileDescriptorMethod ( methodName ) {
|
|
return function () {
|
|
let args = [];
|
|
let i = arguments.length;
|
|
|
|
while ( i-- ) {
|
|
args[i] = arguments[i];
|
|
}
|
|
|
|
return new Promise( ( fulfil, reject ) => {
|
|
args.push( ( err, result ) => {
|
|
if ( err ) {
|
|
reject( err );
|
|
} else {
|
|
fulfil( result );
|
|
}
|
|
});
|
|
|
|
fs[ methodName ].apply( fs, args );
|
|
});
|
|
};
|
|
} |