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
1# 🧀 Magicast2 3[![npm version][npm-version-src]][npm-version-href]4[![npm downloads][npm-downloads-src]][npm-downloads-href]5[![bundle][bundle-src]][bundle-href]6[![Codecov][codecov-src]][codecov-href]7[![License][license-src]][license-href]8[![JSDocs][jsdocs-src]][jsdocs-href]9 10Programmatically modify JavaScript and TypeScript source codes with a simplified, elegant and familiar syntax. Built on top of the [AST](https://en.wikipedia.org/wiki/Abstract_syntax_tree) parsed by [recast](https://github.com/benjamn/recast) and [babel](https://babeljs.io/).11 12❯ 🧙🏼 **Magical** modify a JS/TS file and write back magically just like JSON!<br>13❯ 🔀 **Exports/Import** manipulate module's imports and exports at ease<br>14❯ 💼 **Function Arguments** easily manipulate arguments passed to a function call, like `defineConfig()`<br>15❯ 🎨 **Smart Formatting** preseves the formatting style (quotes, tabs, etc.) from the original code<br>16❯ 🧑💻 **Readable** get rid of the complexity of AST manipulation and make your code super readable<br>17 18## Install19 20Install npm package:21 22```sh23yarn add --dev magicast24 25npm install -D magicast26 27pnpm add -D magicast28```29 30Import utilities:31 32```js33import { parseModule, generateCode, builders, createNode } from "magicast";34```35 36## Examples37 38**Example:** Modify a file:39 40`config.js`:41 42```js43export default {44 foo: ["a"],45};46```47 48Code to modify and append `b` to `foo` prop of defaultExport:49 50```js51import { loadFile, writeFile } from "magicast";52 53const mod = await loadFile("config.js");54 55mod.exports.default.foo.push("b");56 57await writeFile(mod, "config.js");58```59 60Updated `config.js`:61 62```js63export default {64 foo: ["a", "b"],65};66```67 68**Example:** Directly use AST utils:69 70```js71import { parseModule, generateCode } from "magicast";72 73// Parse to AST74const mod = parseModule(`export default { }`);75 76// Ensure foo is an array77mod.exports.default.foo ||= [];78// Add a new array member79mod.exports.default.foo.push("b");80mod.exports.default.foo.unshift("a");81 82// Generate code83const { code, map } = generateCode(mod);84```85 86Generated code:87 88```js89export default {90 foo: ["a", "b"],91};92```93 94**Example:** Get the AST directly:95 96```js97import { parseModule, generateCode } from "magicast";98 99const mod = parseModule(`export default { }`);100 101const ast = mod.exports.default.$ast;102// do something with ast103```104 105**Example:** Function arguments:106 107```js108import { parseModule, generateCode } from "magicast";109 110const mod = parseModule(`export default defineConfig({ foo: 'bar' })`);111 112// Support for both bare object export and `defineConfig` wrapper113const options =114 mod.exports.default.$type === "function-call"115 ? mod.exports.default.$args[0]116 : mod.exports.default;117 118console.log(options.foo); // bar119```120 121**Example:** Create a function call:122 123```js124import { parseModule, generateCode, builders } from "magicast";125 126const mod = parseModule(`export default {}`);127 128const options = (mod.exports.default.list = builders.functionCall(129 "create",130 [1, 2, 3],131));132 133console.log(mod.generateCode()); // export default { list: create([1, 2, 3]) }134```135 136## Notes137 138As JavaScript is a very dynamic language, you should be aware that Magicast's convention **CAN NOT cover all possible cases**. Magicast serves as a simple and maintainable interface to update static-ish JavaScript code. When interacting with Magicast node, be aware that every option might have chance to throw an error depending on the input code. We recommend to always wrap the code in a `try/catch` block (even better to do some defensive coding), for example:139 140```ts141import { loadFile, writeFile } from "magicast";142 143function updateConfig() {144 try {145 const mod = await loadFile("config.js");146 147 mod.exports.default.foo.push("b");148 149 await writeFile(mod);150 } catch {151 console.error("Unable to update config.js");152 console.error(153 "Please update it manually with the following instructions: ...",154 );155 // handle error156 }157}158```159 160## Browser / Worker Support161 162The main export of `magicast` contains filesystem utilities. If you want to use it in a browser or worker, import from `magicast/core` instead.163 164```js165import { parseModule } from "magicast/core";166```167 168## High Level Helpers169 170We also experiment to provide a few high level helpers to make common tasks easier. You could import them from `magicast/helpers`. They might be moved to a separate package in the future.171 172```js173import {174 deepMergeObject,175 addNuxtModule,176 addVitePlugin,177 // ...178} from "magicast/helpers";179```180 181We recommend to check out the [source code](./src/helpers) and [test cases](./test/helpers) for more details.182 183## Development184 185- Clone this repository186- Install latest LTS version of [Node.js](https://nodejs.org/en/)187- Enable [Corepack](https://github.com/nodejs/corepack) using `corepack enable`188- Install dependencies using `pnpm install`189- Run interactive tests using `pnpm dev`190 191## License192 193Made with 💛194 195Published under [MIT License](./LICENSE).196 197<!-- Badges -->198 199[npm-version-src]: https://img.shields.io/npm/v/magicast?style=flat&colorA=18181B&colorB=F0DB4F200[npm-version-href]: https://npmjs.com/package/magicast201[npm-downloads-src]: https://img.shields.io/npm/dm/magicast?style=flat&colorA=18181B&colorB=F0DB4F202[npm-downloads-href]: https://npmjs.com/package/magicast203[codecov-src]: https://img.shields.io/codecov/c/gh/unjs/magicast/main?style=flat&colorA=18181B&colorB=F0DB4F204[codecov-href]: https://codecov.io/gh/unjs/magicast205[bundle-src]: https://img.shields.io/bundlephobia/minzip/magicast?style=flat&colorA=18181B&colorB=F0DB4F206[bundle-href]: https://bundlephobia.com/result?p=magicast207[license-src]: https://img.shields.io/github/license/unjs/magicast.svg?style=flat&colorA=18181B&colorB=F0DB4F208[license-href]: https://github.com/unjs/magicast/blob/main/LICENSE209[jsdocs-src]: https://img.shields.io/badge/jsDocs.io-reference-18181B?style=flat&colorA=18181B&colorB=F0DB4F210[jsdocs-href]: https://www.jsdocs.io/package/magicast211 