REDROOM
PHP 8.2.30
Path:
Logout
Edit File
Size: 2.18 KB
Close
//opt/alt/alt-nodejs20/root/lib/node_modules/npm/node_modules/@npmcli/config/lib/parse-field.js
Text
Base64
// Parse a field, coercing it to the best type available. const typeDefs = require('./type-defs.js') const envReplace = require('./env-replace.js') const { resolve } = require('node:path') const { parse: umaskParse } = require('./umask.js') const parseField = (f, key, opts, listElement = false) => { if (typeof f !== 'string' && !Array.isArray(f)) { return f } const { platform, types, home, env } = opts // type can be array or a single thing. coerce to array. const typeList = new Set([].concat(types[key])) const isPath = typeList.has(typeDefs.path.type) const isBool = typeList.has(typeDefs.Boolean.type) const isString = isPath || typeList.has(typeDefs.String.type) const isUmask = typeList.has(typeDefs.Umask.type) const isNumber = typeList.has(typeDefs.Number.type) const isList = !listElement && typeList.has(Array) const isDate = typeList.has(typeDefs.Date.type) if (Array.isArray(f)) { return !isList ? f : f.map(field => parseField(field, key, opts, true)) } // now we know it's a string f = f.trim() // list types get put in the environment separated by double-\n // usually a single \n would suffice, but ca/cert configs can contain // line breaks and multiple entries. if (isList) { return parseField(f.split('\n\n'), key, opts) } // --foo is like --foo=true for boolean types if (isBool && !isString && f === '') { return true } // string types can be the string 'true', 'false', etc. // otherwise, parse these values out if (!isString && !isPath && !isNumber) { switch (f) { case 'true': return true case 'false': return false case 'null': return null case 'undefined': return undefined } } f = envReplace(f, env) if (isDate) { return new Date(f) } if (isPath) { const homePattern = platform === 'win32' ? /^~(\/|\\)/ : /^~\// if (homePattern.test(f) && home) { f = resolve(home, f.slice(2)) } else { f = resolve(f) } } if (isUmask) { try { return umaskParse(f) } catch (er) { // let it warn later when we validate return f } } if (isNumber && !isNaN(f)) { f = +f } return f } module.exports = parseField
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 1 × Files: 9
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
definitions
DIR
-
drwxr-xr-x
2026-03-14 07:02:08
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
env-replace.js
414 B
lrw-r--r--
2026-02-23 03:24:42
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
errors.js
707 B
lrw-r--r--
2026-02-23 03:24:42
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
index.js
28.21 KB
lrw-r--r--
2026-02-23 03:24:42
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
nerf-dart.js
455 B
lrw-r--r--
2026-02-23 03:24:42
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
parse-field.js
2.18 KB
lrw-r--r--
2026-02-23 03:24:42
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
set-envs.js
3.38 KB
lrw-r--r--
2026-02-23 03:24:42
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
type-defs.js
1.36 KB
lrw-r--r--
2026-02-23 03:24:42
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
type-description.js
574 B
lrw-r--r--
2026-02-23 03:24:42
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
umask.js
914 B
lrw-r--r--
2026-02-23 03:24:42
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).