Skip to content

Commit e22d84b

Browse files
committed
feat: add WishMap class with extended functionality and event emission
- Implemented WishMap class extending Map with array-like methods. - Added event emission for set and delete operations. - Added package.json and tsconfig.json for project setup and TypeScript configuration.
1 parent e6a53a0 commit e22d84b

File tree

13 files changed

+2246
-1
lines changed

13 files changed

+2246
-1
lines changed

.github/workflows/bump-version.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Bump version
2+
3+
on:
4+
pull_request:
5+
branches: [prod]
6+
types: [labeled]
7+
workflow_dispatch:
8+
9+
jobs:
10+
commit:
11+
if: ${{ contains(github.event.label.name, 'major') || contains(github.event.label.name, 'minor') || contains(github.event.label.name, 'patch') }}
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v3
16+
- uses: actions/setup-node@v3
17+
with:
18+
node-version: 22
19+
- name: Get semver
20+
id: semver
21+
run: |
22+
semver=""
23+
24+
if [[ "${{ github.event.label.name }}" == *"patch"* ]]; then
25+
semver='patch'
26+
elif [[ "${{ github.event.label.name }}" == *"minor"* ]]; then
27+
semver='minor'
28+
elif [[ "${{ github.event.label.name }}" == *"major"* ]]; then
29+
semver='major'
30+
fi
31+
32+
echo semver=$semver >> $GITHUB_OUTPUT
33+
- name: Setup Git
34+
run: |
35+
git config user.name "github-actions[bot]"
36+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
37+
git remote set-url --push origin https://${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
38+
- name: Bump version
39+
run: |
40+
git checkout -b $GITHUB_HEAD_REF
41+
npm version ${{ steps.semver.outputs.semver }} -m "chore: bump version to %s"
42+
- name: Push
43+
run: |
44+
git pull --rebase origin $GITHUB_HEAD_REF
45+
git push origin $GITHUB_HEAD_REF --follow-tags

.github/workflows/deploy-docs.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Deploy documentation
2+
3+
on:
4+
# Run when a release is published
5+
workflow_run:
6+
workflows: ['Publish package']
7+
types: [completed]
8+
9+
# Allows you to run this workflow manually from the Actions tab
10+
workflow_dispatch:
11+
12+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
13+
permissions:
14+
contents: read
15+
pages: write
16+
id-token: write
17+
18+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
19+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
20+
concurrency:
21+
group: 'pages'
22+
cancel-in-progress: false
23+
24+
jobs:
25+
deploy:
26+
environment:
27+
name: github-pages
28+
url: ${{ steps.deployment.outputs.page_url }}
29+
runs-on: ubuntu-latest
30+
steps:
31+
- uses: actions/checkout@v4
32+
- uses: actions/setup-node@v4
33+
with:
34+
node-version: 22
35+
- run: |
36+
npx typedoc src/index.ts --out docs
37+
- name: Setup Pages
38+
uses: actions/configure-pages@v4
39+
- name: Upload artifact
40+
uses: actions/upload-pages-artifact@v3
41+
with:
42+
path: './docs'
43+
- name: Deploy to GitHub Pages
44+
id: deployment
45+
uses: actions/deploy-pages@v4
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Publish package
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
8+
permissions:
9+
packages: write
10+
11+
jobs:
12+
publish-ghp:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
- uses: actions/setup-node@v4
17+
with:
18+
node-version: 22
19+
registry-url: https://npm.pkg.github.com/
20+
scope: '@danliyev'
21+
- run: npm ci
22+
- run: npm run build
23+
- run: npm publish
24+
env:
25+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26+
27+
publish-npm:
28+
runs-on: ubuntu-latest
29+
steps:
30+
- uses: actions/checkout@v4
31+
- uses: actions/setup-node@v4
32+
with:
33+
node-version: 22
34+
registry-url: https://registry.npmjs.org/
35+
scope: '@danliyev'
36+
- run: npm ci
37+
- run: npm run build
38+
- run: npm publish --access public
39+
env:
40+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ out
9090
# Nuxt.js build / generate output
9191
.nuxt
9292
dist
93+
docs/
9394

9495
# Gatsby files
9596
.cache/

.npmignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.github/
2+
.vscode/
3+
docs/
4+
src/
5+
.gitignore
6+
.prettierrc
7+
.prettierignore
8+
tsconfig.json

.prettierrc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"trailingComma": "none",
3+
"tabWidth": 4,
4+
"singleQuote": true,
5+
"semi": false,
6+
"arrowParens": "avoid",
7+
"printWidth": 120,
8+
"overrides": [
9+
{
10+
"files": ["*.json", "*.yml"],
11+
"options": {
12+
"tabWidth": 2
13+
}
14+
}
15+
]
16+
}

.vscode/settings.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"editor.defaultFormatter": "esbenp.prettier-vscode",
3+
"editor.formatOnSave": true,
4+
"editor.codeActionsOnSave": {
5+
"source.organizeImports": "explicit"
6+
},
7+
"cSpell.words": []
8+
}

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2024 Lacuna
3+
Copyright (c) 2025 Daniyar Kurmangaliyev
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# About
2+
3+
An extended `Map` with Array-like methods and event emission.
4+
5+
# Links
6+
7+
[API Docs](https://danliyev.github.io/wishmap)
8+
9+
## Installation
10+
11+
```bash
12+
npm install wishmap
13+
```
14+
15+
## Usage
16+
17+
```typescript
18+
import { WishMap } from 'wishmap'
19+
20+
const map = new WishMap<string, number>()
21+
22+
// Listen to events
23+
map.events.on('set', (key, value) => {
24+
console.log(`Set ${key} = ${value}`)
25+
})
26+
27+
map.events.on('delete', (key, value) => {
28+
console.log(`Deleted ${key} (was ${value})`)
29+
})
30+
31+
// Use like a regular Map
32+
map.set('a', 1)
33+
map.set('b', 2)
34+
map.set('c', 3)
35+
36+
// Use Array-like methods
37+
map.filter(v => v > 1) // WishMap { 'b' => 2, 'c' => 3 }
38+
map.map(v => v * 2) // [2, 4, 6]
39+
map.find(v => v === 2) // 2
40+
map.every(v => v > 0) // true
41+
map.some(v => v > 2) // true
42+
map.reduce((acc, v) => acc + v, 0) // 6
43+
```
44+
45+
## License
46+
47+
This project is licensed under the [MIT License](./LICENSE).

0 commit comments

Comments
 (0)