An open API service indexing awesome lists of open source software.

https://github.com/beyondjs/code

A lightweight JavaScript utility library for code manipulation. Provides simple functions to create file headers and wrap code in scoped Immediately Invoked Function Expressions (IIFEs). Ideal for projects requiring code generation or transformation.
https://github.com/beyondjs/code

Last synced: 5 months ago
JSON representation

A lightweight JavaScript utility library for code manipulation. Provides simple functions to create file headers and wrap code in scoped Immediately Invoked Function Expressions (IIFEs). Ideal for projects requiring code generation or transformation.

Awesome Lists containing this project

README

          

# @beyond-js/code

Simple utility functions for code manipulation.

## Installation

```bash
npm install @beyond-js/code
```

## Usage

```javascript
const { header, scoped } = require('@beyond-js/code');

// Create a header for a file
const fileHeader = header('My JavaScript File');
console.log(fileHeader);

// Wrap code in a scoped IIFE
const myCode = `
const x = 1;
console.log(x);
`;
const scopedCode = scoped(myCode);
console.log(scopedCode);
```

## API

- `header(text: string): string` - Creates a comment header for code files.
- `scoped(code: string): string` - Wraps code in a scoped IIFE and adds indentation.

## License

MIT © [[BeyondJS](https://beyondjs.com)]