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.
- Host: GitHub
- URL: https://github.com/beyondjs/code
- Owner: beyondjs
- License: mit
- Created: 2024-09-12T16:55:12.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-09-13T23:05:52.000Z (almost 2 years ago)
- Last Synced: 2024-12-16T09:09:10.390Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: license
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)]