HEX
Server: nginx/1.18.0
System: Linux test-ipsremont 5.4.0-214-generic #234-Ubuntu SMP Fri Mar 14 23:50:27 UTC 2025 x86_64
User: ips (1000)
PHP: 8.0.30
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/design.system/node_modules/react-docgen/dist/utils/expressionTo.js
/*eslint no-loop-func: 0, no-use-before-define: 0*/
import resolveToValue from './resolveToValue.js';
/**
 * Splits a MemberExpression or CallExpression into parts.
 * E.g. foo.bar.baz becomes ['foo', 'bar', 'baz']
 */
function toArray(path) {
    const parts = [path];
    let result = [];
    while (parts.length > 0) {
        path = parts.shift();
        if (path.isCallExpression()) {
            parts.push(path.get('callee'));
            continue;
        }
        else if (path.isMemberExpression()) {
            parts.push(path.get('object'));
            const property = path.get('property');
            if (path.node.computed) {
                const resolvedPath = resolveToValue(property);
                if (resolvedPath !== undefined) {
                    result = result.concat(toArray(resolvedPath));
                }
                else {
                    result.push('<computed>');
                }
            }
            else if (property.isIdentifier()) {
                result.push(property.node.name);
            }
            else if (property.isPrivateName()) {
                // new test
                result.push(`#${property.get('id').node.name}`);
            }
            continue;
        }
        else if (path.isIdentifier()) {
            result.push(path.node.name);
            continue;
        }
        else if (path.isTSAsExpression()) {
            const expression = path.get('expression');
            if (expression.isIdentifier()) {
                result.push(expression.node.name);
            }
            continue;
        }
        else if (path.isLiteral() && path.node.extra?.raw) {
            result.push(path.node.extra.raw);
            continue;
        }
        else if (path.isThisExpression()) {
            result.push('this');
            continue;
        }
        else if (path.isObjectExpression()) {
            const properties = path.get('properties').map(function (property) {
                if (property.isSpreadElement()) {
                    return `...${toString(property.get('argument'))}`;
                }
                else if (property.isObjectProperty()) {
                    return (toString(property.get('key')) +
                        ': ' +
                        toString(property.get('value')));
                }
                else if (property.isObjectMethod()) {
                    return toString(property.get('key')) + ': <function>';
                }
                else {
                    throw new Error('Unrecognized object property type');
                }
            });
            result.push('{' + properties.join(', ') + '}');
            continue;
        }
        else if (path.isArrayExpression()) {
            result.push('[' +
                path
                    .get('elements')
                    .map(function (el) {
                    return toString(el);
                })
                    .join(', ') +
                ']');
            continue;
        }
    }
    return result.reverse();
}
/**
 * Creates a string representation of a member expression.
 */
function toString(path) {
    return toArray(path).join('.');
}
export { toString as String, toArray as Array };