虚拟类型脚本运行时间
类型脚本/ JavaScript 运行时间 福尔特 - 说吧 页:1 基于堆栈的,可调和的语言用于可相容的转换.
使用 Forthic 将您的 TypeScript/ JavaScript 代码包入可复写词中, 利用绝对原理来进行干净而强大的抽象 .
在 extix.com 学习 | 福特医生 | 开始 | 实例 | API 文档
佛提克是什么来着?
Fortic 启用 绝对编码 - 一种解决问题的方法,从有轨电车而不是同化的角度看待问题。 此类型脚本运行时间允许您 :
- 环绕已存在的代码 带有简单的装饰器
- 组成转换 干净地使用基于堆栈的操作
- 构建强大的抽象 从简单的原始人
见 福斯库 用于技术文件和API参考.
快速示例
创建模块
import { DecoratedModule, Word } from '@forthix/forthic';
export class AnalyticsModule extends DecoratedModule {
constructor() {
super("analytics");
}
@Word("( numbers:number[] -- avg:number )", "Calculate average")
async AVERAGE(numbers: number[]) {
return numbers.reduce((a, b) => a + b, 0) / numbers.length;
}
@Word("( numbers:number[] stdDevs:number -- filtered:number[] )", "Filter outliers")
async FILTER_OUTLIERS(numbers: number[], stdDevs: number) {
// Your existing logic here
return filteredNumbers;
}
}
用这个
import { Interpreter } from '@forthix/forthic';
import { AnalyticsModule } from './analytics-module';
const interp = new Interpreter();
interp.register_module(new AnalyticsModule());
await interp.run(`
["analytics"] USE-MODULES
[1 2 3 100 4 5] 2 FILTER-OUTLIERS AVERAGE
`);
const result = interp.stack_pop(); // Clean average without outliers
安装
无
npm install @forthix/forthic
线条
yarn add @forthix/forthic
需求:全球 Temporal
Forthic 的日期和时间值基于 TC39 临时API。运行时间参考 a 全球 Temporal 对象 而不捆绑一个多填料,所以主机负责提供一个. 任何使用日期/时间的Forthic程序(TODAY, (中文(简体) ), NOW,日期字节类似 2020-06-05,则 datetime 模块,或时间值的线条序列化)将抛出 Temporal is not defined 如果没有全局 Temporal 已提供.
土著 Temporal 尚未在Node.js、Chrome或Safari发货,所以大多数消费者需要多功能填充。 安装 temporal-polyfill 导入 一次 在您申请的切入点, 在运行 Forthic 之前:
npm install temporal-polyfill
import "temporal-polyfill/global"; // installs globalThis.Temporal
import { Interpreter } from "@forthix/forthic";
temporal-polyfill 被宣布为 可选同伴依赖: 仅在您的运行时间已经提供本地全局时跳过 Temporal,或者程序从不触及日期/时间。 对于 TypeScript 类型检查 Temperal 类型,也添加 temporal-spec 是一个非常依赖.
开始
节点使用
import { Interpreter } from '@forthix/forthic';
const interp = new Interpreter();
// Execute Forthic code
await interp.run(`
[1 2 3 4 5] "2 *" MAP # Double each element
`);
const result = interp.stack_pop(); // [2, 4, 6, 8, 10]
浏览器使用
<script type="module">
import { Interpreter } from 'https://unpkg.com/@forthix/forthic';
const interp = new Interpreter();
await interp.run('[1 2 3] "2 *" MAP');
console.log(interp.stack_pop()); // [2, 4, 6]
</script>
创建您的第一个模块
import { DecoratedModule, Word } from '@forthix/forthic';
export class MyModule extends DecoratedModule {
constructor() {
super("mymodule");
}
@Word("( data:any[] -- result:any )", "Process data your way")
async PROCESS(data: any[]) {
// Wrap your existing code
return myExistingFunction(data);
}
}
// Register and use
const interp = new Interpreter();
interp.register_module(new MyModule());
await interp.run(`
["mymodule"] USE-MODULES
SOME-DATA PROCESS
`);
见 实例/README.md 用于详细的教程和实例.
特征
标准库
TypeScript运行时间包括全面的标准模块:
- 数组 - MAP、SELECT、SORT、GROUP-BY、ZIP、REDUCE、FLATTEN(30+操作)
- 记录 - REC@, <REC,MERGE, 关键词, VALUES, 永远的KEYS
- 字符串 - SPLIT, JOIN, UPPERCASE, LOWERCASE, TRIM, REPLACE(英语:PERLACE)) - (英语)
- 数学 - +, -, *, /, ROUND, ABS, MIN, MAX, 变相
- 约会时间 - >日期,>日期,日期,日期,日期,格式,日期
- 乔森 - "杰森,杰森",杰森-普雷蒂菲
- 布尔 - ==, <, > 和,或,不
见 文档/模块/ 完全参考.
简单模块创建
这个 @Word 装饰使包装代码变得微不足道:
@Word("( input:type -- output:type )", "Description", "MY-WORD")
async MY_WORD(input: any) {
return yourLogic(input);
}
类型脚本和 JavaScript 支持
- 完整类型脚本类型定义
- 使用ES模块和通用JS的工程
- 浏览器和节点相容
- 支持同步/等待
软件包导出
平方位- ts 为不同的使用例提供多导入路径:
// Main package - Core interpreter and standard library (works everywhere)
import { Interpreter, DecoratedModule, Word } from '@forthix/forthic';
// WebSocket support - Browser-compatible multi-runtime execution
import { ActionCableClient, WebSocketRemoteModule } from '@forthix/forthic/websocket';
// JSON-RPC support - Node.js-only multi-runtime execution
import { JsonRpcClient, RemoteModule, startJsonRpcServer } from '@forthix/forthic/jsonrpc';
环境相容性数字 :
- 主要软件包 (单位:千美元)
@forthix/forthic: 在节点J和浏览器中工作 - 网络安全套 (单位:千美元)
@forthix/forthic/websocket: 在节点J和浏览器中工作 - JSON-RPC 软件公司 (单位:千美元)
@forthix/forthic/jsonrpc: 仅节点.js(使用)http全球fetch(中文(简体) )
文档
学习资源
- extix.com (英语) - 了解福特和分类编码
- 编码器的类别理论 - 了解基础
此运行时间
核心福特概念
实例
参见 实例 目录.
大楼
# Install dependencies
npm install
# Build both CJS and ESM
npm run build
# Run tests
npm test
# Generate documentation
npm run docs:build
多次运行
从其他语言运行时无缝调用代码 - 从TypeScript调用Python的熊猫,或者从Ruby调用TypeScript的fs模块.
快速示例
import { Interpreter } from '@forthix/forthic';
import { JsonRpcClient, RemoteModule } from '@forthix/forthic/jsonrpc';
const interp = new Interpreter();
// Connect to Python runtime
const client = new JsonRpcClient('localhost:8765');
const pandas = new RemoteModule('pandas', client, 'python');
await pandas.initialize();
interp.register_module(pandas);
// Now use Python pandas from TypeScript!
await interp.run(`["pandas"] USE-MODULES [records] DF-FROM-RECORDS`);
方针
- JSON-RPC 软件公司 - Node.js QQ Python Ruby(服务器对服务器,没有本地依赖)
- 网络安全套 - 浏览器QQ铁路(ActionCable,客户端-服务器)
学习更多
📖 完成多运行文档
- 概览 - 何时以及如何使用多跑时间
- JSON-RPC 设置 - 服务器和客户端配置
- WebSocket 设置 - 与浏览器兼容的通信
- 配置 - YAML 配置和连接管理
- 实例 - 工作代码样本(05-jsonrpc-server.ts,06-jsonrpc-client.ts)
运行时状态 : QQ TypeScript, Python, Ruby QQ rust QQ Java, .NET (英语)
捐款
我们欢迎捐款! 见 捐款额 用于:
- 开发设置
- 类型脚本编码标准
- 测试准则
- 公关程序
另见 主要福特贡献指南 哲学和社区准则.
社区
许可证
BSD-2- 休闲许可证 - 版权2024 LinkedIn Corporation. 版权2025Forthix LLC.
相关
- 福特克 (主还原) - 核心文件和概念
福尔特: 包装. 作曲. 摘要.