Brunobkr/llama.cpp_AlgMor24_github
ΩFFFΣLLIa • llama.cpp • AlgMor24 ██████╗ ███████╗███████╗███████╗██╗ ██╗ ██╗ █████╗ ██╔═══██╗██╔════╝██╔════╝██╔════╝██║ ██║ ██║██╔══██╗ ██║ ██║█████╗ █████╗ █████╗ ██║ ██║ ██║███████║ ██║ ██║██╔══╝ ██╔══╝ ██╔══╝ ██║ ██║ ██║██╔══██║ ╚██████╔╝██║ ██║ ███████╗███████╗███████╗██║██║ ██║ ╚═════╝ ╚═╝ ╚═╝ ╚══════╝╚══════╝╚══════╝╚═╝╚═╝ ╚═╝ High-Performance LLM / VLM Inference & Autonomous Agentic Ecosystem… See the full description on the dataset page: https://huggingface.co/datasets/Brunobkr/llama.cpp_AlgMor24_github.
03.1k
1import { WalkerBase } from './walker.js';2 3/**4 * @typedef { import('estree').Node} Node5 * @typedef { import('./walker.js').WalkerContext} WalkerContext6 * @typedef {(7 * this: WalkerContext,8 * node: Node,9 * parent: Node | null,10 * key: string | number | symbol | null | undefined,11 * index: number | null | undefined12 * ) => void} SyncHandler13 */14 15export class SyncWalker extends WalkerBase {16 /**17 *18 * @param {SyncHandler} [enter]19 * @param {SyncHandler} [leave]20 */21 constructor(enter, leave) {22 super();23 24 /** @type {boolean} */25 this.should_skip = false;26 27 /** @type {boolean} */28 this.should_remove = false;29 30 /** @type {Node | null} */31 this.replacement = null;32 33 /** @type {WalkerContext} */34 this.context = {35 skip: () => (this.should_skip = true),36 remove: () => (this.should_remove = true),37 replace: (node) => (this.replacement = node)38 };39 40 /** @type {SyncHandler | undefined} */41 this.enter = enter;42 43 /** @type {SyncHandler | undefined} */44 this.leave = leave;45 }46 47 /**48 * @template {Node} Parent49 * @param {Node} node50 * @param {Parent | null} parent51 * @param {keyof Parent} [prop]52 * @param {number | null} [index]53 * @returns {Node | null}54 */55 visit(node, parent, prop, index) {56 if (node) {57 if (this.enter) {58 const _should_skip = this.should_skip;59 const _should_remove = this.should_remove;60 const _replacement = this.replacement;61 this.should_skip = false;62 this.should_remove = false;63 this.replacement = null;64 65 this.enter.call(this.context, node, parent, prop, index);66 67 if (this.replacement) {68 node = this.replacement;69 this.replace(parent, prop, index, node);70 }71 72 if (this.should_remove) {73 this.remove(parent, prop, index);74 }75 76 const skipped = this.should_skip;77 const removed = this.should_remove;78 79 this.should_skip = _should_skip;80 this.should_remove = _should_remove;81 this.replacement = _replacement;82 83 if (skipped) return node;84 if (removed) return null;85 }86 87 /** @type {keyof Node} */88 let key;89 90 for (key in node) {91 /** @type {unknown} */92 const value = node[key];93 94 if (value && typeof value === 'object') {95 if (Array.isArray(value)) {96 const nodes = /** @type {Array<unknown>} */ (value);97 for (let i = 0; i < nodes.length; i += 1) {98 const item = nodes[i];99 if (isNode(item)) {100 if (!this.visit(item, node, key, i)) {101 // removed102 i--;103 }104 }105 }106 } else if (isNode(value)) {107 this.visit(value, node, key, null);108 }109 }110 }111 112 if (this.leave) {113 const _replacement = this.replacement;114 const _should_remove = this.should_remove;115 this.replacement = null;116 this.should_remove = false;117 118 this.leave.call(this.context, node, parent, prop, index);119 120 if (this.replacement) {121 node = this.replacement;122 this.replace(parent, prop, index, node);123 }124 125 if (this.should_remove) {126 this.remove(parent, prop, index);127 }128 129 const removed = this.should_remove;130 131 this.replacement = _replacement;132 this.should_remove = _should_remove;133 134 if (removed) return null;135 }136 }137 138 return node;139 }140}141 142/**143 * Ducktype a node.144 *145 * @param {unknown} value146 * @returns {value is Node}147 */148function isNode(value) {149 return (150 value !== null && typeof value === 'object' && 'type' in value && typeof value.type === 'string'151 );152}153 