Installation¶
This guide will help you install and set up @arcaelas/collection in your project.
Requirements¶
- Node.js: 14.x or higher
- TypeScript: 4.x or higher (optional, for TypeScript projects)
- Package Manager: npm, yarn, or pnpm
Package Manager Installation¶
Using npm¶
Using yarn¶
Using pnpm¶
Import Methods¶
ES Module (Recommended)¶
Named Import¶
import { Collection } from "@arcaelas/collection";
const collection = new Collection(["a", "b", "c"]);
CommonJS¶
TypeScript Configuration¶
If you're using TypeScript, ensure your tsconfig.json includes proper configuration:
{
"compilerOptions": {
"target": "ES2020",
"module": "ES2020",
"lib": ["ES2020"],
"moduleResolution": "node",
"esModuleInterop": true,
"skipLibCheck": true,
"strict": true,
"resolveJsonModule": true
}
}
Verify Installation¶
Create a simple test file to verify the installation:
// test-collection.ts
import Collection from "@arcaelas/collection";
const numbers = new Collection([1, 2, 3, 4, 5]);
console.log("Total:", numbers.sum(n => n)); // 15
console.log("Max:", numbers.max("value")); // Works with objects
console.log("First:", numbers.first()); // 1
const filtered = numbers.filter(n => n > 2);
console.log("Filtered:", filtered); // [3, 4, 5]
Run the test:
Bundle Size¶
The library is lightweight and tree-shakeable:
- Minified: ~15 KB
- Gzipped: ~5 KB
Browser Compatibility¶
@arcaelas/collection works in all modern browsers that support ES2020:
- Chrome 80+
- Firefox 72+
- Safari 13.1+
- Edge 80+
For older browsers, use a transpiler like Babel.
CDN Usage¶
You can also use the library directly from a CDN:
unpkg¶
<script type="module">
import Collection from "https://unpkg.com/@arcaelas/collection@latest/build/index.js";
const collection = new Collection([1, 2, 3]);
console.log(collection.sum(n => n));
</script>
jsDelivr¶
<script type="module">
import Collection from "https://cdn.jsdelivr.net/npm/@arcaelas/collection@latest/build/index.js";
const collection = new Collection([1, 2, 3]);
console.log(collection.first());
</script>
Development Installation¶
If you want to contribute or work on the library itself:
# Clone the repository
git clone https://github.com/arcaelas/collection.git
cd collection
# Install dependencies
npm install
# Build the project
npm run build
# Run tests
npm test
Troubleshooting¶
Module Not Found Error¶
If you encounter module resolution issues:
Solutions:
-
Clear your package manager cache:
-
Delete
node_modulesand reinstall: -
Check your
package.jsonto ensure the package is listed independencies.
TypeScript Declaration Errors¶
If TypeScript can't find type declarations:
Solutions:
-
The library includes TypeScript declarations. Ensure you're using TypeScript 4.x or higher.
-
Check your
tsconfig.jsonincludes:
Import/Export Syntax Errors¶
If you see syntax errors related to imports:
Solutions:
-
Ensure your Node.js version supports ES modules (14.x+)
-
Add
"type": "module"to yourpackage.jsonfor ES modules: -
Or use
.mjsextension for module files
Next Steps¶
Now that you have @arcaelas/collection installed, you can:
- Read the Getting Started guide
- Explore Core Concepts
- Check out Examples
- Browse the API Reference
Support¶
If you encounter any issues during installation:
- Check the GitHub Issues
- Ask for help in Discussions
- Contact us at community@arcaelas.com