diff --git a/README.md b/README.md index ef08fc6..606e834 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,26 @@ queue.enqueue(3); console.log(queue.dequeue()); // Output: 3 ``` +### 🚧 Using `dslib-core` in CommonJS Projects + +`dslib-core` is primarily designed for ESM (ECMAScript Module) environments. However, you can still use it in CommonJS projects with a few adjustments. + +To use `dslib-core` in a CommonJS project, we suggest using a dynamic `import()` within an async IIFE (Immediately Invoked Function Expression). Here's an example: + +```typescript +// CommonJS project example +(async function () { + const { Queue } = await import('dslib-core'); + + // Your code here + const queue = new Queue(); + queue.enqueue(1); + console.log(queue.dequeue()); // Output: 1 +})(); +``` + +This approach allows you to use the ESM-native `dslib-core` package within your CommonJS environment while maintaining asynchronous module loading. + ## 🏗️ Data Structures ### 🔄 Queue diff --git a/package.json b/package.json index 7a0ac89..218a511 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dslib-core", - "version": "1.0.2", + "version": "1.0.3", "description": "A robust and efficient data structures library.", "type": "module", "scripts": {