├── .gitattributes ├── .npmrc ├── .versionrc ├── docs ├── README.md └── index.yml ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── config.yml │ ├── feature_request.yml │ └── bug_report.yml ├── tsc.json ├── SUPPORT.md ├── workflows │ ├── labelsync.yml │ ├── deploy.yml │ └── test.yml ├── PULL_REQUEST_TEMPLATE.md ├── labels.yml ├── CONTRIBUTING.md ├── COMMIT_CONVENTION.md └── CODE_OF_CONDUCT.md ├── .husky ├── pre-commit └── commit-msg ├── .lintstagedrc.json ├── .prettierrc.json ├── scripts └── docs.mjs ├── .eslintrc.json ├── .gitignore ├── jest.config.js ├── babel.config.js ├── tsconfig.eslint.json ├── tsup.config.ts ├── .commitlintrc.json ├── tsconfig.json ├── README.md ├── CHANGELOG.md ├── package.json ├── LICENSE ├── __tests__ └── collection.test.ts └── src └── index.ts /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf 2 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | audit=false 2 | fund=false 3 | legacy-peer-deps=true 4 | -------------------------------------------------------------------------------- /.versionrc: -------------------------------------------------------------------------------- 1 | { 2 | "releaseCommitMessageFormat": "chore(Release): publish" 3 | } 4 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | ## [View the documentation here.](https://discord.js.org/#/docs/collection) 2 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: [iCrawl, amishshah, vladfrangu, kyranet] 2 | open_collective: discordjs 3 | -------------------------------------------------------------------------------- /.husky/pre-commit: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | . "$(dirname "$0")/_/husky.sh" 3 | 4 | npx --no-install lint-staged 5 | -------------------------------------------------------------------------------- /.husky/commit-msg: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | . "$(dirname "$0")/_/husky.sh" 3 | 4 | npx --no-install commitlint --edit 5 | -------------------------------------------------------------------------------- /docs/index.yml: -------------------------------------------------------------------------------- 1 | - name: General 2 | files: 3 | - name: Welcome 4 | id: welcome 5 | path: ../../README.md 6 | -------------------------------------------------------------------------------- /.lintstagedrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "*.{mjs,js,ts}": "eslint --fix --ext mjs,js,ts", 3 | "*.{json,yml,yaml}": "prettier --write" 4 | } 5 | -------------------------------------------------------------------------------- /.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 120, 3 | "useTabs": true, 4 | "singleQuote": true, 5 | "quoteProps": "as-needed", 6 | "trailingComma": "all", 7 | "endOfLine": "lf" 8 | } 9 | -------------------------------------------------------------------------------- /scripts/docs.mjs: -------------------------------------------------------------------------------- 1 | import { runGenerator } from '@discordjs/ts-docgen'; 2 | 3 | runGenerator({ 4 | existingOutput: 'docs/typedoc-out.json', 5 | custom: 'docs/index.yml', 6 | output: 'docs/docs.json', 7 | }); 8 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: Discord server 4 | url: https://discord.gg/djs 5 | about: Please visit our Discord server for questions and support requests. 6 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "marine/prettier/node", 3 | "parserOptions": { 4 | "project": "./tsconfig.eslint.json", 5 | "extraFileExtensions": [".mjs"] 6 | }, 7 | "ignorePatterns": ["**/dist/*"], 8 | "env": { 9 | "jest": true 10 | }, 11 | "rules": { 12 | "no-redeclare": 0, 13 | "@typescript-eslint/naming-convention": 0 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Packages 2 | node_modules/ 3 | 4 | # Log files 5 | logs/ 6 | *.log 7 | npm-debug.log* 8 | 9 | # Runtime data 10 | pids 11 | *.pid 12 | *.seed 13 | 14 | # Env 15 | .env 16 | 17 | # Dist 18 | dist/ 19 | typings/ 20 | docs/**/* 21 | !docs/index.yml 22 | !docs/README.md 23 | 24 | # Miscellaneous 25 | .tmp/ 26 | coverage/ 27 | tsconfig.tsbuildinfo 28 | -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @type {import('@jest/types').Config.InitialOptions} 3 | */ 4 | module.exports = { 5 | testMatch: ['**/+(*.)+(spec|test).+(ts|js)?(x)'], 6 | testEnvironment: 'node', 7 | collectCoverage: true, 8 | collectCoverageFrom: ['src/**/*.ts'], 9 | coverageDirectory: 'coverage', 10 | coverageReporters: ['text', 'lcov', 'clover'], 11 | }; 12 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @type {import('@babel/core').TransformOptions} 3 | */ 4 | module.exports = { 5 | parserOpts: { strictMode: true }, 6 | sourceMaps: 'inline', 7 | presets: [ 8 | [ 9 | '@babel/preset-env', 10 | { 11 | targets: { node: 'current' }, 12 | modules: 'commonjs', 13 | }, 14 | ], 15 | '@babel/preset-typescript', 16 | ], 17 | }; 18 | -------------------------------------------------------------------------------- /tsconfig.eslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "allowJs": true 5 | }, 6 | "include": [ 7 | "**/*.ts", 8 | "**/*.tsx", 9 | "**/*.js", 10 | "**/*.mjs", 11 | "**/*.jsx", 12 | "**/*.test.ts", 13 | "**/*.test.js", 14 | "**/*.test.mjs", 15 | "**/*.spec.ts", 16 | "**/*.spec.js", 17 | "**/*.spec.mjs" 18 | ], 19 | "exclude": [] 20 | } 21 | -------------------------------------------------------------------------------- /tsup.config.ts: -------------------------------------------------------------------------------- 1 | import type { Options } from 'tsup'; 2 | 3 | export const tsup: Options = { 4 | clean: true, 5 | dts: true, 6 | entryPoints: ['src/index.ts'], 7 | format: ['esm', 'cjs'], 8 | minify: true, 9 | // if false: causes Collection.constructor to be a minified value like: 'o' 10 | keepNames: true, 11 | skipNodeModulesBundle: true, 12 | sourcemap: true, 13 | target: 'es2021', 14 | }; 15 | -------------------------------------------------------------------------------- /.github/tsc.json: -------------------------------------------------------------------------------- 1 | { 2 | "problemMatcher": [ 3 | { 4 | "owner": "tsc", 5 | "pattern": [ 6 | { 7 | "regexp": "^(?:\\s+\\d+\\>)?([^\\s].*)\\((\\d+),(\\d+)\\)\\s*:\\s+(error|warning|info)\\s+(\\w{1,2}\\d+)\\s*:\\s*(.*)$", 8 | "file": 1, 9 | "line": 2, 10 | "column": 3, 11 | "severity": 4, 12 | "code": 5, 13 | "message": 6 14 | } 15 | ] 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /.commitlintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["@commitlint/config-angular"], 3 | "rules": { 4 | "scope-case": [2, "always", "pascal-case"], 5 | "type-enum": [ 6 | 2, 7 | "always", 8 | [ 9 | "chore", 10 | "build", 11 | "ci", 12 | "docs", 13 | "feat", 14 | "fix", 15 | "perf", 16 | "refactor", 17 | "revert", 18 | "style", 19 | "test", 20 | "types", 21 | "workflow", 22 | "wip" 23 | ] 24 | ] 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /.github/SUPPORT.md: -------------------------------------------------------------------------------- 1 | # Seeking support? 2 | 3 | We only use this issue tracker for bug reports and feature request. We are not able to provide general support or answer questions in the form of GitHub issues. 4 | 5 | For general questions about @discordjs/collection installation and use please use the dedicated support channels in our Discord server: https://discord.gg/djs 6 | 7 | Any issues that don't directly involve a bug or a feature request will likely be closed and redirected. 8 | -------------------------------------------------------------------------------- /.github/workflows/labelsync.yml: -------------------------------------------------------------------------------- 1 | name: Label Sync 2 | on: 3 | schedule: 4 | - cron: '0 0 * * *' 5 | workflow_dispatch: 6 | push: 7 | branches: 8 | - main 9 | paths: 10 | - '.github/labels.yml' 11 | jobs: 12 | labeler: 13 | name: Labeler 14 | runs-on: ubuntu-latest 15 | steps: 16 | - name: Checkout repository 17 | uses: actions/checkout@v2 18 | 19 | - name: Run Label Sync 20 | uses: crazy-max/ghaction-github-labeler@v3 21 | with: 22 | github-token: ${{ secrets.GITHUB_TOKEN }} 23 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | **Please describe the changes this PR makes and why it should be merged:** 2 | 3 | 4 | 5 | **Status and versioning classification:** 6 | 7 | 15 | -------------------------------------------------------------------------------- /.github/workflows/deploy.yml: -------------------------------------------------------------------------------- 1 | name: Deployment 2 | on: 3 | push: 4 | branches: 5 | - '*' 6 | - '!docs' 7 | tags: 8 | - '*' 9 | jobs: 10 | docs: 11 | name: Documentation 12 | runs-on: ubuntu-latest 13 | steps: 14 | - name: Checkout repository 15 | uses: actions/checkout@v2 16 | 17 | - name: Install Node v16 18 | uses: actions/setup-node@v2 19 | with: 20 | node-version: 16 21 | cache: npm 22 | 23 | - name: Install dependencies 24 | run: npm ci 25 | 26 | - name: Build and deploy documentation 27 | uses: discordjs/action-docs@v1 28 | env: 29 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 30 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | // Mapped from https://www.typescriptlang.org/tsconfig 3 | "compilerOptions": { 4 | // Type Checking 5 | "allowUnreachableCode": false, 6 | "allowUnusedLabels": false, 7 | "exactOptionalPropertyTypes": true, 8 | "noFallthroughCasesInSwitch": true, 9 | "noImplicitOverride": true, 10 | "noImplicitReturns": true, 11 | "noUnusedLocals": true, 12 | "noUnusedParameters": true, 13 | "strict": true, 14 | "useUnknownInCatchVariables": true, 15 | 16 | // Modules 17 | "module": "CommonJS", 18 | "moduleResolution": "node", 19 | "resolveJsonModule": true, 20 | 21 | // Emit 22 | "declaration": true, 23 | "importHelpers": true, 24 | "importsNotUsedAsValues": "error", 25 | "inlineSources": true, 26 | "newLine": "lf", 27 | "noEmitHelpers": true, 28 | "outDir": "dist", 29 | "preserveConstEnums": true, 30 | "removeComments": false, 31 | "sourceMap": true, 32 | "esModuleInterop": true, 33 | "forceConsistentCasingInFileNames": true, 34 | 35 | // Language and Environment 36 | "emitDecoratorMetadata": true, 37 | "experimentalDecorators": true, 38 | "lib": ["ESNext"], 39 | "target": "ES2020", 40 | "useDefineForClassFields": true, 41 | 42 | // Completeness 43 | "skipLibCheck": true 44 | }, 45 | "include": ["src/**/*.ts"] 46 | } 47 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.yml: -------------------------------------------------------------------------------- 1 | name: Feature request 2 | description: Request a new feature 3 | labels: [feature request] 4 | body: 5 | - type: markdown 6 | attributes: 7 | value: | 8 | Use Discord for questions: https://discord.gg/djs 9 | - type: textarea 10 | id: description 11 | attributes: 12 | label: Feature 13 | description: A clear and concise description of what the problem is, or what feature you want to be implemented. 14 | placeholder: I'm always frustrated when..., A good addition would be... 15 | validations: 16 | required: true 17 | - type: textarea 18 | id: solution 19 | attributes: 20 | label: Ideal solution or implementation 21 | description: A clear and concise description of what you want to happen. 22 | validations: 23 | required: true 24 | - type: textarea 25 | id: alternatives 26 | attributes: 27 | label: Alternative solutions or implementations 28 | description: A clear and concise description of any alternative solutions or features you have considered. 29 | - type: textarea 30 | id: additional-context 31 | attributes: 32 | label: Other context 33 | description: Any other context, screenshots, or file uploads that help us understand your feature request. 34 | -------------------------------------------------------------------------------- /.github/labels.yml: -------------------------------------------------------------------------------- 1 | - name: 'backlog' 2 | color: '7ef7ef' 3 | - name: 'bug' 4 | color: 'd73a4a' 5 | - name: 'chore' 6 | color: 'ffffff' 7 | - name: 'ci' 8 | color: '0075ca' 9 | - name: 'dependencies' 10 | color: '276bd1' 11 | - name: 'discussion' 12 | color: 'b6b1f9' 13 | - name: 'documentation' 14 | color: '0075ca' 15 | - name: 'duplicate' 16 | color: 'cfd3d7' 17 | - name: 'error handling' 18 | color: '80c042' 19 | - name: 'feature request' 20 | color: 'fcf95a' 21 | - name: 'good first issue' 22 | color: '7057ff' 23 | - name: 'has PR' 24 | color: '4b1f8e' 25 | - name: 'help wanted' 26 | color: '008672' 27 | - name: 'in progress' 28 | color: 'ffccd7' 29 | - name: 'in review' 30 | color: 'aed5fc' 31 | - name: 'invalid' 32 | color: 'e4e669' 33 | - name: 'need repro' 34 | color: 'c66037' 35 | - name: 'performance' 36 | color: '80c042' 37 | - name: 'priority:high' 38 | color: 'fc1423' 39 | - name: 'question (please use Discord instead)' 40 | color: 'd876e3' 41 | - name: 'refactor' 42 | color: '1d637f' 43 | - name: 'regression' 44 | color: 'ea8785' 45 | - name: 'semver:major' 46 | color: 'c10f47' 47 | - name: 'semver:minor' 48 | color: 'e4f486' 49 | - name: 'semver:patch' 50 | color: 'e8be8b' 51 | - name: 'tests' 52 | color: 'f06dff' 53 | - name: 'typings' 54 | color: '80c042' 55 | - name: 'wontfix' 56 | color: 'ffffff' 57 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Tests 2 | on: [push, pull_request] 3 | jobs: 4 | lint: 5 | name: ESLint 6 | runs-on: ubuntu-latest 7 | steps: 8 | - name: Checkout repository 9 | uses: actions/checkout@v2 10 | 11 | - name: Install Node v16 12 | uses: actions/setup-node@v2 13 | with: 14 | node-version: 16 15 | cache: npm 16 | 17 | - name: Install dependencies 18 | run: npm ci 19 | 20 | - name: Run ESLint 21 | run: npm run lint 22 | 23 | typescript: 24 | name: TypeScript 25 | runs-on: ubuntu-latest 26 | steps: 27 | - name: Checkout repository 28 | uses: actions/checkout@v2 29 | 30 | - name: Install Node v16 31 | uses: actions/setup-node@v2 32 | with: 33 | node-version: 16 34 | cache: npm 35 | 36 | - name: Install dependencies 37 | run: npm ci 38 | 39 | - name: Register Problem Matcher 40 | run: echo "##[add-matcher].github/tsc.json" 41 | 42 | - name: Run TypeScript compiler 43 | run: npm run build 44 | 45 | docs: 46 | name: Documentation 47 | runs-on: ubuntu-latest 48 | steps: 49 | - name: Checkout repository 50 | uses: actions/checkout@v2 51 | 52 | - name: Install Node v16 53 | uses: actions/setup-node@v2 54 | with: 55 | node-version: 16 56 | cache: npm 57 | 58 | - name: Install dependencies 59 | run: npm ci 60 | 61 | - name: Test documentation 62 | run: npm run docs 63 | 64 | tests: 65 | name: Tests 66 | runs-on: ubuntu-latest 67 | steps: 68 | - name: Checkout repository 69 | uses: actions/checkout@v2 70 | 71 | - name: Install Node v16 72 | uses: actions/setup-node@v2 73 | with: 74 | node-version: 16 75 | cache: npm 76 | 77 | - name: Install dependencies 78 | run: npm ci 79 | 80 | - name: Run Tests 81 | run: npm test 82 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 |
3 |

