This commit is contained in:
2025-06-26 03:35:15 +00:00
parent 56fa52fd80
commit 59f287112f
2193 changed files with 289518 additions and 3540 deletions

View File

@@ -0,0 +1,47 @@
var clone = require('./clone');
module.exports = merge;
function typesMatch(a, b) {
return (typeof a === typeof b) && (Array.isArray(a) === Array.isArray(b));
}
/**
* A deep merge of the source based on the target.
* @param {Object} source [description]
* @param {Object} target [description]
* @return {Object} [description]
*/
function merge(source, target, result) {
if (result === undefined) {
result = clone(source);
}
// merge missing values from the target to the source
Object.getOwnPropertyNames(target).forEach(function (key) {
if (source[key] === undefined) {
result[key] = target[key];
}
});
Object.getOwnPropertyNames(source).forEach(function (key) {
var value = source[key];
if (target[key] && typesMatch(value, target[key])) {
// merge empty values
if (value === '') {
result[key] = target[key];
}
if (Array.isArray(value)) {
if (value.length === 0 && target[key].length) {
result[key] = target[key].slice(0);
}
} else if (typeof value === 'object') {
result[key] = merge(value, target[key]);
}
}
});
return result;
}

View File

@@ -0,0 +1,105 @@
{
"name": "object-inspect",
"version": "1.13.4",
"description": "string representations of objects in node and the browser",
"main": "index.js",
"sideEffects": false,
"devDependencies": {
"@ljharb/eslint-config": "^21.1.1",
"@pkgjs/support": "^0.0.6",
"auto-changelog": "^2.5.0",
"core-js": "^2.6.12",
"error-cause": "^1.0.8",
"es-value-fixtures": "^1.7.1",
"eslint": "=8.8.0",
"for-each": "^0.3.4",
"functions-have-names": "^1.2.3",
"glob": "=10.3.7",
"globalthis": "^1.0.4",
"has-symbols": "^1.1.0",
"has-tostringtag": "^1.0.2",
"in-publish": "^2.0.1",
"jackspeak": "=2.1.1",
"make-arrow-function": "^1.2.0",
"mock-property": "^1.1.0",
"npmignore": "^0.3.1",
"nyc": "^10.3.2",
"safe-publish-latest": "^2.0.0",
"safer-buffer": "^2.1.2",
"semver": "^6.3.1",
"string.prototype.repeat": "^1.0.0",
"tape": "^5.9.0"
},
"scripts": {
"prepack": "npmignore --auto --commentLines=autogenerated",
"prepublish": "not-in-publish || npm run prepublishOnly",
"prepublishOnly": "safe-publish-latest",
"pretest": "npm run lint",
"lint": "eslint --ext=js,mjs .",
"postlint": "npx @pkgjs/support validate",
"test": "npm run tests-only && npm run test:corejs",
"tests-only": "nyc tape 'test/*.js'",
"test:corejs": "nyc tape test-core-js.js 'test/*.js'",
"posttest": "npx npm@'>=10.2' audit --production",
"version": "auto-changelog && git add CHANGELOG.md",
"postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\""
},
"testling": {
"files": [
"test/*.js",
"test/browser/*.js"
],
"browsers": [
"ie/6..latest",
"chrome/latest",
"firefox/latest",
"safari/latest",
"opera/latest",
"iphone/latest",
"ipad/latest",
"android/latest"
]
},
"repository": {
"type": "git",
"url": "git://github.com/inspect-js/object-inspect.git"
},
"homepage": "https://github.com/inspect-js/object-inspect",
"keywords": [
"inspect",
"util.inspect",
"object",
"stringify",
"pretty"
],
"author": {
"name": "James Halliday",
"email": "mail@substack.net",
"url": "http://substack.net"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
},
"license": "MIT",
"browser": {
"./util.inspect.js": false
},
"auto-changelog": {
"output": "CHANGELOG.md",
"template": "keepachangelog",
"unreleased": false,
"commitLimit": false,
"backfillLimit": false,
"hideCredit": true
},
"publishConfig": {
"ignore": [
".github/workflows",
"./test-core-js.js"
]
},
"support": true,
"engines": {
"node": ">= 0.4"
}
}

View File

@@ -0,0 +1,83 @@
'use strict'
/**
* Module dependencies.
*/
var bytes = require('bytes')
var contentType = require('content-type')
var typeis = require('type-is')
/**
* Module exports.
*/
module.exports = {
getCharset,
normalizeOptions
}
/**
* Get the charset of a request.
*
* @param {object} req
* @api private
*/
function getCharset (req) {
try {
return (contentType.parse(req).parameters.charset || '').toLowerCase()
} catch {
return undefined
}
}
/**
* Get the simple type checker.
*
* @param {string | string[]} type
* @return {function}
*/
function typeChecker (type) {
return function checkType (req) {
return Boolean(typeis(req, type))
}
}
/**
* Normalizes the common options for all parsers.
*
* @param {object} options options to normalize
* @param {string | string[] | function} defaultType default content type(s) or a function to determine it
* @returns {object}
*/
function normalizeOptions (options, defaultType) {
if (!defaultType) {
// Parsers must define a default content type
throw new TypeError('defaultType must be provided')
}
var inflate = options?.inflate !== false
var limit = typeof options?.limit !== 'number'
? bytes.parse(options?.limit || '100kb')
: options?.limit
var type = options?.type || defaultType
var verify = options?.verify || false
if (verify !== false && typeof verify !== 'function') {
throw new TypeError('option verify must be function')
}
// create the appropriate type checking function
var shouldParse = typeof type !== 'function'
? typeChecker(type)
: type
return {
inflate,
limit,
verify,
shouldParse
}
}

View File

@@ -0,0 +1,12 @@
import process from 'process';
const packageJson = process.env.npm_package_json;
const userAgent = process.env.npm_config_user_agent;
const isNpm6 = Boolean(userAgent && userAgent.startsWith('npm'));
const isNpm7 = Boolean(packageJson && packageJson.endsWith('package.json'));
const isNpm = isNpm6 || isNpm7;
const isYarn = Boolean(userAgent && userAgent.startsWith('yarn'));
const isNpmOrYarn = isNpm || isYarn;
export default isNpmOrYarn;