format: prettify entire project

This commit is contained in:
Rim
2025-04-02 06:50:39 -04:00
parent 86f0782a98
commit 7ccc0be712
1711 changed files with 755867 additions and 235931 deletions

80
node_modules/jsonfile/index.js generated vendored
View File

@ -1,88 +1,88 @@
let _fs
let _fs;
try {
_fs = require('graceful-fs')
_fs = require('graceful-fs');
} catch (_) {
_fs = require('fs')
_fs = require('fs');
}
const universalify = require('universalify')
const { stringify, stripBom } = require('./utils')
const universalify = require('universalify');
const { stringify, stripBom } = require('./utils');
async function _readFile (file, options = {}) {
async function _readFile(file, options = {}) {
if (typeof options === 'string') {
options = { encoding: options }
options = { encoding: options };
}
const fs = options.fs || _fs
const fs = options.fs || _fs;
const shouldThrow = 'throws' in options ? options.throws : true
const shouldThrow = 'throws' in options ? options.throws : true;
let data = await universalify.fromCallback(fs.readFile)(file, options)
let data = await universalify.fromCallback(fs.readFile)(file, options);
data = stripBom(data)
data = stripBom(data);
let obj
let obj;
try {
obj = JSON.parse(data, options ? options.reviver : null)
obj = JSON.parse(data, options ? options.reviver : null);
} catch (err) {
if (shouldThrow) {
err.message = `${file}: ${err.message}`
throw err
err.message = `${file}: ${err.message}`;
throw err;
} else {
return null
return null;
}
}
return obj
return obj;
}
const readFile = universalify.fromPromise(_readFile)
const readFile = universalify.fromPromise(_readFile);
function readFileSync (file, options = {}) {
function readFileSync(file, options = {}) {
if (typeof options === 'string') {
options = { encoding: options }
options = { encoding: options };
}
const fs = options.fs || _fs
const fs = options.fs || _fs;
const shouldThrow = 'throws' in options ? options.throws : true
const shouldThrow = 'throws' in options ? options.throws : true;
try {
let content = fs.readFileSync(file, options)
content = stripBom(content)
return JSON.parse(content, options.reviver)
let content = fs.readFileSync(file, options);
content = stripBom(content);
return JSON.parse(content, options.reviver);
} catch (err) {
if (shouldThrow) {
err.message = `${file}: ${err.message}`
throw err
err.message = `${file}: ${err.message}`;
throw err;
} else {
return null
return null;
}
}
}
async function _writeFile (file, obj, options = {}) {
const fs = options.fs || _fs
async function _writeFile(file, obj, options = {}) {
const fs = options.fs || _fs;
const str = stringify(obj, options)
const str = stringify(obj, options);
await universalify.fromCallback(fs.writeFile)(file, str, options)
await universalify.fromCallback(fs.writeFile)(file, str, options);
}
const writeFile = universalify.fromPromise(_writeFile)
const writeFile = universalify.fromPromise(_writeFile);
function writeFileSync (file, obj, options = {}) {
const fs = options.fs || _fs
function writeFileSync(file, obj, options = {}) {
const fs = options.fs || _fs;
const str = stringify(obj, options)
const str = stringify(obj, options);
// not sure if fs.writeFileSync returns anything, but just in case
return fs.writeFileSync(file, str, options)
return fs.writeFileSync(file, str, options);
}
const jsonfile = {
readFile,
readFileSync,
writeFile,
writeFileSync
}
writeFileSync,
};
module.exports = jsonfile
module.exports = jsonfile;

19
node_modules/jsonfile/utils.js generated vendored
View File

@ -1,14 +1,17 @@
function stringify (obj, { EOL = '\n', finalEOL = true, replacer = null, spaces } = {}) {
const EOF = finalEOL ? EOL : ''
const str = JSON.stringify(obj, replacer, spaces)
function stringify(
obj,
{ EOL = '\n', finalEOL = true, replacer = null, spaces } = {}
) {
const EOF = finalEOL ? EOL : '';
const str = JSON.stringify(obj, replacer, spaces);
return str.replace(/\n/g, EOL) + EOF
return str.replace(/\n/g, EOL) + EOF;
}
function stripBom (content) {
function stripBom(content) {
// we do this because JSON.parse would convert it to a utf8 string if encoding wasn't specified
if (Buffer.isBuffer(content)) content = content.toString('utf8')
return content.replace(/^\uFEFF/, '')
if (Buffer.isBuffer(content)) content = content.toString('utf8');
return content.replace(/^\uFEFF/, '');
}
module.exports = { stringify, stripBom }
module.exports = { stringify, stripBom };