/
Alex_Ural
/
opencode
Обзор
Документация
Войти
/
Alex_Ural
/
opencode
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
packages/codemode/src/stdlib/string.ts
52 строки
1 KB
Aiden Cline
feat(codemode): sync v2 implementation (#35574)
06 июл 2026, 21:19
Не верифицирован
06 июл 2026, 21:19
d5aa79c
Код
Авторство
О чём код?
export const stringMethods = new Set([ "toLowerCase", "toUpperCase", "trim", "trimStart", "trimEnd", "trimLeft", "trimRight", "split", "slice", "substring", "substr", "includes", "startsWith", "endsWith", "indexOf", "lastIndexOf", "replace", "replaceAll", "repeat", "padStart", "padEnd", "charAt", "charCodeAt", "codePointAt", "at", "concat", "toString", "match", "matchAll", "search", "localeCompare", "normalize", ]) export const stringStatics = new Set(["fromCharCode", "fromCodePoint"]) export const invokeStringStatic = (name: string, args: Array<unknown>, node: AstNode): unknown => { const codes = args.map((arg) => { if (typeof arg !== "number") throw new InterpreterRuntimeError(`String.${name} expects number arguments.`, node) return arg }) switch (name) { case "fromCharCode": return String.fromCharCode(...codes) case "fromCodePoint": return String.fromCodePoint(...codes) default: throw new InterpreterRuntimeError(`String.${name} is not available in CodeMode.`, node) } } import { type AstNode, InterpreterRuntimeError } from "../interpreter/model.js"