Skip to content

Commit 3003e61

Browse files
Merge pull request #28 from oliviacarlisle/dev
Update version to 1.0.3
2 parents c557dd8 + d322d49 commit 3003e61

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,26 @@ queue.enqueue(3);
6161
console.log(queue.dequeue()); // Output: 3
6262
```
6363

64+
### 🚧 Using `dslib-core` in CommonJS Projects
65+
66+
`dslib-core` is primarily designed for ESM (ECMAScript Module) environments. However, you can still use it in CommonJS projects with a few adjustments.
67+
68+
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:
69+
70+
```typescript
71+
// CommonJS project example
72+
(async function () {
73+
const { Queue } = await import('dslib-core');
74+
75+
// Your code here
76+
const queue = new Queue();
77+
queue.enqueue(1);
78+
console.log(queue.dequeue()); // Output: 1
79+
})();
80+
```
81+
82+
This approach allows you to use the ESM-native `dslib-core` package within your CommonJS environment while maintaining asynchronous module loading.
83+
6484
## 🏗️ Data Structures
6585

6686
### 🔄 Queue

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dslib-core",
3-
"version": "1.0.2",
3+
"version": "1.0.3",
44
"description": "A robust and efficient data structures library.",
55
"type": "module",
66
"scripts": {

0 commit comments

Comments
 (0)