UNPKG

pybuiltinfunc

Version:

Python built-in Functions and Modules in Javascript

33 lines (31 loc) 840 B
const fs = require("fs"); const path = require("path"); module.exports.getcwD = () => process.cwd(); module.exports.chdir = (path = "") => process.chdir(path); const joinz = path.join; module.exports.path = { join: joinz, }; module.exports.mKdir = (path = "") => { fs.mkdir(path, () => {}); }; module.exports.listDir = (path = "") => { let list = []; fs.readdirSync(path, { encoding: "utf8", withFileTypes: true, }).forEach((files) => { list.push(files.name); }); return list; }; module.exports.rmDir = (path = "") => { fs.rmdir(path, () => {}); }; module.exports.remove = (path = "") => { return fs.rm(path); }; module.exports.rename = (oldFileName = "", newFileName = "") => { fs.rename(oldFileName, newFileName, () => {}); }; module.exports.name = () => process.platform;