ffmpeg-toolkit
Version:
A modern FFmpeg toolkit for Node.js
104 lines (73 loc) โข 1.62 kB
Markdown
# Example Module
A modern Node.js module template with TypeScript.
## Features
- ๐ TypeScript support
- ๐ฆ ESM and CommonJS support
- ๐งช Vitest for testing
- ๐ ESLint + Prettier for code quality
- ๐ Husky + lint-staged for git hooks
- ๐ Zod for runtime type validation
- ๐ ๏ธ esbuild for fast builds
## Installation
```bash
npm install @your-username/example-module
```
## Usage
```typescript
import { Module, module } from "@your-username/example-module";
// Use default instance
const result = await module.operation("test");
console.log(result);
// Or create custom instance
const customModule = new Module({
debug: true,
retries: 5,
timeout: 10000
});
const customResult = await customModule.operation("test");
console.log(customResult);
```
## API
### Module
Main class for module functionality.
#### Constructor
```typescript
new Module(config?: Partial<Config>)
```
#### Methods
- `getConfig(): Config` - Get current configuration
- `updateConfig(config: Partial<Config>): void` - Update configuration
- `operation<T>(input: T): Promise<Result<T>>` - Perform an operation
### Types
```typescript
interface Config {
debug: boolean;
timeout: number;
retries: number;
}
interface Result<T> {
success: boolean;
data?: T;
error?: ModuleError;
}
class ModuleError extends Error {
constructor(message: string, code: string);
}
```
## Development
```bash
# Install dependencies
npm install
# Run tests
npm test
# Run tests with coverage
npm run test:coverage
# Build
npm run build
# Lint
npm run lint
# Format code
npm run format
```
## License
MIT