Surge_by_SukkaW/Dist/chunks/misc.BpcQjda1.cjs
SukkaW d354c5e988
Some checks are pending
Build / Build (push) Waiting to run
Build / Diff output (push) Blocked by required conditions
Build / Deploy to Cloudflare Pages (push) Blocked by required conditions
Build / Deploy to GitHub and GitLab (push) Blocked by required conditions
Chore: maintainance
2025-02-07 17:52:36 +08:00

122 lines
3.6 KiB
JavaScript

'use strict';const require$$0=require('node:path'),require$$1=require('node:fs'),require$$2=require('node:fs/promises');var misc = {};var hasRequiredMisc;
function requireMisc () {
if (hasRequiredMisc) return misc;
hasRequiredMisc = 1;
(function (exports) {
Object.defineProperty(exports, "__esModule", {
value: true
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
fastIpVersion: function() {
return fastIpVersion;
},
fastStringCompare: function() {
return fastStringCompare;
},
isDirectoryEmptySync: function() {
return isDirectoryEmptySync;
},
mkdirp: function() {
return mkdirp;
},
notSupported: function() {
return notSupported;
},
removeFiles: function() {
return removeFiles;
},
withBannerArray: function() {
return withBannerArray;
},
withIdentityContent: function() {
return withIdentityContent;
},
writeFile: function() {
return writeFile;
}
});
const _nodepath = require$$0;
const _nodefs = /*#__PURE__*/ _interop_require_default(require$$1);
const _promises = /*#__PURE__*/ _interop_require_default(require$$2);
function _interop_require_default(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
function fastStringCompare(a, b) {
const lenA = a.length;
const lenB = b.length;
const minLen = lenA < lenB ? lenA : lenB;
for(let i = 0; i < minLen; ++i){
const ca = a.charCodeAt(i);
const cb = b.charCodeAt(i);
if (ca > cb) return 1;
if (ca < cb) return -1;
}
if (lenA === lenB) {
return 0;
}
return lenA > lenB ? 1 : -1;
}
function mkdirp(dir) {
if (_nodefs.default.existsSync(dir)) {
return;
}
return _promises.default.mkdir(dir, {
recursive: true
});
}
const writeFile = async (destination, input, dir = (0, _nodepath.dirname)(destination))=>{
const p = mkdirp(dir);
if (p) {
await p;
}
return _promises.default.writeFile(destination, input, {
encoding: 'utf-8'
});
};
const removeFiles = async (files)=>Promise.all(files.map((file)=>_promises.default.rm(file, {
force: true
})));
function withBannerArray(title, description, date, content) {
return [
'#########################################',
`# ${title}`,
`# Last Updated: ${date.toISOString()}`,
`# Size: ${content.length}`,
...description.map((line)=>line ? `# ${line}` : '#'),
'#########################################',
...content,
'################## EOF ##################'
];
}
function notSupported(name) {
return (...args)=>{
console.error(`${name}: not supported.`, args);
throw new Error(`${name}: not implemented.`);
};
}
function withIdentityContent(title, description, date, content) {
return content;
}
function isDirectoryEmptySync(path) {
const directoryHandle = _nodefs.default.opendirSync(path);
try {
return directoryHandle.readSync() === null;
} finally{
directoryHandle.closeSync();
}
}
function fastIpVersion(ip) {
return ip.includes(':') ? 6 : ip.includes('.') ? 4 : 0;
}
} (misc));
return misc;
}exports.r=requireMisc;