Thank you for your interest in contributing! This document provides guidelines and instructions for contributing to this project.
This project adheres to the Contributor Covenant Code of Conduct. By participating, you are expected to uphold this code.
- Fork the repository
- Clone your fork:
git clone https://github.com/<your-username>/mega-collection.git - Create a feature branch:
git checkout -b feat/my-feature - Make your changes
- Push and open a Pull Request
# Install dependencies
npm install
# Build the project
npm run build
# Type-check without emitting
npm run typecheck
# Watch mode for development
npm run devThe package is organised into three independent modules (search, filter, sort) plus a lightweight merge wrapper that composes them around a shared dataset. Each engine can be imported individually for optimal tree‑shaking:
// Full package (includes MergeEngines facade)
import { MegaCollection, MergeEngines } from "@devisfuture/mega-collection";
// Individual modules
import { TextSearchEngine } from "@devisfuture/mega-collection/search";
import { FilterEngine } from "@devisfuture/mega-collection/filter";
import { SortEngine } from "@devisfuture/mega-collection/sort";- Decide which module the feature belongs to (
search,filter,sort,merge, or the core facade). - Write the implementation in the appropriate module directory.
- Export it from the module's
index.tsbarrel file. - If it's a public API, also export from
src/index.tsand, when applicable, frommerge/index.ts. - Update types in
src/types.tsif necessary. - Update the README with usage examples — include Quick Start snippets for the single-engine and
MergeEnginesworkflows.
This library is designed for 50k+ item collections. When contributing, please:
- Prefer
forloops over.forEach()/.map()/.filter()in hot paths. - Use typed arrays (
Float64Array,Uint32Array) where appropriate for numeric data. - Avoid creating closures in tight loops.
- Use
Map/Setinstead of plain objects for dynamic key collections. - Benchmark your changes against the existing implementation with large datasets.
- Ensure your code compiles without errors:
npm run typecheck - Ensure the build succeeds:
npm run build - Update documentation if you changed any public API.
- Use Conventional Commits for your commit messages:
feat:— new featurefix:— bug fixperf:— performance improvementdocs:— documentation onlyrefactor:— code change that neither fixes a bug nor adds a featurechore:— build process or auxiliary tool changes
- Open a Pull Request with a clear description of what and why.
- TypeScript: All code must be written in TypeScript with strict mode enabled.
- No runtime dependencies: This package has zero runtime dependencies. Keep it that way.
- Generics: Use
T extends CollectionItemfor all public APIs that operate on collection items. - JSDoc: Document all public classes, methods, and interfaces with JSDoc comments.
- Naming:
- Classes:
PascalCase(e.g.,SortEngine) - Methods/functions:
camelCase(e.g.,buildIndex) - Types/interfaces:
PascalCase(e.g.,FilterCriterion) - Constants:
UPPER_SNAKE_CASE
- Classes:
- No
anyin public APIs: Use proper generics and type constraints. - Exports: Every module has a barrel
index.tsthat re-exports only the public API.