Upakovka v Electron.JS no po staroy sborke cherez .cjs

This commit is contained in:
Neyra
2026-02-10 19:19:41 +08:00
parent 8e9b7201ed
commit a1bba1d3d1
442 changed files with 19825 additions and 47462 deletions

156
node_modules/jsonfile/README.md generated vendored
View File

@@ -1,10 +1,10 @@
Node.js - jsonfile
================
Easily read/write JSON files in Node.js. _Note: this module cannot be used in the browser._
Easily read/write JSON files.
[![npm Package](https://img.shields.io/npm/v/jsonfile.svg?style=flat-square)](https://www.npmjs.org/package/jsonfile)
[![linux build status](https://img.shields.io/github/actions/workflow/status/jprichardson/node-jsonfile/ci.yml?branch=master)](https://github.com/jprichardson/node-jsonfile/actions?query=branch%3Amaster)
[![build status](https://secure.travis-ci.org/jprichardson/node-jsonfile.svg)](http://travis-ci.org/jprichardson/node-jsonfile)
[![windows Build status](https://img.shields.io/appveyor/ci/jprichardson/node-jsonfile/master.svg?label=windows%20build)](https://ci.appveyor.com/project/jprichardson/node-jsonfile/branch/master)
<a href="https://github.com/feross/standard"><img src="https://cdn.rawgit.com/feross/standard/master/sticker.svg" alt="Standard JavaScript" width="100"></a>
@@ -26,152 +26,101 @@ Installation
API
---
* [`readFile(filename, [options], callback)`](#readfilefilename-options-callback)
* [`readFileSync(filename, [options])`](#readfilesyncfilename-options)
* [`writeFile(filename, obj, [options], callback)`](#writefilefilename-obj-options-callback)
* [`writeFileSync(filename, obj, [options])`](#writefilesyncfilename-obj-options)
----
### readFile(filename, [options], callback)
`options` (`object`, default `undefined`): Pass in any [`fs.readFile`](https://nodejs.org/api/fs.html#fs_fs_readfile_path_options_callback) options or set `reviver` for a [JSON reviver](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse).
`options` (`object`, default `undefined`): Pass in any `fs.readFile` options or set `reviver` for a [JSON reviver](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse).
- `throws` (`boolean`, default: `true`). If `JSON.parse` throws an error, pass this error to the callback.
If `false`, returns `null` for the object.
```js
const jsonfile = require('jsonfile')
const file = '/tmp/data.json'
jsonfile.readFile(file, function (err, obj) {
if (err) console.error(err)
var jsonfile = require('jsonfile')
var file = '/tmp/data.json'
jsonfile.readFile(file, function(err, obj) {
console.dir(obj)
})
```
You can also use this method with promises. The `readFile` method will return a promise if you do not pass a callback function.
```js
const jsonfile = require('jsonfile')
const file = '/tmp/data.json'
jsonfile.readFile(file)
.then(obj => console.dir(obj))
.catch(error => console.error(error))
```
----
### readFileSync(filename, [options])
`options` (`object`, default `undefined`): Pass in any [`fs.readFileSync`](https://nodejs.org/api/fs.html#fs_fs_readfilesync_path_options) options or set `reviver` for a [JSON reviver](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse).
`options` (`object`, default `undefined`): Pass in any `fs.readFileSync` options or set `reviver` for a [JSON reviver](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse).
- `throws` (`boolean`, default: `true`). If an error is encountered reading or parsing the file, throw the error. If `false`, returns `null` for the object.
```js
const jsonfile = require('jsonfile')
const file = '/tmp/data.json'
var jsonfile = require('jsonfile')
var file = '/tmp/data.json'
console.dir(jsonfile.readFileSync(file))
```
----
### writeFile(filename, obj, [options], callback)
`options`: Pass in any [`fs.writeFile`](https://nodejs.org/api/fs.html#fs_fs_writefile_file_data_options_callback) options or set `replacer` for a [JSON replacer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify). Can also pass in `spaces`, or override `EOL` string or set `finalEOL` flag as `false` to not save the file with `EOL` at the end.
`options`: Pass in any `fs.writeFile` options or set `replacer` for a [JSON replacer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify). Can also pass in `spaces` and override `EOL` string.
```js
const jsonfile = require('jsonfile')
var jsonfile = require('jsonfile')
const file = '/tmp/data.json'
const obj = { name: 'JP' }
var file = '/tmp/data.json'
var obj = {name: 'JP'}
jsonfile.writeFile(file, obj, function (err) {
if (err) console.error(err)
console.error(err)
})
```
Or use with promises as follows:
```js
const jsonfile = require('jsonfile')
const file = '/tmp/data.json'
const obj = { name: 'JP' }
jsonfile.writeFile(file, obj)
.then(res => {
console.log('Write complete')
})
.catch(error => console.error(error))
```
**formatting with spaces:**
```js
const jsonfile = require('jsonfile')
var jsonfile = require('jsonfile')
const file = '/tmp/data.json'
const obj = { name: 'JP' }
var file = '/tmp/data.json'
var obj = {name: 'JP'}
jsonfile.writeFile(file, obj, { spaces: 2 }, function (err) {
if (err) console.error(err)
jsonfile.writeFile(file, obj, {spaces: 2}, function(err) {
console.error(err)
})
```
**overriding EOL:**
```js
const jsonfile = require('jsonfile')
var jsonfile = require('jsonfile')
const file = '/tmp/data.json'
const obj = { name: 'JP' }
var file = '/tmp/data.json'
var obj = {name: 'JP'}
jsonfile.writeFile(file, obj, { spaces: 2, EOL: '\r\n' }, function (err) {
if (err) console.error(err)
})
```
**disabling the EOL at the end of file:**
```js
const jsonfile = require('jsonfile')
const file = '/tmp/data.json'
const obj = { name: 'JP' }
jsonfile.writeFile(file, obj, { spaces: 2, finalEOL: false }, function (err) {
if (err) console.log(err)
jsonfile.writeFile(file, obj, {spaces: 2, EOL: '\r\n'}, function(err) {
console.error(err)
})
```
**appending to an existing JSON file:**
You can use `fs.writeFile` option `{ flag: 'a' }` to achieve this.
You can use `fs.writeFile` option `{flag: 'a'}` to achieve this.
```js
const jsonfile = require('jsonfile')
var jsonfile = require('jsonfile')
const file = '/tmp/mayAlreadyExistedData.json'
const obj = { name: 'JP' }
var file = '/tmp/mayAlreadyExistedData.json'
var obj = {name: 'JP'}
jsonfile.writeFile(file, obj, { flag: 'a' }, function (err) {
if (err) console.error(err)
jsonfile.writeFile(file, obj, {flag: 'a'}, function (err) {
console.error(err)
})
```
----
### writeFileSync(filename, obj, [options])
`options`: Pass in any [`fs.writeFileSync`](https://nodejs.org/api/fs.html#fs_fs_writefilesync_file_data_options) options or set `replacer` for a [JSON replacer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify). Can also pass in `spaces`, or override `EOL` string or set `finalEOL` flag as `false` to not save the file with `EOL` at the end.
`options`: Pass in any `fs.writeFileSync` options or set `replacer` for a [JSON replacer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify). Can also pass in `spaces` and override `EOL` string.
```js
const jsonfile = require('jsonfile')
var jsonfile = require('jsonfile')
const file = '/tmp/data.json'
const obj = { name: 'JP' }
var file = '/tmp/data.json'
var obj = {name: 'JP'}
jsonfile.writeFileSync(file, obj)
```
@@ -179,47 +128,36 @@ jsonfile.writeFileSync(file, obj)
**formatting with spaces:**
```js
const jsonfile = require('jsonfile')
var jsonfile = require('jsonfile')
const file = '/tmp/data.json'
const obj = { name: 'JP' }
var file = '/tmp/data.json'
var obj = {name: 'JP'}
jsonfile.writeFileSync(file, obj, { spaces: 2 })
jsonfile.writeFileSync(file, obj, {spaces: 2})
```
**overriding EOL:**
```js
const jsonfile = require('jsonfile')
var jsonfile = require('jsonfile')
const file = '/tmp/data.json'
const obj = { name: 'JP' }
var file = '/tmp/data.json'
var obj = {name: 'JP'}
jsonfile.writeFileSync(file, obj, { spaces: 2, EOL: '\r\n' })
```
**disabling the EOL at the end of file:**
```js
const jsonfile = require('jsonfile')
const file = '/tmp/data.json'
const obj = { name: 'JP' }
jsonfile.writeFileSync(file, obj, { spaces: 2, finalEOL: false })
jsonfile.writeFileSync(file, obj, {spaces: 2, EOL: '\r\n'})
```
**appending to an existing JSON file:**
You can use `fs.writeFileSync` option `{ flag: 'a' }` to achieve this.
You can use `fs.writeFileSync` option `{flag: 'a'}` to achieve this.
```js
const jsonfile = require('jsonfile')
var jsonfile = require('jsonfile')
const file = '/tmp/mayAlreadyExistedData.json'
const obj = { name: 'JP' }
var file = '/tmp/mayAlreadyExistedData.json'
var obj = {name: 'JP'}
jsonfile.writeFileSync(file, obj, { flag: 'a' })
jsonfile.writeFileSync(file, obj, {flag: 'a'})
```
License

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

@@ -1,58 +1,69 @@
let _fs
var _fs
try {
_fs = require('graceful-fs')
} catch (_) {
_fs = require('fs')
}
const universalify = require('universalify')
const { stringify, stripBom } = require('./utils')
async function _readFile (file, options = {}) {
function readFile (file, options, callback) {
if (callback == null) {
callback = options
options = {}
}
if (typeof options === 'string') {
options = { encoding: options }
options = {encoding: options}
}
const fs = options.fs || _fs
options = options || {}
var fs = options.fs || _fs
const shouldThrow = 'throws' in options ? options.throws : true
var shouldThrow = true
if ('throws' in options) {
shouldThrow = options.throws
}
let data = await universalify.fromCallback(fs.readFile)(file, options)
fs.readFile(file, options, function (err, data) {
if (err) return callback(err)
data = stripBom(data)
data = stripBom(data)
let obj
try {
obj = JSON.parse(data, options ? options.reviver : null)
} catch (err) {
if (shouldThrow) {
err.message = `${file}: ${err.message}`
throw err
} else {
return null
var obj
try {
obj = JSON.parse(data, options ? options.reviver : null)
} catch (err2) {
if (shouldThrow) {
err2.message = file + ': ' + err2.message
return callback(err2)
} else {
return callback(null, null)
}
}
}
return obj
callback(null, obj)
})
}
const readFile = universalify.fromPromise(_readFile)
function readFileSync (file, options = {}) {
function readFileSync (file, options) {
options = options || {}
if (typeof options === 'string') {
options = { encoding: options }
options = {encoding: options}
}
const fs = options.fs || _fs
var fs = options.fs || _fs
const shouldThrow = 'throws' in options ? options.throws : true
var shouldThrow = true
if ('throws' in options) {
shouldThrow = options.throws
}
try {
let content = fs.readFileSync(file, options)
var content = fs.readFileSync(file, options)
content = stripBom(content)
return JSON.parse(content, options.reviver)
} catch (err) {
if (shouldThrow) {
err.message = `${file}: ${err.message}`
err.message = file + ': ' + err.message
throw err
} else {
return null
@@ -60,29 +71,64 @@ function readFileSync (file, options = {}) {
}
}
async function _writeFile (file, obj, options = {}) {
const fs = options.fs || _fs
function stringify (obj, options) {
var spaces
var EOL = '\n'
if (typeof options === 'object' && options !== null) {
if (options.spaces) {
spaces = options.spaces
}
if (options.EOL) {
EOL = options.EOL
}
}
const str = stringify(obj, options)
var str = JSON.stringify(obj, options ? options.replacer : null, spaces)
await universalify.fromCallback(fs.writeFile)(file, str, options)
return str.replace(/\n/g, EOL) + EOL
}
const writeFile = universalify.fromPromise(_writeFile)
function writeFile (file, obj, options, callback) {
if (callback == null) {
callback = options
options = {}
}
options = options || {}
var fs = options.fs || _fs
function writeFileSync (file, obj, options = {}) {
const fs = options.fs || _fs
var str = ''
try {
str = stringify(obj, options)
} catch (err) {
// Need to return whether a callback was passed or not
if (callback) callback(err, null)
return
}
const str = stringify(obj, options)
fs.writeFile(file, str, options, callback)
}
function writeFileSync (file, obj, options) {
options = options || {}
var fs = options.fs || _fs
var str = stringify(obj, options)
// not sure if fs.writeFileSync returns anything, but just in case
return fs.writeFileSync(file, str, options)
}
// NOTE: do not change this export format; required for ESM compat
// see https://github.com/jprichardson/node-jsonfile/pull/162 for details
module.exports = {
readFile,
readFileSync,
writeFile,
writeFileSync
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')
content = content.replace(/^\uFEFF/, '')
return content
}
var jsonfile = {
readFile: readFile,
readFileSync: readFileSync,
writeFile: writeFile,
writeFileSync: writeFileSync
}
module.exports = jsonfile

13
node_modules/jsonfile/package.json generated vendored
View File

@@ -1,6 +1,6 @@
{
"name": "jsonfile",
"version": "6.2.0",
"version": "4.0.0",
"description": "Easily read/write JSON files.",
"repository": {
"type": "git",
@@ -16,21 +16,18 @@
],
"author": "JP Richardson <jprichardson@gmail.com>",
"license": "MIT",
"dependencies": {
"universalify": "^2.0.0"
},
"dependencies": {},
"optionalDependencies": {
"graceful-fs": "^4.1.6"
},
"devDependencies": {
"mocha": "^8.2.0",
"mocha": "2.x",
"rimraf": "^2.4.0",
"standard": "^16.0.1"
"standard": "^10.0.3"
},
"main": "index.js",
"files": [
"index.js",
"utils.js"
"index.js"
],
"scripts": {
"lint": "standard",

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

@@ -1,14 +0,0 @@
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
}
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/, '')
}
module.exports = { stringify, stripBom }