4 | discord.js 5 |

6 |
7 |

8 | Discord server 9 | npm version 10 | npm downloads 11 | Build status 12 |

13 |
14 | 15 | ## About 16 | 17 | `@discordjs/collection` is a powerful utility data structure used in discord.js. 18 | 19 | ## Installation 20 | 21 | **Node.js 16.0.0 or newer is required.** 22 | 23 | ```sh-session 24 | npm install @discordjs/collection 25 | yarn add @discordjs/collection 26 | pnpm add @discordjs/collection 27 | ``` 28 | 29 | ## Links 30 | 31 | - [Website](https://discord.js.org/) ([source](https://github.com/discordjs/website)) 32 | - [Documentation](https://discord.js.org/#/docs/collection) 33 | - [discord.js Discord server](https://discord.gg/djs) 34 | - [GitHub](https://github.com/discordjs/collection) 35 | - [npm](https://www.npmjs.com/package/@discordjs/collection) 36 | 37 | ## Contributing 38 | 39 | Before creating an issue, please ensure that it hasn't already been reported/suggested, and double-check the 40 | [documentation](https://discord.js.org/#/docs/collection). 41 | See [the contribution guide](https://github.com/discordjs/collection/blob/main/.github/CONTRIBUTING.md) if you'd like to submit a PR. 42 | 43 | ## Help 44 | 45 | If you don't understand something in the documentation, you are experiencing problems, or you just need a gentle 46 | nudge in the right direction, please don't hesitate to join our official [discord.js Server](https://discord.gg/djs). 47 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.yml: -------------------------------------------------------------------------------- 1 | name: Bug report 2 | description: Report incorrect or unexpected behavior 3 | labels: [bug, need repro] 4 | body: 5 | - type: markdown 6 | attributes: 7 | value: | 8 | Use Discord for questions: https://discord.gg/djs 9 | - type: textarea 10 | id: description 11 | attributes: 12 | label: Issue description 13 | description: | 14 | Describe the issue in as much detail as possible. 15 | 16 | Tip: You can attach images or log files by clicking this area to highlight it and then dragging files into it. 17 | placeholder: | 18 | Steps to reproduce with below code sample: 19 | 1. do thing 20 | 2. do thing in Discord client 21 | 3. observe behavior 22 | 4. see error logs below 23 | validations: 24 | required: true 25 | - type: textarea 26 | id: codesample 27 | attributes: 28 | label: Code sample 29 | description: Include a reproducible, minimal code sample. This will be automatically formatted into code, so no need for backticks. 30 | render: typescript 31 | - type: input 32 | id: collection-version 33 | attributes: 34 | label: '@discordjs/collection version' 35 | description: Which version of @discordjs/collection are you using? Run `npm list @discordjs/collection` in your project directory and paste the output. 36 | placeholder: 0.x.x 37 | validations: 38 | required: true 39 | - type: input 40 | id: node-version 41 | attributes: 42 | label: Node.js version 43 | description: | 44 | Which version of Node.js are you using? Run `node --version` in your project directory and paste the output. 45 | If you are using TypeScript, please include its version (`npm list typescript`) as well. 46 | placeholder: Node.js version 16+ is required 47 | validations: 48 | required: true 49 | - type: input 50 | id: os 51 | attributes: 52 | label: Operating system 53 | description: Which OS does your application run on? 54 | - type: dropdown 55 | id: priority 56 | attributes: 57 | label: Priority this issue should have 58 | description: Please be realistic. If you need to elaborate on your reasoning, please use the Issue description field above. 59 | options: 60 | - Low (slightly annoying) 61 | - Medium (should be fixed soon) 62 | - High (immediate attention needed) 63 | validations: 64 | required: true 65 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. 4 | 5 | # [0.4.0](https://github.com/discordjs/collection/compare/v0.3.2...v0.4.0) (2021-12-24) 6 | 7 | 8 | ### Features 9 | 10 | * add #reverse ([#48](https://github.com/discordjs/collection/issues/48)) ([8bcb5e2](https://github.com/discordjs/collection/commit/8bcb5e21bcc15f5b77612d8ff03dec6c37f4d449)) 11 | * add Collection#ensure ([#52](https://github.com/discordjs/collection/issues/52)) ([3809eb4](https://github.com/discordjs/collection/commit/3809eb4d18e70459355d310919a3f57747eee3dd)) 12 | 13 | 14 | 15 | ## [0.3.2](https://github.com/discordjs/collection/compare/v0.3.1...v0.3.2) (2021-10-29) 16 | 17 | 18 | ### Bug Fixes 19 | 20 | * update doc engine ([4c0e24f](https://github.com/discordjs/collection/commit/4c0e24fae0323db9de1991db9cfacc093d529abc)) 21 | 22 | 23 | 24 | ## [0.3.1](https://github.com/discordjs/collection/compare/v0.3.0...v0.3.1) (2021-10-29) 25 | 26 | 27 | 28 | # [0.3.0](https://github.com/discordjs/collection/compare/v0.2.4...v0.3.0) (2021-10-29) 29 | 30 | 31 | ### Features 32 | 33 | * add Collection#at() and Collection#keyAt() ([#46](https://github.com/discordjs/collection/issues/46)) ([66b30b9](https://github.com/discordjs/collection/commit/66b30b91069502493383c059cc38e27c152bf541)) 34 | * improve documentation and resolve [#49](https://github.com/discordjs/collection/issues/49) ([aec01c6](https://github.com/discordjs/collection/commit/aec01c6ae3ff50b0b5f7c070bff10f01bf98d803)) 35 | * ts-docgen ([463b131](https://github.com/discordjs/collection/commit/463b1314e60f2debc526454a6ccd7ce8a9a4ae8a)) 36 | 37 | 38 | 39 | ## [0.2.4](https://github.com/discordjs/collection/compare/v0.2.3...v0.2.4) (2021-10-27) 40 | 41 | 42 | ### Bug Fixes 43 | 44 | * minification of names ([bd2fe2a](https://github.com/discordjs/collection/commit/bd2fe2a47c38f634b0334fe6e89f30f6f6a0b1f5)) 45 | 46 | 47 | 48 | ## [0.2.3](https://github.com/discordjs/collection/compare/v0.2.2...v0.2.3) (2021-10-27) 49 | 50 | 51 | ### Bug Fixes 52 | 53 | * building with useDefineForClassFields false ([2a571d5](https://github.com/discordjs/collection/commit/2a571d5a2c90ed8b708c3c5c017e2f225cd494e9)) 54 | 55 | 56 | 57 | ## [0.2.2](https://github.com/discordjs/collection/compare/v0.2.1...v0.2.2) (2021-10-27) 58 | 59 | 60 | 61 | # Changelog 62 | 63 | All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. 64 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@discordjs/collection", 3 | "version": "0.4.0", 4 | "description": "Utility data structure used in Discord.js", 5 | "scripts": { 6 | "pretest": "npm run build", 7 | "test": "jest --pass-with-no-tests", 8 | "test:ci": "jest --no-stack-trace --verbose --pass-with-no-tests", 9 | "prebuild": "npm run lint", 10 | "build": "tsup", 11 | "lint": "eslint src --ext mjs,js,ts", 12 | "lint:fix": "eslint src --ext mjs,js,ts --fix", 13 | "format": "prettier --write **/*.{ts,js,json,yml,yaml}", 14 | "prepare": "is-ci || husky install", 15 | "docs": "typedoc --json docs/typedoc-out.json src/index.ts && node scripts/docs.mjs", 16 | "prepublishOnly": "npm run lint && npm run test", 17 | "release": "standard-version --preset angular" 18 | }, 19 | "main": "./dist/index.js", 20 | "module": "./dist/index.mjs", 21 | "typings": "./dist/index.d.ts", 22 | "exports": { 23 | "import": "./dist/index.mjs", 24 | "require": "./dist/index.js" 25 | }, 26 | "directories": { 27 | "lib": "src", 28 | "test": "__tests__" 29 | }, 30 | "files": [ 31 | "dist" 32 | ], 33 | "contributors": [ 34 | "Crawl ", 35 | "Amish Shah ", 36 | "SpaceEEC ", 37 | "Vlad Frangu " 38 | ], 39 | "license": "Apache-2.0", 40 | "keywords": [ 41 | "map", 42 | "collection", 43 | "utility" 44 | ], 45 | "repository": { 46 | "type": "git", 47 | "url": "git+https://github.com/discordjs/collection.git" 48 | }, 49 | "bugs": { 50 | "url": "https://github.com/discordjs/collection/issues" 51 | }, 52 | "homepage": "https://github.com/discordjs/collection", 53 | "devDependencies": { 54 | "@babel/core": "^7.16.5", 55 | "@babel/preset-env": "^7.16.5", 56 | "@babel/preset-typescript": "^7.16.5", 57 | "@commitlint/cli": "^15.0.0", 58 | "@commitlint/config-angular": "^15.0.0", 59 | "@discordjs/ts-docgen": "^0.3.4", 60 | "@types/jest": "^27.0.3", 61 | "@types/node": "^16.11.6", 62 | "@typescript-eslint/eslint-plugin": "^5.8.0", 63 | "@typescript-eslint/parser": "^5.8.0", 64 | "eslint": "^8.5.0", 65 | "eslint-config-marine": "^9.1.0", 66 | "eslint-config-prettier": "^8.3.0", 67 | "eslint-plugin-prettier": "^4.0.0", 68 | "husky": "^7.0.4", 69 | "is-ci": "^3.0.1", 70 | "jest": "^27.4.5", 71 | "lint-staged": "^12.1.4", 72 | "prettier": "^2.5.1", 73 | "standard-version": "^9.3.2", 74 | "tsup": "^5.11.8", 75 | "typedoc": "^0.22.10", 76 | "typescript": "^4.5.4" 77 | }, 78 | "engines": { 79 | "node": ">=16.0.0", 80 | "npm": ">=7.0.0" 81 | }, 82 | "publishConfig": { 83 | "access": "public" 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # discord.js Contributing Guide 2 | 3 | **The issue tracker is only for bug reports and enhancement suggestions. If you have a question, please ask it in the [Discord server](https://discord.gg/djs) instead of opening an issue – you will get redirected there anyway.** 4 | 5 | - [Code of Conduct](https://github.com/discordjs/collection/blob/main/.github/CODE_OF_CONDUCT.md) 6 | - [Pull Request Guidelines](#pull-request-guidelines) 7 | - [Development Setup](#development-setup) 8 | - [Project Structure](#project-structure) 9 | - [Contributing Tests](#contributing-tests) 10 | 11 | ## Pull Request Guidelines 12 | 13 | - Checkout a topic branch from a base branch, e.g. `main`, and merge back against that branch. 14 | 15 | - If adding a new feature: 16 | 17 | - Add an accompanying test case. 18 | - Provide a convincing reason to add this feature. Ideally, you should open a suggestion issue first and have it approved before working on it. 19 | 20 | - If fixing a bug: 21 | 22 | - If you are resolving a special issue, add `fix/close #xxxx[,#xxxx]` (#xxxx is the issue id) in your PR body for a better release log, e.g. 23 | 24 | ``` 25 | fix(Guild): handle events correctly 26 | 27 | close #28 28 | ``` 29 | 30 | - Provide a detailed description of the bug in the PR. Live demo preferred. 31 | 32 | - It's OK to have multiple small commits as you work on the PR - GitHub can automatically squash them before merging. 33 | 34 | - Make sure tests pass! 35 | 36 | - Commit messages must follow the [commit message convention](./COMMIT_CONVENTION.md) so that changelogs can be automatically generated. Commit messages are automatically validated before commit (by invoking [Git Hooks](https://git-scm.com/docs/githooks) via [husky](https://github.com/typicode/husky)). 37 | 38 | - No need to worry about code style as long as you have installed the dev dependencies - modified files are automatically formatted with Prettier on commit (by invoking [Git Hooks](https://git-scm.com/docs/githooks) via [husky](https://github.com/typicode/husky)). 39 | 40 | ## Development Setup 41 | 42 | You will need [Node.js](http://nodejs.org) **version 16+**, and [npm](https://www.npmjs.com/). 43 | 44 | After cloning the repo, run: 45 | 46 | ```bash 47 | $ npm ci # install the dependencies of the project 48 | ``` 49 | 50 | A high level overview of tools used: 51 | 52 | - [TypeScript](https://www.typescriptlang.org/) as the development language 53 | - [Jest](https://jestjs.io/) for unit testing 54 | - [Eslint](https://eslint.org/) for code-style 55 | - [Prettier](https://prettier.io/) for code formatting 56 | 57 | ## Contributing Tests 58 | 59 | Unit tests are collocated with the code being tested in each package, inside directories named `__tests__`. Consult the [Jest docs](https://jestjs.io/docs/en/using-matchers) and existing test cases for how to write new test specs. 60 | -------------------------------------------------------------------------------- /.github/COMMIT_CONVENTION.md: -------------------------------------------------------------------------------- 1 | ## Git Commit Message Convention 2 | 3 | > This is adapted from [Angular's commit convention](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-angular). 4 | 5 | #### TL;DR: 6 | 7 | Messages must be matched by the following regex: 8 | 9 | ```js 10 | /^(revert: )?(feat|fix|docs|style|refactor|perf|test|workflow|build|ci|chore|types|wip)(\(.+\))?: .{1,72}/; 11 | ``` 12 | 13 | #### Examples 14 | 15 | Appears under "Features" header, `GuildMember` subheader: 16 | 17 | ``` 18 | feat(GuildMember): add 'tag' method 19 | ``` 20 | 21 | Appears under "Bug Fixes" header, `Guild` subheader, with a link to issue #28: 22 | 23 | ``` 24 | fix(Guild): handle events correctly 25 | 26 | close #28 27 | ``` 28 | 29 | Appears under "Performance Improvements" header, and under "Breaking Changes" with the breaking change explanation: 30 | 31 | ``` 32 | perf(core): improve patching by removing 'bar' option 33 | 34 | BREAKING CHANGE: The 'bar' option has been removed. 35 | ``` 36 | 37 | The following commit and commit `667ecc1` do not appear in the changelog if they are under the same release. If not, the revert commit appears under the "Reverts" header. 38 | 39 | ``` 40 | revert: feat(Managers): add Managers 41 | 42 | This reverts commit 667ecc1654a317a13331b17617d973392f415f02. 43 | ``` 44 | 45 | ### Full Message Format 46 | 47 | A commit message consists of a **header**, **body** and **footer**. The header has a **type**, **scope** and **subject**: 48 | 49 | ``` 50 | (): 51 | 52 | 53 | 54 |