@gram-data/gram-ops
TypeScript icon, indicating that this package has built-in type declarations

0.3.11 • Public • Published

(ast)-[ops]->(features)

Utility operations for extracting path features from gram AST.

How to gram-ops

Install:

npm install @gram-data/gram-ops

Build a path

Use [[gram-builder]] to create a path.

import { node, edge } from '@gram-data/gram-builder';

const left = node('a');
const right = node('b');
const path = edge([left, right], 'right');

Extract features from the path

Extract a node list:

import { nodes } from '@gram-data/gram-ops';

const ns:GramPath[] = nodes(path); 

Extract an edge list:

import { nodes } from '@gram-data/gram-ops';

const es:GramPath[] = edges(path); 

Next Steps

  • Write back to a string using [[gram-stringify]]
  • Introspect the AST using [[gram-ast]]

/@gram-data/gram-ops/

    Package Sidebar

    Install

    npm i @gram-data/gram-ops

    Weekly Downloads

    1

    Version

    0.3.11

    License

    MIT

    Unpacked Size

    55.2 kB

    Total Files

    16

    Last publish

    Collaborators

    • akollegger