omni-ast
TypeScript icon, indicating that this package has built-in type declarations

0.0.0-dev2 • Public • Published

Omni-AST

Omni-AST is an innovative library that blends the robust capabilities of Abstract Syntax Trees (AST) with the flexibility and simplicity of JSON, creating a hybrid format designed to streamline the manipulation, analysis, and transformation of code. Aimed at offering versatility, Omni-AST enables developers to handle complex data structures and programming logic in a way that is both intuitive and powerful, thanks to its hybrid nature.

Features

  • Hybrid JSON-AST Structure: Combines the structural advantages of AST with the ease of use of JSON, allowing for complex code manipulations and transformations.
  • Easy Serialization and Execution: Facilitates the serialization of code structures and logic, making it executable, which is ideal for dynamic web application development.
  • Developer-Friendly: Simplifies the creation, modification, and sharing of programming logic, enhancing efficiency and safety in software development.
  • Tooling and Integration: Offers a foundation for developing a wide range of development tools, including linters, formatters, compilers, and interpreters, leveraging the simplicity of JSON and the semantic richness of ASTs.

Use Cases

Omni-AST is particularly suited for developers and teams looking to:

  • Enhance development tools and pipelines with a format that is easy to parse, analyze, and transform.
  • Build, modify, and execute complex code structures and logic directly from JSON.
  • Facilitate the sharing and distribution of code logic in a format that is both human-readable and machine-executable.
  • Foster innovation in web application development through the efficient manipulation of code structures.

Getting Started

To begin using Omni-AST in your project, you can install the library via npm:

npm install omni-ast 

Example

Here's a simple example of how to use Omni-AST to represent and manipulate a piece of code logic:

import { generate, builders as b } from "omni-ast";

const code = "(x, y) => x(y)";

const jsonAST = {
  type: 'ArrowFunctionExpression',
  params: [b.identifier("x"), b.identifier("y")],
  body: {
    type: 'CallExpression',
    callee: b.identifier("x"),
    arguments: [ b.identifier("y") ]
  }
};
// This generates a code and compares it with the code above
generate(jsonAST) == code // true

Contributing

We welcome contributions to the Omni-AST project! Whether it's through submitting bug reports, writing documentation, or contributing code, your help is appreciated. Please see our CONTRIBUTING.md for more details.

License

Omni-AST is licensed under the MIT License. See the LICENSE file for more information.

Readme

Keywords

none

Package Sidebar

Install

npm i omni-ast

Weekly Downloads

1

Version

0.0.0-dev2

License

MIT

Unpacked Size

154 kB

Total Files

16

Last publish

Collaborators

  • andersondrosa