Skip to content

Latest commit

 

History

History
27 lines (21 loc) · 505 Bytes

README.md

File metadata and controls

27 lines (21 loc) · 505 Bytes

code-snips

Quickly generate code snippets from source code files.

import { snip } from "code-snips/snip";
import { readFileSync } from "fs";

// Snip start myFunc
const myFunc = () => {
    console.log("Hello World!");
}
// Snip end myFunc

const fileContent = readFileSync('./demo.ts', 'utf-8');
const snippet = snip(fileContent, "myFunc", "ts");
console.log(snippet);
Output:
const myFunc = () => {
    console.log("Hello World!");
}

Currently supports TypeScript and JavaScript.