For npm packages, Python libraries, and reusable modules.
Library/Package Template
# package-name
> A concise description of what this library does. Explain the problem it solves in one sentence.
[](https://www.npmjs.com/package/package-name)
[](https://www.npmjs.com/package/package-name)
[](LICENSE)
[](https://www.typescriptlang.org/)
## Why?
Existing solutions have [problem X]. This library solves it by [approach Y], giving you:
- **Benefit 1** — Brief explanation
- **Benefit 2** — Brief explanation
- **Benefit 3** — Brief explanation
## Installation
```bash
npm install package-name
# or
yarn add package-name
# or
pnpm add package-name
```
## Quick Start
```typescript
import { doSomething } from 'package-name';
// Basic usage
const result = doSomething('input');
console.log(result);
// With options
const result = doSomething('input', {
option1: true,
option2: 'value',
});
```
## API Reference
### `doSomething(input, options?)`
Main function description.
**Parameters:**
| Name | Type | Required | Description |
|------|------|----------|-------------|
| `input` | `string` | Yes | The input to process |
| `options` | `Options` | No | Configuration options |
**Options:**
| Option | Type | Default | Description |
|--------|------|---------|-------------|
| `option1` | `boolean` | `false` | Enable feature X |
| `option2` | `string` | `'default'` | Set the mode |
| `option3` | `number` | `100` | Maximum limit |
**Returns:** `Result` — Description of return value
**Example:**
```typescript
const result = doSomething('hello', { option1: true });
// => { processed: 'HELLO', length: 5 }
```
### `anotherFunction(data)`
Secondary function description.
**Parameters:**
| Name | Type | Description |
|------|------|-------------|
| `data` | `Data[]` | Array of data objects |
**Returns:** `Promise<Result[]>`
## TypeScript
Full TypeScript support included. Import types directly:
```typescript
import { doSomething, type Options, type Result } from 'package-name';
const options: Options = {
option1: true,
};
const result: Result = doSomething('input', options);
```
## Advanced Usage
### Custom Configuration
```typescript
import { configure, doSomething } from 'package-name';
// Set global defaults
configure({
option1: true,
option2: 'custom',
});
// All calls now use these defaults
doSomething('input');
```
### Error Handling
```typescript
import { doSomething, PackageError } from 'package-name';
try {
const result = doSomething(invalidInput);
} catch (error) {
if (error instanceof PackageError) {
console.error('Validation failed:', error.message);
}
throw error;
}
```
### Framework Integration
#### React
```tsx
import { useSomething } from 'package-name/react';
function Component() {
const { data, loading, error } = useSomething('input');
if (loading) return <div>Loading...</div>;
if (error) return <div>Error: {error.message}</div>;
return <div>{data.processed}</div>;
}
```
## Browser Support
| Browser | Version |
|---------|---------|
| Chrome | 80+ |
| Firefox | 75+ |
| Safari | 13+ |
| Edge | 80+ |
## Bundle Size
- **Minified:** ~5kb
- **Gzipped:** ~2kb
- **Tree-shakeable:** Yes
## Comparison
| Feature | package-name | alternative-a | alternative-b |
|---------|--------------|---------------|---------------|
| TypeScript | ✅ | ❌ | ✅ |
| Tree-shaking | ✅ | ✅ | ❌ |
| Zero deps | ✅ | ❌ | ❌ |
| Feature X | ✅ | ✅ | ❌ |
## Contributing
Contributions welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
```bash
# Clone and install
git clone https://github.com/user/package-name.git
cd package-name
npm install
# Run tests
npm test
# Build
npm run build
```
## Changelog
See [CHANGELOG.md](CHANGELOG.md) for release history.
## License
MIT © [Your Name](https://github.com/yourusername)
---
**[Documentation](https://package-name.dev)** · **[npm](https://www.npmjs.com/package/package-name)** · **[GitHub](https://github.com/user/package-name)**