2.0.2 • Published 11 months ago

macro-system v2.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
11 months ago

JavaScript Macros

A simple and lightweight macro system for JavaScript, inspired by Lisp macros. This package allows you to define and use macros to perform code transformations at compile time.

Installation

npm install macro-system

Usage

const { macroexpand, macroexpand1, gensym } = require('macro-system');

// Define macros using defmacro
const inputCode = `
  defmacro('log', msg => \`console.log(\${msg})\`);
  log('Hello, World!');
`;

// Expand macros in the input code
const expandedCode = macroexpand(inputCode);

// Output: console.log('Hello, World!');
console.log(expandedCode);

Dependencies

This package relies on the following dependencies:

  • esprima: JavaScript parser used for generating and working with abstract syntax trees (AST).
  • escodegen: JavaScript code generator used for transforming ASTs back into source code.

Author

  • Varun A

License

MIT

2.0.2

11 months ago

1.0.5

12 months ago

2.0.1

11 months ago

2.0.0

12 months ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago