PHP 8.2.30
Preview: walker.js Size: 1.09 KB
/home/byroehnu/.trash/node_modules11/estree-walker/src/walker.js

// @ts-check
/** @typedef { import('estree').BaseNode} BaseNode */

/** @typedef {{
	skip: () => void;
	remove: () => void;
	replace: (node: BaseNode) => void;
}} WalkerContext */

export class WalkerBase {
	constructor() {
		/** @type {boolean} */
		this.should_skip = false;

		/** @type {boolean} */
		this.should_remove = false;

		/** @type {BaseNode | null} */
		this.replacement = null;

		/** @type {WalkerContext} */
		this.context = {
			skip: () => (this.should_skip = true),
			remove: () => (this.should_remove = true),
			replace: (node) => (this.replacement = node)
		};
	}

	/**
	 *
	 * @param {any} parent
	 * @param {string} prop
	 * @param {number} index
	 * @param {BaseNode} node
	 */
	replace(parent, prop, index, node) {
		if (parent) {
			if (index !== null) {
				parent[prop][index] = node;
			} else {
				parent[prop] = node;
			}
		}
	}

	/**
	 *
	 * @param {any} parent
	 * @param {string} prop
	 * @param {number} index
	 */
	remove(parent, prop, index) {
		if (parent) {
			if (index !== null) {
				parent[prop].splice(index, 1);
			} else {
				delete parent[prop];
			}
		}
	}
}

Directory Contents

Dirs: 0 × Files: 5

Name Size Perms Modified Actions
2.65 KB lrw-r--r-- 2026-02-28 00:26:44
Edit Download
842 B lrw-r--r-- 2026-02-28 00:27:28
Edit Download
18 B lrw-r--r-- 2026-02-28 00:28:02
Edit Download
2.60 KB lrw-r--r-- 2026-02-28 00:27:34
Edit Download
1.09 KB lrw-r--r-- 2026-02-28 00:27:42
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).