@morphql/core

中文文档
0.1.47发布于 2026/11/02MITTypeScriptESM + CJS构建来源已验证

A high-performance, isomorphic Query-to-Code engine for structural data transformations.

原始使用文档
文档目录5 节
  1. Key Features
  2. Installation
  3. Usage
  4. Learn More
  5. License

MorphQL

npm version License: MIT

@morphql/core

A high-performance, isomorphic Query-to-Code engine. It provides the Morph Query Language (MorphQL) to transform structural data (JSON, XML, or Objects) by compiling queries into specialized, pure JavaScript functions.

Key Features

  • 🚀 Performance: Compiles DSL to native JS for maximum execution speed.
  • 🌐 Isomorphic: Runs seamlessly in Node.js and the Browser.
  • 🧩 Format Agnostic: Built-in support for JSON, XML, CSV, EDIFACT, Plaintext, and raw Objects.
  • ➗ Expressions: Support for arithmetic, string concatenation, and unary minus.
  • 🔀 Conditional Logic: if function with comparison and logical operators.
  • 🔄 Structural Mapping: Easy handling of nested objects and arrays (multiple).

Installation

npm install @morphql/core

Usage

import { compile, morphQL } from '@morphql/core';

const query = morphQL`
  from object to json
  transform
    set fullName = firstName + " " + lastName
    set isAdult = age >= 18
`;

const engine = await compile(query);
const result = engine({ firstName: 'John', lastName: 'Doe', age: 30 });
// → '{"fullName":"John Doe","isAdult":true}'

Learn More

License

MIT

版本与发布记录

@morphql/core 共发布 44 个版本,首次发布于 2026/01/25;过去 12 个月发布了 44 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.1.47latest2026/11/021 天前
0.1.462026/07/283 个月前
0.1.452026/05/275 个月前
0.1.442026/05/275 个月前
0.1.432026/05/215 个月前
0.1.422026/05/195 个月前

关于 @morphql/core 的常见问题

@morphql/core 是什么?

用于结构数据转换的高性能、同构的查询到代码引擎。

如何安装 @morphql/core?

在项目目录运行 npm install @morphql/core,或使用 pnpm add / yarn add / bun add。

@morphql/core 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@morphql/core 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@morphql/core 可以商用吗?

@morphql/core 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@morphql/core 还在维护吗?

最新版本 0.1.47 发布于 2026/11/02(1 天前);至今共发布 44 个版本,其中过去 12 个月发布了 44 个;首次发布于 2026/01/25。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。