From 9e88b1ab13b914e4b5ef31546cc8478c7e3e70bd Mon Sep 17 00:00:00 2001 From: Olivia Carlisle <151247171+oliviacarlisle@users.noreply.github.com> Date: Mon, 21 Oct 2024 18:27:44 -0400 Subject: [PATCH 1/2] Add Using dslib-core in CommonJS Projects section to README --- README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) 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 From d322d496eebb0cbc22ec4be82fa01ae3864e5927 Mon Sep 17 00:00:00 2001 From: Olivia Carlisle <151247171+oliviacarlisle@users.noreply.github.com> Date: Mon, 21 Oct 2024 18:38:21 -0400 Subject: [PATCH 2/2] Update version to 1.0.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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": {