diff --git a/README.md b/README.md index 0c363f2..b47b81f 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ -# nodejs-project-template +# CasinoJs -nodejs-project-template +CasinoJs ## Table of Contents -- [nodejs-project-template](#nodejs-project-template) +- [CasinoJs](#casinojs) - [Table of Contents](#table-of-contents) - [Feedback and Suggestions](#feedback-and-suggestions) diff --git a/docs/PROJECT_STRUCTURE.md b/docs/PROJECT_STRUCTURE.md index 3e81b33..b84940c 100644 --- a/docs/PROJECT_STRUCTURE.md +++ b/docs/PROJECT_STRUCTURE.md @@ -1,77 +1,313 @@ # Project Structure -This document provides a comprehensive overview of the directory structure for the `pokerjs` repository. It outlines the purpose and organization of each directory and file, ensuring a clear understanding of where to find various components of the project. +## Introduction + +This document provides a comprehensive overview of the directory structure for the `CasinoJs` repository. It outlines the purpose and organization of each directory and file, ensuring a clear understanding of where to find various components of the project. ## Table of Contents - [Project Structure](#project-structure) + - [Introduction](#introduction) - [Table of Contents](#table-of-contents) - - [Root Directory Layout](#root-directory-layout) + - [./ Directory Layout](#-directory-layout) + - [./.envs Directory Layout](#envs-directory-layout) + - [./.github Directory Layout](#github-directory-layout) + - [./coverage Directory Layout](#coverage-directory-layout) + - [./dist Directory Layout](#dist-directory-layout) + - [./docs Directory Layout](#docs-directory-layout) + - [./src Directory Layout](#src-directory-layout) + - [./src/enums Directory Layout](#srcenums-directory-layout) + - [./src/events Directory Layout](#srcevents-directory-layout) + - [./src/interfaces Directory Layout](#srcinterfaces-directory-layout) + - [./src/models Directory Layout](#srcmodels-directory-layout) + - [./tests Directory Layout](#tests-directory-layout) + - [./tests/enums Directory Layout](#testsenums-directory-layout) + - [./tests/events Directory Layout](#testsevents-directory-layout) + - [./tests/interfaces Directory Layout](#testsinterfaces-directory-layout) + - [./tests/models Directory Layout](#testsmodels-directory-layout) -## Root Directory Layout +## ./ Directory Layout ```bash -├── /.envs # Environment configuration files for different environments -│ ├── .env.development.local.example # Example environment configuration file for development environment -│ ├── .env.example # Example environment configuration file for local development -│ ├── .env.local.example # Example environment configuration file for local overrides -│ ├── .env.production.local.example # Example environment configuration file for production environment -│ └── .env.test.local.example # Example environment configuration file for testing environment -│ -├── /.github # GitHub-related configuration files -│ ├── /COMMIT_TEMPLATE # Commit message templates for standardized commit messages -│ │ └── commit_template.md # Template for commit messages to maintain consistency -│ │ -│ ├── /ISSUE_TEMPLATE # Templates for creating issues -│ │ ├── bug_report_form.yml # YAML file defining the form for reporting bugs -│ │ ├── bug_report_template.md # Markdown template for bug reports -│ │ └── feature_request_template.md # Markdown template for feature requests -│ │ -│ └── /PULL_REQUEST_TEMPLATE # Templates for pull requests -│ └── pull_request_template.md # Markdown template for pull requests to ensure all necessary information is provided -│ -├── /docs # Documentation and guides related to the project -│ ├── /site # Generated documentation from Typedoc -│ │ ├── assets/ # Assets used in the documentation site -│ │ ├── classes/ # Generated class documentation -│ │ ├── enums/ # Generated enums documentation -│ │ ├── media/ # Media files for the documentation -│ │ ├── modules/ # Generated modules documentation -│ │ ├── .nojekyll # File to disable GitHub Pages Jekyll processing -│ │ ├── index.html # Documentation index page -│ │ └── modules.html # List of modules in the documentation -│ │ -│ ├── CHANGELOG.md # Record of changes and updates made to the project over time -│ ├── CONTRIBUTING.md # Guidelines and instructions for contributing to the project -│ ├── DEVELOPMENT_GUIDE.md # Step-by-step guide for developers to set up and work on the project -│ ├── DOCS.md # General documentation, including API details, usage instructions, and best practices -│ └── PROJECT_STRUCTURE.md # Detailed explanation of the project's directory structure and file purposes +├── /.envs # Environment configuration files for different environments +├── /.github # GitHub configuration files for commits, issues, and PR templates +├── /coverage # Test coverage reports generated after running the test suite +├── /dist # Compiled output files generated by TypeScript for distribution +├── /docs # Documentation and guides for the project +├── /src # Source code for the CasinoJs library +├── /tests # Unit tests for verifying poker models and project functionality +├── .gitignore # Specifies files and directories ignored by Git +├── jest.config.js # Configuration file for Jest, defining paths and options for testing +├── LICENSE # License file outlining the terms of distribution +├── package-lock.json # Dependency tree capture for consistent installations +├── package.json # Project metadata, including dependencies and scripts +├── README.md # Overview of the project, with setup and usage information +├── tsconfig.cjs.json # TypeScript configuration for CommonJS builds +├── tsconfig.esm.json # TypeScript configuration for ESModule builds +└── tsconfig.json # Main TypeScript configuration for overall compiler options +``` + +## ./.envs Directory Layout + +```bash +├── .env.development.local.example # Development environment configuration file example +├── .env.example # General local development configuration file example +├── .env.local.example # Local overrides configuration file example (machine-specific) +├── .env.production.local.example # Production deployment configuration file example +└── .env.test.local.example # Test environment configuration file example +``` + +## ./.github Directory Layout + +```bash +├── /COMMIT_TEMPLATE # Directory holding templates for commit messages +│ └── commit_template.md # Markdown template for consistent commit messages, ensuring detailed descriptions with title, summary, type, and other sections +├── /ISSUE_TEMPLATE # Directory containing templates for creating GitHub issues +│ ├── bug_report_form.yml # YAML configuration for submitting bug reports via GitHub’s form-based interface +│ ├── bug_report_template.md # Markdown template for reporting bugs, with fields for issue description, steps to reproduce, expected vs. actual behavior, etc. +│ └── feature_request_template.md # Markdown template for requesting new features or improvements, outlining the feature's purpose and desired functionality +└── /PULL_REQUEST_TEMPLATE # Directory containing templates for submitting pull requests + └── pull_request_template.md # Markdown template with structured fields for pull request descriptions, including changes summary, purpose, testing notes, and checklist +``` + +## ./coverage Directory Layout + +```bash +├── /Icov-report # HTML-based coverage reports directory +│ ├── /enums # Coverage for enums in the project +│ ├── /models # Coverage for models in the project +│ ├── base.css # CSS styling for coverage reports +│ ├── block-navigation.js # JavaScript for navigation within the report +│ ├── favicon.png # Favicon for the report HTML pages +│ ├── index.html # Main entry point for the coverage report +│ ├── prettify.css # CSS for code snippet formatting +│ ├── prettify.js # JavaScript for syntax highlighting +│ ├── sort-arrow-sprite.png # Arrow sprite used in report navigation +│ └── sorter.js # JavaScript for sorting report data │ -├── /src # Source code for the pokerjs library -│ ├── /interfaces # TypeScript interfaces for the poker models -│ │ ├── /rank # Rank interface for card ranks -│ │ │ └── index.ts # Exports for rank-related types -│ │ ├── /suit # Suit interface for card suits -│ │ │ └── index.ts # Exports for suit-related types -│ │ └── index.ts # Main export for all interfaces -│ │ -│ ├── /models # Core poker models and logic -│ │ ├── /card # Card model representing a playing card -│ │ │ └── index.ts # Card model implementation -│ │ ├── /deck # Deck model representing a deck of playing cards -│ │ │ └── index.ts # Deck model implementation -│ │ └── index.ts # Exports for all models -│ │ -├── /tests # Unit tests for poker logic -│ ├── deck.test.ts # Unit tests for the Deck model -│ ├── player.test.ts # Unit tests for the Player model +├── clover.xml # XML format report for coverage analysis tools +├── coverage-final.json # JSON summary of coverage results +└── lcov.info # LCOV format coverage report for tools like Coveralls +``` + +## ./dist Directory Layout + +```bash +├── /cjs # CommonJS entry point after TypeScript compilation +│ ├── enums/ # Compiled enums for CommonJS +│ ├── interfaces/ # Compiled interfaces for CommonJS +│ ├── models/ # Compiled models for CommonJS +│ ├── index.d.ts # TypeScript declaration for CommonJS entry point +│ ├── index.js # CommonJS entry point after compilation +│ └── index.js.map # Source map for CommonJS entry point │ -├── /dist # Compiled output files generated by TypeScript +└── /esm # ESModule entry point after TypeScript compilation + ├── enums/ # Compiled enums for ESModule + ├── interfaces/ # Compiled interfaces for ESModule + ├── models/ # Compiled models for ESModule + ├── index.d.ts # TypeScript declaration for ESModule entry point + ├── index.js # ESModule entry point after compilation + └── index.js.map # Source map for ESModule entry point +``` + +## ./docs Directory Layout + +```bash +├── /site # Typedoc generated documentation +│ ├── assets/ # Static assets for the documentation site +│ ├── classes/ # Documentation for classes in the project +│ ├── enums/ # Documentation for enums in the project +│ ├── interfaces/ # Documentation for interfaces in the project +│ ├── media/ # Media files like images and diagrams +│ ├── modules/ # Categorized documentation for modules +│ ├── .nojekyll # Prevents GitHub Pages from processing with Jekyll +│ ├── hierarchy.html # Project structure in hierarchical format +│ ├── index.html # Main entry for the documentation site +│ └── modules.html # List of modules documented within the site │ -├── .gitignore # Specifies files and directories to be ignored by Git -├── LICENSE # License file outlining the terms under which the project is distributed -├── package-lock.json # Automatically generated file that captures the exact dependency tree -├── package.json # Project metadata and dependencies -├── README.md # Overview of the project, including its purpose, setup instructions, and usage -└── tsconfig.json # TypeScript configuration file specifying compiler options +├── CHANGELOG.md # Record of changes, updates, and version history +├── CONTRIBUTING.md # Guidelines for contributing to the project +├── DEVELOPMENT_GUIDE.md # Guide for setting up and contributing to the project +├── DOCS.md # API details, usage instructions, and best practices +└── PROJECT_STRUCTURE.md # Detailed explanation of the project directory structure +``` + +## ./src Directory Layout + +```bash +├── /enums # TypeScript enums for various poker game-related entities +├── /events # TypeScript event structures for handling and managing poker events +├── /interfaces # TypeScript interfaces for poker game entities defining structures +├── /models # Core poker models and logic implementations for the game mechanics +└── index.ts # Main export for all modules in the src directory +``` + +## ./src/enums Directory Layout + +```bash +├── /casinoEventNames # Enum for different casino-related event names +│ └── index.ts # Main export for the casino event names enum +├── /pokerPhaseNames # Enum for the names of different poker phases +│ └── index.ts # Main export for the poker phase names enum +├── /pokerSeatEventNames # Enum for seat-related event names in poker +│ └── index.ts # Main export for the poker seat event names enum +├── /rank # Enum for the ranks of playing cards +│ └── index.ts # Main export for card rank types +├── /suit # Enum for the suits of playing cards +│ └── index.ts # Main export for card suit types +└── index.ts # Aggregated export for all enums in the project +``` + +## ./src/events Directory Layout + +```bash +├── /_baseEvent # Base event structure shared across all poker-related events +│ └── index.ts # Main export for the base event structure (_BaseEvent) +├── /pokerSeatEvents # Events specific to seat management in poker (e.g., seat occupancy) +│ ├── /pokerSeatEvent # Core event structure for seat-related events +│ │ └── index.ts # Export for the poker seat event interface +│ ├── /pokerSeatOccupiedEvent # Specific event structure for seat occupancy +│ │ └── index.ts # Export for the poker seat occupied event interface +│ ├── /pokerSeatVacatedEvent # Specific event structure for vacating a seat +│ │ └── index.ts # Export for the poker seat vacated event interface +│ └── index.ts # Aggregated export for all poker seat events +└── index.ts # Main export for all events in the project +``` + +## ./src/interfaces Directory Layout + +```bash +├── /card # Interface defining the structure of a poker card (e.g., rank, suit) +│ └── index.ts # Export for card-related interfaces +├── /casino # Interface defining the structure of a casino (e.g., rooms, tables) +│ └── index.ts # Export for casino-related interfaces +├── /deck # Interface defining the structure and behavior of a deck of cards +│ └── index.ts # Export for deck-related interfaces +├── /pokerGame # Interface defining the structure of a poker game (e.g., phases, players) +│ └── index.ts # Export for poker game-related interfaces +├── /pokerPhase # Interface defining poker phases and phase transitions during gameplay +│ └── index.ts # Export for poker phase-related interfaces +├── /pokerPlayer # Interface defining the structure and behavior of a poker player +│ └── index.ts # Export for poker player-related interfaces +├── /pokerRoom # Interface defining the structure of a poker room, including table and player management +│ └── index.ts # Export for poker room-related interfaces +├── /pokerSeat # Interface defining a seat at a poker table (e.g., player sitting, bet tracking) +│ └── index.ts # Export for poker seat-related interfaces +├── /pokerTable # Interface defining the structure and behavior of a poker table (e.g., seating, blinds) +│ └── index.ts # Export for poker table-related interfaces +└── index.ts # Main export for all interfaces in the project +``` + +## ./src/models Directory Layout + +```bash +├── /card # Class implementation for a poker card, handling rank and suit logic +│ └── index.ts # Class definition and export for card logic +├── /casino # Class implementation for a casino, handling multiple rooms and tables +│ └── index.ts # Class definition and export for casino logic +├── /deck # Class implementation for a deck of cards, including shuffle and draw logic +│ └── index.ts # Class definition and export for deck logic +├── /pokerGame # Class implementation for managing poker game phases, bets, and progression +│ └── index.ts # Class definition and export for poker game logic +├── /pokerPhase # Class implementation for handling transitions between poker phases +│ └── index.ts # Class definition and export for poker phase logic +├── /pokerPlayer # Class implementation for a poker player, handling actions, chips, and hands +│ └── index.ts # Class definition and export for poker player logic +├── /pokerRoom # Class implementation for managing poker rooms and player seating +│ └── index.ts # Class definition and export for poker room logic +├── /pokerSeat # Class implementation for poker seat behavior (e.g., seating, betting) +│ └── index.ts # Class definition and export for poker seat logic +├── /pokerTable # Class implementation for poker table behavior (e.g., player seating, blinds) +│ └── index.ts # Class definition and export for poker table logic +└── index.ts # Main export for all models in the project +``` + +## ./tests Directory Layout + +```bash +├── /enums # Unit tests for enums +├── /events # Unit tests for events +├── /interfaces # Unit tests for interfaces +├── /models # Unit tests for models +└── index.test.ts # Main test file exporting all test modules +``` + +## ./tests/enums Directory Layout + +```bash +├── /casinoEventNames # Enum for different casino-related event names +│ └── index.test.ts # Test for the casino event names enum +├── /pokerPhaseNames # Enum for the names of different poker phases +│ └── index.test.ts # Test for the poker phase names enum +├── /pokerSeatEventNames # Enum for seat-related event names in poker +│ └── index.test.ts # Test for the poker seat event names enum +├── /rank # Enum for the ranks of playing cards +│ └── index.test.ts # Test for card rank types +├── /suit # Enum for the suits of playing cards +│ └── index.test.ts # Test for card suit types +└── index.test.ts # Aggregated export for all enums in the project +``` + +## ./tests/events Directory Layout + +```bash +├── /_baseEvent # Base event structure shared across all poker-related events +│ └── index.test.ts # Test for the base event structure (_BaseEvent) +├── /pokerSeatEvents # Events specific to seat management in poker (e.g., seat occupancy) +│ ├── /pokerSeatEvent # Core event structure for seat-related events +│ │ └── index.test.ts # Test for the poker seat event interface +│ ├── /pokerSeatOccupiedEvent # Specific event structure for seat occupancy +│ │ └── index.test.ts # Test for the poker seat occupied event interface +│ ├── /pokerSeatVacatedEvent # Specific event structure for vacating a seat +│ │ └── index.test.ts # Test for the poker seat vacated event interface +│ └── index.test.ts # Aggregated export for all poker seat events +└── index.test.ts # Main export for all events in the project +``` + +## ./tests/interfaces Directory Layout + +```bash +├── /card # Interface defining the structure of a poker card (e.g., rank, suit) +│ └── index.test.ts # Test for card-related interfaces +├── /casino # Interface defining the structure of a casino (e.g., rooms, tables) +│ └── index.test.ts # Test for casino-related interfaces +├── /deck # Interface defining the structure and behavior of a deck of cards +│ └── index.test.ts # Test for deck-related interfaces +├── /pokerGame # Interface defining the structure of a poker game (e.g., phases, players) +│ └── index.test.ts # Test for poker game-related interfaces +├── /pokerPhase # Interface defining poker phases and phase transitions during gameplay +│ └── index.test.ts # Test for poker phase-related interfaces +├── /pokerPlayer # Interface defining the structure and behavior of a poker player +│ └── index.test.ts # Test for poker player-related interfaces +├── /pokerRoom # Interface defining the structure of a poker room, including table and player management +│ └── index.test.ts # Test for poker room-related interfaces +├── /pokerSeat # Interface defining a seat at a poker table (e.g., player sitting, bet tracking) +│ └── index.test.ts # Test for poker seat-related interfaces +├── /pokerTable # Interface defining the structure and behavior of a poker table (e.g., seating, blinds) +│ └── index.test.ts # Test for poker table-related interfaces +└── index.test.ts # Main export for all interfaces in the project +``` + +## ./tests/models Directory Layout + +```bash +├── /card # Class implementation for a poker card, handling rank and suit logic +│ └── index.test.ts # Test for card logic +├── /casino # Class implementation for a casino, handling multiple rooms and tables +│ └── index.test.ts # Test for casino logic +├── /deck # Class implementation for a deck of cards, including shuffle and draw logic +│ └── index.test.ts # Test for deck logic +├── /pokerGame # Class implementation for managing poker game phases, bets, and progression +│ └── index.test.ts # Test for poker game logic +├── /pokerPhase # Class implementation for handling transitions between poker phases +│ └── index.test.ts # Test for poker phase logic +├── /pokerPlayer # Class implementation for a poker player, handling actions, chips, and hands +│ └── index.test.ts # Test for poker player logic +├── /pokerRoom # Class implementation for managing poker rooms and player seating +│ └── index.test.ts # Test for poker room logic +├── /pokerSeat # Class implementation for poker seat behavior (e.g., seating, betting) +│ └── index.test.ts # Test for poker seat logic +├── /pokerTable # Class implementation for poker table behavior (e.g., player seating, blinds) +│ └── index.test.ts # Test for poker table logic +└── index.test.ts # Main export for all models in the project ``` diff --git a/docs/site/assets/highlight.css b/docs/site/assets/highlight.css index 2689f2d..bb25871 100644 --- a/docs/site/assets/highlight.css +++ b/docs/site/assets/highlight.css @@ -1,24 +1,26 @@ :root { - --light-hl-0: #0000FF; - --dark-hl-0: #569CD6; - --light-hl-1: #000000; - --dark-hl-1: #D4D4D4; - --light-hl-2: #0070C1; - --dark-hl-2: #4FC1FF; - --light-hl-3: #795E26; - --dark-hl-3: #DCDCAA; - --light-hl-4: #001080; - --dark-hl-4: #9CDCFE; - --light-hl-5: #008000; - --dark-hl-5: #6A9955; - --light-hl-6: #A31515; - --dark-hl-6: #CE9178; - --light-hl-7: #AF00DB; - --dark-hl-7: #C586C0; - --light-hl-8: #098658; - --dark-hl-8: #B5CEA8; - --light-hl-9: #267F99; - --dark-hl-9: #4EC9B0; + --light-hl-0: #008000; + --dark-hl-0: #6A9955; + --light-hl-1: #AF00DB; + --dark-hl-1: #C586C0; + --light-hl-2: #000000; + --dark-hl-2: #D4D4D4; + --light-hl-3: #001080; + --dark-hl-3: #9CDCFE; + --light-hl-4: #A31515; + --dark-hl-4: #CE9178; + --light-hl-5: #0000FF; + --dark-hl-5: #569CD6; + --light-hl-6: #0070C1; + --dark-hl-6: #4FC1FF; + --light-hl-7: #795E26; + --dark-hl-7: #DCDCAA; + --light-hl-8: #267F99; + --dark-hl-8: #4EC9B0; + --light-hl-9: #098658; + --dark-hl-9: #B5CEA8; + --light-hl-10: #000000FF; + --dark-hl-10: #D4D4D4; --light-code-background: #FFFFFF; --dark-code-background: #1E1E1E; } @@ -34,6 +36,7 @@ --hl-7: var(--light-hl-7); --hl-8: var(--light-hl-8); --hl-9: var(--light-hl-9); + --hl-10: var(--light-hl-10); --code-background: var(--light-code-background); } } @@ -48,6 +51,7 @@ --hl-7: var(--dark-hl-7); --hl-8: var(--dark-hl-8); --hl-9: var(--dark-hl-9); + --hl-10: var(--dark-hl-10); --code-background: var(--dark-code-background); } } @@ -62,6 +66,7 @@ --hl-7: var(--light-hl-7); --hl-8: var(--light-hl-8); --hl-9: var(--light-hl-9); + --hl-10: var(--light-hl-10); --code-background: var(--light-code-background); } @@ -76,6 +81,7 @@ --hl-7: var(--dark-hl-7); --hl-8: var(--dark-hl-8); --hl-9: var(--dark-hl-9); + --hl-10: var(--dark-hl-10); --code-background: var(--dark-code-background); } @@ -89,4 +95,5 @@ .hl-7 { color: var(--hl-7); } .hl-8 { color: var(--hl-8); } .hl-9 { color: var(--hl-9); } +.hl-10 { color: var(--hl-10); } pre, code { background: var(--code-background); } diff --git a/docs/site/assets/navigation.js b/docs/site/assets/navigation.js index 45792ba..18c5274 100644 --- a/docs/site/assets/navigation.js +++ b/docs/site/assets/navigation.js @@ -1 +1 @@ -window.navigationData = "data:application/octet-stream;base64,H4sIAAAAAAAACqWUwW6DMBBE/2V7RW2T0irl2l64JscIIct2BQo4FTZSpCr/Xtm4CYvBtujVzDwN410ff0Dxi4IMasH4BRL4JqqCDNoz6xsun8zxY6XaBhI41YJBtk2AVnXDOi4gO94AH6RjPv+DFQyQdPOevjyn1+Tm/+T05PVbwZI/DwbIAwnyYIQ8kGFPhB9gBUv+Q18rr98KsL8YEWqhePdFKJdznL9vURe6WCiirG91gllZLaas7BdDZku+Q2igllIL1jR8Rzg0o5wwX9/QzbNAzaUWxMXCNzYfy9CM0h+rC9xbqQVRsfAEcNG3LmfvwHYojQwMQKkFUWnwKDlpDOfgwHSacZ72zHgzs6rD+T/e3RFg3cM7BgRWc34hBkD8MuD/oA2RckJxd2Cz3UXsgGVEzz8uZJLEUNyxH5IU1+IXhaUGgFIHAAA=" \ No newline at end of file +window.navigationData = "data:application/octet-stream;base64,H4sIAAAAAAAACrWbW2/bOBCF/4v6mnY3abbo5rFtUBRIiyLZPhWFoNiMI8SWUlsOulj0vy90sczbzJyRmFf78JujIW16hvT3/7LG/Gqyi8xU+80uO8kei+Y+u8g29XK/Nrs/updf3TebdXaSPZTVMrs4O8kW9+V6uTVVdvF9BLwvdmVVXz6ZqmE5LzxhDz0//fv89Z/nv0+ivMtqv/nckWCyM4SKoaIruFf16so8mTXLs0QSB7UY11P0r/WD2X69L3bmS7HhwYEUY6K+uVFspBtTNMCSC7UgVeOfGEVFui6qBxY6CLjxqL9QS1Fv6v12wcNGCc9AvcXUJHlfNjysF3DjYV+BlqIabgHm/bupvkJt3LN8k5IBEn4onRjP99nkwkBPs+gen6fnvWjG/Ha0KNPWuwHe/v5h+Xw8PJtgddRBbsm5jBg+kr1RoW3b+JrfJ/PD+5DfcNO1jY6oqygzktDjfkTZ82R4ViObru3V57pjOONbelPJ2/cgi+7OZBvrENcBx/Ww47aQvH8X8uHvRbaTAXMToXlu6C0jb9/DnDgQx0eLuAk4/kIvq6X5FdroXoYcvCt2pvtEXW7KpjFbjvUiIqa+4nzpp6ox27siNn9MAHuUGEkZYhqb2hjYCOKG0A7RhtDRP9fL2Nehxzyo6B1/u2Qhg4Ab/76u7sqVSBllHAubcl8JEYFZiOs5ujwLtor/3SVgBgny2w0gJfstSJChn039AHTOfS1IhY1rZr7VI3Nv6yjaB7OIbMUWZhBw47Ec+kqICOQvrufocu5sFdmVibeiLMpBMb2vY8Pwlb0yldkWjflWlT/35hP/HRsRU9wxy/xjOzKKta5XK+H3wShh+k4So5e8PBUpwD7iCXke9pkItSAVWDDUCD6C/NlwdfreootK0luMILFPSvcU/GoeJWy9/zHamrQwtkokAYsx1IpUbElG5TgbmCJmkBhHXp6BVO4Bo+l2xTJXkfBAr6CjKSdGTe27R/Hp+u4kXnNqsC7+FTYIVwfQ4MXiqgGyZrkEAzR8OOXEMCAW+Dl1xSz3uq43MnBQiSR0Fh2tSFXMoC/H2ejsxQeJccCZs6ViJ1zGDSqRhM6bo518DBCjpuz/03zdMYZi3flynK15COW6a4eA686Wssx/ilvE7UEms9Cl54plrmLyAr2Cjk4fMUqOBE6go9WdOluouafOHmreqbMFS3HqHODmnDrbsJmnzh4Kc/WtKYUC66BwCe6xBNd3OLw36YCC/fA55Gc8TSDipD5SkMKkOlcI4+ja2vQXrUtO09cPmQmb+ww8RX/axydvUrMBoF6rwn/iBjEDB3th6EJM1xiMcZN2B9kAeBsGzUzqLhVBT92qksIoeieqTCVtMFH85F0mMZCmcaDLV9oeCxkhfaNFDoVX7KqUJWxoEPTUXQ0pDF5iqhKl6yBoE/UcZbgURlHLqTKVtOCl+MmrXjGQmK78ttix6LxTpKpLjtwwBDncC/7XG6ewuj0MY59iVOmeBH6EIz8cy/tfEBeIRnQrAO+8hnVH3G2HPMpDg2LtIXDhZ6eu7VhI5Z1fhVnr5i9oeEncNBmhrQAyS9QVcasd1RnB26QvJozIXoLe9o0UEnGnA9Yewq0uspwA6GAuHrmj7ZE8qqCMkDVE3PYR7g3kUsMVE3AYTY6637tykjoZnqVoAcH47/H+UDFRVCmhiKTKFXko68XodIpsResH7iH6AMFgOWFUKaEKpskZdfjpxmhVeL5ipQPzAB3cGyhmiqgh4DCaHFEHjS5f/78SRY7cv5aAOSLKBziMJkfkoZgboJPhWYqWDIz/Hu8PFRNFFQ+KSGyu7GxtiIth/euTftKzMO2fIYjDNp847Qa+TQGu4ANe5txDdznQRXTI0fTb0TYHuB4NuEHuG1O3XW3OFXZlFnCE3fJk7j7aMNXlR8Cc8o4f8YMjIGqugaEuZ99wCojoFSfU4cybPAEPvcqD+pt74yMA4lc+UIvQnQaiXdTDZrSKjsjFutjtfKQvd2Ocnr0FOioDUNVNIW2NjQ7JCbcd6HsbjB+rl8F7ircwBo6qfUG6GdsVvBOqSzFQ1B0K0o/TNuA9Md2CATaxU0Cai1TtgEWiWLeZUwp13qVfMSM+2X1rTpEsWA1KVcAst3lNrU55m26lCFjk9q+pxSFv0S3UAIvsFja9NuNd+kVSzKftdB+/0tW9DBmT/592ZGn+n0Z9KVo08T9loLfc18188Lt9tWjKuiLxfLw359Du0LMVm4MPeiq2ZbtEPFSM+PqsWzY//gfoycouvEsAAA==" \ No newline at end of file diff --git a/docs/site/assets/search.js b/docs/site/assets/search.js index d06e38b..4c0ae29 100644 --- a/docs/site/assets/search.js +++ b/docs/site/assets/search.js @@ -1 +1 @@ -window.searchData = "data:application/octet-stream;base64,H4sIAAAAAAAACq2a227jNhCG34W5FRxzSPp0V+y26HaBAt0UvRGChWsrGzU+pLKcXSDIuxekaGtGJKVx3KvsWpz/J0cfhyKlV1Htvx/EIn8VT+VuLRaQid1yW4iFKHfr4ofIxLHaiIXY7tfHTXG4db+OHuvtRmRitVkeDsVBLIR4y2IKdVE9LFfF4Xa1rNYRrdP1r/Z6v6qZnHU/fcBqyKUr6BpGZDPxvKyKXR3pY+sox6DPltVy93SZ440PYdk2cSnzw7GsLzT3Ie8zh7Genc3r/V1dlbtvF3YAhb2zEzGM1sXqqQ8je52P0UesFh+WE3QN2Ri5PiaSeXg8PjxsistMb9oolnkTmurCulp+v9Dfh7zTPHIfe27h5aWFTM0IE/Z6r2qbmy9Yqtgdt6HQl7haPCGua2hSt+z9+X3PNbpp2rLMXFTC8bEqCr6nb32t6y/7Y8U29Y2v9ixf+AP1ja/1vCt/sC2btlc7Fi/Fju/pW1/r+nP57bFmu55aX+v6e7nj31Hf+Or5ckF2//xfcvvbcsWuPje+8bWefxyLC8Z5an2t62f8PDFk+pn5FDHg+dOKj1DT9l2O0SWKPMBFlih7nblE3WGpYBxO6C6uFh+D61o0Yb8Wy6o+cL1uzs1Zli4w7vuxXG73uzXfGQVc6/1hc/ybb3xqfa3r3fNyXfBtz83f5dsCut2vi01ia9ZcG96WSWjRJLsy35oIDe/GcJdaEyPbTq/2u0NdHVf1vuJ53dCIQd9R306MPGv22/Zu/7h+pHD0+/Xu+Hr8+jd7/Z6Dm7w+3y6H0b2d9x3c12EOybauMwAnNLydw116N4fU6xIOz5HcfWS/89D+ketKto79lr1bxj6/DhUJIHpZ0HKu1bidRPS4KDzIujk1SNVTew7WI/8xfijRyvsG75P/Et/entW/9B8z9YvfxR9MzuJ3/cdI/eJDab8q60NJvyrnKWLIIcUgNufTjsvZ6RgNDIZhlKCI+gygxLBJ8ERtBqBi2ERvD6oM/Wj5ynIhW1i+936c5O8zz9niVbwU1aHc78RCwEiN5iITD2WxWduD98Y0E6v9dmsFMrHer47un/e+2V+FXTRs46b17Vhk+ThTk5GaTu7vs/wU7C64H04a7S8uUIosl7FAGQRKEggiyyGD6Wg+ViQQgkAggUpkucpAjdSMBqogUJFALbJcxwJ1EKhJoBFZbjIlRzCZkUATBBoSOBFZPoklZxIETkjgVGT5NJacaRA4JYEzkeWzWFdnQeCMBM5Fls9jgfMgcE4BsDzIKDsyhEd26HH4xPmJAEQJkpAiQYYMSQqRtGhIiBqHHEkKkrR4SBUNDlmSFCZpEZE6GhzyJClQ0mIiTTQ4ZEpSqKRFRUZ5lCFXkoIlLS5yGg0O2ZIULmmRkbNocMiXpICBA2weC4YQMKCAgUUGonRCCBh0SpSrUVE6IVKlKGFgmYEoYRASBpQwsMxAlDAICQNKGFhmIEoYhIQBJQwsMxAlDELCgBIG01SJhRAwoICBRQaidEIIGFDAwCIDUTohBAwoYMoiA1E6VQiYooApB1iUThUCpihgylWwKJ0qBEx11kG3EMrYKqEiSyEFTFlkFMQKvgoBUxQwZZJLcMiXonypSQoRFeKlKF5qmlqIVYiXongpC4yKzigV4qUoXsoCo3Q01SFeiuKlx8lU6xAvTfHSMrWg65AuTenSkFrTdQiXpnBpB1e0DOgQLt150NKpZzsdedSibGmTevTRIVuasqUnKS51yJambOlk6dIhW5qypWfJmahDtjRlS6fZ0iFbmrJlxqlMmxAtQ9EyMpVpE6JlKFom+ehlQrQMRcuoVKZNSJahZBmdzLQJ0TKdx3iTzLSJPMk3P7k910tR1cX6U7P3ynOxtG9zXsVXvxtrj1dfBRixeH17a3dfi9c3tAGz15yx2062Ekq2Eko1QXrW/DWaJ9m8O0DdmiHNMU8Dnyii3gFS0r53PMXmDBZJoVypuZfyfw0vd+vz2xk01im6BXOejDtQbCXmrcKpX8ASKpp30q2SRImXvM48uI8GkIRBEhOehPvWAUmgTEteZh/9GzeU1wnK64wlUnbZRvCAT6xnyPAYKrsQoZs99YrGK0qeYvMlYqs4bhWZfUKfHqGcIx15qdBtN3GoJnCH1fmurdVC95GHU/A9FOoX7tjFPWteKyE8EOrA69s/Szo4QB0C3qR9ci+ZkIRCEryCe3qfgIobGopWF4gEt14hkBRvROSlF1JCA1O8Gbxz37ug+41KI/Co/rf5rgPlF1cBXmq62OGBNCHS1xPlZ7+e+CrAy9ih+YQJDRQVFsnL1flNWKuCqr9fwTVvkhxKUpMkmrNyylPwL/JR3tG9U8xudCYoWkd83QZfdZXPt/b/N7wbW3fQQKwDr4t18zEhyhWCQ/Kmb70/+FfNrQyavx4pxUt8bb+oRN1BtEtGUu4z8Vw+Fxs78Rb5/dvbf/BDeKhGLwAA"; \ No newline at end of file +window.searchData = "data:application/octet-stream;base64,H4sIAAAAAAAACrWdX5Mbt9Huv8vqdiMRfzjD8Z0sKW90oth6JSepc1SuLWo5WjHmkhuSK8dx+bufAkCQQOPBTGNm9iZReQeNHsyDRgM/APz9ar/79XD13affr35Zb1dX38nrq+3yvr367qrdPt4fXrTf2u3x8OJ2eVhvd1fXV4/7zdV3V/e71eOmPbywz9y4Z27cM8+/Hu83V9dXt5vl4dAerr67uvrj2ltfnK2/sg+/sSXPZk9VAqPh46CG66uH5b7dHjNuXxwQ1dmDDz/++LebVx/evPzpzeshHjwjBtjuRKY6fHv5+vUYz3zxyf36+/vX49rsYmBy316/efdmlG8XA1P79vHm45ufBjvmS4/2Cnfwzp7d2aUzAeNh90u7/9guj90x4/wYM2y898/3R46LaVKoIH5c3gJ+1rc/vP3p7ct3b/9ft+K6PXkWWynxitrDXv746tXf378d5WJgYnr//vHyVV886XHvYmEi74iosYaLusVmd/eu/dZuMt3B/5nZDd5Ra2GbnW29yxtNGufsX0bof/6xoK5np+c5FZ5L4pr/+fLDDyU1n56foOY3Hz78+KGkal9gaN1UMlao778uD+0Py/s2F6LJUyVx9FwKviU1HBfhaIq+AGzm9x/e3Pz53Y/vh/rwLDBQ4AwxhX0b5dcT+fTT3zMdguPTqfDUPn14+483uKtwnPKlp/bq419+/OfrH/85vLUCA5P4Rjv4frn9JdOrzZ+YXflDaCV8RWvjAzaUvIT1BQvu1x3D/DP3WF8VtkCmnq/7FkciWtPpwRF1/Xn3uOdUdXpuTE3rb6yXOj03oqaP6/9wKnKPjanH5FGsmk4Pjqjrzfru65FTl39wRF0/rLesL3V6bozSee3309jW+z/LW05keHZ6bkRN//vY8t7JPziirr+ut3ecqk7Pjajp5S1LEO6x0nroYHDYPe6D+uLhwP2ROSB8jC2Fnp/sfMyZSzw/eQWb5+b7lx/fMKt55h/ur+xUDNf56uUHPFEEVZ6eHV3jx7c/4MkPrPP09MhaX7959VdunadnR9b4/se/vvlw8z8v/8b+pFGJSWp//5cCRcVFpqn/3cv/m0lk8w74MpN4YJb6yuo/lZik9o9vXuIVymztpxKT1P7Ty+/fFX59X2RI/UkAflznFivNn7jBN7QSvYOx8REbSn02VmBT/aVd7jPrnnENz85P9lVky2TC0Hp5v9uuWPUFz46o8dXm8TOrOv/giLo+PixXLauy85OltV1Ett6u2v8k+rL/lbmQuN4e2/2X5W17ePF5eWjtoiUw6B+6OT/UbX9+aZDvfYm33srZflA5rCIt2q1z+DLBV5pJfXnx1Vg3nlkTfE+AnZxz23D9bKh7JyNP4uDtvl0e29XL42gvQ0tP4upmeTj+bbdaf1lP4m9i7kmcPhyXx8fDaGfPZp7EyYf9erdfH38b7WZg6GlaM568DG5Nb+ZJnLxvj8vRLp6MTOVgNZ+rYG52c/ztYXwzGh+fn22NcvW5fd9Mg66WEzToychUDQoH3tvlftU15pq/s4fbV8v96tVu+2V91/Pu1urlafbIar3NNHm0+Myv9tmpHKvuoHC2v4f5coEbp3Ij3KBfgpvznC2WZzrke8iZvkwc7trjh4JPQrR/Kc1vESh64tLHgs+TuvSx9CP1unTcfTzuwwXAMp+C4pM69ePnfw32yJUd586A4N/p0HP7v38SBbEf2AtMTRGFGI4+L45O0Fv/2hPELI7TxbGM6XRmBIM7OSPfe/dxxrHTPM6PnsHmtCERlGzojDrioT1+2O3u+5LxDh+eBSaYzlA7Oefc7MkYH+FeZGRiB+/cq4/w7mLhaVwb82HvnuzDLlerke12sfA0ro1pt8DExM6t2k07ukNERiZ2cL/b3b/aPW77g33ev9DGxO6tD/9Ybtart9HCYrmHxMz0Pfdvy/+8Wx+O7bbdj+zAxNLF1eNh9af14U/r7dd2vz62q8GuoxFz1d6m23QCp83f2aPl6/b2F+5YaQ1HBdjjpPU5/0lMEtH3LTK1PwuKs9yIbWSH7q+PX75sBrbIs0vpCV1a7Ze/DvTnVHRCZ8r6Uce3G9uHul0G/aej65SDj83u7q7dd/VG9wS7P76zj7NWYU6WwxLs/njyOzOhaLfLz5v21W572G1aY79/hptz5lnGFtPDyGBnk3GDWGS3PJAlDRf1is2uqJ0oH9iVtwx71LC7Qv8nhENArOeH2Hp970uwJHuxT8qx2//yGkPhXLcPTDKXNZKdo98vN5vvN+YPo9yL7Ezv5uf13QROBlamd/Fhs/ytf8Tp8fBiZBIHYY/gRiRQQXlcQv1ixIDd69MUQ3dXJaxwZje198Yz+1RZQLNF+BHN1UBLln079y7DoX6fI2ym32Eoi8vCGclA9042nsK9gojR5WFpzCh0ctc3re93cMea1Q/6wMtNu3+/G92GoaGncPQyPE7gLDX2FA77oXICd2NTT+Hs7e7+/nG7Pv7Gma/3+ptYm8hlHM2LRmNax8DxmMb0sQNyt1uTDcnZaniDsg2T/aOyfaxwWLZlCsZlV0dStvAruhcaNd/o9KRkzpEzNDpz6HSwLHfodzHzZcv6aFLN0F5Kvy/tpm8HfuK0e74d86F71+Q+t7wUos9RZ+fJ3Dy0x7eHP+82q3aado3tPZnbQ+I1QxLTRGze62RjdgS9chHbPFQWrz9Y2MSN1tY+KVfWk+1rjIrTWR9KYjQyMjY+5x0ris0lrh1PC7df1ncsteddJJYmcRWKrWgAiSsYOHgQydFA98Ogz5sGuB+Gf2ROPP7JfKABHzl19GzpSVxlD8adbpYNxOUuTvLR7572o99N9tHvnvqjn6JH/76Hfl8jU0/ibMEmiH53S7dCDBRCaVrTJ4dJUhrGa2TTGXjPG32L3lvekhHGlOCnM/GVXkPSGXrRW3k6k/WhJJ1BRvKrmIf1cb3bjnMusDK9i+vDa7sIObL9LlaeoBXjJZRhbehtTOIe7AtF2VZcwcBsi/QImsYM/bBpGjPq406XxnS6WZbGlLv4fnBfTh19P65HM4bdib79yH7NateBvRu06pg+zmjTH29vHx/WvGWanlYNTD2Jsztjv+84ab+jZzNP4uS35e3yODpaPjubeSqFliaEfTqdJCFkvEY2IbQTlN6M0D5VlhL+dFnZ4DSUq4GWLBsD3buMSgs73ChJDLGZsStdXc4VrXWVuXdY/3e0eycbT+Je0f6xTifLd5D1uor7RVF+SOsYmCHS3jF0Qa7bneIluay50Slij6NlSeIQN000Zo0S/Z56U0/k7MHObJjrSL0CuNh6IndLl5J6PB60mDREEKXZQ78uJskfWK+CMgh71UNX8mAfKL/U6M39+njkQ29XS7Y0O0y615nk83Fc6vx+XS7m7cIPdr9btZvMhRjub/2XYQgZ/iBMYOj0dGToFbYWvFHo0qWSubg4fbvbHo77x9vjbs+r61lcordeW5J7xUN3zX1XOhTUGt3i0Ftr560N3FqTixq6q+29mIFfb3gXQ1+lXXcvdNTYed0Co07u9QrUheIbFcp96b5BocuhkksTBvjVeUlCmV8giME7Ec7e9d6HEAeyyFjyqsERVGY4I1ceFAc0WmNZUAtKs+9d6Heh956FkvrB1QqMRui/SqHEB3p7Qr8DfbclDKi95Av0XohQUj+9A6G/+r47DwbUXvL2vdcalNQPbjLo94Bxc0FRHwzXUxj9r2vppKTe9JKE/sr7L0Uo8QDO2/qdYM3PSvy4GRAGb2AcPE2zHva7Y3tLpllFHg0KjDeZyDiZV+XB4gZFi6n9KfpuMH5M5tGggHKTiShTedXer4/xpcP9PoVleMsIfR7R3A3eznFyqPdmjjBvex0aIm92vvSAlbGRyzcK87W4rpJc7VySffNHd9W9N31w641u0uius/PmDG599DKR7ir7Lg/h1trbP0i9g/sG9IT0i0yXYN64caooc9vG6XUYN22E/etdbIy0TXTJAquXdd8MYdbht4fjcnublUFa5bO4FKP6U+nhvR04UdDjc04kvR5fLcJqEOZVIoUevdl+K3PDFZik7ne7u8Pr9f798vi1zIe44HhfVutDx8Uv/S7lyo/3rPNGmn7Hii6hKfErvPCl342uC176aqWx0DINeJ/Lqf7zA+yI+D4xSV7pYvJ9h/H0pS6+Do5LuapLohOw0btNK5ubZB2Kik7oT1c+2OXM666LFYa1zC6bUnS2Ssf1BANbhN5KUNQsfTcRDPLpI7yAoMAvamBC374Hdw0UePY9436Bcr96s9SsS4Pz1R7vYKTFV82ELvZfM5PE2tgoem96FJ8fbundA0PiLay9OOJSK5zjy3xvug4rD/Hiy26T5b4dbpyKTecHPUfGd6Xv5NhAbzjjYdahkhGxwKdXj3tjwFnvC2tZ54CVSb3sHbmznrHH7pLv2DN6578hc/wuahnOCN7RPCVjeIFf/FE861v5OF7gH3ckz3pXOpZzfTP3Ow3w6FRsWj9e4duKyrxKjEzn43L1zSzsDEwCnpHi0/m1bw+7zbf2+/Y4pNHi0tN5dTMsPbih+QGDPpT5NTBhuEkyhsk9u6H7nQu8u+nb4TzEI16ujz0al+13eYjzfXyLVeRn/w1WacYfm4Wvn9zlUpD006uMBmX92IHyvD+xw92XX+JVkU5LPFofvjc7V4+3X9ue/p33jNiY0sP4gECJX91HAgZ7M/gLFs1XSjx69XX90DOE5V3yhSf26S/L7eCvdio7pUdrehFXiUvrvlu3hvo0suM9Ya/rTUIyLrFXKdie8Ab3jDtwdGfnH3wfb6aIo8jKlC3JzEoy3o3MSzq9hJkJvKst9LT3nrYkK+na2HMx+b7DeOb1yO1YQ7IRUHVxJhLbGJOFIG9KMhC2J+RypgJfei5jKvfGbb+Lj1Czv1RUdiqP+nMf5As/72F7MUgvJfkO25OBeum/vGuAejt2/uaFy9j/W+ADuDOM6wnjjrByfzh7grMelewMLvCJlUEgf0ZlD3zfBkr6BsfAif0bExRvclFxWh95eQ1ycFxOk/cO5jPwsrbQw96L2pJ8JjKJXjq+S4Sfz5D7p4bkM6Dq4nwmttGRRZBLkbj+9F+AVe5N/5iNPOGP2WwvkmutCnzpvcaq3KPk5iquO703VQ1rnf4FylzbdF9GNaRlkvun+G3Te99UuT/kiimuLz1XSpX7QW6R4vrRc2tUuR+88QW5Mm58yXsHxxd891PoYv+9T8kI0z/w0+sm+IMMvcJmyCgDay8eZ6iVMTNn7FHJ3LnAm4/pbUlFPn3svyNpiGf9YyD2iD8KFngyqo1o+Uk9+57+CGGRX9/3/fjg0PaK7jkqa6rOe42G+PP4sFoeW/ueQ3wixSfse31z/0yX487++TGAXvVU0v/7rnYa4hF7BQA7VbwGwPWLtQqAfRq1DlDi36hQlRh4Wl9HBC9S/An9NDUNGokuJSdUoP1CA6NrVHg6n3i5LXZpXHbb5SHNb/HNZCcP+28lC7NaetlW7r3x1Vys5JZePFaY13bUXJLYYjODddDlFRbCIJ8uA/9xvTm8uDNXqS2P7d+3638/tkFP9hqwj93QxzrVUOkg28mY//K4vTXrH9kKGDUGr595mex749dkniF2lWWOELvXYZwgVheDxNS35X5tl51jY1mbSTskB4i1aLSaXT6Lu3zASuTwZvt4/zfrfPIu7fbx/nDT2secELMFsTvWwAtnoMOd8xR8gEddZUc5Fb5qYctM3B7lrTDWAd53cFWXtXtHpe92d+/ab+2GWS9+fFjVl+2cJgtlOtBVaJgb5lZEZuXpo8Oq/Lh73N9y3xg9PLDaxzVXX+mjw6osiXnDg910UW5UeBsV10oD2thINiCEMcIIJ3ZMFDD4UWJUaOiLByODQH/PH9Xd+/r4YONv7N+p9bVZ3ziNUKcHsHn7YIf582XBnXVETw2r6G82he+q5PzEsAr+DjPfwL5/YJj53rAWfhJuNOurlJM0BPWWJA19VfOThsCB8qShz42+pCGonJs09FXZnzQElfKTht5qe5KGsFJm0tBXJTNpCGouTBpYImMlDVRkRUlDSTtw336qdy5409FhhBM7JgoY/CgxKjT0xYORQaC/54/q7n19fLBxs0R2HrP7exR+fHjVVq6F9WfKDO3Q+1VB/fjxMbGkqHJcYFj15iaEgsrx44OjzF3w6xOsdAUWGBF/zB01BR50lBkbBEu9yBQa44bdaFbsR6bUCEeiHyZmuoHLjBxxS53AZUY4Ef+gDtOLTKGR4Tn7qzpd8RkUmmqUKBsfRo0M5HcIMwPC+akJhiD24DPVsFMw4Ewz1LAHmZHDS/+3I89NMpYVjGLjx6/+V0wfnWrILBssJxgmmS8bPzvZ2Fw4Kk8xHnNfOH54ujSgNAEYP/Qz3zh6dKpsoyzPGJ9hMN81enSqpKYsnZkgkWG+bPzsZNlTYd40KlWxS9N9GYp/aHi+0FtN+NCYPIFRUfjY8Pygt6LwoTFDdW9F8WMjx8ve2pInRwdwXpXxsyOjKK/K8MmRoYxXYfjk2GjCqzF6dJp5V8l0a1RM6QsnIyNJfxAZFT/6QsfIqNEfMP4kxkcLVqCYIkYww8P4yMAKCuPjASsUTBAFeAFgcEW9u1CD6sCzwyrNbOAMqjo/8ZSMwe8bGAIaznsOJqENqSeFyIHhDo87xJ6UwQeWEzwCQd0owxAMR3gsInajDEgwnOBSidiNUjTBcKSAT8S+DIAUXHeYpAL4U4gr2A4xmQXyqBBccF3i0QvgUBnC4LrD4xjAnTKYwXWHSTSAP4VYo2QwYLCNzGhQADgGjU4DxqXxI1J2nSYdiHqXaUoHwbLhb9KBr3TIm3CwKxvmphjgmN+YCUfKx9XSEXWisZT52nxgMmggHzCETzV4lzQAD6IMyx2GZA2T5QtFjcADKwMTlkGpykRJSkkrsGDLoAxpQG40UVZU8v4sADMoJRuQjE2VhpU0AA/KDMsCh+R/4xMtvJTrTg5zIY17ehClCSvqxzSMivKcJq6qH9T0VpYnNWFV/aimt6IuVhNWxYE1vZX10JqwPiau4VXZxWuSSjnAhldtntgklfYjG16VeWaTVNkPbXhVdlCbpE4GtumttJfb0ADDAjesONMbYsZGF0ZgGRdTesPJ2EjCCCITxA9e6JgkanADxgSxghcmJogQvOAwRVxghoThVfHuEykkOe7KjmKSE1TVQ3JOFfx8fWI63/1+9a3dH8z9rN9dyefqeXN1ffVl3W5Wh6vvPrlqr69ud/f3rb2TZbW7fbT//Pn02D9ac4OMedg9/WJ2df1pdj2vn1eV/Pnn60++sP2D/Q/exuW/2ILi6vqTuNbV86quooIiKSiigvLq+pNENcqkoIwKqqvrTwoVVElBFRXUV9efNCqok4I6Kji/uv40RwXnScF5VLC6uv5UoYJVUrCKCtZX159qVLBOCtZRwcXV9acFKrhICi6igs3V9acGfccmKdjEAjB6EFA7IhWPIOqx8hGwMBBQrCBhdCGghkQqIhGrSBhtCHU9l8/ncx0XToUkYiUJow8BtSRSMYlYTcJoRMyvdfNcLJq4cCooEStKGJ0IqCmRikrEqhJGKwLqSqTCErGyhNGLgNoSqbhErC5hNCMaWDgVmIgVJo1m5Aw1mEwVJmOFSaMZCRUmU4VJEqNskMJRCoSpWGHSaEbCSCVThclYYdJoRkKFyVRhMlaYNJqRMGLJVGEyVpg0mpFQYTJVmIwVJo1mZH2t5fOmIZ8qVZiMFSaNZiRUmEwVJmOFSaMZCRUmU4XJWGHKaEbBGKZShalYYcpoRkGFqVRhKlaYMppRUGEqVZgiI6EdCvFYCAbDWGHKaEZBhalUYSpWmDKaUVBhKlWYihWmjGYUVJhKFaZihSmjGQVjmEoVpmKFKaMZBRWmUoWpWGHKaEZBhalUYSpWmDaa0VBhOlWYjhWmjWY0VJhOFaZjhWmjGS3R0K5ThelYYdpoRkOF6VRhmuRbNuHSsGaQcsUK00Yzeg4LpwrTscK00YyurrV+XtVx2VRgOhaYNpLRUGA6FZiOBaaNZDQUmE4FpmOBaSMZDQWmU4HpWGBzI5k5FNg8Fdg8FtjcSGYOBTZPBTaPBTY3kpnDEDZPBTaPBTY3kplDgc1Tgc1jgc2NZOYajTbzVGBzktTbrB6n9SCvjwU2N5qZwxA2TxU2jxU2N5qZQ4XNU4XNY4XNjWbmUGHzVGHzWGFzo5k5VNg8Vdg8VlhlNFNBhVWpwqpYYZXRTCVQDlelCqtihVVGM5VE37lKFVbFCquMZioFYkGVCqyKBVYZyVRwjKxSgVWxwCojmQoKrEoFVpGZo5064rkjmDzGAquMZCoosCoVWBULrFpkx4sqFVgVC6wykqmgOqtUYFUssNoKrEEaqVOB1bHAaiOZGqqzTgVWxwKrjWRqGP/qVGB1LLDaaKaW0O1UYXWssFpnE+Y6VVgdK6yeZ+NfnSqsjhVWG83UCrqdKqwm6xN2gUKj2XMNlihihdVGM/UcFk4VVscKq41m6goWThVWxwpbGM3UNSq8SBW2iBW2EFl5LlKFLWKFLWT2Oy9ShS1ihS1U9jsvUoUtYoUtjGZqvCaUKmwRK2xhNFPjd04VtogVtjCaWcxga6cKW8QKWxjNLAQsnCpsQVbB7DKYhIXBQlissIXRzAKuDC1ShS1ihTVGMwvYMZpUYU2ssMZoZgE7RpMqrIkV1hjNLGDHaFKFNbHCGqOZBewYTaqwJlZYYzSzWCB5NqnCmlhhjdHMorlWzXM5IzWnCmtihTVGMw0M+k2qsCZWWGM008CUpEkV1sQKa4xmGqiwJlVYQ9Za7WIrVFgDllvpeqsRTQMl5v4WFw/+26m8yLa4+xstT1ZdZ0Y6DVSp+xstTxZeZ0Y9DV7CnIGl1xlZe50ZATU1XD+dgdXXGVl+nRkNNQvsP1iAnZEV2JkVHYyJ7m+0PFmEndlV2BmMi+6P1ABZiJ3ZldgZXjWfgbXYGVmMndnV2BlMWdwfqQEiQbuKjxNygRb9k1V/u+w/w6vvcOGfaNAt/c/wCjxa/Ker/275f4ZVjAAAJQAOAcwq2IYIAlAKIPKBTyAOQEGAIwEzvJqPWACFAY4GzBb4DYAOKRCwa/xwZiUQEaBIwK7yw0UagZgAgQJCzjq+IOACgoABIZ0IMZQAbEAQOCDser/IoC/ABwQBBMKu+YsM/gKMQBBIIOy6v8ghMCBCAgqEXfsXAq6/CMAKBIEFwq7/C6GhiAAvEAQYCMsAMt0AIANBmIGwGEAIOM0WABsIwg2ERQFC4I4M0IEg7ECojmAI6IEg+EBYIoC7EeAHggAEoZwK8XgIGIIgEEEop8LFtZ49V4JAfMARBAEJQjkV4hERsARBYIKwfEBI3JEATxAEKAjLCDIiAkhBEKYgLCYQmBIKgBUE4QrCogIh8YgK0IIgbEFYXJATERAhwQvCEgMsIsAXBAEMwjIDgWGlAIxBEMggtGPxOA4AziAIaBCWHQg5h28AREhYg7D4QEg4/xEANwjCG4Sed3QDgBwEYQ7CcgRh5vhgMwzgDoKAB6GdCnFmCtiDIPBBaKfCBhsAKiQAQlimgGdyAiAIQRiEsFgh0w8BhRAEQwhLFgQGsQKQCEFQhLB0QSg4qROARgiCI4QlDJl+CICEIERCWMggMNAVAEoIQiWEBQ1CwXU5AcCEIGRCWNggMNgVAE4IQieEBQ5CZTaoABkSQiEsdBAKd0UAKQShFGLedHRFACoEIRXCwgeh4HqGALBCEFohKtHxFQCwEIRYiMoJEfdlAC0EoRaicvuTcF8G5EIQdCEqt0cJTzMBvRAEXwhLJISGS3ACEAxBEIaoOkZlADEEoRjCggmhcV8CIEMQkiEsnBA68xWBEAnNEFXHqAx4hiBAQ9T5URkQDUGQhrCUQmCCLgDVEARriFp2zLMB2RAEbQhLK4TGsQDQDUHwhqh1flgHgEMQwiHqrlEZQA5BKIew4EJoHIwA6BCEdIjaqRDHEgA7BKEdwgKMzKAKeIcgwENYhpHpRgB5CMI8hMUYAm9KEAB7CMI9xMLJEOf3AH0Iwj6ExRmZNwD0QxD8ISzREHhzgwAERBAEIhb5nSgCQBBBKIhYuC2b4lrVz2VD3wCokJAQYeEG5mUCsBBBYIiwfAMjMwFwiCA8RFjEgamZAEREECQiLOXA4EwAKCIIFRFNHu0KwEUEASPCsg6MzwRAI4KwEWFxByZoAtARQfCIaJwC8VAECIkgiERY6oG3MwkASQShJKLpUiAAJYKQEtHkYZwArEQQWCKaPI8TAJcIwktEk0dyAhATQZCJaPJUTgBoIgg1kbM8mJOAmkhCTeQsz+YkoCaSUBM5y+M5CaiJJNREzlQ+F5AAm0iCTaTFIBjxSYBNJMEm0mIQPIxJgE0kwSbSYhCBt3pJwE0k4SbScZM53hMNuIkk3EQ6boK3fEnATSThJtJxE7ztSwJuIgk3ke6sBN76JQE4kQScSAdO5gs0lEoATiQBJ9KBE7wFTAJwIgk4kZaDwFV7CbCJJNhEOmyC45gE2EQSbCItBsHgVQJsIgk2kZaCYHoqATWRhJpIC0Ewu5UAmkgCTaQ7RpH7gkCEBJtId5SigpFcAnAi6WkKB04qfCQCHaigJyocOMHTIokOVSSnKqwIKxwK4MEKIkIHTjIqQocr6OkKB07wzj6JDljQExYOnODdfRIdsqCnLBw4wTv8JDpoQU9aWBAi8C4/iQ5b0NMWFoRgDi7ReQt64MKBE8yxJTpzQcCJVE6I+MAHICeSkBOpnBBhWikBO5GEnUjHTjI6AuxEEnYiHTupcRsAdiIJO5GOndQwr5KAnUjCTqRjJzUOiICdSMJOpGUhosYRDcATSeCJdPAET24kgCeSwBPp4Ame3UgATySBJ1I1HTEV0BNJ6Im0OETUuDMCfiIJP5GOn9S4MwJ+Igk/kbpLiYCfSMJPpOMnGMJJAFAkASjSARS8UVACgCIJQJEOoGD+IQFAkQSgSAdQMp0JABRJAIp0AKXGyQ0AKJIAFOkASqY3AoAiCUCRFojkeiMgKJIQFDmfdfRGgFAkQSjSIZRMbwQIRRKEIh1CyfRGgFAkQSjSIhGxgKs1EjAUSRiKdAxlgRMUwFAkYSjSMZQFPrcJGIokDEU6hrLACQpgKJIwFOkYygLnF4ChSMJQpGMoi8wZTqBEwlCkYygLHNIAQ5GEoUjHUDJBFTAUSRiKdAxlgWMiYCiSMBTpGMoCblCSgKFIwlBk1ZUmAoYiCUORVX71WgKEIglCkQ6hLHBAAghFEoQiqyq//C0BQ5GEoUjHUDJBGTAUSRiKdAwF77GVgKFIwlBk5Y5+494MIIokEEVaKiIa3JsBRpEEo0iHURrcmwFGkQSjSIdRMmMrwCiSYBTpMEoDd0dIgFEkwSjSYZQGhwPAUSThKNJxlExvBhxFEo4iHUfB23Yl4CiScBTpOAretysBR5GEo8h60dGbAUiRBKRIC0YyvRmAFElAinQgBW8xkQCkSAJSpAMpTeaEOxAiASlyITvCASApkpAU6UhKJhwAkiIJSZELnd+jIgFKkQSlSIdSMuuYAKVIglLkospvcpGApUjCUqQ7WYIXMgFLkYSlyMWiozMDmCIJTJELFxHxqABoiiQ0RTbuQgwckwFOkQSnyKZrGRHwFEl4irR8ROIt6BIAFUmAirR8ROIt6BIAFUmAimy6FhIBUZGEqEhHVPAuFQmIiiRERTZdYzNAKpIgFdnU+V0qEjAVSZiKbBb5XSoSQBVJoIq0kCSzS0UCqiIJVVGzWX6XigJYRRGsomYiv0tFAa6iCFdRlpNkdqkoAFYUASvKgRXcFxQAK4qAFWVBiZzhazgAWVGErChLSuQMBhQF0IoiaEWd0ArsCwqgFUXQinJoBY6MCpAVRciKsqBEzvB9IICsKEJW1Kxjx5cCZEURsqKEC4n4UhFAVhQhK8qCEomPUyhAVhQhK8qRFbzRRAGyoghZUcKFRHw7CWArirAVdbqVCg6tCrAVRdiKcjdT4a0uCsAVReCKsrAED60KwBVF4IpyR1Lw0KoAXVGErijhhIgvaQF0RRG6oiwskfhMhwJ0RRG6otxlVfhMhwJ0RRG6ok4XVmWuBAJCJHRFObqSCWiArihCV5S7uAofClGArihCV5S7vAofClGArihCV5Ts2O2gAF1RhK4oR1dybQCUSOiKchdZ4WMlCtAVReiKcpdZ4WMlCuAVRfCKchdaCdwZAV5R9E4r5ZSI4wm61orea6U6OJ9CV1vRu60sLZF43qzQ9VbJ/VZWifjqNwWvuCJKdHgFBkR0yRW95cqyEngrokLXXNF7riwpkRLnJuiqK3rXlSUlUsLlZIWuu6L3XVlSIiVcTlboyit655UlJVLC5WSFrr0iaEVZUiIlXE5WAK0oglaUJSUSz7oVQCuKoBWlu1QI0IoiaEXpLhUCtKIIWlE6r0IAVhQBK0rnVQiwiiJYRTmsArfwKkBVFKEqykKS3NsDDRKooiwjwXv3FGAqijAV5a7FghfSKIBUFEEqyt2MBff+KUBUFCEq6nQoBeoPABVFgIqa58/LK8BTFOEpyvEUvOFDAZ6iCE9Rc90xkgCeoghPURaP5OIY4CmK8BQ1rzriGOApivAUNa874hjgKYrwFDVfdMQxwFMU4Slq3nTEMcBTFOEpqpp1xDHAUxThKaoSHXEM8BRFeIqqZEccAzxFEZ6iHE+BHRHQFEVoirJ0BMcxAFMUgSmqyt+bqwBLUYSlKItGcm+P7p0kGqzyd5sqQFIUISmq42ItBUCKIiBFWS6SiWOAoyjCUVTtBIjDAOAoinAUVbuRGK4WKcBRFOEoqnYCxKtFgKMowlFU7a7UxaEQcBRFOIpy120pHMkAR1GEoyiLRaTCkQxwFEU4irJYRCocyQBHUYSjKItFpMKRDHAURTiKslhEKhzJAEdRhKMoy0UkXjlVAKQoAlKU5SISL3wqAFIUASnKchGJ1y0VACmKgBTlQAo+0qIASFEEpCjLRfB9hgpwFEU4inK3csHlbwUwiiIYRbmLueDKrwIURRGKotyBlMz7AxUSiKIW+cuTFIAoikAUZZkIhoEKMBRFGIqySARfwqMAQlEEoajG3R6CPwBAKIogFOUQCr7/RQGEoghCUY07mwd3NyiAUBRBKMqdScmssgCEoghCUQ6hZJYoAEJRBKEoh1Dw1RMKIBRFEIpyCAVfm6AAQlEEoSiHUPC1AwogFEUQijohFCxkgFAUQSjqhFBwWgIQiiIIRTuEgg+paoBQNEEo+oRQoAcaIBRNEIq2RERiiKMBQtEEoWhLRCSGOBogFE0QinYIBUMcDRCKJghFO4Si4bCsAULRBKFoS0SkhsOyBghFE4SiLRKRGg7LGjAUTRiKdgxFw2FZA4aiCUPRFolIDCA0YCiaMBTtGApe/teAoWjCULRjKBoOyxowFE0YihYyv3CsAUPRhKFodzoFXzkOEIomCEWL/DE9DQiKJgRFWyCCLx4H/EQTfqJPv+4BV1w1ACiaABTtAAreEa8BQNEEoOjTr3zAUUkDgKIJQNGnX/qAY4IGAEUTgKJPv/YBxwQNAIomAEU7gIJxqgYARROAot2vfuBxUQOAoglA0e54SuYzAoCiCUDRDqDgqZoGAEUTgKLdL4DgqZoGAEUTgKLdr4DgqZoGAEUTgKIdQMFTNQ0AiiYARTuAgqdqGgAUTQCKdgAFT9U0ACiaABTtAAqeqmkAUDQBKFqJ/FRNA4CiCUDRDqDgqZoGAEUTgKIdQMFTNQ0AiiYARSudn6ppgFA0QShazfNTNQ0giiYQRbvzKXiqpgFE0QSiaMtE8FRNA4aiCUPRFongqZoGCEUThKItEcFTNQ0Iiqa/HGKBCJ6qafTbIfTHQywPwVM1jX4+hP5+iMUhmYCOfkGE/oSIpSF4qqbRj4gkvyKi81M1DX9IhEjQHUzBUzWNfkyE/pqIIyh4qqbRL4rQnxRxB1MyeQ36VRH6syLuYEpmSEK/LEJ/WsQdTMFTNY1+XYRQFO0OpuCpmgYYRROMoh1GwVM1DTiKJhxFd93tpQFI0QSkaAdS8FRNA5CiCUjR7mBKZqoGQIomIEW7gymZqRoAKZqAFO1ASmaqBkCKJiBFO5CSmaoBkKIJSNEOpGSmagCkaAJStAMpmakaACmagBTtQEpmqgZAiiYgRTuQkpmqAZCiCUjRDqRkpmoApGgCUnSlOqZqAKVoglJ0pTumagCmaAJTdDXvmKoBmqIJTdGOpmRCGsApmuAUbfFIZqoGcIomOEU7nIKnagCnaIJTdJW9flgDmqIJTdHuVEomxwc0RROaouuOw8sa0BRNaIquO45HaUBTNKEp+nQqBY8JgKZoQlO0oymZkRnQFE1oiq47dr5qQFM0oSna0ZTMuAhoiiY0RbtTKbnPCGR4+m/2p3i/tftju3rrfpL306erm5tDe1yvrq5/v7o5/VCv2QloqzK/2Wv2+n33+x9/XH6a97vf/wh+ndf8zdTm7Bw+t8f75fH2axtZNKeAzhbNOR+2RVsotLSoAkvzhm/p0C6Ph/g1Zfiagmnq+NtD5FHVXKzUM1dsIdz/mzuhWFaXq9Xe/u518KbzsM1miyJDh9hS2GYzZpt9Xh6i99TqYkQrpo32GH88HX68mmfkdt8uj23aPKGtWZGto/s97kAKs1lgjPvRVu2mRY7VgS3BtPVlt4l7zCL8+nPm1z+0x8/ru88b84vekdKD1zO7f7nGkt7XhI1eK1fUHBay/zBbm7mmgUpV+EErtqXD/XKzSd951oTvzG9AK47YsyYwZQ42cUwtb+PeE3wBzdMEiAlh/2lOscbc+lVgLnqzUGSN8PZ4kXC5+rbc3rYPX0mcMGfYA+XOWcZMsGm/tdtje78+Hs2vyofq1WGc1s6EWUZ3/6h4UqFVrLfHdv+FfCazZnOuS/gwbki6q0sV1gUrqYLhtTpXoXwVvD6UVnG/Wz2SsCYXQcvVp6rMuim3hk7jdWh85o3zBndj/H63ajeRSdWEvcQ3+pzZ6GSwEeGnVCfZSO2DVi15VkE8NT/icjEtygw97OLgEmYhgtl6t8t95JAO/NGnNzUXgp56ipdWxZOWsX67235Z34V11IGfPvKrcx2KF2CNadgn6iD415W3PvfWeTE3so4UGw4JtZeX5MnLGE8VG8d139DM1OZ2eVhvd9GHDAKynvsk8vwh/T8qbmsb+zZKxJoLFHdqat8/lJeP2QlZWke7fbwHzR52RHNc4lSR/0fFG29cRVg8QQVeM2b3j2ss5nBL7IP3UGEW5buAYUB880BAIhSQ/8DMhO928/g5+rJh7skV4e7+/nG7Pv5mBE5CkwpDE2/UuN1tD8f94+1xt4+zu1B0i7O0T/+QXtrm1jv3Dy8U6YUiq3PoPuWb0vcMNfMhg+ulnQesltGIUQVRtGIGYjg3WQTvuqj9qzI/B56hmBsYghyU12VWy+My6ieBgGumiXa5ibO7cKY058UIY6RDZmFzmXuRuCbbfTKWzkLB8sblVXv7SxSCg8myPslKuDmT0anv9sKPTRVvbDLVwODVBG/f1D541T54cT9TYB2FrnBFp/ZRRvKijDEOApcMA5dvDeaKDJ46h2s7je/1M+ZnXC/vd9tYWeG6BzOJXK0PpuuZKLbbtJvd3d16G6VB5vbKi1qZwX+1X/4affMwf5z5iZzgudiu775GcUuF8yNe9zFzIDtmxzE6jDHCzweFj7bKd4LKe1z78O0nj8qnQEr64Z2ZXrXb7nYP45/wcpNMBZvEJI4U4cjmXZ7z+po19iLNqgJd8FQRGnqR5oJBLONlMJG9h90v7d6seUYdLBiXCkxudneb9lvc/8NJuWCKzhqzjtlVA1OcLLQENnmBxNncL7dRDJfhgidXf8bQYfe4Jws3YX5WIpDD4zpq+3B5izlutvs9yaLCTsD8gl2ZuQyHBeVzKOaazZf1t8haNMbwWurLZvcQOxTGVp4JunBah0FM85T5ZfcYtXOU6fM63127bffLY/u4Xf/7saVAJdCjkgs//PoZaM2T6F1mdXcWLsQIXssHtmgSVYcrz8oH/znvc9y1xyTBa4Kv2nh7gicyY+/r+oGEiTAHZc6FjaGOQT1c12YuwhiLj/t9uz0+bJa/pcloOCs1t7YybeLMNlwfkb6nmotU2VbjLNdcGBsYPK+OsRuz3X6LWzBUDXMWdtcevy7J0lqYDktmbn1HCaaIAqU6DfDivKIyP2Uy4pzAVL5J/VKvufnqlNLwndgejmZNPG6Y8Msxg9pde9zs7g6r9f5hefwamwuHNubYdmeg7H8268PRBKmYAAQi9ZNxMfP40k9yhPSzWC89MT/lgMK3nPkNJ/ePBfslE74UrikLP/uS+vyVav+VeAPoXXvqm3HuF4qjOn9v9md2Jkn/DEOSF5zU7O/zsDusj+vdNnY0bI1z0s1cSLBG4/w+XMI1d6qfnGS/OE2z6iBq1l4hC/Y7J9O/wD2PFEXDjkgp3Qp63sKLk/+Zkw0DIlwaEOdVaub6/12eVIbZARMYR9aSwSIczZTvM8zpjbFMUtcwI/Brb2LBliEgqiGYEvrcq3kD79d2uY+/TLhVgpm9xgNGFUjPRwQhfIhT5394Fc39kMIcoVw1ocdB3GWumay3X3bxUBBGB6aJ9XG93Kz/S7bnhMtmPP2dF5viTG8eGvIrAMzU8WLyRbL5xPwUYDDzKfXxxZmWRh89eO2q2CRlcGFCxWSLkTU6/Q/nMcyOEdij+V6YMjdcsZytmZQ5HkSbUHwz3mgcGLSLAHd09J+FjIC544kaTfcjhNMjwe4oxGqaRYhQ68x1KGo22TsUTsgFcycANUoXfUQ4mxXMUYAaTYFEuP4rmGQ5vz8wTJKZaGJ9cFOl+F3Dhb25T1/9LgvJzCbWB7OsQH0Ms6eaGS8Ou9vbx4c1MRXucxAeaynmRp714dtys14lQ8oiCBgejAl9nun4ifd57dQzBsXsE/9axiFFRfs/WCZ+IfPusB2YjH+zPBzvd6v1l3WC74IOWfGSgM0uXgaYRQOhT0sk07MkSIoqWs86s3a/EUd4RO2hpz5vo6l5DerqTDdrNGHM81RZ+aRaa9745KxjahUq+ExffZatmRtESQUIXIV7dP1sXRd9EYCuwq2s3nnNTAHgYng4FvgNCH76qvhitIazi7VhU/isXjG51n0bo+AqCBbMHNa2Y5zGhxmU9IxUMVe3nb0015MhnFGyyBhNyswPMAd5Y6EtmpKZH9MNAEWRtWQBLpwBSOYc8mQLRZpw2Yy5Zf9kDedioUAkcw08NJjmYXW4csXclBNZTHOwRchimfuIQpNJ/hWmtZK5LB8apLmXDFNa2RR9ZZx3mUvbAzbBmxjQdbZwTdKnH8JzXuHHJ6H9vJeZ7WzX25gIBWFR8YIgTJfCpJj3ka2Z3+J8NYwE1XnjEM8eWkUMASgzCqOVw1k4dngWLZhd2GrkhnZeHXQLJnhwhpJOG067mWzgZClpsHBnNXPJ0ZminTQM6UwA4gzRzhluSWNOi5yhpFOG4wJztSMTdcNB4ZIn+t1AzJnR2XaaGJoz6UHi5odsf5hAM4HpuQa8iz5c0RR+a5/ym0S05sWCtBKUIIbh0K/JauaAda4B5Ijhlmo/FdDMMSY3AobDFXMzwcUU+pjhqphXifJbpzQTP1yqwF8z2uohfVbb+DlLSYSJa0GfM9zL5JmCZm4niLeWxKNm0PInrSu/7qyYJ0jIzpVcmh4K0uNzxdyMm010wmzML1BrP2Jr5npjYB2IKVpPlufI4DcLloR/V0dGTeHU9Lwb3LNHXTI0kGqQnMIMxC+BaFXcXCA+hDv1Z95yVWA5TT7D8HDWvp9W6Zo33zjbBp84nEKKszY96dYlo6mpAX9gGe0MO39g/z4lI21UCfq8ITnz/FmrwoYCHzfcA+wHSc08EZGZCIRLQefYKc/rPQXjrrENPm64/0rMz+3upVmSl5ga0g2O4VaBk3V1Xuzw/2BunCfV5GJpuA/LU3Xlj3Cpkt5m6sJ6VdHizXkQ9V+duZqRVoL0Gi6ZLvy3Z+7ZPdcA9Bom/B5b6pJPAeaZ4Uh83t/tFzF1XZDDHU9be6liw3U4UXmh+v3QmnkU4FJF5khn+H3Px3b8HhfN5MWgFvSBwwOX/vioZs59L1WALxxOxPzWbM1cWcSbS8KxgN3UMVkKz1gL5g0KD/v2Jtn3Ga6ScM2sd/v1MZrjh1vzmUTq349tG7VL/AVZNpLdx9E47gr5Mxd+e5k475jXfhhmemxqy8bLsM+q83os8zXaw27zrf3ckl0v4TYayVzo2K+/kUPc4ZYUntjM0Gzus4gXg8Lsmm/mdN4r8ihwiG/IHVyJDIV7T/iGHh9W1KNwxsk2dLt7jHc1hGuiPs+QzHVCu4XKXIIQ9aqgU7GsuPyEuCXCMUrUZ/bIa7KD3xcbh7BwxjI/Hwpkm8zi6HBXpGQGWWsPYOMwhxHMkQBdvSHDYcynQMLHFelXNKVPgxXzThR0F0d4yM+foxXMbSMdN3KEkzHm9g58IUd4vkP4E8uSuS3oYFLOKKREM3aeja+7X1e7XyMzMrqxhWnm8cuXOIaHOyF8DiqZ96oc1tGGgIid8mLcYf1fkjyFkzl/g4T0p7zk+bQ18wgQVoYImYbw2Y1grmrk90FG4IAJEsEJoPCg42n49smq8vsrFPMYgjOfHb/DHuLpi2LuDzw8LFdxPwnP8zGTgMNxeXyMjIQbzpkLZcnRp0BE81Nv9Szf33simvN2Qf/eTC5tass2aLhAoH3KxST9wbSFhJ9Qrsx13JMxOiqGV1IInwpK5h7qI4lj4csyLXzdt3GLhSMfr/2Pu93nf0U7F4OR3k9yBfPapOPucNyTXUIhOL4cMuDp+fi4j4N0dI6GZ+LXaBOAjA7isyy4XM+GqPgGunD9XgmeO4/HdbwLQ4Yrquq8cMuc0llzL7pPr4VRiXni2ZlNNyrI8GSOYmKab8vb5ZGMS2For/woxDwr7uyRNC0cKlhWfl3G0ooWthmt9PP11cP6od0YaP7dp5//+OP/AwQrPUpfwQEA"; \ No newline at end of file diff --git a/docs/site/classes/models__base.BaseEventEmitter.html b/docs/site/classes/models__base.BaseEventEmitter.html new file mode 100644 index 0000000..4f41fe7 --- /dev/null +++ b/docs/site/classes/models__base.BaseEventEmitter.html @@ -0,0 +1,331 @@ +BaseEventEmitter | casinojs

BaseEventEmitter +Represents a base event emitter for handling poker-related events, particularly in managing multiple +poker rooms (PokerRooms). This class is responsible for creating, listing, removing, and searching rooms, +emitting specific events related to these actions.

+

Acts as a central hub for organizing poker games, enabling the creation and management of poker rooms. Each room +can accommodate players and maintain its own game state. The BaseEventEmitter also supports middleware-based event processing, +allowing for validation and transformation of events.

+

Extends the Node.js EventEmitter to emit events when specific actions occur, such as creating or removing a room.

+

Implements the BaseEventEmitterInterface, ensuring a consistent interface structure and predictable behavior +for all event emitters within the library.

+
    +
  • casino:roomCreated: Emitted when a new room is created, signaling listeners to respond to this action.
  • +
  • casino:roomRemoved: Emitted when a room is removed, signaling listeners to update or respond accordingly.
  • +
+

This class can be instantiated to manage rooms, emit events for room-related actions, and handle middleware-based +processing for emitted events. It’s designed for easy integration into poker or casino game management.

+
const casino = new BaseEventEmitter();
casino.on('casino:roomCreated', (room) => console.log(`Room created: ${room.name}`));
const room = casino.createRoom({ name: "Room1", tableSize: 6, smallBlind: 10, bigBlind: 20 });
console.log(room); // Logs details of "Room1" +
+ +

Hierarchy (view full)

Implements

Constructors

Properties

captureRejections: boolean

Value: boolean

+

Change the default captureRejections option on all new EventEmitter objects.

+

v13.4.0, v12.16.0

+
captureRejectionSymbol: typeof captureRejectionSymbol

Value: Symbol.for('nodejs.rejection')

+

See how to write a custom rejection handler.

+

v13.4.0, v12.16.0

+
defaultMaxListeners: number

By default, a maximum of 10 listeners can be registered for any single +event. This limit can be changed for individual EventEmitter instances +using the emitter.setMaxListeners(n) method. To change the default +for allEventEmitter instances, the events.defaultMaxListeners property +can be used. If this value is not a positive number, a RangeError is thrown.

+

Take caution when setting the events.defaultMaxListeners because the +change affects all EventEmitter instances, including those created before +the change is made. However, calling emitter.setMaxListeners(n) still has +precedence over events.defaultMaxListeners.

+

This is not a hard limit. The EventEmitter instance will allow +more listeners to be added but will output a trace warning to stderr indicating +that a "possible EventEmitter memory leak" has been detected. For any single +EventEmitter, the emitter.getMaxListeners() and emitter.setMaxListeners() methods can be used to +temporarily avoid this warning:

+
import { EventEmitter } from 'node:events';
const emitter = new EventEmitter();
emitter.setMaxListeners(emitter.getMaxListeners() + 1);
emitter.once('event', () => {
// do stuff
emitter.setMaxListeners(Math.max(emitter.getMaxListeners() - 1, 0));
}); +
+ +

The --trace-warnings command-line flag can be used to display the +stack trace for such warnings.

+

The emitted warning can be inspected with process.on('warning') and will +have the additional emitter, type, and count properties, referring to +the event emitter instance, the event's name and the number of attached +listeners, respectively. +Its name property is set to 'MaxListenersExceededWarning'.

+

v0.11.2

+
errorMonitor: typeof errorMonitor

This symbol shall be used to install a listener for only monitoring 'error' events. Listeners installed using this symbol are called before the regular 'error' listeners are called.

+

Installing a listener using this symbol does not change the behavior once an 'error' event is emitted. Therefore, the process will still crash if no +regular 'error' listener is installed.

+

v13.6.0, v12.17.0

+

Methods

  • Type Parameters

    • K

    Parameters

    • error: Error
    • event: string | symbol
    • Rest...args: AnyRest

    Returns void

  • Alias for emitter.on(eventName, listener).

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.26

    +
  • Synchronously calls each of the listeners registered for the event named eventName, in the order they were registered, passing the supplied arguments +to each.

    +

    Returns true if the event had listeners, false otherwise.

    +
    import { EventEmitter } from 'node:events';
    const myEmitter = new EventEmitter();

    // First listener
    myEmitter.on('event', function firstListener() {
    console.log('Helloooo! first listener');
    });
    // Second listener
    myEmitter.on('event', function secondListener(arg1, arg2) {
    console.log(`event with parameters ${arg1}, ${arg2} in second listener`);
    });
    // Third listener
    myEmitter.on('event', function thirdListener(...args) {
    const parameters = args.join(', ');
    console.log(`event with parameters ${parameters} in third listener`);
    });

    console.log(myEmitter.listeners('event'));

    myEmitter.emit('event', 1, 2, 3, 4, 5);

    // Prints:
    // [
    // [Function: firstListener],
    // [Function: secondListener],
    // [Function: thirdListener]
    // ]
    // Helloooo! first listener
    // event with parameters 1, 2 in second listener
    // event with parameters 1, 2, 3, 4, 5 in third listener +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • Rest...args: AnyRest

    Returns boolean

    v0.1.26

    +
  • The emitEvent method is a public method for emitting events, with an optional configuration that allows +middleware processing. Middleware functions can intercept and transform the event before it reaches the listeners, +allowing custom validation or data modifications.

    +

    This method enables flexible event emission with support for middleware, providing a robust event processing +mechanism in the BaseEventEmitter. It’s useful for customizing event behavior based on application-specific needs.

    +

    N/A

    +

    N/A

    +

    This method can emit any event specified by eventName, which can then be processed by middleware functions if defined.

    +
      +
    • eventName: string - The name of the event to emit.
    • +
    • options: { event: { data: { [key: string]: any }; [key: string]: any; }, middlewares?: Array<(event: BaseEventInterface, next: () => void) => void | false> } +
        +
      • event - The primary event data to emit, containing specific details.
      • +
      • middlewares - An optional array of middleware functions that process the event before emission.
      • +
      +
    • +
    +
      +
    • eventName must be a valid string.
    • +
    • options.event should include relevant data for the event. If middlewares are provided, they should be functions with an event and next parameter.
    • +
    +
      +
    • void - This method does not return a value.
    • +
    +

    Use this method to emit events with middleware-based customization, which allows for specific processing +logic or transformations before the event reaches listeners.

    +

    Parameters

    • eventName: string

      The name of the event to emit.

      +
    • options: {
          event: {
              data: {
                  [key: string]: any;
              };
              [key: string]: any;
          };
          middlewares?: ((event: BaseEventInterface<any>, next: (() => void)) => false | void)[];
      }

      Configuration for the event and optional middleware functions.

      +
      • event: {
            data: {
                [key: string]: any;
            };
            [key: string]: any;
        }
        • [key: string]: any
        • data: {
              [key: string]: any;
          }
          • [key: string]: any
      • Optionalmiddlewares?: ((event: BaseEventInterface<any>, next: (() => void)) => false | void)[]

    Returns void

    emitter.emitEvent("game:started", {
    event: { data: { gameId: "001", status: "active" } },
    middlewares: [
    (event, next) => { console.log("Processing event:", event); next(); },
    (event, next) => { event.data.processed = true; next(); }
    ]
    }); +
    + +
  • Returns an array listing the events for which the emitter has registered +listeners. The values in the array are strings or Symbols.

    +
    import { EventEmitter } from 'node:events';

    const myEE = new EventEmitter();
    myEE.on('foo', () => {});
    myEE.on('bar', () => {});

    const sym = Symbol('symbol');
    myEE.on(sym, () => {});

    console.log(myEE.eventNames());
    // Prints: [ 'foo', 'bar', Symbol(symbol) ] +
    + +

    Returns (string | symbol)[]

    v6.0.0

    +
  • Returns the current max listener value for the EventEmitter which is either +set by emitter.setMaxListeners(n) or defaults to defaultMaxListeners.

    +

    Returns number

    v1.0.0

    +
  • Returns the number of listeners listening for the event named eventName. +If listener is provided, it will return how many times the listener is found +in the list of the listeners of the event.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event being listened for

      +
    • Optionallistener: Function

      The event handler function

      +

    Returns number

    v3.2.0

    +
  • Returns a copy of the array of listeners for the event named eventName.

    +
    server.on('connection', (stream) => {
    console.log('someone connected!');
    });
    console.log(util.inspect(server.listeners('connection')));
    // Prints: [ [Function] ] +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

    Returns Function[]

    v0.1.26

    +
  • Alias for emitter.removeListener().

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v10.0.0

    +
  • Adds the listener function to the end of the listeners array for the event +named eventName. No checks are made to see if the listener has already +been added. Multiple calls passing the same combination of eventName and +listener will result in the listener being added, and called, multiple times.

    +
    server.on('connection', (stream) => {
    console.log('someone connected!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    By default, event listeners are invoked in the order they are added. The emitter.prependListener() method can be used as an alternative to add the +event listener to the beginning of the listeners array.

    +
    import { EventEmitter } from 'node:events';
    const myEE = new EventEmitter();
    myEE.on('foo', () => console.log('a'));
    myEE.prependListener('foo', () => console.log('b'));
    myEE.emit('foo');
    // Prints:
    // b
    // a +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.101

    +
  • Adds a one-time listener function for the event named eventName. The +next time eventName is triggered, this listener is removed and then invoked.

    +
    server.once('connection', (stream) => {
    console.log('Ah, we have our first user!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    By default, event listeners are invoked in the order they are added. The emitter.prependOnceListener() method can be used as an alternative to add the +event listener to the beginning of the listeners array.

    +
    import { EventEmitter } from 'node:events';
    const myEE = new EventEmitter();
    myEE.once('foo', () => console.log('a'));
    myEE.prependOnceListener('foo', () => console.log('b'));
    myEE.emit('foo');
    // Prints:
    // b
    // a +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.3.0

    +
  • Adds the listener function to the beginning of the listeners array for the +event named eventName. No checks are made to see if the listener has +already been added. Multiple calls passing the same combination of eventName +and listener will result in the listener being added, and called, multiple times.

    +
    server.prependListener('connection', (stream) => {
    console.log('someone connected!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v6.0.0

    +
  • Adds a one-timelistener function for the event named eventName to the beginning of the listeners array. The next time eventName is triggered, this +listener is removed, and then invoked.

    +
    server.prependOnceListener('connection', (stream) => {
    console.log('Ah, we have our first user!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v6.0.0

    +
  • Returns a copy of the array of listeners for the event named eventName, +including any wrappers (such as those created by .once()).

    +
    import { EventEmitter } from 'node:events';
    const emitter = new EventEmitter();
    emitter.once('log', () => console.log('log once'));

    // Returns a new Array with a function `onceWrapper` which has a property
    // `listener` which contains the original listener bound above
    const listeners = emitter.rawListeners('log');
    const logFnWrapper = listeners[0];

    // Logs "log once" to the console and does not unbind the `once` event
    logFnWrapper.listener();

    // Logs "log once" to the console and removes the listener
    logFnWrapper();

    emitter.on('log', () => console.log('log persistently'));
    // Will return a new Array with a single function bound by `.on()` above
    const newListeners = emitter.rawListeners('log');

    // Logs "log persistently" twice
    newListeners[0]();
    emitter.emit('log'); +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

    Returns Function[]

    v9.4.0

    +
  • Removes all listeners, or those of the specified eventName.

    +

    It is bad practice to remove listeners added elsewhere in the code, +particularly when the EventEmitter instance was created by some other +component or module (e.g. sockets or file streams).

    +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Parameters

    • OptionaleventName: string | symbol

    Returns this

    v0.1.26

    +
  • Removes the specified listener from the listener array for the event named eventName.

    +
    const callback = (stream) => {
    console.log('someone connected!');
    };
    server.on('connection', callback);
    // ...
    server.removeListener('connection', callback); +
    + +

    removeListener() will remove, at most, one instance of a listener from the +listener array. If any single listener has been added multiple times to the +listener array for the specified eventName, then removeListener() must be +called multiple times to remove each instance.

    +

    Once an event is emitted, all listeners attached to it at the +time of emitting are called in order. This implies that any removeListener() or removeAllListeners() calls after emitting and before the last listener finishes execution +will not remove them fromemit() in progress. Subsequent events behave as expected.

    +
    import { EventEmitter } from 'node:events';
    class MyEmitter extends EventEmitter {}
    const myEmitter = new MyEmitter();

    const callbackA = () => {
    console.log('A');
    myEmitter.removeListener('event', callbackB);
    };

    const callbackB = () => {
    console.log('B');
    };

    myEmitter.on('event', callbackA);

    myEmitter.on('event', callbackB);

    // callbackA removes listener callbackB but it will still be called.
    // Internal listener array at time of emit [callbackA, callbackB]
    myEmitter.emit('event');
    // Prints:
    // A
    // B

    // callbackB is now removed.
    // Internal listener array [callbackA]
    myEmitter.emit('event');
    // Prints:
    // A +
    + +

    Because listeners are managed using an internal array, calling this will +change the position indices of any listener registered after the listener +being removed. This will not impact the order in which listeners are called, +but it means that any copies of the listener array as returned by +the emitter.listeners() method will need to be recreated.

    +

    When a single function has been added as a handler multiple times for a single +event (as in the example below), removeListener() will remove the most +recently added instance. In the example the once('ping') listener is removed:

    +
    import { EventEmitter } from 'node:events';
    const ee = new EventEmitter();

    function pong() {
    console.log('pong');
    }

    ee.on('ping', pong);
    ee.once('ping', pong);
    ee.removeListener('ping', pong);

    ee.emit('ping');
    ee.emit('ping'); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.26

    +
  • By default EventEmitters will print a warning if more than 10 listeners are +added for a particular event. This is a useful default that helps finding +memory leaks. The emitter.setMaxListeners() method allows the limit to be +modified for this specific EventEmitter instance. The value can be set to Infinity (or 0) to indicate an unlimited number of listeners.

    +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Parameters

    • n: number

    Returns this

    v0.3.5

    +
  • Experimental

    Listens once to the abort event on the provided signal.

    +

    Listening to the abort event on abort signals is unsafe and may +lead to resource leaks since another third party with the signal can +call e.stopImmediatePropagation(). Unfortunately Node.js cannot change +this since it would violate the web standard. Additionally, the original +API makes it easy to forget to remove listeners.

    +

    This API allows safely using AbortSignals in Node.js APIs by solving these +two issues by listening to the event such that stopImmediatePropagation does +not prevent the listener from running.

    +

    Returns a disposable so that it may be unsubscribed from more easily.

    +
    import { addAbortListener } from 'node:events';

    function example(signal) {
    let disposable;
    try {
    signal.addEventListener('abort', (e) => e.stopImmediatePropagation());
    disposable = addAbortListener(signal, (e) => {
    // Do something when signal is aborted.
    });
    } finally {
    disposable?.[Symbol.dispose]();
    }
    } +
    + +

    Parameters

    • signal: AbortSignal
    • resource: ((event: Event) => void)
        • (event): void
        • Parameters

          • event: Event

          Returns void

    Returns Disposable

    Disposable that removes the abort listener.

    +

    v20.5.0

    +
  • Returns a copy of the array of listeners for the event named eventName.

    +

    For EventEmitters this behaves exactly the same as calling .listeners on +the emitter.

    +

    For EventTargets this is the only way to get the event listeners for the +event target. This is useful for debugging and diagnostic purposes.

    +
    import { getEventListeners, EventEmitter } from 'node:events';

    {
    const ee = new EventEmitter();
    const listener = () => console.log('Events are fun');
    ee.on('foo', listener);
    console.log(getEventListeners(ee, 'foo')); // [ [Function: listener] ]
    }
    {
    const et = new EventTarget();
    const listener = () => console.log('Events are fun');
    et.addEventListener('foo', listener);
    console.log(getEventListeners(et, 'foo')); // [ [Function: listener] ]
    } +
    + +

    Parameters

    • emitter: EventEmitter<DefaultEventMap> | EventTarget
    • name: string | symbol

    Returns Function[]

    v15.2.0, v14.17.0

    +
  • Returns the currently set max amount of listeners.

    +

    For EventEmitters this behaves exactly the same as calling .getMaxListeners on +the emitter.

    +

    For EventTargets this is the only way to get the max event listeners for the +event target. If the number of event handlers on a single EventTarget exceeds +the max set, the EventTarget will print a warning.

    +
    import { getMaxListeners, setMaxListeners, EventEmitter } from 'node:events';

    {
    const ee = new EventEmitter();
    console.log(getMaxListeners(ee)); // 10
    setMaxListeners(11, ee);
    console.log(getMaxListeners(ee)); // 11
    }
    {
    const et = new EventTarget();
    console.log(getMaxListeners(et)); // 10
    setMaxListeners(11, et);
    console.log(getMaxListeners(et)); // 11
    } +
    + +

    Parameters

    • emitter: EventEmitter<DefaultEventMap> | EventTarget

    Returns number

    v19.9.0

    +
  • A class method that returns the number of listeners for the given eventName registered on the given emitter.

    +
    import { EventEmitter, listenerCount } from 'node:events';

    const myEmitter = new EventEmitter();
    myEmitter.on('event', () => {});
    myEmitter.on('event', () => {});
    console.log(listenerCount(myEmitter, 'event'));
    // Prints: 2 +
    + +

    Parameters

    • emitter: EventEmitter<DefaultEventMap>

      The emitter to query

      +
    • eventName: string | symbol

      The event name

      +

    Returns number

    v0.9.12

    +

    Since v3.2.0 - Use listenerCount instead.

    +
  • import { on, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ee = new EventEmitter();

    // Emit later on
    process.nextTick(() => {
    ee.emit('foo', 'bar');
    ee.emit('foo', 42);
    });

    for await (const event of on(ee, 'foo')) {
    // The execution of this inner block is synchronous and it
    // processes one event at a time (even with await). Do not use
    // if concurrent execution is required.
    console.log(event); // prints ['bar'] [42]
    }
    // Unreachable here +
    + +

    Returns an AsyncIterator that iterates eventName events. It will throw +if the EventEmitter emits 'error'. It removes all listeners when +exiting the loop. The value returned by each iteration is an array +composed of the emitted event arguments.

    +

    An AbortSignal can be used to cancel waiting on events:

    +
    import { on, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ac = new AbortController();

    (async () => {
    const ee = new EventEmitter();

    // Emit later on
    process.nextTick(() => {
    ee.emit('foo', 'bar');
    ee.emit('foo', 42);
    });

    for await (const event of on(ee, 'foo', { signal: ac.signal })) {
    // The execution of this inner block is synchronous and it
    // processes one event at a time (even with await). Do not use
    // if concurrent execution is required.
    console.log(event); // prints ['bar'] [42]
    }
    // Unreachable here
    })();

    process.nextTick(() => ac.abort()); +
    + +

    Use the close option to specify an array of event names that will end the iteration:

    +
    import { on, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ee = new EventEmitter();

    // Emit later on
    process.nextTick(() => {
    ee.emit('foo', 'bar');
    ee.emit('foo', 42);
    ee.emit('close');
    });

    for await (const event of on(ee, 'foo', { close: ['close'] })) {
    console.log(event); // prints ['bar'] [42]
    }
    // the loop will exit after 'close' is emitted
    console.log('done'); // prints 'done' +
    + +

    Parameters

    • emitter: EventEmitter<DefaultEventMap>
    • eventName: string | symbol
    • Optionaloptions: StaticEventEmitterIteratorOptions

    Returns AsyncIterator<any[], any, any>

    An AsyncIterator that iterates eventName events emitted by the emitter

    +

    v13.6.0, v12.16.0

    +
  • Parameters

    • emitter: EventTarget
    • eventName: string
    • Optionaloptions: StaticEventEmitterIteratorOptions

    Returns AsyncIterator<any[], any, any>

  • Creates a Promise that is fulfilled when the EventEmitter emits the given +event or that is rejected if the EventEmitter emits 'error' while waiting. +The Promise will resolve with an array of all the arguments emitted to the +given event.

    +

    This method is intentionally generic and works with the web platform EventTarget interface, which has no special'error' event +semantics and does not listen to the 'error' event.

    +
    import { once, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ee = new EventEmitter();

    process.nextTick(() => {
    ee.emit('myevent', 42);
    });

    const [value] = await once(ee, 'myevent');
    console.log(value);

    const err = new Error('kaboom');
    process.nextTick(() => {
    ee.emit('error', err);
    });

    try {
    await once(ee, 'myevent');
    } catch (err) {
    console.error('error happened', err);
    } +
    + +

    The special handling of the 'error' event is only used when events.once() is used to wait for another event. If events.once() is used to wait for the +'error' event itself, then it is treated as any other kind of event without +special handling:

    +
    import { EventEmitter, once } from 'node:events';

    const ee = new EventEmitter();

    once(ee, 'error')
    .then(([err]) => console.log('ok', err.message))
    .catch((err) => console.error('error', err.message));

    ee.emit('error', new Error('boom'));

    // Prints: ok boom +
    + +

    An AbortSignal can be used to cancel waiting for the event:

    +
    import { EventEmitter, once } from 'node:events';

    const ee = new EventEmitter();
    const ac = new AbortController();

    async function foo(emitter, event, signal) {
    try {
    await once(emitter, event, { signal });
    console.log('event emitted!');
    } catch (error) {
    if (error.name === 'AbortError') {
    console.error('Waiting for the event was canceled!');
    } else {
    console.error('There was an error', error.message);
    }
    }
    }

    foo(ee, 'foo', ac.signal);
    ac.abort(); // Abort waiting for the event
    ee.emit('foo'); // Prints: Waiting for the event was canceled! +
    + +

    Parameters

    • emitter: EventEmitter<DefaultEventMap>
    • eventName: string | symbol
    • Optionaloptions: StaticEventEmitterOptions

    Returns Promise<any[]>

    v11.13.0, v10.16.0

    +
  • Parameters

    • emitter: EventTarget
    • eventName: string
    • Optionaloptions: StaticEventEmitterOptions

    Returns Promise<any[]>

  • import { setMaxListeners, EventEmitter } from 'node:events';

    const target = new EventTarget();
    const emitter = new EventEmitter();

    setMaxListeners(5, target, emitter); +
    + +

    Parameters

    • Optionaln: number

      A non-negative number. The maximum number of listeners per EventTarget event.

      +
    • Rest...eventTargets: (EventEmitter<DefaultEventMap> | EventTarget)[]

      Zero or more {EventTarget} or {EventEmitter} instances. If none are specified, n is set as the default max for all newly created {EventTarget} and {EventEmitter} +objects.

      +

    Returns void

    v15.4.0

    +
diff --git a/docs/site/classes/models_card.Card.html b/docs/site/classes/models_card.Card.html index ad7354d..a7fa59f 100644 --- a/docs/site/classes/models_card.Card.html +++ b/docs/site/classes/models_card.Card.html @@ -1,23 +1,45 @@ -Card | pokerjs

Card : Represents a playing card in a poker game, consisting of a rank and a suit. -Implements the ICard interface.

-
const card = new Card(Rank.Ace, Suit.Spades);
console.log(card.toString()); // "A of Spades" +Card | casinojs

Card +Represents a playing card in a poker game, consisting of a rank and a suit. +Implements the CardInterface.

+

The Card class encapsulates its properties (rank and suit) as private +and provides public getter methods to access these properties. +It also includes private setter methods for internal control over the state.

+
const card = new Card(Rank.Ace, Suit.Spades);
console.log(card.toString()); // "A of Spades"
-

Constructors

Properties

Methods

Constructors

  • Parameters

    • rank: Rank

      The rank of the card.

      -
    • suit: Suit

      The suit of the card.

      -

    Returns Card

    constructor

    +

Implements

Constructors

Methods

Constructors

  • constructor

    Creates an instance of a Card with the given rank and suit.

    -
    const card = new Card(Rank.Ace, Suit.Spades);
    +

    Parameters

    • config: CardConfig

      The configuration of the card.

      +

    Returns Card

    const card = new Card(Rank.Ace, Suit.Spades);
     
    -

Properties

rank: Rank
suit: Suit

Methods

  • Returns string

    The card's rank and suit as a formatted string.

    -

    toString

    +

Methods

  • toObj

    +

    Returns an object representation of the card, containing its rank and suit.

    +

    Returns {
        rank: Rank;
        suit: Suit;
    }

    The card's rank and suit as an object.

    +
    const cardObj = card.toObj();
    console.log(cardObj); // { rank: "A", suit: "Spades" } +
    + +
  • toString

    Returns a string representation of the card, displaying its rank and suit.

    -
    const card = new Card(Rank.Ace, Suit.Spades);
    console.log(card.toString()); // "A of Spades" +

    Returns string

    The card's rank and suit as a formatted string.

    +
    const description = card.toString();
    console.log(description); // "A of Spades"
    -
+
diff --git a/docs/site/classes/models_casino.Casino.html b/docs/site/classes/models_casino.Casino.html new file mode 100644 index 0000000..9563d2b --- /dev/null +++ b/docs/site/classes/models_casino.Casino.html @@ -0,0 +1,710 @@ +Casino | casinojs

Casino +Represents a Casino environment that manages multiple poker rooms (PokerRooms). +This class handles operations related to room creation, listing, removal, and searching.

+

A Casino serves as a central hub for organizing poker games by managing rooms. +Each room can accommodate players and maintain its own game state.

+

Additionally, it extends the Node.js BaseEventEmitter to emit events when specific actions +occur, such as creating or removing a room.

+

This class implements the CasinoInterface and inherits from the BaseEventEmitter class, +allowing it to emit events and conform to the defined interface structure for consistency +and predictability.

+

The Casino class emits custom events to signal room-related actions. For instance, +when a room is created, an event casino:roomCreated is emitted, making it easy +to handle notifications or updates related to the Casino’s operations.

+
const casino = new Casino();
casino.on('casino:roomCreated', (room) => console.log(`Room created: ${room.name}`));
const room = casino.createRoom({ name: "Room1", tableSize: 6, smallBlind: 10, bigBlind: 20 });
console.log(room); // Logs details of "Room1" +
+ +

Hierarchy (view full)

Implements

Constructors

Properties

captureRejections: boolean

Value: boolean

+

Change the default captureRejections option on all new EventEmitter objects.

+

v13.4.0, v12.16.0

+
captureRejectionSymbol: typeof captureRejectionSymbol

Value: Symbol.for('nodejs.rejection')

+

See how to write a custom rejection handler.

+

v13.4.0, v12.16.0

+
defaultMaxListeners: number

By default, a maximum of 10 listeners can be registered for any single +event. This limit can be changed for individual EventEmitter instances +using the emitter.setMaxListeners(n) method. To change the default +for allEventEmitter instances, the events.defaultMaxListeners property +can be used. If this value is not a positive number, a RangeError is thrown.

+

Take caution when setting the events.defaultMaxListeners because the +change affects all EventEmitter instances, including those created before +the change is made. However, calling emitter.setMaxListeners(n) still has +precedence over events.defaultMaxListeners.

+

This is not a hard limit. The EventEmitter instance will allow +more listeners to be added but will output a trace warning to stderr indicating +that a "possible EventEmitter memory leak" has been detected. For any single +EventEmitter, the emitter.getMaxListeners() and emitter.setMaxListeners() methods can be used to +temporarily avoid this warning:

+
import { EventEmitter } from 'node:events';
const emitter = new EventEmitter();
emitter.setMaxListeners(emitter.getMaxListeners() + 1);
emitter.once('event', () => {
// do stuff
emitter.setMaxListeners(Math.max(emitter.getMaxListeners() - 1, 0));
}); +
+ +

The --trace-warnings command-line flag can be used to display the +stack trace for such warnings.

+

The emitted warning can be inspected with process.on('warning') and will +have the additional emitter, type, and count properties, referring to +the event emitter instance, the event's name and the number of attached +listeners, respectively. +Its name property is set to 'MaxListenersExceededWarning'.

+

v0.11.2

+
errorMonitor: typeof errorMonitor

This symbol shall be used to install a listener for only monitoring 'error' events. Listeners installed using this symbol are called before the regular 'error' listeners are called.

+

Installing a listener using this symbol does not change the behavior once an 'error' event is emitted. Therefore, the process will still crash if no +regular 'error' listener is installed.

+

v13.6.0, v12.17.0

+

Methods

  • Adds a single PokerRoom instance to the Casino's list of managed rooms.

    +

    N/A

    +

    N/A

    +

    Allows dynamic expansion of rooms within the Casino environment, enabling additional gaming options for players.

    +
      +
    • Emits a CasinoEvents.ROOM_ADDED event after adding a room.
    • +
    +
      +
    • room: The PokerRoomInterface instance representing the room to be added.
    • +
    +
      +
    • The room parameter must be a valid instance implementing PokerRoomInterface.
    • +
    +
      +
    • The updated list of rooms currently managed by the Casino.
    • +
    +

    Useful when adding a new room to the Casino in response to game demand or configuration changes.

    +

    Parameters

    Returns PokerRoomInterface[]

      +
    • The updated list of rooms managed by the Casino.
    • +
    +
    const casino = new Casino();
    const room = new PokerRoom({ name: "HighRollers", tableSize: 6, smallBlind: 10, bigBlind: 20 });
    const rooms = casino.addRoom(room);
    console.log(rooms); // Updated rooms list with the new room +
    + +
  • Adds multiple PokerRoom instances to the Casino's list of managed rooms.

    +

    N/A

    +

    N/A

    +

    Enables efficient management of batch room additions within the Casino, ensuring all rooms are processed together.

    +
      +
    • Emits a CasinoEvents.ROOMS_SET event once all rooms are added.
    • +
    +
      +
    • rooms: An array of PokerRoomInterface instances to add.
    • +
    +
      +
    • Each element in the rooms array must be a valid PokerRoomInterface instance.
    • +
    +
      +
    • The updated list of rooms currently managed by the Casino.
    • +
    +

    Useful in scenarios where multiple rooms need to be added to the Casino at once, such as during setup or a bulk update.

    +

    Parameters

    Returns PokerRoomInterface[]

      +
    • The updated list of rooms managed by the Casino.
    • +
    +
    const extendedCasino = new Casino();
    const rooms = [new PokerRoom({ name: "VIP Room", tableSize: 8, smallBlind: 50, bigBlind: 100 })];
    extendedCasino.addRooms(rooms); // Adds VIP rooms to the Casino +
    + +
  • Creates a new PokerRoom instance based on the provided configuration and adds it to the Casino's rooms list.

    +

    N/A

    +

    N/A

    +

    Allows the Casino to dynamically create new rooms as needed by providing specific room configurations.

    +
      +
    • Emits a CasinoEvents.ROOM_CREATED event, enabling listeners to respond to the creation of a new room.
    • +
    +
      +
    • config: A PokerRoomConfig object containing details like name, tableSize, smallBlind, and bigBlind.
    • +
    +

    N/A

    +
      +
    • Returns the newly created PokerRoomInterface instance.
    • +
    +

    Primarily used within subclasses or protected methods to dynamically create and add rooms to the Casino.

    +

    Parameters

    • config: undefined | PokerRoomConfig

      Configuration settings for creating a new PokerRoom.

      +

    Returns PokerRoomInterface

      +
    • The newly created room instance.
    • +
    +
    class SpecialCasino extends Casino {
    public createSpecialRoom(config: PokerRoomConfig): PokerRoomInterface {
    return this._createRoom(config);
    }
    }
    const specialCasino = new SpecialCasino();
    const newRoom = specialCasino.createSpecialRoom({ name: "Champions Lounge", tableSize: 10, smallBlind: 100, bigBlind: 200 });
    console.log(newRoom.getName()); // Outputs: "Champions Lounge" +
    + +
  • Removes a PokerRoom from the Casino's list based on the room's index, providing controlled removal of rooms.

    +

    N/A

    +

    N/A

    +

    Allows for the safe removal of a specific room from the Casino’s list.

    +
      +
    • Emits a CasinoEvents.ROOM_DELETED event once the room is successfully removed.
    • +
    +
      +
    • index: The zero-based index of the room to remove.
    • +
    +
      +
    • index must be valid within the bounds of the __rooms array.
    • +
    +
      +
    • The updated list of rooms managed by the Casino.
    • +
    +

    Primarily used for controlled removal of a specific room from the Casino's room list.

    +

    Parameters

    • index: number

      The index of the room to be removed.

      +

    Returns PokerRoomInterface[]

      +
    • The updated list of rooms managed by the Casino.
    • +
    +
    const casino = new Casino();
    const room = casino.createRoom({ name: "HighRollers", tableSize: 6, smallBlind: 10, bigBlind: 20 });
    const rooms = casino.deleteRoom(room);
    console.log(rooms); // Updated rooms list without the deleted room +
    + +
  • Sets the complete list of rooms managed by the Casino with a new array of PokerRoomInterface objects.

    +

    N/A

    +

    N/A

    +

    This protected method allows subclasses of Casino to modify the entire __rooms property, which can be used +when needing to replace or reset the Casino's room list.

    +
      +
    • Emits a CasinoEvents.ROOMS_SET event, allowing external listeners to respond to room updates.
    • +
    +
      +
    • rooms: An array of PokerRoomInterface instances representing the new rooms for the Casino.
    • +
    +
      +
    • The rooms array should contain at least one room (rooms.length >= 1).
    • +
    +
      +
    • Returns the updated list of rooms currently managed by the Casino.
    • +
    +

    This method is useful when an update or replacement of all rooms is needed, such as during initialization +or batch updates.

    +

    Parameters

    Returns PokerRoomInterface[]

      +
    • The updated list of rooms managed by the Casino.
    • +
    +
    class ExtendedCasino extends Casino {
    public resetRooms(newRooms: PokerRoomInterface[]): PokerRoomInterface[] {
    return this._setRooms(newRooms);
    }
    }
    const extendedCasino = new ExtendedCasino();
    const rooms = [new PokerRoom({ name: "VIP", tableSize: 8, smallBlind: 50, bigBlind: 100 })];
    extendedCasino.resetRooms(rooms); // Resets the Casino's rooms list +
    + +
  • Alias for emitter.on(eventName, listener).

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.26

    +
  • Adds a new PokerRoom instance to the Casino's list of managed rooms, enabling dynamic expansion +of rooms within the Casino environment.

    +

    N/A

    +

    N/A

    +

    This method provides a flexible mechanism for expanding the Casino's room offerings by allowing new +rooms to be added as required, thereby supporting various gaming scenarios and player demand.

    +

    N/A

    +
      +
    • room - A PokerRoomInterface instance representing the room to be added to the Casino’s list.
    • +
    +
      +
    • The room parameter must be a valid instance implementing PokerRoomInterface.
    • +
    +
      +
    • Returns true to confirm that the room has been successfully added to the Casino.
    • +
    +

    Typically used in scenarios where the Casino environment needs to expand by adding more gaming rooms.

    +

    Parameters

    Returns PokerRoomInterface[]

      +
    • Returns true when the room has been added successfully.
    • +
    +
    const casino = new Casino();
    const room = new PokerRoom({ name: "HighRollers", tableSize: 6, smallBlind: 10, bigBlind: 20 });
    const success = casino.addRoom(room);
    console.log(success); // true +
    + +
  • Adds multiple PokerRoom instances to the Casino's list of managed rooms in a single operation, enabling +efficient and scalable room management.

    +

    N/A

    +

    N/A

    +

    This method provides a convenient way to add several rooms at once, allowing the Casino's environment to +scale in response to gaming demand or operational changes.

    +

    N/A

    +
      +
    • rooms: An array of PokerRoomInterface instances representing the rooms to be added to the Casino.
    • +
    +
      +
    • Each element in the rooms array must be a valid PokerRoomInterface instance.
    • +
    • The array should contain at least one room.
    • +
    +
      +
    • Returns true when all rooms have been added successfully.
    • +
    +

    Typically used in scenarios where multiple rooms need to be added to the Casino simultaneously, such as +during batch operations or initial setup.

    +

    Parameters

    Returns PokerRoomInterface[]

      +
    • Returns true when all rooms have been successfully added.
    • +
    +
    const casino = new Casino();
    const rooms = [
    new PokerRoom({ name: "Room1", tableSize: 5, smallBlind: 5, bigBlind: 10 }),
    new PokerRoom({ name: "Room2", tableSize: 6, smallBlind: 10, bigBlind: 20 })
    ];
    const success = casino.addRooms(rooms);
    console.log(success); // true if both rooms were added successfully +
    + +
  • Creates a new PokerRoom within the Casino and adds it to the list of rooms.

    +

    Implements the createRoom method of CasinoInterface.

    +

    N/A

    +

    Enables the dynamic creation and addition of a PokerRoom to the Casino, expanding the Casino’s managed rooms as required. +This facilitates flexible game setup and room management in response to user needs.

    +
      +
    • casino:roomCreated: This custom event is emitted once the room is successfully added. +Listeners to this event can respond with actions, such as logging or notifying users.
    • +
    +
      +
    • config: A configuration object containing details like the room’s name, table size, small blind, and big blind values.
    • +
    +
      +
    • The configuration object must include valid values for name, tableSize, smallBlind, and bigBlind.
    • +
    +
      +
    • Returns the newly created PokerRoom instance, confirming its addition to the Casino.
    • +
    +

    This method creates a new room based on the provided configuration, then pushes it into the Casino’s room list. +After adding the room, it emits a casino:roomCreated event for any listeners tracking room creation.

    +

    Parameters

    • config: PokerRoomConfig

      A configuration object with properties like the room name, table size, small blind, and big blind values.

      +

    Returns PokerRoomInterface

      +
    • Returns the newly created PokerRoom instance.
    • +
    +
    const casino = new Casino();
    const room = casino.createRoom({ name: "HighRollers", tableSize: 6, smallBlind: 10, bigBlind: 20 });
    console.log(casino.getRooms()); // Logs the new room within the array of rooms +
    + +
  • Removes a PokerRoom from the Casino's list of managed rooms based on the room's name, enabling dynamic +contraction of the Casino environment as required.

    +

    N/A

    +

    N/A

    +

    Allows the Casino environment to remain current by dynamically removing rooms that are no longer active +or needed. This supports a clean and manageable set of active rooms within the Casino.

    +
      +
    • Emits a casino:roomRemoved event when a room is successfully removed. This event can be used +to trigger updates, logging, or notifications.
    • +
    +
      +
    • roomName: A string representing the name of the PokerRoom to be removed from the Casino.
    • +
    +
      +
    • The roomName parameter should match the name property of an existing room for successful deletion.
    • +
    +
      +
    • Returns true if the room was successfully removed, or false if no room with the specified name was found.
    • +
    +

    Use this method when removing a room that is no longer active or required, ensuring that only +currently used rooms remain managed by the Casino.

    +

    Parameters

    • index: number

      The name of the PokerRoom to be removed.

      +

    Returns PokerRoomInterface[]

      +
    • Returns true if the room was removed; false if not found.
    • +
    +
    const casino = new Casino();
    casino.createRoom({ name: "HighRollers", tableSize: 6, smallBlind: 10, bigBlind: 20 });
    const success = casino.deleteRoom("HighRollers");
    console.log(success); // true if room was found and removed, false otherwise +
    + +
  • Synchronously calls each of the listeners registered for the event named eventName, in the order they were registered, passing the supplied arguments +to each.

    +

    Returns true if the event had listeners, false otherwise.

    +
    import { EventEmitter } from 'node:events';
    const myEmitter = new EventEmitter();

    // First listener
    myEmitter.on('event', function firstListener() {
    console.log('Helloooo! first listener');
    });
    // Second listener
    myEmitter.on('event', function secondListener(arg1, arg2) {
    console.log(`event with parameters ${arg1}, ${arg2} in second listener`);
    });
    // Third listener
    myEmitter.on('event', function thirdListener(...args) {
    const parameters = args.join(', ');
    console.log(`event with parameters ${parameters} in third listener`);
    });

    console.log(myEmitter.listeners('event'));

    myEmitter.emit('event', 1, 2, 3, 4, 5);

    // Prints:
    // [
    // [Function: firstListener],
    // [Function: secondListener],
    // [Function: thirdListener]
    // ]
    // Helloooo! first listener
    // event with parameters 1, 2 in second listener
    // event with parameters 1, 2, 3, 4, 5 in third listener +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • Rest...args: AnyRest

    Returns boolean

    v0.1.26

    +
  • The emitEvent method is a public method for emitting events, with an optional configuration that allows +middleware processing. Middleware functions can intercept and transform the event before it reaches the listeners, +allowing custom validation or data modifications.

    +

    This method enables flexible event emission with support for middleware, providing a robust event processing +mechanism in the BaseEventEmitter. It’s useful for customizing event behavior based on application-specific needs.

    +

    N/A

    +

    N/A

    +

    This method can emit any event specified by eventName, which can then be processed by middleware functions if defined.

    +
      +
    • eventName: string - The name of the event to emit.
    • +
    • options: { event: { data: { [key: string]: any }; [key: string]: any; }, middlewares?: Array<(event: BaseEventInterface, next: () => void) => void | false> } +
        +
      • event - The primary event data to emit, containing specific details.
      • +
      • middlewares - An optional array of middleware functions that process the event before emission.
      • +
      +
    • +
    +
      +
    • eventName must be a valid string.
    • +
    • options.event should include relevant data for the event. If middlewares are provided, they should be functions with an event and next parameter.
    • +
    +
      +
    • void - This method does not return a value.
    • +
    +

    Use this method to emit events with middleware-based customization, which allows for specific processing +logic or transformations before the event reaches listeners.

    +

    Parameters

    • eventName: string

      The name of the event to emit.

      +
    • options: {
          event: {
              data: {
                  [key: string]: any;
              };
              [key: string]: any;
          };
          middlewares?: ((event: BaseEventInterface<any>, next: (() => void)) => false | void)[];
      }

      Configuration for the event and optional middleware functions.

      +
      • event: {
            data: {
                [key: string]: any;
            };
            [key: string]: any;
        }
        • [key: string]: any
        • data: {
              [key: string]: any;
          }
          • [key: string]: any
      • Optionalmiddlewares?: ((event: BaseEventInterface<any>, next: (() => void)) => false | void)[]

    Returns void

    emitter.emitEvent("game:started", {
    event: { data: { gameId: "001", status: "active" } },
    middlewares: [
    (event, next) => { console.log("Processing event:", event); next(); },
    (event, next) => { event.data.processed = true; next(); }
    ]
    }); +
    + +
  • Returns an array listing the events for which the emitter has registered +listeners. The values in the array are strings or Symbols.

    +
    import { EventEmitter } from 'node:events';

    const myEE = new EventEmitter();
    myEE.on('foo', () => {});
    myEE.on('bar', () => {});

    const sym = Symbol('symbol');
    myEE.on(sym, () => {});

    console.log(myEE.eventNames());
    // Prints: [ 'foo', 'bar', Symbol(symbol) ] +
    + +

    Returns (string | symbol)[]

    v6.0.0

    +
  • Retrieves a specific PokerRoom based on its position within the Casino’s list of rooms.

    +

    N/A

    +

    N/A

    +

    This method provides direct access to a single PokerRoom by index, allowing for targeted retrieval of rooms, +which can be useful for room-specific operations or when sequentially processing rooms.

    +

    N/A

    +
      +
    • index: A zero-based index representing the position of the desired PokerRoom in the Casino’s room list.
    • +
    +
      +
    • The index provided must be within the bounds of the __rooms array (i.e., 0 <= index < __rooms.length).
    • +
    • Passing an out-of-bounds index will result in an undefined return.
    • +
    +
      +
    • Returns the PokerRoomInterface instance located at the specified index.
    • +
    • Returns undefined if the provided index is out of bounds.
    • +
    +

    Use this method when you need to access a particular room directly by its index in the Casino’s list of rooms. +This can be useful in looped operations or when accessing rooms based on their position in the list.

    +

    Parameters

    • index: number

      The zero-based index of the desired room in the Casino’s room list.

      +

    Returns PokerRoomInterface

      +
    • The PokerRoom at the specified index or undefined if the index is out of bounds.
    • +
    +
    const casino = new Casino();
    const room = casino.getRoom(0); // Returns the first room or undefined if no rooms exist +
    + +
  • Retrieves the full list of rooms currently managed by the Casino.

    +

    Implements the getRooms method of CasinoInterface.

    +

    N/A

    +

    Provides access to the Casino's list of rooms, allowing external components or systems to retrieve and display +information on all currently managed poker rooms.

    +

    N/A

    +

    N/A

    +

    N/A

    +
      +
    • Returns an array containing all PokerRoomInterface instances currently managed by the Casino.
    • +
    • Returns an empty array if no rooms have been added to the Casino.
    • +
    +

    This method is useful when a complete list of active rooms is needed, such as when displaying the Casino's +available games or managing room states.

    +

    Returns PokerRoomInterface[]

      +
    • An array of all PokerRoom objects in the Casino.
    • +
    +
    const casino = new Casino();
    console.log(casino.getRooms()); // Output: [] +
    + +
  • Checks if a provided index is within the valid range of the Casino’s room list, helping avoid out-of-bounds errors.

    +

    isValidIndex method from CasinoInterface.

    +

    N/A

    +

    This method validates an index before it's used to access or modify a room in the Casino’s list, protecting +against out-of-bound errors. It is useful in any operations that involve room access by index.

    +

    N/A

    +
      +
    • index: A zero-based integer representing the position of a room in the Casino's managed list.
    • +
    +
      +
    • The index should be a non-negative integer within the range [0, roomCount - 1].
    • +
    +
      +
    • Returns true if the index is valid.
    • +
    • Throws an Error if the index is out of range, providing a descriptive message.
    • +
    +

    Use this method before performing operations that involve accessing a room by index. This helps prevent +out-of-bound errors in index-based room access.

    +

    Parameters

    • index: number

      The zero-based index to validate.

      +

    Returns boolean

      +
    • Returns true if the index is within bounds.
    • +
    +
      +
    • Throws an error with a descriptive message if the index is out of bounds.
    • +
    +
    const casino = new Casino();
    try {
    casino.isValidIndex(2); // Returns true if there are at least 3 rooms
    } catch (error) {
    console.error(error.message); // If index 2 is out of bounds, logs error message
    } +
    + +
  • Returns the number of listeners listening for the event named eventName. +If listener is provided, it will return how many times the listener is found +in the list of the listeners of the event.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event being listened for

      +
    • Optionallistener: Function

      The event handler function

      +

    Returns number

    v3.2.0

    +
  • Returns a copy of the array of listeners for the event named eventName.

    +
    server.on('connection', (stream) => {
    console.log('someone connected!');
    });
    console.log(util.inspect(server.listeners('connection')));
    // Prints: [ [Function] ] +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

    Returns Function[]

    v0.1.26

    +
  • Alias for emitter.removeListener().

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v10.0.0

    +
  • Adds the listener function to the end of the listeners array for the event +named eventName. No checks are made to see if the listener has already +been added. Multiple calls passing the same combination of eventName and +listener will result in the listener being added, and called, multiple times.

    +
    server.on('connection', (stream) => {
    console.log('someone connected!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    By default, event listeners are invoked in the order they are added. The emitter.prependListener() method can be used as an alternative to add the +event listener to the beginning of the listeners array.

    +
    import { EventEmitter } from 'node:events';
    const myEE = new EventEmitter();
    myEE.on('foo', () => console.log('a'));
    myEE.prependListener('foo', () => console.log('b'));
    myEE.emit('foo');
    // Prints:
    // b
    // a +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.101

    +
  • Adds a one-time listener function for the event named eventName. The +next time eventName is triggered, this listener is removed and then invoked.

    +
    server.once('connection', (stream) => {
    console.log('Ah, we have our first user!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    By default, event listeners are invoked in the order they are added. The emitter.prependOnceListener() method can be used as an alternative to add the +event listener to the beginning of the listeners array.

    +
    import { EventEmitter } from 'node:events';
    const myEE = new EventEmitter();
    myEE.once('foo', () => console.log('a'));
    myEE.prependOnceListener('foo', () => console.log('b'));
    myEE.emit('foo');
    // Prints:
    // b
    // a +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.3.0

    +
  • Adds the listener function to the beginning of the listeners array for the +event named eventName. No checks are made to see if the listener has +already been added. Multiple calls passing the same combination of eventName +and listener will result in the listener being added, and called, multiple times.

    +
    server.prependListener('connection', (stream) => {
    console.log('someone connected!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v6.0.0

    +
  • Adds a one-timelistener function for the event named eventName to the beginning of the listeners array. The next time eventName is triggered, this +listener is removed, and then invoked.

    +
    server.prependOnceListener('connection', (stream) => {
    console.log('Ah, we have our first user!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v6.0.0

    +
  • Returns a copy of the array of listeners for the event named eventName, +including any wrappers (such as those created by .once()).

    +
    import { EventEmitter } from 'node:events';
    const emitter = new EventEmitter();
    emitter.once('log', () => console.log('log once'));

    // Returns a new Array with a function `onceWrapper` which has a property
    // `listener` which contains the original listener bound above
    const listeners = emitter.rawListeners('log');
    const logFnWrapper = listeners[0];

    // Logs "log once" to the console and does not unbind the `once` event
    logFnWrapper.listener();

    // Logs "log once" to the console and removes the listener
    logFnWrapper();

    emitter.on('log', () => console.log('log persistently'));
    // Will return a new Array with a single function bound by `.on()` above
    const newListeners = emitter.rawListeners('log');

    // Logs "log persistently" twice
    newListeners[0]();
    emitter.emit('log'); +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

    Returns Function[]

    v9.4.0

    +
  • Removes all listeners, or those of the specified eventName.

    +

    It is bad practice to remove listeners added elsewhere in the code, +particularly when the EventEmitter instance was created by some other +component or module (e.g. sockets or file streams).

    +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Parameters

    • OptionaleventName: string | symbol

    Returns this

    v0.1.26

    +
  • Removes the specified listener from the listener array for the event named eventName.

    +
    const callback = (stream) => {
    console.log('someone connected!');
    };
    server.on('connection', callback);
    // ...
    server.removeListener('connection', callback); +
    + +

    removeListener() will remove, at most, one instance of a listener from the +listener array. If any single listener has been added multiple times to the +listener array for the specified eventName, then removeListener() must be +called multiple times to remove each instance.

    +

    Once an event is emitted, all listeners attached to it at the +time of emitting are called in order. This implies that any removeListener() or removeAllListeners() calls after emitting and before the last listener finishes execution +will not remove them fromemit() in progress. Subsequent events behave as expected.

    +
    import { EventEmitter } from 'node:events';
    class MyEmitter extends EventEmitter {}
    const myEmitter = new MyEmitter();

    const callbackA = () => {
    console.log('A');
    myEmitter.removeListener('event', callbackB);
    };

    const callbackB = () => {
    console.log('B');
    };

    myEmitter.on('event', callbackA);

    myEmitter.on('event', callbackB);

    // callbackA removes listener callbackB but it will still be called.
    // Internal listener array at time of emit [callbackA, callbackB]
    myEmitter.emit('event');
    // Prints:
    // A
    // B

    // callbackB is now removed.
    // Internal listener array [callbackA]
    myEmitter.emit('event');
    // Prints:
    // A +
    + +

    Because listeners are managed using an internal array, calling this will +change the position indices of any listener registered after the listener +being removed. This will not impact the order in which listeners are called, +but it means that any copies of the listener array as returned by +the emitter.listeners() method will need to be recreated.

    +

    When a single function has been added as a handler multiple times for a single +event (as in the example below), removeListener() will remove the most +recently added instance. In the example the once('ping') listener is removed:

    +
    import { EventEmitter } from 'node:events';
    const ee = new EventEmitter();

    function pong() {
    console.log('pong');
    }

    ee.on('ping', pong);
    ee.once('ping', pong);
    ee.removeListener('ping', pong);

    ee.emit('ping');
    ee.emit('ping'); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.26

    +
  • Returns the total number of PokerRoom instances currently managed by the Casino.

    +

    Part of CasinoInterface, ensuring standardization across implementations of the Casino class.

    +

    N/A

    +

    Provides a reliable way to retrieve the number of active poker rooms managed by the Casino. Useful for +general management, reporting, and in situations where the Casino’s room capacity or state must be assessed.

    +

    N/A

    +

    N/A - This method does not accept any parameters.

    +

    N/A

    +
      +
    • Returns the current count of managed rooms.
    • +
    +

    Use this method whenever a precise count of rooms is required, such as when iterating through rooms +or validating bounds.

    +

    Returns number

      +
    • Returns the count of rooms in the Casino.
    • +
    +
    const casino = new Casino();
    const count = casino.roomCount();
    console.log(count); // Console Output: 0 if no rooms exist, or the total count of rooms otherwise +
    + +
  • By default EventEmitters will print a warning if more than 10 listeners are +added for a particular event. This is a useful default that helps finding +memory leaks. The emitter.setMaxListeners() method allows the limit to be +modified for this specific EventEmitter instance. The value can be set to Infinity (or 0) to indicate an unlimited number of listeners.

    +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Parameters

    • n: number

    Returns this

    v0.3.5

    +
  • Sets the list of rooms managed by the Casino. This method is typically used to replace or update +the entire list of poker rooms in the casino.

    +

    Implements the setRooms method of CasinoInterface.

    +

    N/A

    +

    Provides a way to update the current list of rooms managed by the Casino, ensuring a consistent and up-to-date +list of poker rooms as defined by the casino’s configuration.

    +
      +
    • N/A: No event is emitted by this method.
    • +
    +
      +
    • rooms: An array of PokerRoomInterface instances, representing individual poker rooms in the Casino.
    • +
    +
      +
    • The rooms array must contain at least one room (i.e., rooms.length >= 1).
    • +
    +
      +
    • Returns true when the rooms have been successfully set.
    • +
    +

    This method accepts an array of PokerRoomInterface objects, representing poker rooms to manage in the casino.

    +
      +
    • Replaces any existing rooms with the new provided list.
    • +
    • Calls the internal _setRooms method to update the private __rooms property securely.
    • +
    +

    Parameters

    Returns PokerRoomInterface[]

      +
    • Returns true when the rooms have been successfully set.
    • +
    +
    const casino = new Casino();
    const rooms: PokerRoomInterface[] = [
    new PokerRoom({ name: "Room1", tableSize: 6, smallBlind: 10, bigBlind: 20 })
    ];
    casino.setRooms(rooms);
    console.log(casino.getRooms()); // Logs an array with the newly set rooms +
    + +
  • Retrieves the total count of rooms managed by the Casino, enabling easy access to the room quantity.

    +

    N/A - This method is unique to the Casino class and does not implement any other methods.

    +

    N/A - This method does not override any superclass or parent methods.

    +

    The size method provides a shortcut to access the number of poker rooms currently managed by the Casino. +This method is useful for quickly obtaining the count of active rooms, which can help in managing or displaying +the Casino's state.

    +

    N/A

    +

    N/A - This method does not require any input parameters.

    +

    N/A

    +
      +
    • Returns a number representing the current count of poker rooms managed by the Casino.
    • +
    +

    Call this method when a quick count of managed rooms is needed, especially for UI updates or managing limits.

    +

    Returns number

      +
    • Returns the current count of poker rooms.
    • +
    +
    const casino = new Casino();
    const count = casino.size();
    console.log(count); // Console Output: 0 if no rooms have been added +
    + +
  • Experimental

    Listens once to the abort event on the provided signal.

    +

    Listening to the abort event on abort signals is unsafe and may +lead to resource leaks since another third party with the signal can +call e.stopImmediatePropagation(). Unfortunately Node.js cannot change +this since it would violate the web standard. Additionally, the original +API makes it easy to forget to remove listeners.

    +

    This API allows safely using AbortSignals in Node.js APIs by solving these +two issues by listening to the event such that stopImmediatePropagation does +not prevent the listener from running.

    +

    Returns a disposable so that it may be unsubscribed from more easily.

    +
    import { addAbortListener } from 'node:events';

    function example(signal) {
    let disposable;
    try {
    signal.addEventListener('abort', (e) => e.stopImmediatePropagation());
    disposable = addAbortListener(signal, (e) => {
    // Do something when signal is aborted.
    });
    } finally {
    disposable?.[Symbol.dispose]();
    }
    } +
    + +

    Parameters

    • signal: AbortSignal
    • resource: ((event: Event) => void)
        • (event): void
        • Parameters

          • event: Event

          Returns void

    Returns Disposable

    Disposable that removes the abort listener.

    +

    v20.5.0

    +
  • Returns a copy of the array of listeners for the event named eventName.

    +

    For EventEmitters this behaves exactly the same as calling .listeners on +the emitter.

    +

    For EventTargets this is the only way to get the event listeners for the +event target. This is useful for debugging and diagnostic purposes.

    +
    import { getEventListeners, EventEmitter } from 'node:events';

    {
    const ee = new EventEmitter();
    const listener = () => console.log('Events are fun');
    ee.on('foo', listener);
    console.log(getEventListeners(ee, 'foo')); // [ [Function: listener] ]
    }
    {
    const et = new EventTarget();
    const listener = () => console.log('Events are fun');
    et.addEventListener('foo', listener);
    console.log(getEventListeners(et, 'foo')); // [ [Function: listener] ]
    } +
    + +

    Parameters

    • emitter: EventEmitter<DefaultEventMap> | EventTarget
    • name: string | symbol

    Returns Function[]

    v15.2.0, v14.17.0

    +
  • Returns the currently set max amount of listeners.

    +

    For EventEmitters this behaves exactly the same as calling .getMaxListeners on +the emitter.

    +

    For EventTargets this is the only way to get the max event listeners for the +event target. If the number of event handlers on a single EventTarget exceeds +the max set, the EventTarget will print a warning.

    +
    import { getMaxListeners, setMaxListeners, EventEmitter } from 'node:events';

    {
    const ee = new EventEmitter();
    console.log(getMaxListeners(ee)); // 10
    setMaxListeners(11, ee);
    console.log(getMaxListeners(ee)); // 11
    }
    {
    const et = new EventTarget();
    console.log(getMaxListeners(et)); // 10
    setMaxListeners(11, et);
    console.log(getMaxListeners(et)); // 11
    } +
    + +

    Parameters

    • emitter: EventEmitter<DefaultEventMap> | EventTarget

    Returns number

    v19.9.0

    +
  • A class method that returns the number of listeners for the given eventName registered on the given emitter.

    +
    import { EventEmitter, listenerCount } from 'node:events';

    const myEmitter = new EventEmitter();
    myEmitter.on('event', () => {});
    myEmitter.on('event', () => {});
    console.log(listenerCount(myEmitter, 'event'));
    // Prints: 2 +
    + +

    Parameters

    • emitter: EventEmitter<DefaultEventMap>

      The emitter to query

      +
    • eventName: string | symbol

      The event name

      +

    Returns number

    v0.9.12

    +

    Since v3.2.0 - Use listenerCount instead.

    +
  • import { on, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ee = new EventEmitter();

    // Emit later on
    process.nextTick(() => {
    ee.emit('foo', 'bar');
    ee.emit('foo', 42);
    });

    for await (const event of on(ee, 'foo')) {
    // The execution of this inner block is synchronous and it
    // processes one event at a time (even with await). Do not use
    // if concurrent execution is required.
    console.log(event); // prints ['bar'] [42]
    }
    // Unreachable here +
    + +

    Returns an AsyncIterator that iterates eventName events. It will throw +if the EventEmitter emits 'error'. It removes all listeners when +exiting the loop. The value returned by each iteration is an array +composed of the emitted event arguments.

    +

    An AbortSignal can be used to cancel waiting on events:

    +
    import { on, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ac = new AbortController();

    (async () => {
    const ee = new EventEmitter();

    // Emit later on
    process.nextTick(() => {
    ee.emit('foo', 'bar');
    ee.emit('foo', 42);
    });

    for await (const event of on(ee, 'foo', { signal: ac.signal })) {
    // The execution of this inner block is synchronous and it
    // processes one event at a time (even with await). Do not use
    // if concurrent execution is required.
    console.log(event); // prints ['bar'] [42]
    }
    // Unreachable here
    })();

    process.nextTick(() => ac.abort()); +
    + +

    Use the close option to specify an array of event names that will end the iteration:

    +
    import { on, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ee = new EventEmitter();

    // Emit later on
    process.nextTick(() => {
    ee.emit('foo', 'bar');
    ee.emit('foo', 42);
    ee.emit('close');
    });

    for await (const event of on(ee, 'foo', { close: ['close'] })) {
    console.log(event); // prints ['bar'] [42]
    }
    // the loop will exit after 'close' is emitted
    console.log('done'); // prints 'done' +
    + +

    Parameters

    • emitter: EventEmitter<DefaultEventMap>
    • eventName: string | symbol
    • Optionaloptions: StaticEventEmitterIteratorOptions

    Returns AsyncIterator<any[], any, any>

    An AsyncIterator that iterates eventName events emitted by the emitter

    +

    v13.6.0, v12.16.0

    +
  • Parameters

    • emitter: EventTarget
    • eventName: string
    • Optionaloptions: StaticEventEmitterIteratorOptions

    Returns AsyncIterator<any[], any, any>

  • Creates a Promise that is fulfilled when the EventEmitter emits the given +event or that is rejected if the EventEmitter emits 'error' while waiting. +The Promise will resolve with an array of all the arguments emitted to the +given event.

    +

    This method is intentionally generic and works with the web platform EventTarget interface, which has no special'error' event +semantics and does not listen to the 'error' event.

    +
    import { once, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ee = new EventEmitter();

    process.nextTick(() => {
    ee.emit('myevent', 42);
    });

    const [value] = await once(ee, 'myevent');
    console.log(value);

    const err = new Error('kaboom');
    process.nextTick(() => {
    ee.emit('error', err);
    });

    try {
    await once(ee, 'myevent');
    } catch (err) {
    console.error('error happened', err);
    } +
    + +

    The special handling of the 'error' event is only used when events.once() is used to wait for another event. If events.once() is used to wait for the +'error' event itself, then it is treated as any other kind of event without +special handling:

    +
    import { EventEmitter, once } from 'node:events';

    const ee = new EventEmitter();

    once(ee, 'error')
    .then(([err]) => console.log('ok', err.message))
    .catch((err) => console.error('error', err.message));

    ee.emit('error', new Error('boom'));

    // Prints: ok boom +
    + +

    An AbortSignal can be used to cancel waiting for the event:

    +
    import { EventEmitter, once } from 'node:events';

    const ee = new EventEmitter();
    const ac = new AbortController();

    async function foo(emitter, event, signal) {
    try {
    await once(emitter, event, { signal });
    console.log('event emitted!');
    } catch (error) {
    if (error.name === 'AbortError') {
    console.error('Waiting for the event was canceled!');
    } else {
    console.error('There was an error', error.message);
    }
    }
    }

    foo(ee, 'foo', ac.signal);
    ac.abort(); // Abort waiting for the event
    ee.emit('foo'); // Prints: Waiting for the event was canceled! +
    + +

    Parameters

    • emitter: EventEmitter<DefaultEventMap>
    • eventName: string | symbol
    • Optionaloptions: StaticEventEmitterOptions

    Returns Promise<any[]>

    v11.13.0, v10.16.0

    +
  • Parameters

    • emitter: EventTarget
    • eventName: string
    • Optionaloptions: StaticEventEmitterOptions

    Returns Promise<any[]>

  • import { setMaxListeners, EventEmitter } from 'node:events';

    const target = new EventTarget();
    const emitter = new EventEmitter();

    setMaxListeners(5, target, emitter); +
    + +

    Parameters

    • Optionaln: number

      A non-negative number. The maximum number of listeners per EventTarget event.

      +
    • Rest...eventTargets: (EventEmitter<DefaultEventMap> | EventTarget)[]

      Zero or more {EventTarget} or {EventEmitter} instances. If none are specified, n is set as the default max for all newly created {EventTarget} and {EventEmitter} +objects.

      +

    Returns void

    v15.4.0

    +
diff --git a/docs/site/classes/models_deck.Deck.html b/docs/site/classes/models_deck.Deck.html index c068ff6..5eb5d1e 100644 --- a/docs/site/classes/models_deck.Deck.html +++ b/docs/site/classes/models_deck.Deck.html @@ -1,9 +1,12 @@ -Deck | pokerjs

Deck : Represents a deck of 52 playing cards used in poker games. -This class extends EventEmitter and implements the IDeck interface.

-
const deck = new Deck();
deck.on('deck:shuffled', () => console.log('Deck has been shuffled.'));
deck.shuffle();
const card = deck.draw();
console.log(card?.toString()); +Deck | casinojs

Deck +Represents a deck of 52 playing cards used in poker games. +This class extends BaseEventEmitter and implements the DeckInterface interface.

+

The Deck class provides methods to shuffle the deck, draw cards, and emits +events for important actions like shuffling and drawing cards.

+
const deck = new Deck();
deck.on('deck:shuffled', () => console.log('Deck has been shuffled.'));
deck.shuffle();
const card = deck.draw();
console.log(card?.toString()); // "A of Spades"
-

Hierarchy

  • EventEmitter
    • Deck

Implements

Constructors

Hierarchy (view full)

Implements

Constructors

  • Returns Deck

    constructor

    +

Constructors

  • constructor

    Creates an instance of a Deck with 52 cards. Automatically initializes the deck with all combinations of ranks and suits.

    -
    const deck = new Deck();
    +

    Returns Deck

    const deck = new Deck();
     
    -

Properties

captureRejections: boolean

Value: boolean

+

Properties

captureRejections: boolean

Value: boolean

Change the default captureRejections option on all new EventEmitter objects.

v13.4.0, v12.16.0

-
captureRejectionSymbol: typeof captureRejectionSymbol

Value: Symbol.for('nodejs.rejection')

+
captureRejectionSymbol: typeof captureRejectionSymbol

Value: Symbol.for('nodejs.rejection')

See how to write a custom rejection handler.

v13.4.0, v12.16.0

-
defaultMaxListeners: number

By default, a maximum of 10 listeners can be registered for any single +

defaultMaxListeners: number

By default, a maximum of 10 listeners can be registered for any single event. This limit can be changed for individual EventEmitter instances using the emitter.setMaxListeners(n) method. To change the default for allEventEmitter instances, the events.defaultMaxListeners property @@ -59,7 +64,7 @@ that a "possible EventEmitter memory leak" has been detected. For any single EventEmitter, the emitter.getMaxListeners() and emitter.setMaxListeners() methods can be used to temporarily avoid this warning:

-
import { EventEmitter } from 'node:events';
const emitter = new EventEmitter();
emitter.setMaxListeners(emitter.getMaxListeners() + 1);
emitter.once('event', () => {
// do stuff
emitter.setMaxListeners(Math.max(emitter.getMaxListeners() - 1, 0));
}); +
import { EventEmitter } from 'node:events';
const emitter = new EventEmitter();
emitter.setMaxListeners(emitter.getMaxListeners() + 1);
emitter.once('event', () => {
// do stuff
emitter.setMaxListeners(Math.max(emitter.getMaxListeners() - 1, 0));
});

The --trace-warnings command-line flag can be used to display the @@ -70,113 +75,150 @@ listeners, respectively. Its name property is set to 'MaxListenersExceededWarning'.

v0.11.2

-
errorMonitor: typeof errorMonitor

This symbol shall be used to install a listener for only monitoring 'error' events. Listeners installed using this symbol are called before the regular 'error' listeners are called.

+
errorMonitor: typeof errorMonitor

This symbol shall be used to install a listener for only monitoring 'error' events. Listeners installed using this symbol are called before the regular 'error' listeners are called.

Installing a listener using this symbol does not change the behavior once an 'error' event is emitted. Therefore, the process will still crash if no regular 'error' listener is installed.

v13.6.0, v12.17.0

-

Methods

  • Type Parameters

    • K

    Parameters

    • error: Error
    • event: string | symbol
    • Rest...args: AnyRest

    Returns void

  • Alias for emitter.on(eventName, listener).

    +

Methods

  • Alias for emitter.on(eventName, listener).

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.26

    -
  • draw

    Draws a card from the top of the deck. -Removes and returns the top card from the deck, or undefined if the deck is empty.

    -

    deck:drawn : Emits a deck:drawn event when a card is drawn.

    -
    const deck = new Deck();
    const drawnCard = deck.draw();
    console.log(drawnCard?.toString()); +Removes and returns the top card from the deck, or undefined if the deck is empty. +deck:drawn : Emits a deck:drawn event when a card is drawn.

    +

    Returns undefined | CardInterface

    Returns the drawn card or undefined if no cards remain.

    +
    const deck = new Deck();
    const drawnCard = deck.draw();
    console.log(drawnCard?.toString()); // "A of Spades"
    -
  • Synchronously calls each of the listeners registered for the event named eventName, in the order they were registered, passing the supplied arguments +

  • Synchronously calls each of the listeners registered for the event named eventName, in the order they were registered, passing the supplied arguments to each.

    Returns true if the event had listeners, false otherwise.

    -
    import { EventEmitter } from 'node:events';
    const myEmitter = new EventEmitter();

    // First listener
    myEmitter.on('event', function firstListener() {
    console.log('Helloooo! first listener');
    });
    // Second listener
    myEmitter.on('event', function secondListener(arg1, arg2) {
    console.log(`event with parameters ${arg1}, ${arg2} in second listener`);
    });
    // Third listener
    myEmitter.on('event', function thirdListener(...args) {
    const parameters = args.join(', ');
    console.log(`event with parameters ${parameters} in third listener`);
    });

    console.log(myEmitter.listeners('event'));

    myEmitter.emit('event', 1, 2, 3, 4, 5);

    // Prints:
    // [
    // [Function: firstListener],
    // [Function: secondListener],
    // [Function: thirdListener]
    // ]
    // Helloooo! first listener
    // event with parameters 1, 2 in second listener
    // event with parameters 1, 2, 3, 4, 5 in third listener +
    import { EventEmitter } from 'node:events';
    const myEmitter = new EventEmitter();

    // First listener
    myEmitter.on('event', function firstListener() {
    console.log('Helloooo! first listener');
    });
    // Second listener
    myEmitter.on('event', function secondListener(arg1, arg2) {
    console.log(`event with parameters ${arg1}, ${arg2} in second listener`);
    });
    // Third listener
    myEmitter.on('event', function thirdListener(...args) {
    const parameters = args.join(', ');
    console.log(`event with parameters ${parameters} in third listener`);
    });

    console.log(myEmitter.listeners('event'));

    myEmitter.emit('event', 1, 2, 3, 4, 5);

    // Prints:
    // [
    // [Function: firstListener],
    // [Function: secondListener],
    // [Function: thirdListener]
    // ]
    // Helloooo! first listener
    // event with parameters 1, 2 in second listener
    // event with parameters 1, 2, 3, 4, 5 in third listener

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • Rest...args: AnyRest

    Returns boolean

    v0.1.26

    -
  • Returns an array listing the events for which the emitter has registered +

  • The emitEvent method is a public method for emitting events, with an optional configuration that allows +middleware processing. Middleware functions can intercept and transform the event before it reaches the listeners, +allowing custom validation or data modifications.

    +

    This method enables flexible event emission with support for middleware, providing a robust event processing +mechanism in the BaseEventEmitter. It’s useful for customizing event behavior based on application-specific needs.

    +

    N/A

    +

    N/A

    +

    This method can emit any event specified by eventName, which can then be processed by middleware functions if defined.

    +
      +
    • eventName: string - The name of the event to emit.
    • +
    • options: { event: { data: { [key: string]: any }; [key: string]: any; }, middlewares?: Array<(event: BaseEventInterface, next: () => void) => void | false> } +
        +
      • event - The primary event data to emit, containing specific details.
      • +
      • middlewares - An optional array of middleware functions that process the event before emission.
      • +
      +
    • +
    +
      +
    • eventName must be a valid string.
    • +
    • options.event should include relevant data for the event. If middlewares are provided, they should be functions with an event and next parameter.
    • +
    +
      +
    • void - This method does not return a value.
    • +
    +

    Use this method to emit events with middleware-based customization, which allows for specific processing +logic or transformations before the event reaches listeners.

    +

    Parameters

    • eventName: string

      The name of the event to emit.

      +
    • options: {
          event: {
              data: {
                  [key: string]: any;
              };
              [key: string]: any;
          };
          middlewares?: ((event: BaseEventInterface<any>, next: (() => void)) => false | void)[];
      }

      Configuration for the event and optional middleware functions.

      +
      • event: {
            data: {
                [key: string]: any;
            };
            [key: string]: any;
        }
        • [key: string]: any
        • data: {
              [key: string]: any;
          }
          • [key: string]: any
      • Optionalmiddlewares?: ((event: BaseEventInterface<any>, next: (() => void)) => false | void)[]

    Returns void

    emitter.emitEvent("game:started", {
    event: { data: { gameId: "001", status: "active" } },
    middlewares: [
    (event, next) => { console.log("Processing event:", event); next(); },
    (event, next) => { event.data.processed = true; next(); }
    ]
    }); +
    + +
  • Returns an array listing the events for which the emitter has registered listeners. The values in the array are strings or Symbols.

    -
    import { EventEmitter } from 'node:events';

    const myEE = new EventEmitter();
    myEE.on('foo', () => {});
    myEE.on('bar', () => {});

    const sym = Symbol('symbol');
    myEE.on(sym, () => {});

    console.log(myEE.eventNames());
    // Prints: [ 'foo', 'bar', Symbol(symbol) ] +
    import { EventEmitter } from 'node:events';

    const myEE = new EventEmitter();
    myEE.on('foo', () => {});
    myEE.on('bar', () => {});

    const sym = Symbol('symbol');
    myEE.on(sym, () => {});

    console.log(myEE.eventNames());
    // Prints: [ 'foo', 'bar', Symbol(symbol) ]

    Returns (string | symbol)[]

    v6.0.0

    -
  • Returns the current max listener value for the EventEmitter which is either set by emitter.setMaxListeners(n) or defaults to defaultMaxListeners.

    Returns number

    v1.0.0

    -
  • Returns the number of listeners listening for the event named eventName. If listener is provided, it will return how many times the listener is found in the list of the listeners of the event.

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event being listened for

    • Optionallistener: Function

      The event handler function

    Returns number

    v3.2.0

    -
  • Returns a copy of the array of listeners for the event named eventName.

    -
    server.on('connection', (stream) => {
    console.log('someone connected!');
    });
    console.log(util.inspect(server.listeners('connection')));
    // Prints: [ [Function] ] +
  • Returns a copy of the array of listeners for the event named eventName.

    +
    server.on('connection', (stream) => {
    console.log('someone connected!');
    });
    console.log(util.inspect(server.listeners('connection')));
    // Prints: [ [Function] ]

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

    Returns Function[]

    v0.1.26

    -
  • Alias for emitter.removeListener().

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v10.0.0

    -
  • Adds the listener function to the end of the listeners array for the event +

  • Adds the listener function to the end of the listeners array for the event named eventName. No checks are made to see if the listener has already been added. Multiple calls passing the same combination of eventName and listener will result in the listener being added, and called, multiple times.

    -
    server.on('connection', (stream) => {
    console.log('someone connected!');
    }); +
    server.on('connection', (stream) => {
    console.log('someone connected!');
    });

    Returns a reference to the EventEmitter, so that calls can be chained.

    By default, event listeners are invoked in the order they are added. The emitter.prependListener() method can be used as an alternative to add the event listener to the beginning of the listeners array.

    -
    import { EventEmitter } from 'node:events';
    const myEE = new EventEmitter();
    myEE.on('foo', () => console.log('a'));
    myEE.prependListener('foo', () => console.log('b'));
    myEE.emit('foo');
    // Prints:
    // b
    // a +
    import { EventEmitter } from 'node:events';
    const myEE = new EventEmitter();
    myEE.on('foo', () => console.log('a'));
    myEE.prependListener('foo', () => console.log('b'));
    myEE.emit('foo');
    // Prints:
    // b
    // a

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

    • listener: ((...args: any[]) => void)

      The callback function

        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.101

    -
  • Adds a one-time listener function for the event named eventName. The +

  • Adds a one-time listener function for the event named eventName. The next time eventName is triggered, this listener is removed and then invoked.

    -
    server.once('connection', (stream) => {
    console.log('Ah, we have our first user!');
    }); +
    server.once('connection', (stream) => {
    console.log('Ah, we have our first user!');
    });

    Returns a reference to the EventEmitter, so that calls can be chained.

    By default, event listeners are invoked in the order they are added. The emitter.prependOnceListener() method can be used as an alternative to add the event listener to the beginning of the listeners array.

    -
    import { EventEmitter } from 'node:events';
    const myEE = new EventEmitter();
    myEE.once('foo', () => console.log('a'));
    myEE.prependOnceListener('foo', () => console.log('b'));
    myEE.emit('foo');
    // Prints:
    // b
    // a +
    import { EventEmitter } from 'node:events';
    const myEE = new EventEmitter();
    myEE.once('foo', () => console.log('a'));
    myEE.prependOnceListener('foo', () => console.log('b'));
    myEE.emit('foo');
    // Prints:
    // b
    // a

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

    • listener: ((...args: any[]) => void)

      The callback function

        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.3.0

    -
  • Adds the listener function to the beginning of the listeners array for the +

  • Adds the listener function to the beginning of the listeners array for the event named eventName. No checks are made to see if the listener has already been added. Multiple calls passing the same combination of eventName and listener will result in the listener being added, and called, multiple times.

    -
    server.prependListener('connection', (stream) => {
    console.log('someone connected!');
    }); +
    server.prependListener('connection', (stream) => {
    console.log('someone connected!');
    });

    Returns a reference to the EventEmitter, so that calls can be chained.

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

    • listener: ((...args: any[]) => void)

      The callback function

        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v6.0.0

    -
  • Adds a one-timelistener function for the event named eventName to the beginning of the listeners array. The next time eventName is triggered, this +

  • Adds a one-timelistener function for the event named eventName to the beginning of the listeners array. The next time eventName is triggered, this listener is removed, and then invoked.

    -
    server.prependOnceListener('connection', (stream) => {
    console.log('Ah, we have our first user!');
    }); +
    server.prependOnceListener('connection', (stream) => {
    console.log('Ah, we have our first user!');
    });

    Returns a reference to the EventEmitter, so that calls can be chained.

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

    • listener: ((...args: any[]) => void)

      The callback function

        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v6.0.0

    -
  • Returns a copy of the array of listeners for the event named eventName, including any wrappers (such as those created by .once()).

    -
    import { EventEmitter } from 'node:events';
    const emitter = new EventEmitter();
    emitter.once('log', () => console.log('log once'));

    // Returns a new Array with a function `onceWrapper` which has a property
    // `listener` which contains the original listener bound above
    const listeners = emitter.rawListeners('log');
    const logFnWrapper = listeners[0];

    // Logs "log once" to the console and does not unbind the `once` event
    logFnWrapper.listener();

    // Logs "log once" to the console and removes the listener
    logFnWrapper();

    emitter.on('log', () => console.log('log persistently'));
    // Will return a new Array with a single function bound by `.on()` above
    const newListeners = emitter.rawListeners('log');

    // Logs "log persistently" twice
    newListeners[0]();
    emitter.emit('log'); +
    import { EventEmitter } from 'node:events';
    const emitter = new EventEmitter();
    emitter.once('log', () => console.log('log once'));

    // Returns a new Array with a function `onceWrapper` which has a property
    // `listener` which contains the original listener bound above
    const listeners = emitter.rawListeners('log');
    const logFnWrapper = listeners[0];

    // Logs "log once" to the console and does not unbind the `once` event
    logFnWrapper.listener();

    // Logs "log once" to the console and removes the listener
    logFnWrapper();

    emitter.on('log', () => console.log('log persistently'));
    // Will return a new Array with a single function bound by `.on()` above
    const newListeners = emitter.rawListeners('log');

    // Logs "log persistently" twice
    newListeners[0]();
    emitter.emit('log');

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

    Returns Function[]

    v9.4.0

    -
  • Removes all listeners, or those of the specified eventName.

    It is bad practice to remove listeners added elsewhere in the code, particularly when the EventEmitter instance was created by some other component or module (e.g. sockets or file streams).

    Returns a reference to the EventEmitter, so that calls can be chained.

    Parameters

    • OptionaleventName: string | symbol

    Returns this

    v0.1.26

    -
  • Removes the specified listener from the listener array for the event named eventName.

    -
    const callback = (stream) => {
    console.log('someone connected!');
    };
    server.on('connection', callback);
    // ...
    server.removeListener('connection', callback); +
  • Removes the specified listener from the listener array for the event named eventName.

    +
    const callback = (stream) => {
    console.log('someone connected!');
    };
    server.on('connection', callback);
    // ...
    server.removeListener('connection', callback);

    removeListener() will remove, at most, one instance of a listener from the @@ -186,7 +228,7 @@

    Once an event is emitted, all listeners attached to it at the time of emitting are called in order. This implies that any removeListener() or removeAllListeners() calls after emitting and before the last listener finishes execution will not remove them fromemit() in progress. Subsequent events behave as expected.

    -
    import { EventEmitter } from 'node:events';
    class MyEmitter extends EventEmitter {}
    const myEmitter = new MyEmitter();

    const callbackA = () => {
    console.log('A');
    myEmitter.removeListener('event', callbackB);
    };

    const callbackB = () => {
    console.log('B');
    };

    myEmitter.on('event', callbackA);

    myEmitter.on('event', callbackB);

    // callbackA removes listener callbackB but it will still be called.
    // Internal listener array at time of emit [callbackA, callbackB]
    myEmitter.emit('event');
    // Prints:
    // A
    // B

    // callbackB is now removed.
    // Internal listener array [callbackA]
    myEmitter.emit('event');
    // Prints:
    // A +
    import { EventEmitter } from 'node:events';
    class MyEmitter extends EventEmitter {}
    const myEmitter = new MyEmitter();

    const callbackA = () => {
    console.log('A');
    myEmitter.removeListener('event', callbackB);
    };

    const callbackB = () => {
    console.log('B');
    };

    myEmitter.on('event', callbackA);

    myEmitter.on('event', callbackB);

    // callbackA removes listener callbackB but it will still be called.
    // Internal listener array at time of emit [callbackA, callbackB]
    myEmitter.emit('event');
    // Prints:
    // A
    // B

    // callbackB is now removed.
    // Internal listener array [callbackA]
    myEmitter.emit('event');
    // Prints:
    // A

    Because listeners are managed using an internal array, calling this will @@ -197,24 +239,24 @@

    When a single function has been added as a handler multiple times for a single event (as in the example below), removeListener() will remove the most recently added instance. In the example the once('ping') listener is removed:

    -
    import { EventEmitter } from 'node:events';
    const ee = new EventEmitter();

    function pong() {
    console.log('pong');
    }

    ee.on('ping', pong);
    ee.once('ping', pong);
    ee.removeListener('ping', pong);

    ee.emit('ping');
    ee.emit('ping'); +
    import { EventEmitter } from 'node:events';
    const ee = new EventEmitter();

    function pong() {
    console.log('pong');
    }

    ee.on('ping', pong);
    ee.once('ping', pong);
    ee.removeListener('ping', pong);

    ee.emit('ping');
    ee.emit('ping');

    Returns a reference to the EventEmitter, so that calls can be chained.

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.26

    -
  • By default EventEmitters will print a warning if more than 10 listeners are added for a particular event. This is a useful default that helps finding memory leaks. The emitter.setMaxListeners() method allows the limit to be modified for this specific EventEmitter instance. The value can be set to Infinity (or 0) to indicate an unlimited number of listeners.

    Returns a reference to the EventEmitter, so that calls can be chained.

    Parameters

    • n: number

    Returns this

    v0.3.5

    -
  • Returns void

    shuffle

    -

    Shuffles the deck of cards using the Fisher-Yates algorithm.

    -

    deck:shuffled Emits a deck:shuffled event after the deck is shuffled.

    -
    const deck = new Deck();
    deck.shuffle(); +
  • shuffle

    +

    Shuffles the deck of cards using the Fisher-Yates algorithm. +deck:shuffled Emits a deck:shuffled event after the deck is shuffled.

    +

    Returns void

    const deck = new Deck();
    deck.shuffle();
    -
  • Experimental

    Listens once to the abort event on the provided signal.

    Listening to the abort event on abort signals is unsafe and may lead to resource leaks since another third party with the signal can call e.stopImmediatePropagation(). Unfortunately Node.js cannot change @@ -224,39 +266,39 @@ two issues by listening to the event such that stopImmediatePropagation does not prevent the listener from running.

    Returns a disposable so that it may be unsubscribed from more easily.

    -
    import { addAbortListener } from 'node:events';

    function example(signal) {
    let disposable;
    try {
    signal.addEventListener('abort', (e) => e.stopImmediatePropagation());
    disposable = addAbortListener(signal, (e) => {
    // Do something when signal is aborted.
    });
    } finally {
    disposable?.[Symbol.dispose]();
    }
    } +
    import { addAbortListener } from 'node:events';

    function example(signal) {
    let disposable;
    try {
    signal.addEventListener('abort', (e) => e.stopImmediatePropagation());
    disposable = addAbortListener(signal, (e) => {
    // Do something when signal is aborted.
    });
    } finally {
    disposable?.[Symbol.dispose]();
    }
    }

    Parameters

    • signal: AbortSignal
    • resource: ((event: Event) => void)
        • (event): void
        • Parameters

          • event: Event

          Returns void

    Returns Disposable

    Disposable that removes the abort listener.

    v20.5.0

    -
  • Returns a copy of the array of listeners for the event named eventName.

    +
  • Returns a copy of the array of listeners for the event named eventName.

    For EventEmitters this behaves exactly the same as calling .listeners on the emitter.

    For EventTargets this is the only way to get the event listeners for the event target. This is useful for debugging and diagnostic purposes.

    -
    import { getEventListeners, EventEmitter } from 'node:events';

    {
    const ee = new EventEmitter();
    const listener = () => console.log('Events are fun');
    ee.on('foo', listener);
    console.log(getEventListeners(ee, 'foo')); // [ [Function: listener] ]
    }
    {
    const et = new EventTarget();
    const listener = () => console.log('Events are fun');
    et.addEventListener('foo', listener);
    console.log(getEventListeners(et, 'foo')); // [ [Function: listener] ]
    } +
    import { getEventListeners, EventEmitter } from 'node:events';

    {
    const ee = new EventEmitter();
    const listener = () => console.log('Events are fun');
    ee.on('foo', listener);
    console.log(getEventListeners(ee, 'foo')); // [ [Function: listener] ]
    }
    {
    const et = new EventTarget();
    const listener = () => console.log('Events are fun');
    et.addEventListener('foo', listener);
    console.log(getEventListeners(et, 'foo')); // [ [Function: listener] ]
    }

    Parameters

    • emitter: EventEmitter<DefaultEventMap> | EventTarget
    • name: string | symbol

    Returns Function[]

    v15.2.0, v14.17.0

    -
  • Returns the currently set max amount of listeners.

    +
  • Returns the currently set max amount of listeners.

    For EventEmitters this behaves exactly the same as calling .getMaxListeners on the emitter.

    For EventTargets this is the only way to get the max event listeners for the event target. If the number of event handlers on a single EventTarget exceeds the max set, the EventTarget will print a warning.

    -
    import { getMaxListeners, setMaxListeners, EventEmitter } from 'node:events';

    {
    const ee = new EventEmitter();
    console.log(getMaxListeners(ee)); // 10
    setMaxListeners(11, ee);
    console.log(getMaxListeners(ee)); // 11
    }
    {
    const et = new EventTarget();
    console.log(getMaxListeners(et)); // 10
    setMaxListeners(11, et);
    console.log(getMaxListeners(et)); // 11
    } +
    import { getMaxListeners, setMaxListeners, EventEmitter } from 'node:events';

    {
    const ee = new EventEmitter();
    console.log(getMaxListeners(ee)); // 10
    setMaxListeners(11, ee);
    console.log(getMaxListeners(ee)); // 11
    }
    {
    const et = new EventTarget();
    console.log(getMaxListeners(et)); // 10
    setMaxListeners(11, et);
    console.log(getMaxListeners(et)); // 11
    }

    Parameters

    • emitter: EventEmitter<DefaultEventMap> | EventTarget

    Returns number

    v19.9.0

    -
  • A class method that returns the number of listeners for the given eventName registered on the given emitter.

    -
    import { EventEmitter, listenerCount } from 'node:events';

    const myEmitter = new EventEmitter();
    myEmitter.on('event', () => {});
    myEmitter.on('event', () => {});
    console.log(listenerCount(myEmitter, 'event'));
    // Prints: 2 +
  • A class method that returns the number of listeners for the given eventName registered on the given emitter.

    +
    import { EventEmitter, listenerCount } from 'node:events';

    const myEmitter = new EventEmitter();
    myEmitter.on('event', () => {});
    myEmitter.on('event', () => {});
    console.log(listenerCount(myEmitter, 'event'));
    // Prints: 2

    Parameters

    • emitter: EventEmitter<DefaultEventMap>

      The emitter to query

    • eventName: string | symbol

      The event name

    Returns number

    v0.9.12

    Since v3.2.0 - Use listenerCount instead.

    -
  • import { on, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ee = new EventEmitter();

    // Emit later on
    process.nextTick(() => {
    ee.emit('foo', 'bar');
    ee.emit('foo', 42);
    });

    for await (const event of on(ee, 'foo')) {
    // The execution of this inner block is synchronous and it
    // processes one event at a time (even with await). Do not use
    // if concurrent execution is required.
    console.log(event); // prints ['bar'] [42]
    }
    // Unreachable here +
  • import { on, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ee = new EventEmitter();

    // Emit later on
    process.nextTick(() => {
    ee.emit('foo', 'bar');
    ee.emit('foo', 42);
    });

    for await (const event of on(ee, 'foo')) {
    // The execution of this inner block is synchronous and it
    // processes one event at a time (even with await). Do not use
    // if concurrent execution is required.
    console.log(event); // prints ['bar'] [42]
    }
    // Unreachable here

    Returns an AsyncIterator that iterates eventName events. It will throw @@ -264,40 +306,40 @@ exiting the loop. The value returned by each iteration is an array composed of the emitted event arguments.

    An AbortSignal can be used to cancel waiting on events:

    -
    import { on, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ac = new AbortController();

    (async () => {
    const ee = new EventEmitter();

    // Emit later on
    process.nextTick(() => {
    ee.emit('foo', 'bar');
    ee.emit('foo', 42);
    });

    for await (const event of on(ee, 'foo', { signal: ac.signal })) {
    // The execution of this inner block is synchronous and it
    // processes one event at a time (even with await). Do not use
    // if concurrent execution is required.
    console.log(event); // prints ['bar'] [42]
    }
    // Unreachable here
    })();

    process.nextTick(() => ac.abort()); +
    import { on, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ac = new AbortController();

    (async () => {
    const ee = new EventEmitter();

    // Emit later on
    process.nextTick(() => {
    ee.emit('foo', 'bar');
    ee.emit('foo', 42);
    });

    for await (const event of on(ee, 'foo', { signal: ac.signal })) {
    // The execution of this inner block is synchronous and it
    // processes one event at a time (even with await). Do not use
    // if concurrent execution is required.
    console.log(event); // prints ['bar'] [42]
    }
    // Unreachable here
    })();

    process.nextTick(() => ac.abort());

    Use the close option to specify an array of event names that will end the iteration:

    -
    import { on, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ee = new EventEmitter();

    // Emit later on
    process.nextTick(() => {
    ee.emit('foo', 'bar');
    ee.emit('foo', 42);
    ee.emit('close');
    });

    for await (const event of on(ee, 'foo', { close: ['close'] })) {
    console.log(event); // prints ['bar'] [42]
    }
    // the loop will exit after 'close' is emitted
    console.log('done'); // prints 'done' +
    import { on, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ee = new EventEmitter();

    // Emit later on
    process.nextTick(() => {
    ee.emit('foo', 'bar');
    ee.emit('foo', 42);
    ee.emit('close');
    });

    for await (const event of on(ee, 'foo', { close: ['close'] })) {
    console.log(event); // prints ['bar'] [42]
    }
    // the loop will exit after 'close' is emitted
    console.log('done'); // prints 'done'

    Parameters

    • emitter: EventEmitter<DefaultEventMap>
    • eventName: string | symbol
    • Optionaloptions: StaticEventEmitterIteratorOptions

    Returns AsyncIterator<any[], any, any>

    An AsyncIterator that iterates eventName events emitted by the emitter

    v13.6.0, v12.16.0

    -
  • Parameters

    • emitter: EventTarget
    • eventName: string
    • Optionaloptions: StaticEventEmitterIteratorOptions

    Returns AsyncIterator<any[], any, any>

  • Creates a Promise that is fulfilled when the EventEmitter emits the given +

  • Parameters

    • emitter: EventTarget
    • eventName: string
    • Optionaloptions: StaticEventEmitterIteratorOptions

    Returns AsyncIterator<any[], any, any>

  • Creates a Promise that is fulfilled when the EventEmitter emits the given event or that is rejected if the EventEmitter emits 'error' while waiting. The Promise will resolve with an array of all the arguments emitted to the given event.

    This method is intentionally generic and works with the web platform EventTarget interface, which has no special'error' event semantics and does not listen to the 'error' event.

    -
    import { once, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ee = new EventEmitter();

    process.nextTick(() => {
    ee.emit('myevent', 42);
    });

    const [value] = await once(ee, 'myevent');
    console.log(value);

    const err = new Error('kaboom');
    process.nextTick(() => {
    ee.emit('error', err);
    });

    try {
    await once(ee, 'myevent');
    } catch (err) {
    console.error('error happened', err);
    } +
    import { once, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ee = new EventEmitter();

    process.nextTick(() => {
    ee.emit('myevent', 42);
    });

    const [value] = await once(ee, 'myevent');
    console.log(value);

    const err = new Error('kaboom');
    process.nextTick(() => {
    ee.emit('error', err);
    });

    try {
    await once(ee, 'myevent');
    } catch (err) {
    console.error('error happened', err);
    }

    The special handling of the 'error' event is only used when events.once() is used to wait for another event. If events.once() is used to wait for the 'error' event itself, then it is treated as any other kind of event without special handling:

    -
    import { EventEmitter, once } from 'node:events';

    const ee = new EventEmitter();

    once(ee, 'error')
    .then(([err]) => console.log('ok', err.message))
    .catch((err) => console.error('error', err.message));

    ee.emit('error', new Error('boom'));

    // Prints: ok boom +
    import { EventEmitter, once } from 'node:events';

    const ee = new EventEmitter();

    once(ee, 'error')
    .then(([err]) => console.log('ok', err.message))
    .catch((err) => console.error('error', err.message));

    ee.emit('error', new Error('boom'));

    // Prints: ok boom

    An AbortSignal can be used to cancel waiting for the event:

    -
    import { EventEmitter, once } from 'node:events';

    const ee = new EventEmitter();
    const ac = new AbortController();

    async function foo(emitter, event, signal) {
    try {
    await once(emitter, event, { signal });
    console.log('event emitted!');
    } catch (error) {
    if (error.name === 'AbortError') {
    console.error('Waiting for the event was canceled!');
    } else {
    console.error('There was an error', error.message);
    }
    }
    }

    foo(ee, 'foo', ac.signal);
    ac.abort(); // Abort waiting for the event
    ee.emit('foo'); // Prints: Waiting for the event was canceled! +
    import { EventEmitter, once } from 'node:events';

    const ee = new EventEmitter();
    const ac = new AbortController();

    async function foo(emitter, event, signal) {
    try {
    await once(emitter, event, { signal });
    console.log('event emitted!');
    } catch (error) {
    if (error.name === 'AbortError') {
    console.error('Waiting for the event was canceled!');
    } else {
    console.error('There was an error', error.message);
    }
    }
    }

    foo(ee, 'foo', ac.signal);
    ac.abort(); // Abort waiting for the event
    ee.emit('foo'); // Prints: Waiting for the event was canceled!

    Parameters

    • emitter: EventEmitter<DefaultEventMap>
    • eventName: string | symbol
    • Optionaloptions: StaticEventEmitterOptions

    Returns Promise<any[]>

    v11.13.0, v10.16.0

    -
  • Parameters

    • emitter: EventTarget
    • eventName: string
    • Optionaloptions: StaticEventEmitterOptions

    Returns Promise<any[]>

  • import { setMaxListeners, EventEmitter } from 'node:events';

    const target = new EventTarget();
    const emitter = new EventEmitter();

    setMaxListeners(5, target, emitter); +
  • Parameters

    • emitter: EventTarget
    • eventName: string
    • Optionaloptions: StaticEventEmitterOptions

    Returns Promise<any[]>

  • import { setMaxListeners, EventEmitter } from 'node:events';

    const target = new EventTarget();
    const emitter = new EventEmitter();

    setMaxListeners(5, target, emitter);

    Parameters

    • Optionaln: number

      A non-negative number. The maximum number of listeners per EventTarget event.

    • Rest...eventTargets: (EventEmitter<DefaultEventMap> | EventTarget)[]

      Zero or more {EventTarget} or {EventEmitter} instances. If none are specified, n is set as the default max for all newly created {EventTarget} and {EventEmitter} objects.

    Returns void

    v15.4.0

    -
+
diff --git a/docs/site/classes/models_logger.Logger.html b/docs/site/classes/models_logger.Logger.html new file mode 100644 index 0000000..7ba794e --- /dev/null +++ b/docs/site/classes/models_logger.Logger.html @@ -0,0 +1,213 @@ +Logger | casinojs

Logger

+

Provides logging functionality for the library, supporting both file-based and console logging. This class +allows configurable logging levels and environment-specific log directories for flexible and organized logging.

+

The Logger class is designed to capture and store logs with various severity levels. It centralizes +logging within the library, ensuring that messages are consistently recorded and easily accessible for +debugging, monitoring, and auditing purposes.

+

Implements LoggerInterface, adhering to standardized log methods and configuration options.

+

The Logger class includes the following methods:

+
    +
  • log(level: LogLevel, message: string, data?: Record<string, any>): Promise<void>: Logs a message with a specified level and optional data context.
  • +
  • initializeLogDirectory(): Initializes the log directory structure if it does not exist.
  • +
  • setupLogDirPath(basePath: string): string: Configures the base path for log files, adding environment-specific subdirectories.
  • +
  • __writeLogToFile(level: LogLevel, message: string): Promise<void>: Writes a formatted log message to a file based on the log level and date.
  • +
+

Instantiate the Logger with a configuration to customize logging behavior, including specifying the log +directory path and enabling console output. Once instantiated, use the log method to record messages +with various levels, which are stored in both files and optionally displayed in the console.

+
const logger = new Logger({ logDirPath: "./logs", enableConsoleLogging: true });
logger.log(LogLevel.INFO, "Application started"); +
+ +

Implements

Constructors

  • Initializes a new instance of the Logger class with optional configuration settings.

    +

    This constructor configures the Logger class by initializing settings such as the log directory path, +console logging preferences, and environment setup.

    +
      +
    • config?: LoggerConfig - Optional. A configuration object for log directory path and console logging settings. +
        +
      • logDirPath: string - Specifies the base directory for log files. Defaults to ./logs if not provided.
      • +
      • enableConsoleLogging: boolean - Determines if logs should also appear in the console. Defaults to true.
      • +
      +
    • +
    +
      +
    • This method requires no mandatory parameters; configuration is optional.
    • +
    +
      +
    • void - The constructor does not return a value.
    • +
    +

    Instantiates the Logger with custom configurations, which dictate logging behavior across the library.

    +

    Parameters

    • Optionalconfig: LoggerConfig

      Optional. Configuration for log directory path and console logging settings.

      +

    Returns Logger

    const logger = new Logger({ logDirPath: "./logs", enableConsoleLogging: true });
    // Logs will be saved in "./logs" directory and printed to the console. +
    + +

Methods

  • The disableConsoleLogging method disables console logging for the Logger instance. When disabled, log +entries are only written to log files and are no longer displayed in the console.

    +

    This method provides a way to turn off console output of log messages, which is useful for reducing console +clutter in production environments where log messages are typically directed only to log files.

    +

    N/A

    +

    N/A

    +

    N/A

    +
      +
    • This method requires no parameters and should be called when console logging is no longer needed.
    • +
    +
      +
    • boolean - Returns false indicating console logging is now disabled.
    • +
    +

    Use this method to disable console logging, especially in production environments where log messages +should only be stored in log files.

    +

    Returns boolean

      +
    • false indicating that console logging is disabled.
    • +
    +
    // Disable console logging for production
    logger.disableConsoleLogging();
    logger.log(LogLevel.INFO, "Console logging disabled"); +
    + +
  • The enableConsoleLogging method enables console logging for the Logger instance. When activated, all log +entries are displayed in the console in addition to being recorded in log files.

    +

    This method provides a way to turn on real-time logging output to the console, which is particularly useful +for development and debugging purposes, allowing for immediate feedback on logged events.

    +

    N/A

    +

    N/A

    +

    N/A

    +
      +
    • This method requires no parameters and should be called when console logging is desired.
    • +
    +
      +
    • boolean - Returns true indicating console logging is now enabled.
    • +
    +

    Use this method to enable console logging for quick visibility of log messages during debugging or development.

    +

    Returns boolean

      +
    • true indicating that console logging is enabled.
    • +
    +
    // Enable console logging for immediate log output
    logger.enableConsoleLogging();
    logger.log(LogLevel.INFO, "Console logging enabled"); +
    + +
  • Retrieves the current status of console logging, indicating if logs are also output to the console.

    +

    This getter provides access to the console logging status, useful for checking if real-time log output is enabled.

    +

    N/A

    +
      +
    • No parameters or dependencies are needed to access this property.
    • +
    +
      +
    • boolean - true if console logging is enabled, false otherwise.
    • +
    +

    This method is used to verify whether logs are configured to appear in the console.

    +

    Returns boolean

      +
    • The console logging status.
    • +
    +
    const logger = Logger.getInstance();
    console.log(logger.getConsoleLogging());
    // Console Output: true (or false based on configuration) +
    + +
  • Retrieves the environment setting currently configured in the Logger instance, such as "development" or "production".

    +

    This getter method allows access to the environment setting, which determines where logs are stored based on runtime context.

    +

    N/A

    +
      +
    • No parameters are required to retrieve this property.
    • +
    +
      +
    • string - The environment setting in use.
    • +
    +

    Use this method to check the runtime environment configured for the Logger.

    +

    Returns string

      +
    • The current environment setting (e.g., "development").
    • +
    +
    const logger = Logger.getInstance();
    console.log(logger.getEnv());
    // Console Output: "development" +
    + +
  • Retrieves the path of the directory where logs are stored, based on the Logger's configuration and environment setting.

    +

    This method allows access to the path where logs are written, organized by environment. Useful for managing and verifying log storage locations.

    +

    N/A

    +
      +
    • The logs directory should be accessible or creatable by the system.
    • +
    +
      +
    • string - The full directory path for log storage.
    • +
    +

    This method is used to determine where logs are stored on the filesystem, ensuring accessibility and organization.

    +

    Returns string

      +
    • The directory path where logs are stored.
    • +
    +
    const logger = Logger.getInstance();
    console.log(logger.getLogsDirPath());
    // Console Output: "./logs/development" (example for development environment) +
    + +
  • The log method logs a message at a specified severity level with optional data. It supports both console +output and file-based logging, structuring logs based on environment and log level.

    +

    This method serves as the core logging function, allowing consistent recording of messages across the library. +By accepting a log level and optional data, it provides detailed logging for events, errors, or informational messages.

    +

    Implements the logging functionality from the LoggerInterface.

    +

    N/A

    +
      +
    • Console Logging: If console logging is enabled, the message is output to the console.
    • +
    • File Logging: Each log entry is stored in a file based on log level and date for organized access and auditing.
    • +
    +
      +
    • level: LogLevel - The log's severity level, which determines where it appears. Valid options include: +
        +
      • LogLevel.INFO: Informational messages indicating standard operations.
      • +
      • LogLevel.WARN: Warnings that indicate potential issues.
      • +
      • LogLevel.ERROR: Critical errors requiring attention.
      • +
      +
    • +
    • message: string - The primary log message, ideally concise and descriptive.
    • +
    • data?: Record<string, any> - Optional. Additional data to provide context, such as error codes or debug info.
    • +
    +
      +
    • level must be a recognized value in LogLevel.
    • +
    • message should clearly describe the log's purpose, providing insight into system operations.
    • +
    +
      +
    • Promise<void> - Resolves when the log entry is recorded, either in the console or file.
    • +
    +

    Use this method to log critical information across the library, choosing the appropriate LogLevel to match +the importance and visibility requirements of the message.

    +

    Parameters

    • level: LogLevel

      The log's severity level.

      +
    • message: string

      The main log message.

      +
    • Optionaldata: Record<string, any>

      Optional additional data for context.

      +

    Returns Promise<void>

      +
    • A promise that resolves when logging completes.
    • +
    +
    // Logs a critical error with associated data
    logger.log(LogLevel.ERROR, "Database connection failed", { errorCode: "DB_CONN_ERR", timestamp: Date.now() });

    // Logs an informational message
    logger.log(LogLevel.INFO, "Server started successfully"); +
    + +
  • Provides access to the singleton instance of the Logger class. This method ensures that only one instance of +the logger is created and shared across the application, providing a centralized logging management system. +It initializes the logger with a configuration if not already initialized.

    +

    The getInstance method enforces the Singleton pattern, ensuring that a single instance of the logger is used +across the entire library or application. This approach helps maintain consistency in logging configuration, +making sure that all logs are handled by a single, globally accessible instance.

    +

    N/A

    +

    N/A

    +

    N/A

    +
      +
    • config?: LoggerConfig - An optional configuration object for customizing the logger instance: +
        +
      • logDirPath: string - Optional. Specifies the directory path for storing log files. Defaults to a standard location if omitted.
      • +
      • enableConsoleLogging: boolean - Optional. Enables or disables logging to the console. Defaults to true if omitted.
      • +
      +
    • +
    +
      +
    • The logger configuration should be provided only once at initialization; subsequent calls to getInstance +ignore additional configurations.
    • +
    +
      +
    • Logger - Returns the singleton instance of the Logger class, ensuring that the same instance is shared +throughout the application.
    • +
    +

    Use this method to retrieve the Logger instance wherever logging is required. This method guarantees that the +same instance of the Logger is used, maintaining a consistent logging configuration.

    +

    Parameters

    • Optionalconfig: LoggerConfig

      Configuration options for the logger instance.

      +

    Returns Logger

      +
    • The singleton instance of Logger.
    • +
    +
    // Initialize and retrieve the Logger instance with configuration
    const logger = Logger.getInstance({ logDirPath: "./logs", enableConsoleLogging: true });
    logger.log(LogLevel.INFO, "Application started"); // Logs with the singleton logger instance

    // Retrieve the existing Logger instance without reinitializing
    const anotherLoggerReference = Logger.getInstance();
    anotherLoggerReference.log(LogLevel.ERROR, "Unexpected error occurred");
    // Both `logger` and `anotherLoggerReference` refer to the same Logger instance +
    + +
diff --git a/docs/site/classes/models_pokerGame.PokerGame.html b/docs/site/classes/models_pokerGame.PokerGame.html new file mode 100644 index 0000000..3abf1cf --- /dev/null +++ b/docs/site/classes/models_pokerGame.PokerGame.html @@ -0,0 +1,326 @@ +PokerGame | casinojs

PokerGame +Represents the current PokerGame being played at the PokerTable. +Manages the deck, community cards, and game phases, such as pre-flop, flop, turn, and river.

+

Hierarchy (view full)

Implements

Constructors

Properties

captureRejections: boolean

Value: boolean

+

Change the default captureRejections option on all new EventEmitter objects.

+

v13.4.0, v12.16.0

+
captureRejectionSymbol: typeof captureRejectionSymbol

Value: Symbol.for('nodejs.rejection')

+

See how to write a custom rejection handler.

+

v13.4.0, v12.16.0

+
defaultMaxListeners: number

By default, a maximum of 10 listeners can be registered for any single +event. This limit can be changed for individual EventEmitter instances +using the emitter.setMaxListeners(n) method. To change the default +for allEventEmitter instances, the events.defaultMaxListeners property +can be used. If this value is not a positive number, a RangeError is thrown.

+

Take caution when setting the events.defaultMaxListeners because the +change affects all EventEmitter instances, including those created before +the change is made. However, calling emitter.setMaxListeners(n) still has +precedence over events.defaultMaxListeners.

+

This is not a hard limit. The EventEmitter instance will allow +more listeners to be added but will output a trace warning to stderr indicating +that a "possible EventEmitter memory leak" has been detected. For any single +EventEmitter, the emitter.getMaxListeners() and emitter.setMaxListeners() methods can be used to +temporarily avoid this warning:

+
import { EventEmitter } from 'node:events';
const emitter = new EventEmitter();
emitter.setMaxListeners(emitter.getMaxListeners() + 1);
emitter.once('event', () => {
// do stuff
emitter.setMaxListeners(Math.max(emitter.getMaxListeners() - 1, 0));
}); +
+ +

The --trace-warnings command-line flag can be used to display the +stack trace for such warnings.

+

The emitted warning can be inspected with process.on('warning') and will +have the additional emitter, type, and count properties, referring to +the event emitter instance, the event's name and the number of attached +listeners, respectively. +Its name property is set to 'MaxListenersExceededWarning'.

+

v0.11.2

+
errorMonitor: typeof errorMonitor

This symbol shall be used to install a listener for only monitoring 'error' events. Listeners installed using this symbol are called before the regular 'error' listeners are called.

+

Installing a listener using this symbol does not change the behavior once an 'error' event is emitted. Therefore, the process will still crash if no +regular 'error' listener is installed.

+

v13.6.0, v12.17.0

+

Methods

  • Alias for emitter.on(eventName, listener).

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.26

    +
  • Synchronously calls each of the listeners registered for the event named eventName, in the order they were registered, passing the supplied arguments +to each.

    +

    Returns true if the event had listeners, false otherwise.

    +
    import { EventEmitter } from 'node:events';
    const myEmitter = new EventEmitter();

    // First listener
    myEmitter.on('event', function firstListener() {
    console.log('Helloooo! first listener');
    });
    // Second listener
    myEmitter.on('event', function secondListener(arg1, arg2) {
    console.log(`event with parameters ${arg1}, ${arg2} in second listener`);
    });
    // Third listener
    myEmitter.on('event', function thirdListener(...args) {
    const parameters = args.join(', ');
    console.log(`event with parameters ${parameters} in third listener`);
    });

    console.log(myEmitter.listeners('event'));

    myEmitter.emit('event', 1, 2, 3, 4, 5);

    // Prints:
    // [
    // [Function: firstListener],
    // [Function: secondListener],
    // [Function: thirdListener]
    // ]
    // Helloooo! first listener
    // event with parameters 1, 2 in second listener
    // event with parameters 1, 2, 3, 4, 5 in third listener +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • Rest...args: AnyRest

    Returns boolean

    v0.1.26

    +
  • The emitEvent method is a public method for emitting events, with an optional configuration that allows +middleware processing. Middleware functions can intercept and transform the event before it reaches the listeners, +allowing custom validation or data modifications.

    +

    This method enables flexible event emission with support for middleware, providing a robust event processing +mechanism in the BaseEventEmitter. It’s useful for customizing event behavior based on application-specific needs.

    +

    N/A

    +

    N/A

    +

    This method can emit any event specified by eventName, which can then be processed by middleware functions if defined.

    +
      +
    • eventName: string - The name of the event to emit.
    • +
    • options: { event: { data: { [key: string]: any }; [key: string]: any; }, middlewares?: Array<(event: BaseEventInterface, next: () => void) => void | false> } +
        +
      • event - The primary event data to emit, containing specific details.
      • +
      • middlewares - An optional array of middleware functions that process the event before emission.
      • +
      +
    • +
    +
      +
    • eventName must be a valid string.
    • +
    • options.event should include relevant data for the event. If middlewares are provided, they should be functions with an event and next parameter.
    • +
    +
      +
    • void - This method does not return a value.
    • +
    +

    Use this method to emit events with middleware-based customization, which allows for specific processing +logic or transformations before the event reaches listeners.

    +

    Parameters

    • eventName: string

      The name of the event to emit.

      +
    • options: {
          event: {
              data: {
                  [key: string]: any;
              };
              [key: string]: any;
          };
          middlewares?: ((event: BaseEventInterface<any>, next: (() => void)) => false | void)[];
      }

      Configuration for the event and optional middleware functions.

      +
      • event: {
            data: {
                [key: string]: any;
            };
            [key: string]: any;
        }
        • [key: string]: any
        • data: {
              [key: string]: any;
          }
          • [key: string]: any
      • Optionalmiddlewares?: ((event: BaseEventInterface<any>, next: (() => void)) => false | void)[]

    Returns void

    emitter.emitEvent("game:started", {
    event: { data: { gameId: "001", status: "active" } },
    middlewares: [
    (event, next) => { console.log("Processing event:", event); next(); },
    (event, next) => { event.data.processed = true; next(); }
    ]
    }); +
    + +
  • Returns an array listing the events for which the emitter has registered +listeners. The values in the array are strings or Symbols.

    +
    import { EventEmitter } from 'node:events';

    const myEE = new EventEmitter();
    myEE.on('foo', () => {});
    myEE.on('bar', () => {});

    const sym = Symbol('symbol');
    myEE.on(sym, () => {});

    console.log(myEE.eventNames());
    // Prints: [ 'foo', 'bar', Symbol(symbol) ] +
    + +

    Returns (string | symbol)[]

    v6.0.0

    +
  • Returns the number of listeners listening for the event named eventName. +If listener is provided, it will return how many times the listener is found +in the list of the listeners of the event.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event being listened for

      +
    • Optionallistener: Function

      The event handler function

      +

    Returns number

    v3.2.0

    +
  • Returns a copy of the array of listeners for the event named eventName.

    +
    server.on('connection', (stream) => {
    console.log('someone connected!');
    });
    console.log(util.inspect(server.listeners('connection')));
    // Prints: [ [Function] ] +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

    Returns Function[]

    v0.1.26

    +
  • Alias for emitter.removeListener().

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v10.0.0

    +
  • Adds the listener function to the end of the listeners array for the event +named eventName. No checks are made to see if the listener has already +been added. Multiple calls passing the same combination of eventName and +listener will result in the listener being added, and called, multiple times.

    +
    server.on('connection', (stream) => {
    console.log('someone connected!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    By default, event listeners are invoked in the order they are added. The emitter.prependListener() method can be used as an alternative to add the +event listener to the beginning of the listeners array.

    +
    import { EventEmitter } from 'node:events';
    const myEE = new EventEmitter();
    myEE.on('foo', () => console.log('a'));
    myEE.prependListener('foo', () => console.log('b'));
    myEE.emit('foo');
    // Prints:
    // b
    // a +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.101

    +
  • Adds a one-time listener function for the event named eventName. The +next time eventName is triggered, this listener is removed and then invoked.

    +
    server.once('connection', (stream) => {
    console.log('Ah, we have our first user!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    By default, event listeners are invoked in the order they are added. The emitter.prependOnceListener() method can be used as an alternative to add the +event listener to the beginning of the listeners array.

    +
    import { EventEmitter } from 'node:events';
    const myEE = new EventEmitter();
    myEE.once('foo', () => console.log('a'));
    myEE.prependOnceListener('foo', () => console.log('b'));
    myEE.emit('foo');
    // Prints:
    // b
    // a +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.3.0

    +
  • Adds the listener function to the beginning of the listeners array for the +event named eventName. No checks are made to see if the listener has +already been added. Multiple calls passing the same combination of eventName +and listener will result in the listener being added, and called, multiple times.

    +
    server.prependListener('connection', (stream) => {
    console.log('someone connected!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v6.0.0

    +
  • Adds a one-timelistener function for the event named eventName to the beginning of the listeners array. The next time eventName is triggered, this +listener is removed, and then invoked.

    +
    server.prependOnceListener('connection', (stream) => {
    console.log('Ah, we have our first user!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v6.0.0

    +
  • Returns a copy of the array of listeners for the event named eventName, +including any wrappers (such as those created by .once()).

    +
    import { EventEmitter } from 'node:events';
    const emitter = new EventEmitter();
    emitter.once('log', () => console.log('log once'));

    // Returns a new Array with a function `onceWrapper` which has a property
    // `listener` which contains the original listener bound above
    const listeners = emitter.rawListeners('log');
    const logFnWrapper = listeners[0];

    // Logs "log once" to the console and does not unbind the `once` event
    logFnWrapper.listener();

    // Logs "log once" to the console and removes the listener
    logFnWrapper();

    emitter.on('log', () => console.log('log persistently'));
    // Will return a new Array with a single function bound by `.on()` above
    const newListeners = emitter.rawListeners('log');

    // Logs "log persistently" twice
    newListeners[0]();
    emitter.emit('log'); +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

    Returns Function[]

    v9.4.0

    +
  • Removes all listeners, or those of the specified eventName.

    +

    It is bad practice to remove listeners added elsewhere in the code, +particularly when the EventEmitter instance was created by some other +component or module (e.g. sockets or file streams).

    +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Parameters

    • OptionaleventName: string | symbol

    Returns this

    v0.1.26

    +
  • Removes the specified listener from the listener array for the event named eventName.

    +
    const callback = (stream) => {
    console.log('someone connected!');
    };
    server.on('connection', callback);
    // ...
    server.removeListener('connection', callback); +
    + +

    removeListener() will remove, at most, one instance of a listener from the +listener array. If any single listener has been added multiple times to the +listener array for the specified eventName, then removeListener() must be +called multiple times to remove each instance.

    +

    Once an event is emitted, all listeners attached to it at the +time of emitting are called in order. This implies that any removeListener() or removeAllListeners() calls after emitting and before the last listener finishes execution +will not remove them fromemit() in progress. Subsequent events behave as expected.

    +
    import { EventEmitter } from 'node:events';
    class MyEmitter extends EventEmitter {}
    const myEmitter = new MyEmitter();

    const callbackA = () => {
    console.log('A');
    myEmitter.removeListener('event', callbackB);
    };

    const callbackB = () => {
    console.log('B');
    };

    myEmitter.on('event', callbackA);

    myEmitter.on('event', callbackB);

    // callbackA removes listener callbackB but it will still be called.
    // Internal listener array at time of emit [callbackA, callbackB]
    myEmitter.emit('event');
    // Prints:
    // A
    // B

    // callbackB is now removed.
    // Internal listener array [callbackA]
    myEmitter.emit('event');
    // Prints:
    // A +
    + +

    Because listeners are managed using an internal array, calling this will +change the position indices of any listener registered after the listener +being removed. This will not impact the order in which listeners are called, +but it means that any copies of the listener array as returned by +the emitter.listeners() method will need to be recreated.

    +

    When a single function has been added as a handler multiple times for a single +event (as in the example below), removeListener() will remove the most +recently added instance. In the example the once('ping') listener is removed:

    +
    import { EventEmitter } from 'node:events';
    const ee = new EventEmitter();

    function pong() {
    console.log('pong');
    }

    ee.on('ping', pong);
    ee.once('ping', pong);
    ee.removeListener('ping', pong);

    ee.emit('ping');
    ee.emit('ping'); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.26

    +
  • By default EventEmitters will print a warning if more than 10 listeners are +added for a particular event. This is a useful default that helps finding +memory leaks. The emitter.setMaxListeners() method allows the limit to be +modified for this specific EventEmitter instance. The value can be set to Infinity (or 0) to indicate an unlimited number of listeners.

    +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Parameters

    • n: number

    Returns this

    v0.3.5

    +
  • Experimental

    Listens once to the abort event on the provided signal.

    +

    Listening to the abort event on abort signals is unsafe and may +lead to resource leaks since another third party with the signal can +call e.stopImmediatePropagation(). Unfortunately Node.js cannot change +this since it would violate the web standard. Additionally, the original +API makes it easy to forget to remove listeners.

    +

    This API allows safely using AbortSignals in Node.js APIs by solving these +two issues by listening to the event such that stopImmediatePropagation does +not prevent the listener from running.

    +

    Returns a disposable so that it may be unsubscribed from more easily.

    +
    import { addAbortListener } from 'node:events';

    function example(signal) {
    let disposable;
    try {
    signal.addEventListener('abort', (e) => e.stopImmediatePropagation());
    disposable = addAbortListener(signal, (e) => {
    // Do something when signal is aborted.
    });
    } finally {
    disposable?.[Symbol.dispose]();
    }
    } +
    + +

    Parameters

    • signal: AbortSignal
    • resource: ((event: Event) => void)
        • (event): void
        • Parameters

          • event: Event

          Returns void

    Returns Disposable

    Disposable that removes the abort listener.

    +

    v20.5.0

    +
  • Returns a copy of the array of listeners for the event named eventName.

    +

    For EventEmitters this behaves exactly the same as calling .listeners on +the emitter.

    +

    For EventTargets this is the only way to get the event listeners for the +event target. This is useful for debugging and diagnostic purposes.

    +
    import { getEventListeners, EventEmitter } from 'node:events';

    {
    const ee = new EventEmitter();
    const listener = () => console.log('Events are fun');
    ee.on('foo', listener);
    console.log(getEventListeners(ee, 'foo')); // [ [Function: listener] ]
    }
    {
    const et = new EventTarget();
    const listener = () => console.log('Events are fun');
    et.addEventListener('foo', listener);
    console.log(getEventListeners(et, 'foo')); // [ [Function: listener] ]
    } +
    + +

    Parameters

    • emitter: EventEmitter<DefaultEventMap> | EventTarget
    • name: string | symbol

    Returns Function[]

    v15.2.0, v14.17.0

    +
  • Returns the currently set max amount of listeners.

    +

    For EventEmitters this behaves exactly the same as calling .getMaxListeners on +the emitter.

    +

    For EventTargets this is the only way to get the max event listeners for the +event target. If the number of event handlers on a single EventTarget exceeds +the max set, the EventTarget will print a warning.

    +
    import { getMaxListeners, setMaxListeners, EventEmitter } from 'node:events';

    {
    const ee = new EventEmitter();
    console.log(getMaxListeners(ee)); // 10
    setMaxListeners(11, ee);
    console.log(getMaxListeners(ee)); // 11
    }
    {
    const et = new EventTarget();
    console.log(getMaxListeners(et)); // 10
    setMaxListeners(11, et);
    console.log(getMaxListeners(et)); // 11
    } +
    + +

    Parameters

    • emitter: EventEmitter<DefaultEventMap> | EventTarget

    Returns number

    v19.9.0

    +
  • A class method that returns the number of listeners for the given eventName registered on the given emitter.

    +
    import { EventEmitter, listenerCount } from 'node:events';

    const myEmitter = new EventEmitter();
    myEmitter.on('event', () => {});
    myEmitter.on('event', () => {});
    console.log(listenerCount(myEmitter, 'event'));
    // Prints: 2 +
    + +

    Parameters

    • emitter: EventEmitter<DefaultEventMap>

      The emitter to query

      +
    • eventName: string | symbol

      The event name

      +

    Returns number

    v0.9.12

    +

    Since v3.2.0 - Use listenerCount instead.

    +
  • import { on, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ee = new EventEmitter();

    // Emit later on
    process.nextTick(() => {
    ee.emit('foo', 'bar');
    ee.emit('foo', 42);
    });

    for await (const event of on(ee, 'foo')) {
    // The execution of this inner block is synchronous and it
    // processes one event at a time (even with await). Do not use
    // if concurrent execution is required.
    console.log(event); // prints ['bar'] [42]
    }
    // Unreachable here +
    + +

    Returns an AsyncIterator that iterates eventName events. It will throw +if the EventEmitter emits 'error'. It removes all listeners when +exiting the loop. The value returned by each iteration is an array +composed of the emitted event arguments.

    +

    An AbortSignal can be used to cancel waiting on events:

    +
    import { on, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ac = new AbortController();

    (async () => {
    const ee = new EventEmitter();

    // Emit later on
    process.nextTick(() => {
    ee.emit('foo', 'bar');
    ee.emit('foo', 42);
    });

    for await (const event of on(ee, 'foo', { signal: ac.signal })) {
    // The execution of this inner block is synchronous and it
    // processes one event at a time (even with await). Do not use
    // if concurrent execution is required.
    console.log(event); // prints ['bar'] [42]
    }
    // Unreachable here
    })();

    process.nextTick(() => ac.abort()); +
    + +

    Use the close option to specify an array of event names that will end the iteration:

    +
    import { on, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ee = new EventEmitter();

    // Emit later on
    process.nextTick(() => {
    ee.emit('foo', 'bar');
    ee.emit('foo', 42);
    ee.emit('close');
    });

    for await (const event of on(ee, 'foo', { close: ['close'] })) {
    console.log(event); // prints ['bar'] [42]
    }
    // the loop will exit after 'close' is emitted
    console.log('done'); // prints 'done' +
    + +

    Parameters

    • emitter: EventEmitter<DefaultEventMap>
    • eventName: string | symbol
    • Optionaloptions: StaticEventEmitterIteratorOptions

    Returns AsyncIterator<any[], any, any>

    An AsyncIterator that iterates eventName events emitted by the emitter

    +

    v13.6.0, v12.16.0

    +
  • Parameters

    • emitter: EventTarget
    • eventName: string
    • Optionaloptions: StaticEventEmitterIteratorOptions

    Returns AsyncIterator<any[], any, any>

  • Creates a Promise that is fulfilled when the EventEmitter emits the given +event or that is rejected if the EventEmitter emits 'error' while waiting. +The Promise will resolve with an array of all the arguments emitted to the +given event.

    +

    This method is intentionally generic and works with the web platform EventTarget interface, which has no special'error' event +semantics and does not listen to the 'error' event.

    +
    import { once, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ee = new EventEmitter();

    process.nextTick(() => {
    ee.emit('myevent', 42);
    });

    const [value] = await once(ee, 'myevent');
    console.log(value);

    const err = new Error('kaboom');
    process.nextTick(() => {
    ee.emit('error', err);
    });

    try {
    await once(ee, 'myevent');
    } catch (err) {
    console.error('error happened', err);
    } +
    + +

    The special handling of the 'error' event is only used when events.once() is used to wait for another event. If events.once() is used to wait for the +'error' event itself, then it is treated as any other kind of event without +special handling:

    +
    import { EventEmitter, once } from 'node:events';

    const ee = new EventEmitter();

    once(ee, 'error')
    .then(([err]) => console.log('ok', err.message))
    .catch((err) => console.error('error', err.message));

    ee.emit('error', new Error('boom'));

    // Prints: ok boom +
    + +

    An AbortSignal can be used to cancel waiting for the event:

    +
    import { EventEmitter, once } from 'node:events';

    const ee = new EventEmitter();
    const ac = new AbortController();

    async function foo(emitter, event, signal) {
    try {
    await once(emitter, event, { signal });
    console.log('event emitted!');
    } catch (error) {
    if (error.name === 'AbortError') {
    console.error('Waiting for the event was canceled!');
    } else {
    console.error('There was an error', error.message);
    }
    }
    }

    foo(ee, 'foo', ac.signal);
    ac.abort(); // Abort waiting for the event
    ee.emit('foo'); // Prints: Waiting for the event was canceled! +
    + +

    Parameters

    • emitter: EventEmitter<DefaultEventMap>
    • eventName: string | symbol
    • Optionaloptions: StaticEventEmitterOptions

    Returns Promise<any[]>

    v11.13.0, v10.16.0

    +
  • Parameters

    • emitter: EventTarget
    • eventName: string
    • Optionaloptions: StaticEventEmitterOptions

    Returns Promise<any[]>

  • import { setMaxListeners, EventEmitter } from 'node:events';

    const target = new EventTarget();
    const emitter = new EventEmitter();

    setMaxListeners(5, target, emitter); +
    + +

    Parameters

    • Optionaln: number

      A non-negative number. The maximum number of listeners per EventTarget event.

      +
    • Rest...eventTargets: (EventEmitter<DefaultEventMap> | EventTarget)[]

      Zero or more {EventTarget} or {EventEmitter} instances. If none are specified, n is set as the default max for all newly created {EventTarget} and {EventEmitter} +objects.

      +

    Returns void

    v15.4.0

    +
diff --git a/docs/site/classes/models_pokerPhase.PokerPhase.html b/docs/site/classes/models_pokerPhase.PokerPhase.html new file mode 100644 index 0000000..483962a --- /dev/null +++ b/docs/site/classes/models_pokerPhase.PokerPhase.html @@ -0,0 +1,516 @@ +PokerPhase | casinojs

PokerPhase

+

Manages the various phases of a poker game, such as "Pre-Flop," "Flop," "Turn," and "River." This class encapsulates +the deck, community cards, and controls to transition between these game phases within a single round of poker.

+

The PokerPhase class standardizes and manages the sequence and actions taken during each phase of a poker game. +It ensures that the game progresses logically from one phase to another, maintaining the integrity of gameplay by +enforcing rules specific to each phase and managing the deck and community cards.

+
    +
  • Extends Node.js BaseEventEmitter, enabling event-based responses to phase changes and key game events.
  • +
+
    +
  • Implements the PokerPhaseInterface, defining essential methods and properties for managing a poker game phase.
  • +
+
    +
  • Initialization: constructor, __initPhase (sets up the deck and initial phase properties).
  • +
  • Phase Control: Methods to control transitions between phases like nextPhase, resetPhase.
  • +
  • Deck and Community Cards Management: Methods for dealing and revealing community cards.
  • +
+
    +
  • phase:change - Emitted each time the phase changes, enabling updates to game state.
  • +
  • phase:end - Emitted when the final phase (River) ends, signaling the conclusion of the phase sequence.
  • +
+

This class is instantiated and utilized during a poker game to control the progression through each game phase. +It is designed for integration within a PokerTable or PokerRoom, where it serves as the core game phase manager.

+
const pokerPhase = new PokerPhase();
pokerPhase.on('phase:change', (newPhase) => console.log(`Phase changed to ${newPhase}`));
pokerPhase.nextPhase();
console.log(pokerPhase.getCurrentPhase()); // Outputs the next game phase, e.g., "Flop" +
+ +

Hierarchy (view full)

Implements

Constructors

  • constructor

    +

    Initializes a new instance of PokerPhase with configurable settings for the game round, including players, deck, +community cards, pot, and player positions (dealer, small blind, big blind).

    +

    The constructor sets up the PokerPhase instance, calling the __init method to initialize the deck, player settings, +and positions for the game round. It also emits events for listeners when the phase starts.

    +
      +
    • config (optional): A PokerPhaseConfig object to configure properties like phase name, deck, community cards, +players, pot, and positional markers.
    • +
    +

    The constructor is used to initialize a PokerPhase instance with specific configurations, including player information +and positions for the phase.

    +

    Parameters

    • Optionalconfig: PokerPhaseConfig

      Optional configuration object with properties for setting up the poker phase.

      +

    Returns PokerPhase

    const pokerPhase = new PokerPhase({
    name: PokerPhaseName.PRE_FLOP,
    deck: new Deck(),
    communityCards: [],
    players: [...],
    pot: 0,
    dealerPos: 0,
    smallBlindPos: 1,
    bigBlindPos: 2
    }); +
    + +

Properties

captureRejections: boolean

Value: boolean

+

Change the default captureRejections option on all new EventEmitter objects.

+

v13.4.0, v12.16.0

+
captureRejectionSymbol: typeof captureRejectionSymbol

Value: Symbol.for('nodejs.rejection')

+

See how to write a custom rejection handler.

+

v13.4.0, v12.16.0

+
defaultMaxListeners: number

By default, a maximum of 10 listeners can be registered for any single +event. This limit can be changed for individual EventEmitter instances +using the emitter.setMaxListeners(n) method. To change the default +for allEventEmitter instances, the events.defaultMaxListeners property +can be used. If this value is not a positive number, a RangeError is thrown.

+

Take caution when setting the events.defaultMaxListeners because the +change affects all EventEmitter instances, including those created before +the change is made. However, calling emitter.setMaxListeners(n) still has +precedence over events.defaultMaxListeners.

+

This is not a hard limit. The EventEmitter instance will allow +more listeners to be added but will output a trace warning to stderr indicating +that a "possible EventEmitter memory leak" has been detected. For any single +EventEmitter, the emitter.getMaxListeners() and emitter.setMaxListeners() methods can be used to +temporarily avoid this warning:

+
import { EventEmitter } from 'node:events';
const emitter = new EventEmitter();
emitter.setMaxListeners(emitter.getMaxListeners() + 1);
emitter.once('event', () => {
// do stuff
emitter.setMaxListeners(Math.max(emitter.getMaxListeners() - 1, 0));
}); +
+ +

The --trace-warnings command-line flag can be used to display the +stack trace for such warnings.

+

The emitted warning can be inspected with process.on('warning') and will +have the additional emitter, type, and count properties, referring to +the event emitter instance, the event's name and the number of attached +listeners, respectively. +Its name property is set to 'MaxListenersExceededWarning'.

+

v0.11.2

+
errorMonitor: typeof errorMonitor

This symbol shall be used to install a listener for only monitoring 'error' events. Listeners installed using this symbol are called before the regular 'error' listeners are called.

+

Installing a listener using this symbol does not change the behavior once an 'error' event is emitted. Therefore, the process will still crash if no +regular 'error' listener is installed.

+

v13.6.0, v12.17.0

+

Methods

  • Alias for emitter.on(eventName, listener).

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.26

    +
  • dealCommunityCards +Deals the community cards to the table during the flop, turn, or river phases.

    +

    Parameters

    • count: number

      The number of community cards to deal (3 for the flop, 1 for the turn/river).

      +

    Returns boolean

  • Synchronously calls each of the listeners registered for the event named eventName, in the order they were registered, passing the supplied arguments +to each.

    +

    Returns true if the event had listeners, false otherwise.

    +
    import { EventEmitter } from 'node:events';
    const myEmitter = new EventEmitter();

    // First listener
    myEmitter.on('event', function firstListener() {
    console.log('Helloooo! first listener');
    });
    // Second listener
    myEmitter.on('event', function secondListener(arg1, arg2) {
    console.log(`event with parameters ${arg1}, ${arg2} in second listener`);
    });
    // Third listener
    myEmitter.on('event', function thirdListener(...args) {
    const parameters = args.join(', ');
    console.log(`event with parameters ${parameters} in third listener`);
    });

    console.log(myEmitter.listeners('event'));

    myEmitter.emit('event', 1, 2, 3, 4, 5);

    // Prints:
    // [
    // [Function: firstListener],
    // [Function: secondListener],
    // [Function: thirdListener]
    // ]
    // Helloooo! first listener
    // event with parameters 1, 2 in second listener
    // event with parameters 1, 2, 3, 4, 5 in third listener +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • Rest...args: AnyRest

    Returns boolean

    v0.1.26

    +
  • The emitEvent method is a public method for emitting events, with an optional configuration that allows +middleware processing. Middleware functions can intercept and transform the event before it reaches the listeners, +allowing custom validation or data modifications.

    +

    This method enables flexible event emission with support for middleware, providing a robust event processing +mechanism in the BaseEventEmitter. It’s useful for customizing event behavior based on application-specific needs.

    +

    N/A

    +

    N/A

    +

    This method can emit any event specified by eventName, which can then be processed by middleware functions if defined.

    +
      +
    • eventName: string - The name of the event to emit.
    • +
    • options: { event: { data: { [key: string]: any }; [key: string]: any; }, middlewares?: Array<(event: BaseEventInterface, next: () => void) => void | false> } +
        +
      • event - The primary event data to emit, containing specific details.
      • +
      • middlewares - An optional array of middleware functions that process the event before emission.
      • +
      +
    • +
    +
      +
    • eventName must be a valid string.
    • +
    • options.event should include relevant data for the event. If middlewares are provided, they should be functions with an event and next parameter.
    • +
    +
      +
    • void - This method does not return a value.
    • +
    +

    Use this method to emit events with middleware-based customization, which allows for specific processing +logic or transformations before the event reaches listeners.

    +

    Parameters

    • eventName: string

      The name of the event to emit.

      +
    • options: {
          event: {
              data: {
                  [key: string]: any;
              };
              [key: string]: any;
          };
          middlewares?: ((event: BaseEventInterface<any>, next: (() => void)) => false | void)[];
      }

      Configuration for the event and optional middleware functions.

      +
      • event: {
            data: {
                [key: string]: any;
            };
            [key: string]: any;
        }
        • [key: string]: any
        • data: {
              [key: string]: any;
          }
          • [key: string]: any
      • Optionalmiddlewares?: ((event: BaseEventInterface<any>, next: (() => void)) => false | void)[]

    Returns void

    emitter.emitEvent("game:started", {
    event: { data: { gameId: "001", status: "active" } },
    middlewares: [
    (event, next) => { console.log("Processing event:", event); next(); },
    (event, next) => { event.data.processed = true; next(); }
    ]
    }); +
    + +
  • Returns an array listing the events for which the emitter has registered +listeners. The values in the array are strings or Symbols.

    +
    import { EventEmitter } from 'node:events';

    const myEE = new EventEmitter();
    myEE.on('foo', () => {});
    myEE.on('bar', () => {});

    const sym = Symbol('symbol');
    myEE.on(sym, () => {});

    console.log(myEE.eventNames());
    // Prints: [ 'foo', 'bar', Symbol(symbol) ] +
    + +

    Returns (string | symbol)[]

    v6.0.0

    +
  • Retrieves the position of the player assigned the big blind.

    +

    N/A

    +

    N/A

    +

    Helps identify the player with the big blind, aiding in betting actions.

    +

    N/A

    +

    N/A

    +
      +
    • {number}: Position of the big blind player.
    • +
    +

    Used to determine the big blind in betting rounds.

    +

    Returns number

      +
    • Position of the big blind player.
    • +
    +
    const bigBlindPosition = pokerPhase.getBigBlindPos();
    console.log(bigBlindPosition); // Outputs: 2 +
    + +
  • Retrieves the position of the player whose turn it currently is within the PokerPhase.

    +

    N/A

    +

    N/A

    +

    Helps identify the active player during the phase, supporting turn-based actions.

    +

    N/A

    +

    N/A

    +
      +
    • {number}: The zero-based position of the current player.
    • +
    +

    Useful in determining which player should act next in the game round.

    +

    Returns number

      +
    • Position of the active player.
    • +
    +
    const currentPosition = pokerPhase.getCurrentPlayerPos();
    console.log(currentPosition); // Outputs: 2 +
    + +
  • Retrieves the dealer's position for the current phase of poker.

    +

    N/A

    +

    N/A

    +

    Indicates which player holds the dealer role, which is essential for turn-based actions.

    +

    N/A

    +

    N/A

    +
      +
    • {number}: The position of the dealer in the game.
    • +
    +

    Useful for determining turn order and dealer-related actions.

    +

    Returns number

      +
    • Dealer’s position in the phase.
    • +
    +
    const dealerPosition = pokerPhase.getDealerPos();
    console.log(dealerPosition); // Outputs: 0 +
    + +
  • Retrieves the deck of cards currently being used in the PokerPhase.

    +

    N/A

    +

    N/A

    +

    Accesses the deck to support game actions involving the deck, such as dealing or shuffling.

    +

    N/A

    +

    N/A

    +
      +
    • {DeckInterface}: The deck object used for this phase.
    • +
    +

    Useful for accessing the deck when cards need to be drawn or reset.

    +

    Returns DeckInterface

      +
    • The deck used in the phase.
    • +
    +
    const deck = pokerPhase.getDeck();
    console.log(deck); // Outputs the deck object +
    + +
  • Retrieves the current phase name (e.g., "Pre-Flop," "Flop") of the PokerPhase.

    +

    N/A

    +

    N/A

    +

    Provides the phase name, helping other parts of the code determine the current stage of the game round.

    +

    N/A

    +

    N/A

    +
      +
    • {PokerPhaseName}: The name of the current game phase.
    • +
    +

    Useful for determining the phase of gameplay, allowing specific actions based on the current phase.

    +

    Returns PokerPhaseName

      +
    • The name of the current phase in the poker round.
    • +
    +
    const phaseName = pokerPhase.getName();
    console.log(phaseName); // Outputs: "Pre-Flop" +
    + +
  • Retrieves the list of players currently involved in the PokerPhase.

    +

    N/A

    +

    N/A

    +

    Accesses the players participating in the current phase, supporting functions that involve player actions or status.

    +

    N/A

    +

    N/A

    +
      +
    • {PokerPlayerInterface[]}: An array of player objects involved in this phase.
    • +
    +

    This method is commonly used when the current players need to be accessed, such as for dealing cards or determining +player turns.

    +

    Returns PokerPlayerInterface[]

      +
    • List of players in the phase.
    • +
    +
    const players = pokerPhase.getPlayers();
    console.log(players); // Outputs an array of player objects +
    + +
  • Retrieves the current total pot amount for the PokerPhase.

    +

    N/A

    +

    N/A

    +

    Provides the total value of bets placed in the current phase, aiding in bet-related actions.

    +

    N/A

    +

    N/A

    +
      +
    • {number}: The current value of the pot.
    • +
    +

    Useful for calculating winnings or determining the total bet pool.

    +

    Returns number

      +
    • The current pot value in the phase.
    • +
    +
    const potAmount = pokerPhase.getPot();
    console.log(potAmount); // Outputs: 1000 +
    + +
  • Retrieves the position of the player assigned the small blind.

    +

    N/A

    +

    N/A

    +

    Helps identify the player with the small blind, aiding in betting actions.

    +

    N/A

    +

    N/A

    +
      +
    • {number}: Position of the small blind player.
    • +
    +

    Used to determine the small blind in betting rounds.

    +

    Returns number

      +
    • Position of the small blind player.
    • +
    +
    const smallBlindPosition = pokerPhase.getSmallBlindPos();
    console.log(smallBlindPosition); // Outputs: 1 +
    + +
  • Returns the number of listeners listening for the event named eventName. +If listener is provided, it will return how many times the listener is found +in the list of the listeners of the event.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event being listened for

      +
    • Optionallistener: Function

      The event handler function

      +

    Returns number

    v3.2.0

    +
  • Returns a copy of the array of listeners for the event named eventName.

    +
    server.on('connection', (stream) => {
    console.log('someone connected!');
    });
    console.log(util.inspect(server.listeners('connection')));
    // Prints: [ [Function] ] +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

    Returns Function[]

    v0.1.26

    +
  • Alias for emitter.removeListener().

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v10.0.0

    +
  • Adds the listener function to the end of the listeners array for the event +named eventName. No checks are made to see if the listener has already +been added. Multiple calls passing the same combination of eventName and +listener will result in the listener being added, and called, multiple times.

    +
    server.on('connection', (stream) => {
    console.log('someone connected!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    By default, event listeners are invoked in the order they are added. The emitter.prependListener() method can be used as an alternative to add the +event listener to the beginning of the listeners array.

    +
    import { EventEmitter } from 'node:events';
    const myEE = new EventEmitter();
    myEE.on('foo', () => console.log('a'));
    myEE.prependListener('foo', () => console.log('b'));
    myEE.emit('foo');
    // Prints:
    // b
    // a +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.101

    +
  • Adds a one-time listener function for the event named eventName. The +next time eventName is triggered, this listener is removed and then invoked.

    +
    server.once('connection', (stream) => {
    console.log('Ah, we have our first user!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    By default, event listeners are invoked in the order they are added. The emitter.prependOnceListener() method can be used as an alternative to add the +event listener to the beginning of the listeners array.

    +
    import { EventEmitter } from 'node:events';
    const myEE = new EventEmitter();
    myEE.once('foo', () => console.log('a'));
    myEE.prependOnceListener('foo', () => console.log('b'));
    myEE.emit('foo');
    // Prints:
    // b
    // a +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.3.0

    +
  • Adds the listener function to the beginning of the listeners array for the +event named eventName. No checks are made to see if the listener has +already been added. Multiple calls passing the same combination of eventName +and listener will result in the listener being added, and called, multiple times.

    +
    server.prependListener('connection', (stream) => {
    console.log('someone connected!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v6.0.0

    +
  • Adds a one-timelistener function for the event named eventName to the beginning of the listeners array. The next time eventName is triggered, this +listener is removed, and then invoked.

    +
    server.prependOnceListener('connection', (stream) => {
    console.log('Ah, we have our first user!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v6.0.0

    +
  • Returns a copy of the array of listeners for the event named eventName, +including any wrappers (such as those created by .once()).

    +
    import { EventEmitter } from 'node:events';
    const emitter = new EventEmitter();
    emitter.once('log', () => console.log('log once'));

    // Returns a new Array with a function `onceWrapper` which has a property
    // `listener` which contains the original listener bound above
    const listeners = emitter.rawListeners('log');
    const logFnWrapper = listeners[0];

    // Logs "log once" to the console and does not unbind the `once` event
    logFnWrapper.listener();

    // Logs "log once" to the console and removes the listener
    logFnWrapper();

    emitter.on('log', () => console.log('log persistently'));
    // Will return a new Array with a single function bound by `.on()` above
    const newListeners = emitter.rawListeners('log');

    // Logs "log persistently" twice
    newListeners[0]();
    emitter.emit('log'); +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

    Returns Function[]

    v9.4.0

    +
  • Removes all listeners, or those of the specified eventName.

    +

    It is bad practice to remove listeners added elsewhere in the code, +particularly when the EventEmitter instance was created by some other +component or module (e.g. sockets or file streams).

    +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Parameters

    • OptionaleventName: string | symbol

    Returns this

    v0.1.26

    +
  • Removes the specified listener from the listener array for the event named eventName.

    +
    const callback = (stream) => {
    console.log('someone connected!');
    };
    server.on('connection', callback);
    // ...
    server.removeListener('connection', callback); +
    + +

    removeListener() will remove, at most, one instance of a listener from the +listener array. If any single listener has been added multiple times to the +listener array for the specified eventName, then removeListener() must be +called multiple times to remove each instance.

    +

    Once an event is emitted, all listeners attached to it at the +time of emitting are called in order. This implies that any removeListener() or removeAllListeners() calls after emitting and before the last listener finishes execution +will not remove them fromemit() in progress. Subsequent events behave as expected.

    +
    import { EventEmitter } from 'node:events';
    class MyEmitter extends EventEmitter {}
    const myEmitter = new MyEmitter();

    const callbackA = () => {
    console.log('A');
    myEmitter.removeListener('event', callbackB);
    };

    const callbackB = () => {
    console.log('B');
    };

    myEmitter.on('event', callbackA);

    myEmitter.on('event', callbackB);

    // callbackA removes listener callbackB but it will still be called.
    // Internal listener array at time of emit [callbackA, callbackB]
    myEmitter.emit('event');
    // Prints:
    // A
    // B

    // callbackB is now removed.
    // Internal listener array [callbackA]
    myEmitter.emit('event');
    // Prints:
    // A +
    + +

    Because listeners are managed using an internal array, calling this will +change the position indices of any listener registered after the listener +being removed. This will not impact the order in which listeners are called, +but it means that any copies of the listener array as returned by +the emitter.listeners() method will need to be recreated.

    +

    When a single function has been added as a handler multiple times for a single +event (as in the example below), removeListener() will remove the most +recently added instance. In the example the once('ping') listener is removed:

    +
    import { EventEmitter } from 'node:events';
    const ee = new EventEmitter();

    function pong() {
    console.log('pong');
    }

    ee.on('ping', pong);
    ee.once('ping', pong);
    ee.removeListener('ping', pong);

    ee.emit('ping');
    ee.emit('ping'); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.26

    +
  • resolveBets +Resolves the current betting round, updating player chip stacks and determining the winner if applicable.

    +

    Returns void

  • By default EventEmitters will print a warning if more than 10 listeners are +added for a particular event. This is a useful default that helps finding +memory leaks. The emitter.setMaxListeners() method allows the limit to be +modified for this specific EventEmitter instance. The value can be set to Infinity (or 0) to indicate an unlimited number of listeners.

    +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Parameters

    • n: number

    Returns this

    v0.3.5

    +
  • Experimental

    Listens once to the abort event on the provided signal.

    +

    Listening to the abort event on abort signals is unsafe and may +lead to resource leaks since another third party with the signal can +call e.stopImmediatePropagation(). Unfortunately Node.js cannot change +this since it would violate the web standard. Additionally, the original +API makes it easy to forget to remove listeners.

    +

    This API allows safely using AbortSignals in Node.js APIs by solving these +two issues by listening to the event such that stopImmediatePropagation does +not prevent the listener from running.

    +

    Returns a disposable so that it may be unsubscribed from more easily.

    +
    import { addAbortListener } from 'node:events';

    function example(signal) {
    let disposable;
    try {
    signal.addEventListener('abort', (e) => e.stopImmediatePropagation());
    disposable = addAbortListener(signal, (e) => {
    // Do something when signal is aborted.
    });
    } finally {
    disposable?.[Symbol.dispose]();
    }
    } +
    + +

    Parameters

    • signal: AbortSignal
    • resource: ((event: Event) => void)
        • (event): void
        • Parameters

          • event: Event

          Returns void

    Returns Disposable

    Disposable that removes the abort listener.

    +

    v20.5.0

    +
  • Returns a copy of the array of listeners for the event named eventName.

    +

    For EventEmitters this behaves exactly the same as calling .listeners on +the emitter.

    +

    For EventTargets this is the only way to get the event listeners for the +event target. This is useful for debugging and diagnostic purposes.

    +
    import { getEventListeners, EventEmitter } from 'node:events';

    {
    const ee = new EventEmitter();
    const listener = () => console.log('Events are fun');
    ee.on('foo', listener);
    console.log(getEventListeners(ee, 'foo')); // [ [Function: listener] ]
    }
    {
    const et = new EventTarget();
    const listener = () => console.log('Events are fun');
    et.addEventListener('foo', listener);
    console.log(getEventListeners(et, 'foo')); // [ [Function: listener] ]
    } +
    + +

    Parameters

    • emitter: EventEmitter<DefaultEventMap> | EventTarget
    • name: string | symbol

    Returns Function[]

    v15.2.0, v14.17.0

    +
  • Returns the currently set max amount of listeners.

    +

    For EventEmitters this behaves exactly the same as calling .getMaxListeners on +the emitter.

    +

    For EventTargets this is the only way to get the max event listeners for the +event target. If the number of event handlers on a single EventTarget exceeds +the max set, the EventTarget will print a warning.

    +
    import { getMaxListeners, setMaxListeners, EventEmitter } from 'node:events';

    {
    const ee = new EventEmitter();
    console.log(getMaxListeners(ee)); // 10
    setMaxListeners(11, ee);
    console.log(getMaxListeners(ee)); // 11
    }
    {
    const et = new EventTarget();
    console.log(getMaxListeners(et)); // 10
    setMaxListeners(11, et);
    console.log(getMaxListeners(et)); // 11
    } +
    + +

    Parameters

    • emitter: EventEmitter<DefaultEventMap> | EventTarget

    Returns number

    v19.9.0

    +
  • A class method that returns the number of listeners for the given eventName registered on the given emitter.

    +
    import { EventEmitter, listenerCount } from 'node:events';

    const myEmitter = new EventEmitter();
    myEmitter.on('event', () => {});
    myEmitter.on('event', () => {});
    console.log(listenerCount(myEmitter, 'event'));
    // Prints: 2 +
    + +

    Parameters

    • emitter: EventEmitter<DefaultEventMap>

      The emitter to query

      +
    • eventName: string | symbol

      The event name

      +

    Returns number

    v0.9.12

    +

    Since v3.2.0 - Use listenerCount instead.

    +
  • import { on, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ee = new EventEmitter();

    // Emit later on
    process.nextTick(() => {
    ee.emit('foo', 'bar');
    ee.emit('foo', 42);
    });

    for await (const event of on(ee, 'foo')) {
    // The execution of this inner block is synchronous and it
    // processes one event at a time (even with await). Do not use
    // if concurrent execution is required.
    console.log(event); // prints ['bar'] [42]
    }
    // Unreachable here +
    + +

    Returns an AsyncIterator that iterates eventName events. It will throw +if the EventEmitter emits 'error'. It removes all listeners when +exiting the loop. The value returned by each iteration is an array +composed of the emitted event arguments.

    +

    An AbortSignal can be used to cancel waiting on events:

    +
    import { on, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ac = new AbortController();

    (async () => {
    const ee = new EventEmitter();

    // Emit later on
    process.nextTick(() => {
    ee.emit('foo', 'bar');
    ee.emit('foo', 42);
    });

    for await (const event of on(ee, 'foo', { signal: ac.signal })) {
    // The execution of this inner block is synchronous and it
    // processes one event at a time (even with await). Do not use
    // if concurrent execution is required.
    console.log(event); // prints ['bar'] [42]
    }
    // Unreachable here
    })();

    process.nextTick(() => ac.abort()); +
    + +

    Use the close option to specify an array of event names that will end the iteration:

    +
    import { on, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ee = new EventEmitter();

    // Emit later on
    process.nextTick(() => {
    ee.emit('foo', 'bar');
    ee.emit('foo', 42);
    ee.emit('close');
    });

    for await (const event of on(ee, 'foo', { close: ['close'] })) {
    console.log(event); // prints ['bar'] [42]
    }
    // the loop will exit after 'close' is emitted
    console.log('done'); // prints 'done' +
    + +

    Parameters

    • emitter: EventEmitter<DefaultEventMap>
    • eventName: string | symbol
    • Optionaloptions: StaticEventEmitterIteratorOptions

    Returns AsyncIterator<any[], any, any>

    An AsyncIterator that iterates eventName events emitted by the emitter

    +

    v13.6.0, v12.16.0

    +
  • Parameters

    • emitter: EventTarget
    • eventName: string
    • Optionaloptions: StaticEventEmitterIteratorOptions

    Returns AsyncIterator<any[], any, any>

  • Creates a Promise that is fulfilled when the EventEmitter emits the given +event or that is rejected if the EventEmitter emits 'error' while waiting. +The Promise will resolve with an array of all the arguments emitted to the +given event.

    +

    This method is intentionally generic and works with the web platform EventTarget interface, which has no special'error' event +semantics and does not listen to the 'error' event.

    +
    import { once, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ee = new EventEmitter();

    process.nextTick(() => {
    ee.emit('myevent', 42);
    });

    const [value] = await once(ee, 'myevent');
    console.log(value);

    const err = new Error('kaboom');
    process.nextTick(() => {
    ee.emit('error', err);
    });

    try {
    await once(ee, 'myevent');
    } catch (err) {
    console.error('error happened', err);
    } +
    + +

    The special handling of the 'error' event is only used when events.once() is used to wait for another event. If events.once() is used to wait for the +'error' event itself, then it is treated as any other kind of event without +special handling:

    +
    import { EventEmitter, once } from 'node:events';

    const ee = new EventEmitter();

    once(ee, 'error')
    .then(([err]) => console.log('ok', err.message))
    .catch((err) => console.error('error', err.message));

    ee.emit('error', new Error('boom'));

    // Prints: ok boom +
    + +

    An AbortSignal can be used to cancel waiting for the event:

    +
    import { EventEmitter, once } from 'node:events';

    const ee = new EventEmitter();
    const ac = new AbortController();

    async function foo(emitter, event, signal) {
    try {
    await once(emitter, event, { signal });
    console.log('event emitted!');
    } catch (error) {
    if (error.name === 'AbortError') {
    console.error('Waiting for the event was canceled!');
    } else {
    console.error('There was an error', error.message);
    }
    }
    }

    foo(ee, 'foo', ac.signal);
    ac.abort(); // Abort waiting for the event
    ee.emit('foo'); // Prints: Waiting for the event was canceled! +
    + +

    Parameters

    • emitter: EventEmitter<DefaultEventMap>
    • eventName: string | symbol
    • Optionaloptions: StaticEventEmitterOptions

    Returns Promise<any[]>

    v11.13.0, v10.16.0

    +
  • Parameters

    • emitter: EventTarget
    • eventName: string
    • Optionaloptions: StaticEventEmitterOptions

    Returns Promise<any[]>

  • import { setMaxListeners, EventEmitter } from 'node:events';

    const target = new EventTarget();
    const emitter = new EventEmitter();

    setMaxListeners(5, target, emitter); +
    + +

    Parameters

    • Optionaln: number

      A non-negative number. The maximum number of listeners per EventTarget event.

      +
    • Rest...eventTargets: (EventEmitter<DefaultEventMap> | EventTarget)[]

      Zero or more {EventTarget} or {EventEmitter} instances. If none are specified, n is set as the default max for all newly created {EventTarget} and {EventEmitter} +objects.

      +

    Returns void

    v15.4.0

    +
diff --git a/docs/site/classes/models_pokerPlayer.PokerPlayer.html b/docs/site/classes/models_pokerPlayer.PokerPlayer.html new file mode 100644 index 0000000..70173e6 --- /dev/null +++ b/docs/site/classes/models_pokerPlayer.PokerPlayer.html @@ -0,0 +1,408 @@ +PokerPlayer | casinojs

PokerPlayerInterface +Represents a player seated at the PokerTable. +The player can place bets, fold, and manage their chip stack during the game.

+

Hierarchy (view full)

Implements

Constructors

Properties

captureRejections: boolean

Value: boolean

+

Change the default captureRejections option on all new EventEmitter objects.

+

v13.4.0, v12.16.0

+
captureRejectionSymbol: typeof captureRejectionSymbol

Value: Symbol.for('nodejs.rejection')

+

See how to write a custom rejection handler.

+

v13.4.0, v12.16.0

+
defaultMaxListeners: number

By default, a maximum of 10 listeners can be registered for any single +event. This limit can be changed for individual EventEmitter instances +using the emitter.setMaxListeners(n) method. To change the default +for allEventEmitter instances, the events.defaultMaxListeners property +can be used. If this value is not a positive number, a RangeError is thrown.

+

Take caution when setting the events.defaultMaxListeners because the +change affects all EventEmitter instances, including those created before +the change is made. However, calling emitter.setMaxListeners(n) still has +precedence over events.defaultMaxListeners.

+

This is not a hard limit. The EventEmitter instance will allow +more listeners to be added but will output a trace warning to stderr indicating +that a "possible EventEmitter memory leak" has been detected. For any single +EventEmitter, the emitter.getMaxListeners() and emitter.setMaxListeners() methods can be used to +temporarily avoid this warning:

+
import { EventEmitter } from 'node:events';
const emitter = new EventEmitter();
emitter.setMaxListeners(emitter.getMaxListeners() + 1);
emitter.once('event', () => {
// do stuff
emitter.setMaxListeners(Math.max(emitter.getMaxListeners() - 1, 0));
}); +
+ +

The --trace-warnings command-line flag can be used to display the +stack trace for such warnings.

+

The emitted warning can be inspected with process.on('warning') and will +have the additional emitter, type, and count properties, referring to +the event emitter instance, the event's name and the number of attached +listeners, respectively. +Its name property is set to 'MaxListenersExceededWarning'.

+

v0.11.2

+
errorMonitor: typeof errorMonitor

This symbol shall be used to install a listener for only monitoring 'error' events. Listeners installed using this symbol are called before the regular 'error' listeners are called.

+

Installing a listener using this symbol does not change the behavior once an 'error' event is emitted. Therefore, the process will still crash if no +regular 'error' listener is installed.

+

v13.6.0, v12.17.0

+

Methods

  • getHand

    +

    Returns the poker table's id.

    +

    Parameters

    • betMatched: boolean

    Returns boolean

    The poker table's id.

    +
    const rank = card.getRank();
    console.log(rank); // "A" +
    + +
  • Alias for emitter.on(eventName, listener).

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.26

    +
  • Synchronously calls each of the listeners registered for the event named eventName, in the order they were registered, passing the supplied arguments +to each.

    +

    Returns true if the event had listeners, false otherwise.

    +
    import { EventEmitter } from 'node:events';
    const myEmitter = new EventEmitter();

    // First listener
    myEmitter.on('event', function firstListener() {
    console.log('Helloooo! first listener');
    });
    // Second listener
    myEmitter.on('event', function secondListener(arg1, arg2) {
    console.log(`event with parameters ${arg1}, ${arg2} in second listener`);
    });
    // Third listener
    myEmitter.on('event', function thirdListener(...args) {
    const parameters = args.join(', ');
    console.log(`event with parameters ${parameters} in third listener`);
    });

    console.log(myEmitter.listeners('event'));

    myEmitter.emit('event', 1, 2, 3, 4, 5);

    // Prints:
    // [
    // [Function: firstListener],
    // [Function: secondListener],
    // [Function: thirdListener]
    // ]
    // Helloooo! first listener
    // event with parameters 1, 2 in second listener
    // event with parameters 1, 2, 3, 4, 5 in third listener +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • Rest...args: AnyRest

    Returns boolean

    v0.1.26

    +
  • The emitEvent method is a public method for emitting events, with an optional configuration that allows +middleware processing. Middleware functions can intercept and transform the event before it reaches the listeners, +allowing custom validation or data modifications.

    +

    This method enables flexible event emission with support for middleware, providing a robust event processing +mechanism in the BaseEventEmitter. It’s useful for customizing event behavior based on application-specific needs.

    +

    N/A

    +

    N/A

    +

    This method can emit any event specified by eventName, which can then be processed by middleware functions if defined.

    +
      +
    • eventName: string - The name of the event to emit.
    • +
    • options: { event: { data: { [key: string]: any }; [key: string]: any; }, middlewares?: Array<(event: BaseEventInterface, next: () => void) => void | false> } +
        +
      • event - The primary event data to emit, containing specific details.
      • +
      • middlewares - An optional array of middleware functions that process the event before emission.
      • +
      +
    • +
    +
      +
    • eventName must be a valid string.
    • +
    • options.event should include relevant data for the event. If middlewares are provided, they should be functions with an event and next parameter.
    • +
    +
      +
    • void - This method does not return a value.
    • +
    +

    Use this method to emit events with middleware-based customization, which allows for specific processing +logic or transformations before the event reaches listeners.

    +

    Parameters

    • eventName: string

      The name of the event to emit.

      +
    • options: {
          event: {
              data: {
                  [key: string]: any;
              };
              [key: string]: any;
          };
          middlewares?: ((event: BaseEventInterface<any>, next: (() => void)) => false | void)[];
      }

      Configuration for the event and optional middleware functions.

      +
      • event: {
            data: {
                [key: string]: any;
            };
            [key: string]: any;
        }
        • [key: string]: any
        • data: {
              [key: string]: any;
          }
          • [key: string]: any
      • Optionalmiddlewares?: ((event: BaseEventInterface<any>, next: (() => void)) => false | void)[]

    Returns void

    emitter.emitEvent("game:started", {
    event: { data: { gameId: "001", status: "active" } },
    middlewares: [
    (event, next) => { console.log("Processing event:", event); next(); },
    (event, next) => { event.data.processed = true; next(); }
    ]
    }); +
    + +
  • Returns an array listing the events for which the emitter has registered +listeners. The values in the array are strings or Symbols.

    +
    import { EventEmitter } from 'node:events';

    const myEE = new EventEmitter();
    myEE.on('foo', () => {});
    myEE.on('bar', () => {});

    const sym = Symbol('symbol');
    myEE.on(sym, () => {});

    console.log(myEE.eventNames());
    // Prints: [ 'foo', 'bar', Symbol(symbol) ] +
    + +

    Returns (string | symbol)[]

    v6.0.0

    +
  • getChips

    +

    Returns the poker table's id.

    +

    Returns number

    The poker table's id.

    +
    const rank = card.getRank();
    console.log(rank); // "A" +
    + +
  • getName

    +

    Returns the poker table's id.

    +

    Returns string

    The poker table's id.

    +
    const rank = card.getRank();
    console.log(rank); // "A" +
    + +
  • getHand

    +

    Returns the poker table's id.

    +

    Returns boolean

    The poker table's id.

    +
    const rank = card.getRank();
    console.log(rank); // "A" +
    + +
  • isFolded

    +

    Returns the poker table's id.

    +

    Returns boolean

    The poker table's id.

    +
    const rank = card.getRank();
    console.log(rank); // "A" +
    + +
  • Returns the number of listeners listening for the event named eventName. +If listener is provided, it will return how many times the listener is found +in the list of the listeners of the event.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event being listened for

      +
    • Optionallistener: Function

      The event handler function

      +

    Returns number

    v3.2.0

    +
  • Returns a copy of the array of listeners for the event named eventName.

    +
    server.on('connection', (stream) => {
    console.log('someone connected!');
    });
    console.log(util.inspect(server.listeners('connection')));
    // Prints: [ [Function] ] +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

    Returns Function[]

    v0.1.26

    +
  • Alias for emitter.removeListener().

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v10.0.0

    +
  • Adds the listener function to the end of the listeners array for the event +named eventName. No checks are made to see if the listener has already +been added. Multiple calls passing the same combination of eventName and +listener will result in the listener being added, and called, multiple times.

    +
    server.on('connection', (stream) => {
    console.log('someone connected!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    By default, event listeners are invoked in the order they are added. The emitter.prependListener() method can be used as an alternative to add the +event listener to the beginning of the listeners array.

    +
    import { EventEmitter } from 'node:events';
    const myEE = new EventEmitter();
    myEE.on('foo', () => console.log('a'));
    myEE.prependListener('foo', () => console.log('b'));
    myEE.emit('foo');
    // Prints:
    // b
    // a +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.101

    +
  • Adds a one-time listener function for the event named eventName. The +next time eventName is triggered, this listener is removed and then invoked.

    +
    server.once('connection', (stream) => {
    console.log('Ah, we have our first user!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    By default, event listeners are invoked in the order they are added. The emitter.prependOnceListener() method can be used as an alternative to add the +event listener to the beginning of the listeners array.

    +
    import { EventEmitter } from 'node:events';
    const myEE = new EventEmitter();
    myEE.once('foo', () => console.log('a'));
    myEE.prependOnceListener('foo', () => console.log('b'));
    myEE.emit('foo');
    // Prints:
    // b
    // a +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.3.0

    +
  • Adds the listener function to the beginning of the listeners array for the +event named eventName. No checks are made to see if the listener has +already been added. Multiple calls passing the same combination of eventName +and listener will result in the listener being added, and called, multiple times.

    +
    server.prependListener('connection', (stream) => {
    console.log('someone connected!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v6.0.0

    +
  • Adds a one-timelistener function for the event named eventName to the beginning of the listeners array. The next time eventName is triggered, this +listener is removed, and then invoked.

    +
    server.prependOnceListener('connection', (stream) => {
    console.log('Ah, we have our first user!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v6.0.0

    +
  • Returns a copy of the array of listeners for the event named eventName, +including any wrappers (such as those created by .once()).

    +
    import { EventEmitter } from 'node:events';
    const emitter = new EventEmitter();
    emitter.once('log', () => console.log('log once'));

    // Returns a new Array with a function `onceWrapper` which has a property
    // `listener` which contains the original listener bound above
    const listeners = emitter.rawListeners('log');
    const logFnWrapper = listeners[0];

    // Logs "log once" to the console and does not unbind the `once` event
    logFnWrapper.listener();

    // Logs "log once" to the console and removes the listener
    logFnWrapper();

    emitter.on('log', () => console.log('log persistently'));
    // Will return a new Array with a single function bound by `.on()` above
    const newListeners = emitter.rawListeners('log');

    // Logs "log persistently" twice
    newListeners[0]();
    emitter.emit('log'); +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

    Returns Function[]

    v9.4.0

    +
  • Removes all listeners, or those of the specified eventName.

    +

    It is bad practice to remove listeners added elsewhere in the code, +particularly when the EventEmitter instance was created by some other +component or module (e.g. sockets or file streams).

    +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Parameters

    • OptionaleventName: string | symbol

    Returns this

    v0.1.26

    +
  • Removes the specified listener from the listener array for the event named eventName.

    +
    const callback = (stream) => {
    console.log('someone connected!');
    };
    server.on('connection', callback);
    // ...
    server.removeListener('connection', callback); +
    + +

    removeListener() will remove, at most, one instance of a listener from the +listener array. If any single listener has been added multiple times to the +listener array for the specified eventName, then removeListener() must be +called multiple times to remove each instance.

    +

    Once an event is emitted, all listeners attached to it at the +time of emitting are called in order. This implies that any removeListener() or removeAllListeners() calls after emitting and before the last listener finishes execution +will not remove them fromemit() in progress. Subsequent events behave as expected.

    +
    import { EventEmitter } from 'node:events';
    class MyEmitter extends EventEmitter {}
    const myEmitter = new MyEmitter();

    const callbackA = () => {
    console.log('A');
    myEmitter.removeListener('event', callbackB);
    };

    const callbackB = () => {
    console.log('B');
    };

    myEmitter.on('event', callbackA);

    myEmitter.on('event', callbackB);

    // callbackA removes listener callbackB but it will still be called.
    // Internal listener array at time of emit [callbackA, callbackB]
    myEmitter.emit('event');
    // Prints:
    // A
    // B

    // callbackB is now removed.
    // Internal listener array [callbackA]
    myEmitter.emit('event');
    // Prints:
    // A +
    + +

    Because listeners are managed using an internal array, calling this will +change the position indices of any listener registered after the listener +being removed. This will not impact the order in which listeners are called, +but it means that any copies of the listener array as returned by +the emitter.listeners() method will need to be recreated.

    +

    When a single function has been added as a handler multiple times for a single +event (as in the example below), removeListener() will remove the most +recently added instance. In the example the once('ping') listener is removed:

    +
    import { EventEmitter } from 'node:events';
    const ee = new EventEmitter();

    function pong() {
    console.log('pong');
    }

    ee.on('ping', pong);
    ee.once('ping', pong);
    ee.removeListener('ping', pong);

    ee.emit('ping');
    ee.emit('ping'); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.26

    +
  • getHand

    +

    Returns the poker table's id.

    +

    Parameters

    • betMatched: boolean

    Returns boolean

    The poker table's id.

    +
    const rank = card.getRank();
    console.log(rank); // "A" +
    + +
  • By default EventEmitters will print a warning if more than 10 listeners are +added for a particular event. This is a useful default that helps finding +memory leaks. The emitter.setMaxListeners() method allows the limit to be +modified for this specific EventEmitter instance. The value can be set to Infinity (or 0) to indicate an unlimited number of listeners.

    +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Parameters

    • n: number

    Returns this

    v0.3.5

    +
  • Sets the name of the PokerRoom, allowing the name to be updated or customized.

    +

    N/A - This method is part of the PokerRoomInterface and does not implement any external methods.

    +

    N/A - This method does not override any superclass or parent methods.

    +

    The setName method is used to assign a specific name to a PokerRoom, which helps distinguish it within the system. +This is essential for systems where rooms need to be identifiable and manageable through a unique name.

    +

    N/A - No events are emitted by this method.

    +
      +
    • name: A string representing the new name for the room. It must be a valid, non-empty string to ensure +the room has a clear, identifiable label.
    • +
    +
      +
    • The name parameter should be a non-empty string to provide meaningful identification.
    • +
    • Passing an empty or invalid value could result in future misidentification of rooms if validation is implemented.
    • +
    +
      +
    • Returns the name that was set for the PokerRoom.
    • +
    +

    Use this method to set or update the name of a room in a system where unique or identifiable room names +are necessary for reference.

    +

    Parameters

    • name: string

      The new name for the PokerRoom.

      +

    Returns string

      +
    • Returns the name of the room that was set.
    • +
    +
    const pokerRoom = new PokerRoom({ name: "Room1", tableSize: 6 });
    pokerRoom.setName("HighRollers"); // Sets the name of the room to "HighRollers"
    console.log(pokerRoom.getName()); // Logs "HighRollers" +
    + +
  • Experimental

    Listens once to the abort event on the provided signal.

    +

    Listening to the abort event on abort signals is unsafe and may +lead to resource leaks since another third party with the signal can +call e.stopImmediatePropagation(). Unfortunately Node.js cannot change +this since it would violate the web standard. Additionally, the original +API makes it easy to forget to remove listeners.

    +

    This API allows safely using AbortSignals in Node.js APIs by solving these +two issues by listening to the event such that stopImmediatePropagation does +not prevent the listener from running.

    +

    Returns a disposable so that it may be unsubscribed from more easily.

    +
    import { addAbortListener } from 'node:events';

    function example(signal) {
    let disposable;
    try {
    signal.addEventListener('abort', (e) => e.stopImmediatePropagation());
    disposable = addAbortListener(signal, (e) => {
    // Do something when signal is aborted.
    });
    } finally {
    disposable?.[Symbol.dispose]();
    }
    } +
    + +

    Parameters

    • signal: AbortSignal
    • resource: ((event: Event) => void)
        • (event): void
        • Parameters

          • event: Event

          Returns void

    Returns Disposable

    Disposable that removes the abort listener.

    +

    v20.5.0

    +
  • Returns a copy of the array of listeners for the event named eventName.

    +

    For EventEmitters this behaves exactly the same as calling .listeners on +the emitter.

    +

    For EventTargets this is the only way to get the event listeners for the +event target. This is useful for debugging and diagnostic purposes.

    +
    import { getEventListeners, EventEmitter } from 'node:events';

    {
    const ee = new EventEmitter();
    const listener = () => console.log('Events are fun');
    ee.on('foo', listener);
    console.log(getEventListeners(ee, 'foo')); // [ [Function: listener] ]
    }
    {
    const et = new EventTarget();
    const listener = () => console.log('Events are fun');
    et.addEventListener('foo', listener);
    console.log(getEventListeners(et, 'foo')); // [ [Function: listener] ]
    } +
    + +

    Parameters

    • emitter: EventEmitter<DefaultEventMap> | EventTarget
    • name: string | symbol

    Returns Function[]

    v15.2.0, v14.17.0

    +
  • Returns the currently set max amount of listeners.

    +

    For EventEmitters this behaves exactly the same as calling .getMaxListeners on +the emitter.

    +

    For EventTargets this is the only way to get the max event listeners for the +event target. If the number of event handlers on a single EventTarget exceeds +the max set, the EventTarget will print a warning.

    +
    import { getMaxListeners, setMaxListeners, EventEmitter } from 'node:events';

    {
    const ee = new EventEmitter();
    console.log(getMaxListeners(ee)); // 10
    setMaxListeners(11, ee);
    console.log(getMaxListeners(ee)); // 11
    }
    {
    const et = new EventTarget();
    console.log(getMaxListeners(et)); // 10
    setMaxListeners(11, et);
    console.log(getMaxListeners(et)); // 11
    } +
    + +

    Parameters

    • emitter: EventEmitter<DefaultEventMap> | EventTarget

    Returns number

    v19.9.0

    +
  • A class method that returns the number of listeners for the given eventName registered on the given emitter.

    +
    import { EventEmitter, listenerCount } from 'node:events';

    const myEmitter = new EventEmitter();
    myEmitter.on('event', () => {});
    myEmitter.on('event', () => {});
    console.log(listenerCount(myEmitter, 'event'));
    // Prints: 2 +
    + +

    Parameters

    • emitter: EventEmitter<DefaultEventMap>

      The emitter to query

      +
    • eventName: string | symbol

      The event name

      +

    Returns number

    v0.9.12

    +

    Since v3.2.0 - Use listenerCount instead.

    +
  • import { on, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ee = new EventEmitter();

    // Emit later on
    process.nextTick(() => {
    ee.emit('foo', 'bar');
    ee.emit('foo', 42);
    });

    for await (const event of on(ee, 'foo')) {
    // The execution of this inner block is synchronous and it
    // processes one event at a time (even with await). Do not use
    // if concurrent execution is required.
    console.log(event); // prints ['bar'] [42]
    }
    // Unreachable here +
    + +

    Returns an AsyncIterator that iterates eventName events. It will throw +if the EventEmitter emits 'error'. It removes all listeners when +exiting the loop. The value returned by each iteration is an array +composed of the emitted event arguments.

    +

    An AbortSignal can be used to cancel waiting on events:

    +
    import { on, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ac = new AbortController();

    (async () => {
    const ee = new EventEmitter();

    // Emit later on
    process.nextTick(() => {
    ee.emit('foo', 'bar');
    ee.emit('foo', 42);
    });

    for await (const event of on(ee, 'foo', { signal: ac.signal })) {
    // The execution of this inner block is synchronous and it
    // processes one event at a time (even with await). Do not use
    // if concurrent execution is required.
    console.log(event); // prints ['bar'] [42]
    }
    // Unreachable here
    })();

    process.nextTick(() => ac.abort()); +
    + +

    Use the close option to specify an array of event names that will end the iteration:

    +
    import { on, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ee = new EventEmitter();

    // Emit later on
    process.nextTick(() => {
    ee.emit('foo', 'bar');
    ee.emit('foo', 42);
    ee.emit('close');
    });

    for await (const event of on(ee, 'foo', { close: ['close'] })) {
    console.log(event); // prints ['bar'] [42]
    }
    // the loop will exit after 'close' is emitted
    console.log('done'); // prints 'done' +
    + +

    Parameters

    • emitter: EventEmitter<DefaultEventMap>
    • eventName: string | symbol
    • Optionaloptions: StaticEventEmitterIteratorOptions

    Returns AsyncIterator<any[], any, any>

    An AsyncIterator that iterates eventName events emitted by the emitter

    +

    v13.6.0, v12.16.0

    +
  • Parameters

    • emitter: EventTarget
    • eventName: string
    • Optionaloptions: StaticEventEmitterIteratorOptions

    Returns AsyncIterator<any[], any, any>

  • Creates a Promise that is fulfilled when the EventEmitter emits the given +event or that is rejected if the EventEmitter emits 'error' while waiting. +The Promise will resolve with an array of all the arguments emitted to the +given event.

    +

    This method is intentionally generic and works with the web platform EventTarget interface, which has no special'error' event +semantics and does not listen to the 'error' event.

    +
    import { once, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ee = new EventEmitter();

    process.nextTick(() => {
    ee.emit('myevent', 42);
    });

    const [value] = await once(ee, 'myevent');
    console.log(value);

    const err = new Error('kaboom');
    process.nextTick(() => {
    ee.emit('error', err);
    });

    try {
    await once(ee, 'myevent');
    } catch (err) {
    console.error('error happened', err);
    } +
    + +

    The special handling of the 'error' event is only used when events.once() is used to wait for another event. If events.once() is used to wait for the +'error' event itself, then it is treated as any other kind of event without +special handling:

    +
    import { EventEmitter, once } from 'node:events';

    const ee = new EventEmitter();

    once(ee, 'error')
    .then(([err]) => console.log('ok', err.message))
    .catch((err) => console.error('error', err.message));

    ee.emit('error', new Error('boom'));

    // Prints: ok boom +
    + +

    An AbortSignal can be used to cancel waiting for the event:

    +
    import { EventEmitter, once } from 'node:events';

    const ee = new EventEmitter();
    const ac = new AbortController();

    async function foo(emitter, event, signal) {
    try {
    await once(emitter, event, { signal });
    console.log('event emitted!');
    } catch (error) {
    if (error.name === 'AbortError') {
    console.error('Waiting for the event was canceled!');
    } else {
    console.error('There was an error', error.message);
    }
    }
    }

    foo(ee, 'foo', ac.signal);
    ac.abort(); // Abort waiting for the event
    ee.emit('foo'); // Prints: Waiting for the event was canceled! +
    + +

    Parameters

    • emitter: EventEmitter<DefaultEventMap>
    • eventName: string | symbol
    • Optionaloptions: StaticEventEmitterOptions

    Returns Promise<any[]>

    v11.13.0, v10.16.0

    +
  • Parameters

    • emitter: EventTarget
    • eventName: string
    • Optionaloptions: StaticEventEmitterOptions

    Returns Promise<any[]>

  • import { setMaxListeners, EventEmitter } from 'node:events';

    const target = new EventTarget();
    const emitter = new EventEmitter();

    setMaxListeners(5, target, emitter); +
    + +

    Parameters

    • Optionaln: number

      A non-negative number. The maximum number of listeners per EventTarget event.

      +
    • Rest...eventTargets: (EventEmitter<DefaultEventMap> | EventTarget)[]

      Zero or more {EventTarget} or {EventEmitter} instances. If none are specified, n is set as the default max for all newly created {EventTarget} and {EventEmitter} +objects.

      +

    Returns void

    v15.4.0

    +
diff --git a/docs/site/classes/models_pokerRoom.PokerRoom.html b/docs/site/classes/models_pokerRoom.PokerRoom.html new file mode 100644 index 0000000..f067c25 --- /dev/null +++ b/docs/site/classes/models_pokerRoom.PokerRoom.html @@ -0,0 +1,534 @@ +PokerRoom | casinojs

PokerRoom +Represents a PokerRoom within a Casino that holds a single PokerTable. The PokerRoom manages the player queue, automatically assigning players to the PokerTable as seats become available. +This class extends BaseEventEmitter and implements the PokerRoomInterface interface.

+

Hierarchy (view full)

Implements

Constructors

Properties

captureRejections: boolean

Value: boolean

+

Change the default captureRejections option on all new EventEmitter objects.

+

v13.4.0, v12.16.0

+
captureRejectionSymbol: typeof captureRejectionSymbol

Value: Symbol.for('nodejs.rejection')

+

See how to write a custom rejection handler.

+

v13.4.0, v12.16.0

+
defaultMaxListeners: number

By default, a maximum of 10 listeners can be registered for any single +event. This limit can be changed for individual EventEmitter instances +using the emitter.setMaxListeners(n) method. To change the default +for allEventEmitter instances, the events.defaultMaxListeners property +can be used. If this value is not a positive number, a RangeError is thrown.

+

Take caution when setting the events.defaultMaxListeners because the +change affects all EventEmitter instances, including those created before +the change is made. However, calling emitter.setMaxListeners(n) still has +precedence over events.defaultMaxListeners.

+

This is not a hard limit. The EventEmitter instance will allow +more listeners to be added but will output a trace warning to stderr indicating +that a "possible EventEmitter memory leak" has been detected. For any single +EventEmitter, the emitter.getMaxListeners() and emitter.setMaxListeners() methods can be used to +temporarily avoid this warning:

+
import { EventEmitter } from 'node:events';
const emitter = new EventEmitter();
emitter.setMaxListeners(emitter.getMaxListeners() + 1);
emitter.once('event', () => {
// do stuff
emitter.setMaxListeners(Math.max(emitter.getMaxListeners() - 1, 0));
}); +
+ +

The --trace-warnings command-line flag can be used to display the +stack trace for such warnings.

+

The emitted warning can be inspected with process.on('warning') and will +have the additional emitter, type, and count properties, referring to +the event emitter instance, the event's name and the number of attached +listeners, respectively. +Its name property is set to 'MaxListenersExceededWarning'.

+

v0.11.2

+
errorMonitor: typeof errorMonitor

This symbol shall be used to install a listener for only monitoring 'error' events. Listeners installed using this symbol are called before the regular 'error' listeners are called.

+

Installing a listener using this symbol does not change the behavior once an 'error' event is emitted. Therefore, the process will still crash if no +regular 'error' listener is installed.

+

v13.6.0, v12.17.0

+

Methods

  • Creates a new PokerRoom instance based on the provided configuration and adds it to the Casino's rooms list.

    +

    N/A

    +

    N/A

    +

    Allows the Casino to dynamically create new rooms as needed by providing specific room configurations.

    +
      +
    • Emits a CasinoEventName.ROOM_CREATED event, enabling listeners to respond to the creation of a new room.
    • +
    +
      +
    • config: A PokerRoomConfig object containing details like name, tableSize, smallBlind, and bigBlind.
    • +
    +

    N/A

    +
      +
    • Returns the newly created PokerRoomInterface instance.
    • +
    +

    Primarily used within subclasses or protected methods to dynamically create and add rooms to the Casino.

    +

    Parameters

    • Optionalconfig: PokerTableConfig

      Configuration settings for creating a new PokerRoom.

      +

    Returns PokerTableInterface

      +
    • The newly created room instance.
    • +
    +
    class SpecialCasino extends Casino {
    public createSpecialRoom(config: PokerRoomConfig): PokerRoomInterface {
    return this._createRoom(config);
    }
    }
    const specialCasino = new SpecialCasino();
    const newRoom = specialCasino.createSpecialRoom({ name: "Champions Lounge", tableSize: 10, smallBlind: 100, bigBlind: 200 });
    console.log(newRoom.getName()); // Outputs: "Champions Lounge" +
    + +
  • Alias for emitter.on(eventName, listener).

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.26

    +
  • Creates a new PokerRoom instance based on the provided configuration and adds it to the Casino's rooms list.

    +

    N/A

    +

    N/A

    +

    Allows the Casino to dynamically create new rooms as needed by providing specific room configurations.

    +
      +
    • Emits a CasinoEventName.ROOM_CREATED event, enabling listeners to respond to the creation of a new room.
    • +
    +
      +
    • config: A PokerRoomConfig object containing details like name, tableSize, smallBlind, and bigBlind.
    • +
    +

    N/A

    +
      +
    • Returns the newly created PokerRoomInterface instance.
    • +
    +

    Primarily used within subclasses or protected methods to dynamically create and add rooms to the Casino.

    +

    Parameters

    Returns PokerTableInterface

      +
    • The newly created room instance.
    • +
    +
    class SpecialCasino extends Casino {
    public createSpecialRoom(config: PokerRoomConfig): PokerRoomInterface {
    return this._createRoom(config);
    }
    }
    const specialCasino = new SpecialCasino();
    const newRoom = specialCasino.createSpecialRoom({ name: "Champions Lounge", tableSize: 10, smallBlind: 100, bigBlind: 200 });
    console.log(newRoom.getName()); // Outputs: "Champions Lounge" +
    + +
  • Synchronously calls each of the listeners registered for the event named eventName, in the order they were registered, passing the supplied arguments +to each.

    +

    Returns true if the event had listeners, false otherwise.

    +
    import { EventEmitter } from 'node:events';
    const myEmitter = new EventEmitter();

    // First listener
    myEmitter.on('event', function firstListener() {
    console.log('Helloooo! first listener');
    });
    // Second listener
    myEmitter.on('event', function secondListener(arg1, arg2) {
    console.log(`event with parameters ${arg1}, ${arg2} in second listener`);
    });
    // Third listener
    myEmitter.on('event', function thirdListener(...args) {
    const parameters = args.join(', ');
    console.log(`event with parameters ${parameters} in third listener`);
    });

    console.log(myEmitter.listeners('event'));

    myEmitter.emit('event', 1, 2, 3, 4, 5);

    // Prints:
    // [
    // [Function: firstListener],
    // [Function: secondListener],
    // [Function: thirdListener]
    // ]
    // Helloooo! first listener
    // event with parameters 1, 2 in second listener
    // event with parameters 1, 2, 3, 4, 5 in third listener +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • Rest...args: AnyRest

    Returns boolean

    v0.1.26

    +
  • The emitEvent method is a public method for emitting events, with an optional configuration that allows +middleware processing. Middleware functions can intercept and transform the event before it reaches the listeners, +allowing custom validation or data modifications.

    +

    This method enables flexible event emission with support for middleware, providing a robust event processing +mechanism in the BaseEventEmitter. It’s useful for customizing event behavior based on application-specific needs.

    +

    N/A

    +

    N/A

    +

    This method can emit any event specified by eventName, which can then be processed by middleware functions if defined.

    +
      +
    • eventName: string - The name of the event to emit.
    • +
    • options: { event: { data: { [key: string]: any }; [key: string]: any; }, middlewares?: Array<(event: BaseEventInterface, next: () => void) => void | false> } +
        +
      • event - The primary event data to emit, containing specific details.
      • +
      • middlewares - An optional array of middleware functions that process the event before emission.
      • +
      +
    • +
    +
      +
    • eventName must be a valid string.
    • +
    • options.event should include relevant data for the event. If middlewares are provided, they should be functions with an event and next parameter.
    • +
    +
      +
    • void - This method does not return a value.
    • +
    +

    Use this method to emit events with middleware-based customization, which allows for specific processing +logic or transformations before the event reaches listeners.

    +

    Parameters

    • eventName: string

      The name of the event to emit.

      +
    • options: {
          event: {
              data: {
                  [key: string]: any;
              };
              [key: string]: any;
          };
          middlewares?: ((event: BaseEventInterface<any>, next: (() => void)) => false | void)[];
      }

      Configuration for the event and optional middleware functions.

      +
      • event: {
            data: {
                [key: string]: any;
            };
            [key: string]: any;
        }
        • [key: string]: any
        • data: {
              [key: string]: any;
          }
          • [key: string]: any
      • Optionalmiddlewares?: ((event: BaseEventInterface<any>, next: (() => void)) => false | void)[]

    Returns void

    emitter.emitEvent("game:started", {
    event: { data: { gameId: "001", status: "active" } },
    middlewares: [
    (event, next) => { console.log("Processing event:", event); next(); },
    (event, next) => { event.data.processed = true; next(); }
    ]
    }); +
    + +
  • Returns an array listing the events for which the emitter has registered +listeners. The values in the array are strings or Symbols.

    +
    import { EventEmitter } from 'node:events';

    const myEE = new EventEmitter();
    myEE.on('foo', () => {});
    myEE.on('bar', () => {});

    const sym = Symbol('symbol');
    myEE.on(sym, () => {});

    console.log(myEE.eventNames());
    // Prints: [ 'foo', 'bar', Symbol(symbol) ] +
    + +

    Returns (string | symbol)[]

    v6.0.0

    +
  • Creates a new PokerRoom instance based on the provided configuration and adds it to the Casino's rooms list.

    +

    N/A

    +

    N/A

    +

    Allows the Casino to dynamically create new rooms as needed by providing specific room configurations.

    +
      +
    • Emits a CasinoEventName.ROOM_CREATED event, enabling listeners to respond to the creation of a new room.
    • +
    +
      +
    • config: A PokerRoomConfig object containing details like name, tableSize, smallBlind, and bigBlind.
    • +
    +

    N/A

    +
      +
    • Returns the newly created PokerRoomInterface instance.
    • +
    +

    Primarily used within subclasses or protected methods to dynamically create and add rooms to the Casino.

    +

    Returns string

      +
    • The newly created room instance.
    • +
    +
    class SpecialCasino extends Casino {
    public createSpecialRoom(config: PokerRoomConfig): PokerRoomInterface {
    return this._createRoom(config);
    }
    }
    const specialCasino = new SpecialCasino();
    const newRoom = specialCasino.createSpecialRoom({ name: "Champions Lounge", tableSize: 10, smallBlind: 100, bigBlind: 200 });
    console.log(newRoom.getName()); // Outputs: "Champions Lounge" +
    + +
  • Retrieves the current name of the PokerRoom.

    +

    N/A - This method is defined within PokerRoomInterface and is implemented by any class adhering to this interface.

    +

    N/A - This method does not override any superclass or parent methods.

    +

    The getName method enables access to the current name of a PokerRoom, which can be essential for +identification, logging, and displaying room information to users.

    +

    N/A - No events are emitted by this method.

    +

    N/A - This method does not require any parameters.

    +

    N/A - This method simply returns the current name as set by setName.

    +
      +
    • Returns the current name of the PokerRoom as a string.
    • +
    +

    Use this method to fetch the current name of a PokerRoom. This can be particularly helpful for displaying +or verifying the room name during operations.

    +

    Returns string

      +
    • The current name of the PokerRoom.
    • +
    +
    const pokerRoom = new PokerRoom({ name: "VIP Room", tableSize: 6 });
    console.log(pokerRoom.getName()); // Logs "VIP Room" +
    + +
  • Retrieves the associated PokerTable instance within the PokerRoom.

    +

    N/A - This method does not implement external interfaces.

    +

    N/A - This method does not override any superclass or parent methods.

    +

    The getTable method provides access to the PokerTable instance that is actively managed by the PokerRoom. +This can be used to view table configuration, status, and player seating arrangements.

    +

    N/A - This method does not emit any events.

    +

    N/A - No parameters are required for this method.

    +

    N/A - This method does not modify the table, only retrieves it.

    +
      +
    • Returns the PokerTableInterface instance currently set for the room.
    • +
    +

    Use this method to access the poker table associated with a specific room. This allows for table-specific +operations and inquiries.

    +

    Returns PokerTableInterface[]

      +
    • The PokerTable instance associated with this room.
    • +
    +
    const pokerRoom = new PokerRoom({ name: "High Stakes", tableSize: 6 });
    const table = pokerRoom.getTable();
    console.log(table); // Logs the PokerTable instance associated with "High Stakes" room +
    + +
  • Checks if a provided index is within the valid range of the Casino’s room list.

    +

    Implements the isValidIndex method of CasinoInterface.

    +

    N/A

    +

    This method helps validate that an index is within the valid bounds of the Casino’s room list. It prevents +out-of-bound errors and ensures that methods calling on rooms by index are provided with a valid reference.

    +

    N/A

    +
      +
    • index: A zero-based integer representing the position of a room in the Casino's managed list of rooms.
    • +
    +
      +
    • The index should be a non-negative integer and within the bounds of the __rooms array.
    • +
    +
      +
    • Returns true if the index is within bounds.
    • +
    • Throws an Error if the index is out of range.
    • +
    +

    Call this method before performing operations that require a valid room index to prevent out-of-bounds errors. +Can be used in any index-based access patterns for room retrieval or modification.

    +

    Parameters

    • index: number

      The zero-based index to validate.

      +

    Returns boolean

      +
    • Returns true if the index is within bounds.
    • +
    +
      +
    • Throws an error with a message indicating the invalid index.
    • +
    +
    const casino = new Casino();
    try {
    casino.isValidIndex(2); // Returns true if there are at least 3 rooms
    } catch (error) {
    console.error(error.message); // If index 2 is out of bounds, logs error message
    } +
    + +
  • Returns the number of listeners listening for the event named eventName. +If listener is provided, it will return how many times the listener is found +in the list of the listeners of the event.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event being listened for

      +
    • Optionallistener: Function

      The event handler function

      +

    Returns number

    v3.2.0

    +
  • Returns a copy of the array of listeners for the event named eventName.

    +
    server.on('connection', (stream) => {
    console.log('someone connected!');
    });
    console.log(util.inspect(server.listeners('connection')));
    // Prints: [ [Function] ] +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

    Returns Function[]

    v0.1.26

    +
  • Alias for emitter.removeListener().

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v10.0.0

    +
  • Adds the listener function to the end of the listeners array for the event +named eventName. No checks are made to see if the listener has already +been added. Multiple calls passing the same combination of eventName and +listener will result in the listener being added, and called, multiple times.

    +
    server.on('connection', (stream) => {
    console.log('someone connected!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    By default, event listeners are invoked in the order they are added. The emitter.prependListener() method can be used as an alternative to add the +event listener to the beginning of the listeners array.

    +
    import { EventEmitter } from 'node:events';
    const myEE = new EventEmitter();
    myEE.on('foo', () => console.log('a'));
    myEE.prependListener('foo', () => console.log('b'));
    myEE.emit('foo');
    // Prints:
    // b
    // a +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.101

    +
  • Adds a one-time listener function for the event named eventName. The +next time eventName is triggered, this listener is removed and then invoked.

    +
    server.once('connection', (stream) => {
    console.log('Ah, we have our first user!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    By default, event listeners are invoked in the order they are added. The emitter.prependOnceListener() method can be used as an alternative to add the +event listener to the beginning of the listeners array.

    +
    import { EventEmitter } from 'node:events';
    const myEE = new EventEmitter();
    myEE.once('foo', () => console.log('a'));
    myEE.prependOnceListener('foo', () => console.log('b'));
    myEE.emit('foo');
    // Prints:
    // b
    // a +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.3.0

    +
  • Adds the listener function to the beginning of the listeners array for the +event named eventName. No checks are made to see if the listener has +already been added. Multiple calls passing the same combination of eventName +and listener will result in the listener being added, and called, multiple times.

    +
    server.prependListener('connection', (stream) => {
    console.log('someone connected!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v6.0.0

    +
  • Adds a one-timelistener function for the event named eventName to the beginning of the listeners array. The next time eventName is triggered, this +listener is removed, and then invoked.

    +
    server.prependOnceListener('connection', (stream) => {
    console.log('Ah, we have our first user!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v6.0.0

    +
  • Returns a copy of the array of listeners for the event named eventName, +including any wrappers (such as those created by .once()).

    +
    import { EventEmitter } from 'node:events';
    const emitter = new EventEmitter();
    emitter.once('log', () => console.log('log once'));

    // Returns a new Array with a function `onceWrapper` which has a property
    // `listener` which contains the original listener bound above
    const listeners = emitter.rawListeners('log');
    const logFnWrapper = listeners[0];

    // Logs "log once" to the console and does not unbind the `once` event
    logFnWrapper.listener();

    // Logs "log once" to the console and removes the listener
    logFnWrapper();

    emitter.on('log', () => console.log('log persistently'));
    // Will return a new Array with a single function bound by `.on()` above
    const newListeners = emitter.rawListeners('log');

    // Logs "log persistently" twice
    newListeners[0]();
    emitter.emit('log'); +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

    Returns Function[]

    v9.4.0

    +
  • Removes all listeners, or those of the specified eventName.

    +

    It is bad practice to remove listeners added elsewhere in the code, +particularly when the EventEmitter instance was created by some other +component or module (e.g. sockets or file streams).

    +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Parameters

    • OptionaleventName: string | symbol

    Returns this

    v0.1.26

    +
  • Removes the specified listener from the listener array for the event named eventName.

    +
    const callback = (stream) => {
    console.log('someone connected!');
    };
    server.on('connection', callback);
    // ...
    server.removeListener('connection', callback); +
    + +

    removeListener() will remove, at most, one instance of a listener from the +listener array. If any single listener has been added multiple times to the +listener array for the specified eventName, then removeListener() must be +called multiple times to remove each instance.

    +

    Once an event is emitted, all listeners attached to it at the +time of emitting are called in order. This implies that any removeListener() or removeAllListeners() calls after emitting and before the last listener finishes execution +will not remove them fromemit() in progress. Subsequent events behave as expected.

    +
    import { EventEmitter } from 'node:events';
    class MyEmitter extends EventEmitter {}
    const myEmitter = new MyEmitter();

    const callbackA = () => {
    console.log('A');
    myEmitter.removeListener('event', callbackB);
    };

    const callbackB = () => {
    console.log('B');
    };

    myEmitter.on('event', callbackA);

    myEmitter.on('event', callbackB);

    // callbackA removes listener callbackB but it will still be called.
    // Internal listener array at time of emit [callbackA, callbackB]
    myEmitter.emit('event');
    // Prints:
    // A
    // B

    // callbackB is now removed.
    // Internal listener array [callbackA]
    myEmitter.emit('event');
    // Prints:
    // A +
    + +

    Because listeners are managed using an internal array, calling this will +change the position indices of any listener registered after the listener +being removed. This will not impact the order in which listeners are called, +but it means that any copies of the listener array as returned by +the emitter.listeners() method will need to be recreated.

    +

    When a single function has been added as a handler multiple times for a single +event (as in the example below), removeListener() will remove the most +recently added instance. In the example the once('ping') listener is removed:

    +
    import { EventEmitter } from 'node:events';
    const ee = new EventEmitter();

    function pong() {
    console.log('pong');
    }

    ee.on('ping', pong);
    ee.once('ping', pong);
    ee.removeListener('ping', pong);

    ee.emit('ping');
    ee.emit('ping'); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.26

    +
  • By default EventEmitters will print a warning if more than 10 listeners are +added for a particular event. This is a useful default that helps finding +memory leaks. The emitter.setMaxListeners() method allows the limit to be +modified for this specific EventEmitter instance. The value can be set to Infinity (or 0) to indicate an unlimited number of listeners.

    +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Parameters

    • n: number

    Returns this

    v0.3.5

    +
  • Sets the name of the PokerRoom, allowing the name to be updated or customized.

    +

    N/A - This method is part of the PokerRoomInterface and does not implement any external methods.

    +

    N/A - This method does not override any superclass or parent methods.

    +

    The setName method is used to assign a specific name to a PokerRoom, which helps distinguish it within the system. +This is essential for systems where rooms need to be identifiable and manageable through a unique name.

    +

    N/A - No events are emitted by this method.

    +
      +
    • name: A string representing the new name for the room. It must be a valid, non-empty string to ensure +the room has a clear, identifiable label.
    • +
    +
      +
    • The name parameter should be a non-empty string to provide meaningful identification.
    • +
    • Passing an empty or invalid value could result in future misidentification of rooms if validation is implemented.
    • +
    +
      +
    • Returns the name that was set for the PokerRoom.
    • +
    +

    Use this method to set or update the name of a room in a system where unique or identifiable room names +are necessary for reference.

    +

    Parameters

    • name: string

      The new name for the PokerRoom.

      +

    Returns string

      +
    • Returns the name of the room that was set.
    • +
    +
    const pokerRoom = new PokerRoom({ name: "Room1", tableSize: 6 });
    pokerRoom.setName("HighRollers"); // Sets the name of the room to "HighRollers"
    console.log(pokerRoom.getName()); // Logs "HighRollers" +
    + +
  • Sets the table configuration within the PokerRoom. The table configuration determines essential +settings for the poker table, such as table size, small blind, and big blind values.

    +

    N/A - This method is part of the PokerRoomInterface and does not implement any external methods.

    +

    N/A - This method does not override any superclass or parent methods.

    +

    The setTables method allows configuration or reconfiguration of the poker table within a room. +Properly setting up the table configuration is vital for game mechanics and player experience.

    +

    N/A - No events are emitted by this method.

    +
      +
    • table: A PokerTableInterface instance containing configuration details for the room’s table.
    • +
    +
      +
    • The table parameter should be a valid instance of PokerTableInterface, configured with necessary game parameters.
    • +
    +
      +
    • Returns the PokerTableInterface instance after updating it within the room.
    • +
    +

    Call this method to configure or update the settings of a poker table in the room. This helps ensure +all game-related settings, such as seating and blinds, are properly managed.

    +

    Parameters

    Returns PokerTableInterface[]

      +
    • Returns the table configuration set for the room.
    • +
    +
    const pokerRoom = new PokerRoom({ name: "Room3", tableSize: 8 });
    const tableConfig = new PokerTable({ tableSize: 8, smallBlind: 10, bigBlind: 20 });
    pokerRoom.setTables(tableConfig); // Configures the table for the room
    console.log(pokerRoom.getTable()); // Logs the table configuration +
    + +
  • size +Starts a new PokerGame if there are at least two active players at the PokerTable. +This method initiates the game flow, including assigning blinds and starting the rounds.

    +

    Returns number

  • Returns the total number of PokerRoom instances currently managed by the Casino.

    +

    Implements the roomCount method of CasinoInterface.

    +

    N/A

    +

    Provides a simple way to check how many poker rooms the Casino is currently managing. Useful for general +information about the Casino's state and for validating indices or conditions that depend on room count.

    +

    N/A

    +

    N/A

    +

    N/A

    +
      +
    • Returns the number of rooms currently managed by the Casino.
    • +
    +

    This method is useful for any scenario where the total number of active rooms is needed, such as iterating +over all rooms or validating index-based operations.

    +

    Returns number

      +
    • The current count of rooms in the Casino.
    • +
    +
    const casino = new Casino();
    const count = casino.roomCount();
    console.log(count); // Logs the total number of managed rooms, e.g., 5 +
    + +
  • Experimental

    Listens once to the abort event on the provided signal.

    +

    Listening to the abort event on abort signals is unsafe and may +lead to resource leaks since another third party with the signal can +call e.stopImmediatePropagation(). Unfortunately Node.js cannot change +this since it would violate the web standard. Additionally, the original +API makes it easy to forget to remove listeners.

    +

    This API allows safely using AbortSignals in Node.js APIs by solving these +two issues by listening to the event such that stopImmediatePropagation does +not prevent the listener from running.

    +

    Returns a disposable so that it may be unsubscribed from more easily.

    +
    import { addAbortListener } from 'node:events';

    function example(signal) {
    let disposable;
    try {
    signal.addEventListener('abort', (e) => e.stopImmediatePropagation());
    disposable = addAbortListener(signal, (e) => {
    // Do something when signal is aborted.
    });
    } finally {
    disposable?.[Symbol.dispose]();
    }
    } +
    + +

    Parameters

    • signal: AbortSignal
    • resource: ((event: Event) => void)
        • (event): void
        • Parameters

          • event: Event

          Returns void

    Returns Disposable

    Disposable that removes the abort listener.

    +

    v20.5.0

    +
  • Returns a copy of the array of listeners for the event named eventName.

    +

    For EventEmitters this behaves exactly the same as calling .listeners on +the emitter.

    +

    For EventTargets this is the only way to get the event listeners for the +event target. This is useful for debugging and diagnostic purposes.

    +
    import { getEventListeners, EventEmitter } from 'node:events';

    {
    const ee = new EventEmitter();
    const listener = () => console.log('Events are fun');
    ee.on('foo', listener);
    console.log(getEventListeners(ee, 'foo')); // [ [Function: listener] ]
    }
    {
    const et = new EventTarget();
    const listener = () => console.log('Events are fun');
    et.addEventListener('foo', listener);
    console.log(getEventListeners(et, 'foo')); // [ [Function: listener] ]
    } +
    + +

    Parameters

    • emitter: EventEmitter<DefaultEventMap> | EventTarget
    • name: string | symbol

    Returns Function[]

    v15.2.0, v14.17.0

    +
  • Returns the currently set max amount of listeners.

    +

    For EventEmitters this behaves exactly the same as calling .getMaxListeners on +the emitter.

    +

    For EventTargets this is the only way to get the max event listeners for the +event target. If the number of event handlers on a single EventTarget exceeds +the max set, the EventTarget will print a warning.

    +
    import { getMaxListeners, setMaxListeners, EventEmitter } from 'node:events';

    {
    const ee = new EventEmitter();
    console.log(getMaxListeners(ee)); // 10
    setMaxListeners(11, ee);
    console.log(getMaxListeners(ee)); // 11
    }
    {
    const et = new EventTarget();
    console.log(getMaxListeners(et)); // 10
    setMaxListeners(11, et);
    console.log(getMaxListeners(et)); // 11
    } +
    + +

    Parameters

    • emitter: EventEmitter<DefaultEventMap> | EventTarget

    Returns number

    v19.9.0

    +
  • A class method that returns the number of listeners for the given eventName registered on the given emitter.

    +
    import { EventEmitter, listenerCount } from 'node:events';

    const myEmitter = new EventEmitter();
    myEmitter.on('event', () => {});
    myEmitter.on('event', () => {});
    console.log(listenerCount(myEmitter, 'event'));
    // Prints: 2 +
    + +

    Parameters

    • emitter: EventEmitter<DefaultEventMap>

      The emitter to query

      +
    • eventName: string | symbol

      The event name

      +

    Returns number

    v0.9.12

    +

    Since v3.2.0 - Use listenerCount instead.

    +
  • import { on, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ee = new EventEmitter();

    // Emit later on
    process.nextTick(() => {
    ee.emit('foo', 'bar');
    ee.emit('foo', 42);
    });

    for await (const event of on(ee, 'foo')) {
    // The execution of this inner block is synchronous and it
    // processes one event at a time (even with await). Do not use
    // if concurrent execution is required.
    console.log(event); // prints ['bar'] [42]
    }
    // Unreachable here +
    + +

    Returns an AsyncIterator that iterates eventName events. It will throw +if the EventEmitter emits 'error'. It removes all listeners when +exiting the loop. The value returned by each iteration is an array +composed of the emitted event arguments.

    +

    An AbortSignal can be used to cancel waiting on events:

    +
    import { on, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ac = new AbortController();

    (async () => {
    const ee = new EventEmitter();

    // Emit later on
    process.nextTick(() => {
    ee.emit('foo', 'bar');
    ee.emit('foo', 42);
    });

    for await (const event of on(ee, 'foo', { signal: ac.signal })) {
    // The execution of this inner block is synchronous and it
    // processes one event at a time (even with await). Do not use
    // if concurrent execution is required.
    console.log(event); // prints ['bar'] [42]
    }
    // Unreachable here
    })();

    process.nextTick(() => ac.abort()); +
    + +

    Use the close option to specify an array of event names that will end the iteration:

    +
    import { on, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ee = new EventEmitter();

    // Emit later on
    process.nextTick(() => {
    ee.emit('foo', 'bar');
    ee.emit('foo', 42);
    ee.emit('close');
    });

    for await (const event of on(ee, 'foo', { close: ['close'] })) {
    console.log(event); // prints ['bar'] [42]
    }
    // the loop will exit after 'close' is emitted
    console.log('done'); // prints 'done' +
    + +

    Parameters

    • emitter: EventEmitter<DefaultEventMap>
    • eventName: string | symbol
    • Optionaloptions: StaticEventEmitterIteratorOptions

    Returns AsyncIterator<any[], any, any>

    An AsyncIterator that iterates eventName events emitted by the emitter

    +

    v13.6.0, v12.16.0

    +
  • Parameters

    • emitter: EventTarget
    • eventName: string
    • Optionaloptions: StaticEventEmitterIteratorOptions

    Returns AsyncIterator<any[], any, any>

  • Creates a Promise that is fulfilled when the EventEmitter emits the given +event or that is rejected if the EventEmitter emits 'error' while waiting. +The Promise will resolve with an array of all the arguments emitted to the +given event.

    +

    This method is intentionally generic and works with the web platform EventTarget interface, which has no special'error' event +semantics and does not listen to the 'error' event.

    +
    import { once, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ee = new EventEmitter();

    process.nextTick(() => {
    ee.emit('myevent', 42);
    });

    const [value] = await once(ee, 'myevent');
    console.log(value);

    const err = new Error('kaboom');
    process.nextTick(() => {
    ee.emit('error', err);
    });

    try {
    await once(ee, 'myevent');
    } catch (err) {
    console.error('error happened', err);
    } +
    + +

    The special handling of the 'error' event is only used when events.once() is used to wait for another event. If events.once() is used to wait for the +'error' event itself, then it is treated as any other kind of event without +special handling:

    +
    import { EventEmitter, once } from 'node:events';

    const ee = new EventEmitter();

    once(ee, 'error')
    .then(([err]) => console.log('ok', err.message))
    .catch((err) => console.error('error', err.message));

    ee.emit('error', new Error('boom'));

    // Prints: ok boom +
    + +

    An AbortSignal can be used to cancel waiting for the event:

    +
    import { EventEmitter, once } from 'node:events';

    const ee = new EventEmitter();
    const ac = new AbortController();

    async function foo(emitter, event, signal) {
    try {
    await once(emitter, event, { signal });
    console.log('event emitted!');
    } catch (error) {
    if (error.name === 'AbortError') {
    console.error('Waiting for the event was canceled!');
    } else {
    console.error('There was an error', error.message);
    }
    }
    }

    foo(ee, 'foo', ac.signal);
    ac.abort(); // Abort waiting for the event
    ee.emit('foo'); // Prints: Waiting for the event was canceled! +
    + +

    Parameters

    • emitter: EventEmitter<DefaultEventMap>
    • eventName: string | symbol
    • Optionaloptions: StaticEventEmitterOptions

    Returns Promise<any[]>

    v11.13.0, v10.16.0

    +
  • Parameters

    • emitter: EventTarget
    • eventName: string
    • Optionaloptions: StaticEventEmitterOptions

    Returns Promise<any[]>

  • import { setMaxListeners, EventEmitter } from 'node:events';

    const target = new EventTarget();
    const emitter = new EventEmitter();

    setMaxListeners(5, target, emitter); +
    + +

    Parameters

    • Optionaln: number

      A non-negative number. The maximum number of listeners per EventTarget event.

      +
    • Rest...eventTargets: (EventEmitter<DefaultEventMap> | EventTarget)[]

      Zero or more {EventTarget} or {EventEmitter} instances. If none are specified, n is set as the default max for all newly created {EventTarget} and {EventEmitter} +objects.

      +

    Returns void

    v15.4.0

    +
diff --git a/docs/site/classes/models_pokerSeat.PokerSeat.html b/docs/site/classes/models_pokerSeat.PokerSeat.html new file mode 100644 index 0000000..9e32202 --- /dev/null +++ b/docs/site/classes/models_pokerSeat.PokerSeat.html @@ -0,0 +1,503 @@ +PokerSeat | casinojs

PokerSeat

+

Represents a single seat at a poker table, managing player occupancy and seat status events. +The PokerSeat class is central to tracking each player’s seat position, handling seat-related +events like occupancy, vacancy, and position designation for dealer or blind roles.

+

PokerSeat is designed to provide a controlled environment for managing players at individual +seats on a poker table. It facilitates managing seat occupancy, seat status updates, and emitting +events that alert the broader poker room to seat changes or player actions.

+

This class extends Node.js’s EventEmitter, allowing PokerSeat to emit events like +seatOccupied or seatVacated to notify other components when a seat’s status changes.

+

This class implements PokerSeatInterface, providing a standard interface for seat operations, +ensuring consistent seat management across various parts of the application.

+

The PokerSeat includes the following methods:

+
    +
  • occupySeat: Adds a player to the seat and emits a seat-occupied event.
  • +
  • vacateSeat: Removes the player from the seat and emits a seat-vacated event.
  • +
  • isSeatOccupied: Checks if the seat is currently occupied.
  • +
  • assignBlind: Assigns the small or big blind role to the seat.
  • +
+

The PokerSeat class emits events related to player actions at the seat:

+
    +
  • PokerSeat:Occupied: Emitted when a player occupies the seat.
  • +
  • PokerSeat:Vacated: Emitted when the seat is vacated.
  • +
+

This class standardizes player management at a single seat, supporting operations like setting +the dealer or blind role and monitoring seat status.

+
const pokerSeat = new PokerSeat();
pokerSeat.on(PokerSeatEvents.SEAT_OCCUPIED, () => console.log("Seat is now occupied"));
pokerSeat.occupySeat(player);
console.log(pokerSeat.isSeatOccupied()); // Console Output: true +
+ +

Hierarchy (view full)

Implements

Constructors

  • The public constructor method initializes a new instance of PokerSeat, setting up its configuration based on the +provided PokerSeatConfig parameter. This configuration includes seat properties such as id, position, isDealer, +and the player occupying the seat.

    +

    The constructor method creates a fully initialized PokerSeat instance. It provides a structure for each seat +at a poker table and uses the __init method to ensure all required configurations are applied.

    +

    N/A

    +

    N/A

    +
      +
    • config: PokerSeatConfig - An optional configuration object that defines initial properties for the seat. +This includes the id, position, isDealer status, and the player.
    • +
    +
      +
    • The config object should be structured to align with the PokerSeatConfig interface.
    • +
    • Default values are set if config is missing or incomplete.
    • +
    +
      +
    • N/A - As a constructor, this does not return a value.
    • +
    +

    Use this constructor to create new PokerSeat instances for each seat at a poker table, each with a unique +configuration. This can be particularly useful when setting up multiple seats within a table class.

    +

    Parameters

    • config: PokerSeatConfig

      Configuration object for setting initial seat properties.

      +

    Returns PokerSeat

    const seatConfig = { id: "seat1", position: 3, isDealer: false };
    const pokerSeat = new PokerSeat(seatConfig);
    console.log(pokerSeat.getPosition()); // Console Output: 3 +
    + +

Properties

captureRejections: boolean

Value: boolean

+

Change the default captureRejections option on all new EventEmitter objects.

+

v13.4.0, v12.16.0

+
captureRejectionSymbol: typeof captureRejectionSymbol

Value: Symbol.for('nodejs.rejection')

+

See how to write a custom rejection handler.

+

v13.4.0, v12.16.0

+
defaultMaxListeners: number

By default, a maximum of 10 listeners can be registered for any single +event. This limit can be changed for individual EventEmitter instances +using the emitter.setMaxListeners(n) method. To change the default +for allEventEmitter instances, the events.defaultMaxListeners property +can be used. If this value is not a positive number, a RangeError is thrown.

+

Take caution when setting the events.defaultMaxListeners because the +change affects all EventEmitter instances, including those created before +the change is made. However, calling emitter.setMaxListeners(n) still has +precedence over events.defaultMaxListeners.

+

This is not a hard limit. The EventEmitter instance will allow +more listeners to be added but will output a trace warning to stderr indicating +that a "possible EventEmitter memory leak" has been detected. For any single +EventEmitter, the emitter.getMaxListeners() and emitter.setMaxListeners() methods can be used to +temporarily avoid this warning:

+
import { EventEmitter } from 'node:events';
const emitter = new EventEmitter();
emitter.setMaxListeners(emitter.getMaxListeners() + 1);
emitter.once('event', () => {
// do stuff
emitter.setMaxListeners(Math.max(emitter.getMaxListeners() - 1, 0));
}); +
+ +

The --trace-warnings command-line flag can be used to display the +stack trace for such warnings.

+

The emitted warning can be inspected with process.on('warning') and will +have the additional emitter, type, and count properties, referring to +the event emitter instance, the event's name and the number of attached +listeners, respectively. +Its name property is set to 'MaxListenersExceededWarning'.

+

v0.11.2

+
errorMonitor: typeof errorMonitor

This symbol shall be used to install a listener for only monitoring 'error' events. Listeners installed using this symbol are called before the regular 'error' listeners are called.

+

Installing a listener using this symbol does not change the behavior once an 'error' event is emitted. Therefore, the process will still crash if no +regular 'error' listener is installed.

+

v13.6.0, v12.17.0

+

Methods

  • Alias for emitter.on(eventName, listener).

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.26

    +
  • Synchronously calls each of the listeners registered for the event named eventName, in the order they were registered, passing the supplied arguments +to each.

    +

    Returns true if the event had listeners, false otherwise.

    +
    import { EventEmitter } from 'node:events';
    const myEmitter = new EventEmitter();

    // First listener
    myEmitter.on('event', function firstListener() {
    console.log('Helloooo! first listener');
    });
    // Second listener
    myEmitter.on('event', function secondListener(arg1, arg2) {
    console.log(`event with parameters ${arg1}, ${arg2} in second listener`);
    });
    // Third listener
    myEmitter.on('event', function thirdListener(...args) {
    const parameters = args.join(', ');
    console.log(`event with parameters ${parameters} in third listener`);
    });

    console.log(myEmitter.listeners('event'));

    myEmitter.emit('event', 1, 2, 3, 4, 5);

    // Prints:
    // [
    // [Function: firstListener],
    // [Function: secondListener],
    // [Function: thirdListener]
    // ]
    // Helloooo! first listener
    // event with parameters 1, 2 in second listener
    // event with parameters 1, 2, 3, 4, 5 in third listener +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • Rest...args: AnyRest

    Returns boolean

    v0.1.26

    +
  • The emitEvent method is a public method for emitting events, with an optional configuration that allows +middleware processing. Middleware functions can intercept and transform the event before it reaches the listeners, +allowing custom validation or data modifications.

    +

    This method enables flexible event emission with support for middleware, providing a robust event processing +mechanism in the BaseEventEmitter. It’s useful for customizing event behavior based on application-specific needs.

    +

    N/A

    +

    N/A

    +

    This method can emit any event specified by eventName, which can then be processed by middleware functions if defined.

    +
      +
    • eventName: string - The name of the event to emit.
    • +
    • options: { event: { data: { [key: string]: any }; [key: string]: any; }, middlewares?: Array<(event: BaseEventInterface, next: () => void) => void | false> } +
        +
      • event - The primary event data to emit, containing specific details.
      • +
      • middlewares - An optional array of middleware functions that process the event before emission.
      • +
      +
    • +
    +
      +
    • eventName must be a valid string.
    • +
    • options.event should include relevant data for the event. If middlewares are provided, they should be functions with an event and next parameter.
    • +
    +
      +
    • void - This method does not return a value.
    • +
    +

    Use this method to emit events with middleware-based customization, which allows for specific processing +logic or transformations before the event reaches listeners.

    +

    Parameters

    • eventName: string

      The name of the event to emit.

      +
    • options: {
          event: {
              data: {
                  [key: string]: any;
              };
              [key: string]: any;
          };
          middlewares?: ((event: BaseEventInterface<any>, next: (() => void)) => false | void)[];
      }

      Configuration for the event and optional middleware functions.

      +
      • event: {
            data: {
                [key: string]: any;
            };
            [key: string]: any;
        }
        • [key: string]: any
        • data: {
              [key: string]: any;
          }
          • [key: string]: any
      • Optionalmiddlewares?: ((event: BaseEventInterface<any>, next: (() => void)) => false | void)[]

    Returns void

    emitter.emitEvent("game:started", {
    event: { data: { gameId: "001", status: "active" } },
    middlewares: [
    (event, next) => { console.log("Processing event:", event); next(); },
    (event, next) => { event.data.processed = true; next(); }
    ]
    }); +
    + +
  • Returns an array listing the events for which the emitter has registered +listeners. The values in the array are strings or Symbols.

    +
    import { EventEmitter } from 'node:events';

    const myEE = new EventEmitter();
    myEE.on('foo', () => {});
    myEE.on('bar', () => {});

    const sym = Symbol('symbol');
    myEE.on(sym, () => {});

    console.log(myEE.eventNames());
    // Prints: [ 'foo', 'bar', Symbol(symbol) ] +
    + +

    Returns (string | symbol)[]

    v6.0.0

    +
  • The getId method is a public getter that retrieves the unique identifier (id) of the PokerSeat instance.

    +

    N/A

    +

    N/A

    +

    This method provides access to the unique id of each PokerSeat, allowing it to be referenced or compared +with other seats at the table. This identifier is essential for managing individual seats, especially in a table +with multiple players.

    +

    N/A

    +

    N/A

    +
      +
    • This method requires no parameters.
    • +
    +
      +
    • string - Returns the unique identifier (id) assigned to the seat.
    • +
    +

    Use this method to retrieve the id of the seat, which can be useful for logging, comparisons, or when tracking +which seat a player occupies.

    +

    Returns string

      +
    • The unique identifier of the seat.
    • +
    +
    const pokerSeat = new PokerSeat();
    console.log(pokerSeat.getId());
    // Console Output: a unique string identifier, e.g., "123e4567-e89b-12d3-a456-426614174000" +
    + +
  • The getPlayer method is a public getter that retrieves the player occupying this seat, if any.

    +

    N/A

    +

    N/A

    +

    This method provides access to the player currently occupying the seat, allowing the application to retrieve +player-specific data, manage player actions, or determine seat vacancy.

    +

    N/A

    +

    N/A

    +
      +
    • This method requires no parameters.
    • +
    +
      +
    • PokerPlayerInterface | undefined - Returns the player instance occupying this seat, or undefined if the seat is vacant.
    • +
    +

    Use this method to retrieve the player occupying this seat, which is helpful in managing player actions or +determining if the seat is available for another player.

    +

    Returns undefined | PokerPlayerInterface

      +
    • The player instance if occupied, or undefined if vacant.
    • +
    +
    const pokerSeat = new PokerSeat();
    pokerSeat.occupySeat(player); // player implements PokerPlayerInterface
    console.log(pokerSeat.getPlayer());
    // Console Output: <PlayerInstance> +
    + +
  • The getPosition method is a public getter that retrieves the seat’s position at the poker table.

    +

    N/A

    +

    N/A

    +

    This method provides access to the seat's specific position on the poker table, which is important for managing +turn order, dealer rotation, and blind assignments in poker games.

    +

    N/A

    +

    N/A

    +
      +
    • This method requires no parameters.
    • +
    +
      +
    • number - Returns the position of the seat at the table.
    • +
    +

    Use this method to retrieve the position of the seat, which can be essential for turn-based logic and managing +seating order at the poker table.

    +

    Returns number

      +
    • The position of the seat at the table.
    • +
    +
    const pokerSeat = new PokerSeat({ position: 3 });
    console.log(pokerSeat.getPosition());
    // Console Output: 3 +
    + +
  • The isDealer method is a public getter that checks if this seat is currently designated as the dealer seat.

    +

    N/A

    +

    N/A

    +

    This method indicates whether the seat has been designated as the dealer, which is critical for determining +turn order and managing the game's flow, especially in games where the dealer role rotates between players.

    +

    N/A

    +

    N/A

    +
      +
    • This method requires no parameters.
    • +
    +
      +
    • boolean - Returns true if this seat is designated as the dealer, otherwise false.
    • +
    +

    Use this method to check if the seat has the dealer role, which is particularly useful for managing dealer-related +functions like initiating blinds or handling turn order.

    +

    Returns boolean

      +
    • The dealer status of the seat.
    • +
    +
    const pokerSeat = new PokerSeat();
    pokerSeat.setDealer(true);
    console.log(pokerSeat.isDealer());
    // Console Output: true +
    + +
  • The isOccupied method checks if the seat is currently occupied by a player.

    +

    This method is essential for determining seat occupancy status, enabling other parts of the program to +verify if a seat is taken before allowing actions such as seating another player.

    +

    Returns boolean

      +
    • true if the seat has a player, otherwise false.
    • +
    +
  • Returns the number of listeners listening for the event named eventName. +If listener is provided, it will return how many times the listener is found +in the list of the listeners of the event.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event being listened for

      +
    • Optionallistener: Function

      The event handler function

      +

    Returns number

    v3.2.0

    +
  • Returns a copy of the array of listeners for the event named eventName.

    +
    server.on('connection', (stream) => {
    console.log('someone connected!');
    });
    console.log(util.inspect(server.listeners('connection')));
    // Prints: [ [Function] ] +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

    Returns Function[]

    v0.1.26

    +
  • The occupy method assigns a player to occupy this seat.

    +

    This method assigns a player to the seat, indicating the seat is occupied. It is essential for seating +management, allowing a player to be seated at a specific position at the poker table.

    +

    Parameters

    Returns void

  • Alias for emitter.removeListener().

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v10.0.0

    +
  • Adds the listener function to the end of the listeners array for the event +named eventName. No checks are made to see if the listener has already +been added. Multiple calls passing the same combination of eventName and +listener will result in the listener being added, and called, multiple times.

    +
    server.on('connection', (stream) => {
    console.log('someone connected!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    By default, event listeners are invoked in the order they are added. The emitter.prependListener() method can be used as an alternative to add the +event listener to the beginning of the listeners array.

    +
    import { EventEmitter } from 'node:events';
    const myEE = new EventEmitter();
    myEE.on('foo', () => console.log('a'));
    myEE.prependListener('foo', () => console.log('b'));
    myEE.emit('foo');
    // Prints:
    // b
    // a +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.101

    +
  • Adds a one-time listener function for the event named eventName. The +next time eventName is triggered, this listener is removed and then invoked.

    +
    server.once('connection', (stream) => {
    console.log('Ah, we have our first user!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    By default, event listeners are invoked in the order they are added. The emitter.prependOnceListener() method can be used as an alternative to add the +event listener to the beginning of the listeners array.

    +
    import { EventEmitter } from 'node:events';
    const myEE = new EventEmitter();
    myEE.once('foo', () => console.log('a'));
    myEE.prependOnceListener('foo', () => console.log('b'));
    myEE.emit('foo');
    // Prints:
    // b
    // a +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.3.0

    +
  • Adds the listener function to the beginning of the listeners array for the +event named eventName. No checks are made to see if the listener has +already been added. Multiple calls passing the same combination of eventName +and listener will result in the listener being added, and called, multiple times.

    +
    server.prependListener('connection', (stream) => {
    console.log('someone connected!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v6.0.0

    +
  • Adds a one-timelistener function for the event named eventName to the beginning of the listeners array. The next time eventName is triggered, this +listener is removed, and then invoked.

    +
    server.prependOnceListener('connection', (stream) => {
    console.log('Ah, we have our first user!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v6.0.0

    +
  • Returns a copy of the array of listeners for the event named eventName, +including any wrappers (such as those created by .once()).

    +
    import { EventEmitter } from 'node:events';
    const emitter = new EventEmitter();
    emitter.once('log', () => console.log('log once'));

    // Returns a new Array with a function `onceWrapper` which has a property
    // `listener` which contains the original listener bound above
    const listeners = emitter.rawListeners('log');
    const logFnWrapper = listeners[0];

    // Logs "log once" to the console and does not unbind the `once` event
    logFnWrapper.listener();

    // Logs "log once" to the console and removes the listener
    logFnWrapper();

    emitter.on('log', () => console.log('log persistently'));
    // Will return a new Array with a single function bound by `.on()` above
    const newListeners = emitter.rawListeners('log');

    // Logs "log persistently" twice
    newListeners[0]();
    emitter.emit('log'); +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

    Returns Function[]

    v9.4.0

    +
  • Removes all listeners, or those of the specified eventName.

    +

    It is bad practice to remove listeners added elsewhere in the code, +particularly when the EventEmitter instance was created by some other +component or module (e.g. sockets or file streams).

    +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Parameters

    • OptionaleventName: string | symbol

    Returns this

    v0.1.26

    +
  • Removes the specified listener from the listener array for the event named eventName.

    +
    const callback = (stream) => {
    console.log('someone connected!');
    };
    server.on('connection', callback);
    // ...
    server.removeListener('connection', callback); +
    + +

    removeListener() will remove, at most, one instance of a listener from the +listener array. If any single listener has been added multiple times to the +listener array for the specified eventName, then removeListener() must be +called multiple times to remove each instance.

    +

    Once an event is emitted, all listeners attached to it at the +time of emitting are called in order. This implies that any removeListener() or removeAllListeners() calls after emitting and before the last listener finishes execution +will not remove them fromemit() in progress. Subsequent events behave as expected.

    +
    import { EventEmitter } from 'node:events';
    class MyEmitter extends EventEmitter {}
    const myEmitter = new MyEmitter();

    const callbackA = () => {
    console.log('A');
    myEmitter.removeListener('event', callbackB);
    };

    const callbackB = () => {
    console.log('B');
    };

    myEmitter.on('event', callbackA);

    myEmitter.on('event', callbackB);

    // callbackA removes listener callbackB but it will still be called.
    // Internal listener array at time of emit [callbackA, callbackB]
    myEmitter.emit('event');
    // Prints:
    // A
    // B

    // callbackB is now removed.
    // Internal listener array [callbackA]
    myEmitter.emit('event');
    // Prints:
    // A +
    + +

    Because listeners are managed using an internal array, calling this will +change the position indices of any listener registered after the listener +being removed. This will not impact the order in which listeners are called, +but it means that any copies of the listener array as returned by +the emitter.listeners() method will need to be recreated.

    +

    When a single function has been added as a handler multiple times for a single +event (as in the example below), removeListener() will remove the most +recently added instance. In the example the once('ping') listener is removed:

    +
    import { EventEmitter } from 'node:events';
    const ee = new EventEmitter();

    function pong() {
    console.log('pong');
    }

    ee.on('ping', pong);
    ee.once('ping', pong);
    ee.removeListener('ping', pong);

    ee.emit('ping');
    ee.emit('ping'); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.26

    +
  • The setDealer method is a public setter that designates the PokerSeat instance as the dealer seat if true +is passed, or removes the dealer designation if false is passed.

    +

    N/A

    +

    N/A

    +

    This method allows toggling the dealer status for a seat, which is essential for poker games where the dealer +role shifts between players. By marking a seat as the dealer, this method helps manage game flow, particularly +in the context of determining blinds, turn order, and betting phases.

    +

    N/A

    +
      +
    • bool: boolean - A boolean value indicating whether this seat should be designated as the dealer. +
        +
      • If true, the seat is set as the dealer.
      • +
      • If false, the seat's dealer status is removed.
      • +
      +
    • +
    +
      +
    • bool must be a boolean value (true or false).
    • +
    • Passing true designates the seat as the dealer, while false removes the dealer status.
    • +
    +
      +
    • boolean - The assigned dealer status for the seat. +
        +
      • Returns true if the seat is designated as the dealer, and false if it is not.
      • +
      +
    • +
    +

    Use this method to assign or remove the dealer status of a seat. Typically, only one seat at a table should +have the dealer status at any given time. This method is useful in scenarios where the dealer role rotates, +such as in each new round of a poker game.

    +

    Parameters

    • bool: boolean

      A boolean indicating whether this seat is the dealer.

      +

    Returns boolean

      +
    • The updated dealer status of the seat.
    • +
    +
    const pokerSeat = new PokerSeat({ position: 2 });
    pokerSeat.setDealer(true); // Sets the seat as the dealer
    console.log(pokerSeat.isDealer()); // Console Output: true

    pokerSeat.setDealer(false); // Removes dealer designation
    console.log(pokerSeat.isDealer()); // Console Output: false +
    + +
  • By default EventEmitters will print a warning if more than 10 listeners are +added for a particular event. This is a useful default that helps finding +memory leaks. The emitter.setMaxListeners() method allows the limit to be +modified for this specific EventEmitter instance. The value can be set to Infinity (or 0) to indicate an unlimited number of listeners.

    +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Parameters

    • n: number

    Returns this

    v0.3.5

    +
  • The vacate method removes the player from the seat, marking it as unoccupied.

    +

    This method allows for freeing up the seat by removing the player, which is essential in poker games +where players may need to leave their seat or be reassigned to a different seat.

    +

    Returns void

  • Experimental

    Listens once to the abort event on the provided signal.

    +

    Listening to the abort event on abort signals is unsafe and may +lead to resource leaks since another third party with the signal can +call e.stopImmediatePropagation(). Unfortunately Node.js cannot change +this since it would violate the web standard. Additionally, the original +API makes it easy to forget to remove listeners.

    +

    This API allows safely using AbortSignals in Node.js APIs by solving these +two issues by listening to the event such that stopImmediatePropagation does +not prevent the listener from running.

    +

    Returns a disposable so that it may be unsubscribed from more easily.

    +
    import { addAbortListener } from 'node:events';

    function example(signal) {
    let disposable;
    try {
    signal.addEventListener('abort', (e) => e.stopImmediatePropagation());
    disposable = addAbortListener(signal, (e) => {
    // Do something when signal is aborted.
    });
    } finally {
    disposable?.[Symbol.dispose]();
    }
    } +
    + +

    Parameters

    • signal: AbortSignal
    • resource: ((event: Event) => void)
        • (event): void
        • Parameters

          • event: Event

          Returns void

    Returns Disposable

    Disposable that removes the abort listener.

    +

    v20.5.0

    +
  • Returns a copy of the array of listeners for the event named eventName.

    +

    For EventEmitters this behaves exactly the same as calling .listeners on +the emitter.

    +

    For EventTargets this is the only way to get the event listeners for the +event target. This is useful for debugging and diagnostic purposes.

    +
    import { getEventListeners, EventEmitter } from 'node:events';

    {
    const ee = new EventEmitter();
    const listener = () => console.log('Events are fun');
    ee.on('foo', listener);
    console.log(getEventListeners(ee, 'foo')); // [ [Function: listener] ]
    }
    {
    const et = new EventTarget();
    const listener = () => console.log('Events are fun');
    et.addEventListener('foo', listener);
    console.log(getEventListeners(et, 'foo')); // [ [Function: listener] ]
    } +
    + +

    Parameters

    • emitter: EventEmitter<DefaultEventMap> | EventTarget
    • name: string | symbol

    Returns Function[]

    v15.2.0, v14.17.0

    +
  • Returns the currently set max amount of listeners.

    +

    For EventEmitters this behaves exactly the same as calling .getMaxListeners on +the emitter.

    +

    For EventTargets this is the only way to get the max event listeners for the +event target. If the number of event handlers on a single EventTarget exceeds +the max set, the EventTarget will print a warning.

    +
    import { getMaxListeners, setMaxListeners, EventEmitter } from 'node:events';

    {
    const ee = new EventEmitter();
    console.log(getMaxListeners(ee)); // 10
    setMaxListeners(11, ee);
    console.log(getMaxListeners(ee)); // 11
    }
    {
    const et = new EventTarget();
    console.log(getMaxListeners(et)); // 10
    setMaxListeners(11, et);
    console.log(getMaxListeners(et)); // 11
    } +
    + +

    Parameters

    • emitter: EventEmitter<DefaultEventMap> | EventTarget

    Returns number

    v19.9.0

    +
  • A class method that returns the number of listeners for the given eventName registered on the given emitter.

    +
    import { EventEmitter, listenerCount } from 'node:events';

    const myEmitter = new EventEmitter();
    myEmitter.on('event', () => {});
    myEmitter.on('event', () => {});
    console.log(listenerCount(myEmitter, 'event'));
    // Prints: 2 +
    + +

    Parameters

    • emitter: EventEmitter<DefaultEventMap>

      The emitter to query

      +
    • eventName: string | symbol

      The event name

      +

    Returns number

    v0.9.12

    +

    Since v3.2.0 - Use listenerCount instead.

    +
  • import { on, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ee = new EventEmitter();

    // Emit later on
    process.nextTick(() => {
    ee.emit('foo', 'bar');
    ee.emit('foo', 42);
    });

    for await (const event of on(ee, 'foo')) {
    // The execution of this inner block is synchronous and it
    // processes one event at a time (even with await). Do not use
    // if concurrent execution is required.
    console.log(event); // prints ['bar'] [42]
    }
    // Unreachable here +
    + +

    Returns an AsyncIterator that iterates eventName events. It will throw +if the EventEmitter emits 'error'. It removes all listeners when +exiting the loop. The value returned by each iteration is an array +composed of the emitted event arguments.

    +

    An AbortSignal can be used to cancel waiting on events:

    +
    import { on, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ac = new AbortController();

    (async () => {
    const ee = new EventEmitter();

    // Emit later on
    process.nextTick(() => {
    ee.emit('foo', 'bar');
    ee.emit('foo', 42);
    });

    for await (const event of on(ee, 'foo', { signal: ac.signal })) {
    // The execution of this inner block is synchronous and it
    // processes one event at a time (even with await). Do not use
    // if concurrent execution is required.
    console.log(event); // prints ['bar'] [42]
    }
    // Unreachable here
    })();

    process.nextTick(() => ac.abort()); +
    + +

    Use the close option to specify an array of event names that will end the iteration:

    +
    import { on, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ee = new EventEmitter();

    // Emit later on
    process.nextTick(() => {
    ee.emit('foo', 'bar');
    ee.emit('foo', 42);
    ee.emit('close');
    });

    for await (const event of on(ee, 'foo', { close: ['close'] })) {
    console.log(event); // prints ['bar'] [42]
    }
    // the loop will exit after 'close' is emitted
    console.log('done'); // prints 'done' +
    + +

    Parameters

    • emitter: EventEmitter<DefaultEventMap>
    • eventName: string | symbol
    • Optionaloptions: StaticEventEmitterIteratorOptions

    Returns AsyncIterator<any[], any, any>

    An AsyncIterator that iterates eventName events emitted by the emitter

    +

    v13.6.0, v12.16.0

    +
  • Parameters

    • emitter: EventTarget
    • eventName: string
    • Optionaloptions: StaticEventEmitterIteratorOptions

    Returns AsyncIterator<any[], any, any>

  • Creates a Promise that is fulfilled when the EventEmitter emits the given +event or that is rejected if the EventEmitter emits 'error' while waiting. +The Promise will resolve with an array of all the arguments emitted to the +given event.

    +

    This method is intentionally generic and works with the web platform EventTarget interface, which has no special'error' event +semantics and does not listen to the 'error' event.

    +
    import { once, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ee = new EventEmitter();

    process.nextTick(() => {
    ee.emit('myevent', 42);
    });

    const [value] = await once(ee, 'myevent');
    console.log(value);

    const err = new Error('kaboom');
    process.nextTick(() => {
    ee.emit('error', err);
    });

    try {
    await once(ee, 'myevent');
    } catch (err) {
    console.error('error happened', err);
    } +
    + +

    The special handling of the 'error' event is only used when events.once() is used to wait for another event. If events.once() is used to wait for the +'error' event itself, then it is treated as any other kind of event without +special handling:

    +
    import { EventEmitter, once } from 'node:events';

    const ee = new EventEmitter();

    once(ee, 'error')
    .then(([err]) => console.log('ok', err.message))
    .catch((err) => console.error('error', err.message));

    ee.emit('error', new Error('boom'));

    // Prints: ok boom +
    + +

    An AbortSignal can be used to cancel waiting for the event:

    +
    import { EventEmitter, once } from 'node:events';

    const ee = new EventEmitter();
    const ac = new AbortController();

    async function foo(emitter, event, signal) {
    try {
    await once(emitter, event, { signal });
    console.log('event emitted!');
    } catch (error) {
    if (error.name === 'AbortError') {
    console.error('Waiting for the event was canceled!');
    } else {
    console.error('There was an error', error.message);
    }
    }
    }

    foo(ee, 'foo', ac.signal);
    ac.abort(); // Abort waiting for the event
    ee.emit('foo'); // Prints: Waiting for the event was canceled! +
    + +

    Parameters

    • emitter: EventEmitter<DefaultEventMap>
    • eventName: string | symbol
    • Optionaloptions: StaticEventEmitterOptions

    Returns Promise<any[]>

    v11.13.0, v10.16.0

    +
  • Parameters

    • emitter: EventTarget
    • eventName: string
    • Optionaloptions: StaticEventEmitterOptions

    Returns Promise<any[]>

  • import { setMaxListeners, EventEmitter } from 'node:events';

    const target = new EventTarget();
    const emitter = new EventEmitter();

    setMaxListeners(5, target, emitter); +
    + +

    Parameters

    • Optionaln: number

      A non-negative number. The maximum number of listeners per EventTarget event.

      +
    • Rest...eventTargets: (EventEmitter<DefaultEventMap> | EventTarget)[]

      Zero or more {EventTarget} or {EventEmitter} instances. If none are specified, n is set as the default max for all newly created {EventTarget} and {EventEmitter} +objects.

      +

    Returns void

    v15.4.0

    +
diff --git a/docs/site/classes/models_pokerTable.PokerTable.html b/docs/site/classes/models_pokerTable.PokerTable.html new file mode 100644 index 0000000..6d75a00 --- /dev/null +++ b/docs/site/classes/models_pokerTable.PokerTable.html @@ -0,0 +1,512 @@ +PokerTable | casinojs

PokerTable

+

Represents a poker table within a larger casino or poker room environment. This class manages player seating, +tracks the positions of the dealer, small blind, and big blind, and coordinates the start and stop of poker games. +It includes several methods and properties to control game flow and player seating effectively.

+

The PokerTable class is central to organizing poker games within a room. It keeps track of players, manages game +states, and ensures a smooth flow of actions at the table by overseeing betting rounds, blind assignments, and game +progression.

+

This class extends the Node.js BaseEventEmitter, enabling it to emit events for key actions such as player seating, +game start, or game completion. This event-driven approach facilitates integration with other parts of the casino +system, allowing external components to listen and respond to table actions.

+

Implements the PokerTableInterface, ensuring a consistent structure and a clear contract for managing poker games, +player queues, and table configuration.

+

The PokerTable class includes essential methods for:

+
    +
  • Player Management: seatPlayer, removePlayer, getQueue, setQueue.
  • +
  • Game Control: startGame, endGame, setBlinds.
  • +
  • Table Configuration: setTableConfig, getTableConfig, resetTable.
  • +
+

The PokerTable emits events to signal key actions, including:

+
    +
  • table:playerSeated - Emitted when a new player is seated.
  • +
  • table:gameStarted - Emitted at the start of a new game.
  • +
  • table:gameEnded - Emitted upon game completion.
  • +
+

This class is designed to be used within a larger poker or casino environment, providing a structured system for +managing player actions, game states, and blind assignments at a poker table. It offers methods to control various +aspects of the game and seating, making it a foundational part of managing poker tables in an organized way.

+
const pokerTable = new PokerTable();
pokerTable.on('table:gameStarted', () => console.log("Game has started"));
pokerTable.seatPlayer({ name: "Alice", chips: 100 });
pokerTable.startGame();
console.log(pokerTable.getQueue()); // Logs the current queue of waiting players +
+ +

Hierarchy (view full)

Implements

Constructors

  • Creates a new PokerTable instance with configuration settings for table ID, small blind, and number of seats. +If a configuration object is provided, it customizes the table based on this data; otherwise, default values are used.

    +
      +
    • N/A (standard constructor for object instantiation).
    • +
    +
      +
    • N/A
    • +
    +

    This constructor initiates a new instance of PokerTable, setting up basic table properties and triggering the initialization process.

    +
      +
    • config (optional): A configuration object that includes table properties such as id, smallBlind, and size.
    • +
    +
      +
    • Optional: If no configuration is provided, default values for small blind and seat count are applied.
    • +
    +

    This constructor is typically called when a new table is added to a poker room, allowing optional customization for game settings.

    +

    Parameters

    Returns PokerTable

    const config = { id: "Table42", smallBlind: 25, size: 6 };
    const pokerTable = new PokerTable(config);
    console.log(pokerTable.getSeats().length); // Output: 6 +
    + +

Properties

captureRejections: boolean

Value: boolean

+

Change the default captureRejections option on all new EventEmitter objects.

+

v13.4.0, v12.16.0

+
captureRejectionSymbol: typeof captureRejectionSymbol

Value: Symbol.for('nodejs.rejection')

+

See how to write a custom rejection handler.

+

v13.4.0, v12.16.0

+
defaultMaxListeners: number

By default, a maximum of 10 listeners can be registered for any single +event. This limit can be changed for individual EventEmitter instances +using the emitter.setMaxListeners(n) method. To change the default +for allEventEmitter instances, the events.defaultMaxListeners property +can be used. If this value is not a positive number, a RangeError is thrown.

+

Take caution when setting the events.defaultMaxListeners because the +change affects all EventEmitter instances, including those created before +the change is made. However, calling emitter.setMaxListeners(n) still has +precedence over events.defaultMaxListeners.

+

This is not a hard limit. The EventEmitter instance will allow +more listeners to be added but will output a trace warning to stderr indicating +that a "possible EventEmitter memory leak" has been detected. For any single +EventEmitter, the emitter.getMaxListeners() and emitter.setMaxListeners() methods can be used to +temporarily avoid this warning:

+
import { EventEmitter } from 'node:events';
const emitter = new EventEmitter();
emitter.setMaxListeners(emitter.getMaxListeners() + 1);
emitter.once('event', () => {
// do stuff
emitter.setMaxListeners(Math.max(emitter.getMaxListeners() - 1, 0));
}); +
+ +

The --trace-warnings command-line flag can be used to display the +stack trace for such warnings.

+

The emitted warning can be inspected with process.on('warning') and will +have the additional emitter, type, and count properties, referring to +the event emitter instance, the event's name and the number of attached +listeners, respectively. +Its name property is set to 'MaxListenersExceededWarning'.

+

v0.11.2

+
errorMonitor: typeof errorMonitor

This symbol shall be used to install a listener for only monitoring 'error' events. Listeners installed using this symbol are called before the regular 'error' listeners are called.

+

Installing a listener using this symbol does not change the behavior once an 'error' event is emitted. Therefore, the process will still crash if no +regular 'error' listener is installed.

+

v13.6.0, v12.17.0

+

Methods

  • setId

    +

    Returns the poker table's id.

    +

    Parameters

    • id: string

    Returns string

    The poker table's id.

    +
    const rank = card.getRank();
    console.log(rank); // "A" +
    + +
  • Alias for emitter.on(eventName, listener).

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.26

    +
  • Synchronously calls each of the listeners registered for the event named eventName, in the order they were registered, passing the supplied arguments +to each.

    +

    Returns true if the event had listeners, false otherwise.

    +
    import { EventEmitter } from 'node:events';
    const myEmitter = new EventEmitter();

    // First listener
    myEmitter.on('event', function firstListener() {
    console.log('Helloooo! first listener');
    });
    // Second listener
    myEmitter.on('event', function secondListener(arg1, arg2) {
    console.log(`event with parameters ${arg1}, ${arg2} in second listener`);
    });
    // Third listener
    myEmitter.on('event', function thirdListener(...args) {
    const parameters = args.join(', ');
    console.log(`event with parameters ${parameters} in third listener`);
    });

    console.log(myEmitter.listeners('event'));

    myEmitter.emit('event', 1, 2, 3, 4, 5);

    // Prints:
    // [
    // [Function: firstListener],
    // [Function: secondListener],
    // [Function: thirdListener]
    // ]
    // Helloooo! first listener
    // event with parameters 1, 2 in second listener
    // event with parameters 1, 2, 3, 4, 5 in third listener +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • Rest...args: AnyRest

    Returns boolean

    v0.1.26

    +
  • The emitEvent method is a public method for emitting events, with an optional configuration that allows +middleware processing. Middleware functions can intercept and transform the event before it reaches the listeners, +allowing custom validation or data modifications.

    +

    This method enables flexible event emission with support for middleware, providing a robust event processing +mechanism in the BaseEventEmitter. It’s useful for customizing event behavior based on application-specific needs.

    +

    N/A

    +

    N/A

    +

    This method can emit any event specified by eventName, which can then be processed by middleware functions if defined.

    +
      +
    • eventName: string - The name of the event to emit.
    • +
    • options: { event: { data: { [key: string]: any }; [key: string]: any; }, middlewares?: Array<(event: BaseEventInterface, next: () => void) => void | false> } +
        +
      • event - The primary event data to emit, containing specific details.
      • +
      • middlewares - An optional array of middleware functions that process the event before emission.
      • +
      +
    • +
    +
      +
    • eventName must be a valid string.
    • +
    • options.event should include relevant data for the event. If middlewares are provided, they should be functions with an event and next parameter.
    • +
    +
      +
    • void - This method does not return a value.
    • +
    +

    Use this method to emit events with middleware-based customization, which allows for specific processing +logic or transformations before the event reaches listeners.

    +

    Parameters

    • eventName: string

      The name of the event to emit.

      +
    • options: {
          event: {
              data: {
                  [key: string]: any;
              };
              [key: string]: any;
          };
          middlewares?: ((event: BaseEventInterface<any>, next: (() => void)) => false | void)[];
      }

      Configuration for the event and optional middleware functions.

      +
      • event: {
            data: {
                [key: string]: any;
            };
            [key: string]: any;
        }
        • [key: string]: any
        • data: {
              [key: string]: any;
          }
          • [key: string]: any
      • Optionalmiddlewares?: ((event: BaseEventInterface<any>, next: (() => void)) => false | void)[]

    Returns void

    emitter.emitEvent("game:started", {
    event: { data: { gameId: "001", status: "active" } },
    middlewares: [
    (event, next) => { console.log("Processing event:", event); next(); },
    (event, next) => { event.data.processed = true; next(); }
    ]
    }); +
    + +
  • Returns an array listing the events for which the emitter has registered +listeners. The values in the array are strings or Symbols.

    +
    import { EventEmitter } from 'node:events';

    const myEE = new EventEmitter();
    myEE.on('foo', () => {});
    myEE.on('bar', () => {});

    const sym = Symbol('symbol');
    myEE.on(sym, () => {});

    console.log(myEE.eventNames());
    // Prints: [ 'foo', 'bar', Symbol(symbol) ] +
    + +

    Returns (string | symbol)[]

    v6.0.0

    +
  • getId

    +

    Returns the poker table's id.

    +

    Returns number

    The poker table's id.

    +
    const rank = card.getRank();
    console.log(rank); // "A" +
    + +
  • getId

    +

    Returns the poker table's id.

    +

    Returns number

    The poker table's id.

    +
    const rank = card.getRank();
    console.log(rank); // "A" +
    + +
  • Checks if a provided index is within the valid range of the Casino’s room list.

    +

    Implements the isValidIndex method of CasinoInterface.

    +

    N/A

    +

    This method helps validate that an index is within the valid bounds of the Casino’s room list. It prevents +out-of-bound errors and ensures that methods calling on rooms by index are provided with a valid reference.

    +

    N/A

    +
      +
    • index: A zero-based integer representing the position of a room in the Casino's managed list of rooms.
    • +
    +
      +
    • The index should be a non-negative integer and within the bounds of the __rooms array.
    • +
    +
      +
    • Returns true if the index is within bounds.
    • +
    • Throws an Error if the index is out of range.
    • +
    +

    Call this method before performing operations that require a valid room index to prevent out-of-bounds errors. +Can be used in any index-based access patterns for room retrieval or modification.

    +

    Parameters

    • index: number

      The zero-based index to validate.

      +

    Returns boolean

      +
    • Returns true if the index is within bounds.
    • +
    +
      +
    • Throws an error with a message indicating the invalid index.
    • +
    +
    const casino = new Casino();
    try {
    casino.isValidIndex(2); // Returns true if there are at least 3 rooms
    } catch (error) {
    console.error(error.message); // If index 2 is out of bounds, logs error message
    } +
    + +
  • Returns the number of listeners listening for the event named eventName. +If listener is provided, it will return how many times the listener is found +in the list of the listeners of the event.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event being listened for

      +
    • Optionallistener: Function

      The event handler function

      +

    Returns number

    v3.2.0

    +
  • Returns a copy of the array of listeners for the event named eventName.

    +
    server.on('connection', (stream) => {
    console.log('someone connected!');
    });
    console.log(util.inspect(server.listeners('connection')));
    // Prints: [ [Function] ] +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

    Returns Function[]

    v0.1.26

    +
  • Alias for emitter.removeListener().

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v10.0.0

    +
  • Adds the listener function to the end of the listeners array for the event +named eventName. No checks are made to see if the listener has already +been added. Multiple calls passing the same combination of eventName and +listener will result in the listener being added, and called, multiple times.

    +
    server.on('connection', (stream) => {
    console.log('someone connected!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    By default, event listeners are invoked in the order they are added. The emitter.prependListener() method can be used as an alternative to add the +event listener to the beginning of the listeners array.

    +
    import { EventEmitter } from 'node:events';
    const myEE = new EventEmitter();
    myEE.on('foo', () => console.log('a'));
    myEE.prependListener('foo', () => console.log('b'));
    myEE.emit('foo');
    // Prints:
    // b
    // a +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.101

    +
  • Adds a one-time listener function for the event named eventName. The +next time eventName is triggered, this listener is removed and then invoked.

    +
    server.once('connection', (stream) => {
    console.log('Ah, we have our first user!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    By default, event listeners are invoked in the order they are added. The emitter.prependOnceListener() method can be used as an alternative to add the +event listener to the beginning of the listeners array.

    +
    import { EventEmitter } from 'node:events';
    const myEE = new EventEmitter();
    myEE.once('foo', () => console.log('a'));
    myEE.prependOnceListener('foo', () => console.log('b'));
    myEE.emit('foo');
    // Prints:
    // b
    // a +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.3.0

    +
  • Adds the listener function to the beginning of the listeners array for the +event named eventName. No checks are made to see if the listener has +already been added. Multiple calls passing the same combination of eventName +and listener will result in the listener being added, and called, multiple times.

    +
    server.prependListener('connection', (stream) => {
    console.log('someone connected!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v6.0.0

    +
  • Adds a one-timelistener function for the event named eventName to the beginning of the listeners array. The next time eventName is triggered, this +listener is removed, and then invoked.

    +
    server.prependOnceListener('connection', (stream) => {
    console.log('Ah, we have our first user!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v6.0.0

    +
  • Returns a copy of the array of listeners for the event named eventName, +including any wrappers (such as those created by .once()).

    +
    import { EventEmitter } from 'node:events';
    const emitter = new EventEmitter();
    emitter.once('log', () => console.log('log once'));

    // Returns a new Array with a function `onceWrapper` which has a property
    // `listener` which contains the original listener bound above
    const listeners = emitter.rawListeners('log');
    const logFnWrapper = listeners[0];

    // Logs "log once" to the console and does not unbind the `once` event
    logFnWrapper.listener();

    // Logs "log once" to the console and removes the listener
    logFnWrapper();

    emitter.on('log', () => console.log('log persistently'));
    // Will return a new Array with a single function bound by `.on()` above
    const newListeners = emitter.rawListeners('log');

    // Logs "log persistently" twice
    newListeners[0]();
    emitter.emit('log'); +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

    Returns Function[]

    v9.4.0

    +
  • Removes all listeners, or those of the specified eventName.

    +

    It is bad practice to remove listeners added elsewhere in the code, +particularly when the EventEmitter instance was created by some other +component or module (e.g. sockets or file streams).

    +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Parameters

    • OptionaleventName: string | symbol

    Returns this

    v0.1.26

    +
  • Removes the specified listener from the listener array for the event named eventName.

    +
    const callback = (stream) => {
    console.log('someone connected!');
    };
    server.on('connection', callback);
    // ...
    server.removeListener('connection', callback); +
    + +

    removeListener() will remove, at most, one instance of a listener from the +listener array. If any single listener has been added multiple times to the +listener array for the specified eventName, then removeListener() must be +called multiple times to remove each instance.

    +

    Once an event is emitted, all listeners attached to it at the +time of emitting are called in order. This implies that any removeListener() or removeAllListeners() calls after emitting and before the last listener finishes execution +will not remove them fromemit() in progress. Subsequent events behave as expected.

    +
    import { EventEmitter } from 'node:events';
    class MyEmitter extends EventEmitter {}
    const myEmitter = new MyEmitter();

    const callbackA = () => {
    console.log('A');
    myEmitter.removeListener('event', callbackB);
    };

    const callbackB = () => {
    console.log('B');
    };

    myEmitter.on('event', callbackA);

    myEmitter.on('event', callbackB);

    // callbackA removes listener callbackB but it will still be called.
    // Internal listener array at time of emit [callbackA, callbackB]
    myEmitter.emit('event');
    // Prints:
    // A
    // B

    // callbackB is now removed.
    // Internal listener array [callbackA]
    myEmitter.emit('event');
    // Prints:
    // A +
    + +

    Because listeners are managed using an internal array, calling this will +change the position indices of any listener registered after the listener +being removed. This will not impact the order in which listeners are called, +but it means that any copies of the listener array as returned by +the emitter.listeners() method will need to be recreated.

    +

    When a single function has been added as a handler multiple times for a single +event (as in the example below), removeListener() will remove the most +recently added instance. In the example the once('ping') listener is removed:

    +
    import { EventEmitter } from 'node:events';
    const ee = new EventEmitter();

    function pong() {
    console.log('pong');
    }

    ee.on('ping', pong);
    ee.once('ping', pong);
    ee.removeListener('ping', pong);

    ee.emit('ping');
    ee.emit('ping'); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.26

    +
  • Returns the total number of PokerRoom instances currently managed by the Casino.

    +

    Implements the roomCount method of CasinoInterface.

    +

    N/A

    +

    Provides a simple way to check how many poker rooms the Casino is currently managing. Useful for general +information about the Casino's state and for validating indices or conditions that depend on room count.

    +

    N/A

    +

    N/A

    +

    N/A

    +
      +
    • Returns the number of rooms currently managed by the Casino.
    • +
    +

    This method is useful for any scenario where the total number of active rooms is needed, such as iterating +over all rooms or validating index-based operations.

    +

    Returns number

      +
    • The current count of rooms in the Casino.
    • +
    +
    const casino = new Casino();
    const count = casino.roomCount();
    console.log(count); // Logs the total number of managed rooms, e.g., 5 +
    + +
  • By default EventEmitters will print a warning if more than 10 listeners are +added for a particular event. This is a useful default that helps finding +memory leaks. The emitter.setMaxListeners() method allows the limit to be +modified for this specific EventEmitter instance. The value can be set to Infinity (or 0) to indicate an unlimited number of listeners.

    +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Parameters

    • n: number

    Returns this

    v0.3.5

    +
  • Sets the name of the PokerRoom, allowing the name to be updated or customized.

    +

    N/A - This method is part of the PokerRoomInterface and does not implement any external methods.

    +

    N/A - This method does not override any superclass or parent methods.

    +

    The setName method is used to assign a specific name to a PokerRoom, which helps distinguish it within the system. +This is essential for systems where rooms need to be identifiable and manageable through a unique name.

    +

    N/A - No events are emitted by this method.

    +
      +
    • name: A string representing the new name for the room. It must be a valid, non-empty string to ensure +the room has a clear, identifiable label.
    • +
    +
      +
    • The name parameter should be a non-empty string to provide meaningful identification.
    • +
    • Passing an empty or invalid value could result in future misidentification of rooms if validation is implemented.
    • +
    +
      +
    • Returns the name that was set for the PokerRoom.
    • +
    +

    Use this method to set or update the name of a room in a system where unique or identifiable room names +are necessary for reference.

    +

    Parameters

    • name: string

      The new name for the PokerRoom.

      +

    Returns string

      +
    • Returns the name of the room that was set.
    • +
    +
    const pokerRoom = new PokerRoom({ name: "Room1", tableSize: 6 });
    pokerRoom.setName("HighRollers"); // Sets the name of the room to "HighRollers"
    console.log(pokerRoom.getName()); // Logs "HighRollers" +
    + +
  • Sets the queue of players waiting to enter the PokerTable within the PokerRoom. This queue helps +manage player flow and assign seating as tables become available.

    +

    N/A - This method is part of the PokerRoomInterface and does not implement any external methods.

    +

    N/A - This method does not override any superclass or parent methods.

    +

    The setQueue method provides a structured way to set or update the player queue. This queue is essential +for room management, helping to keep a record of players awaiting entry and manage seating arrangements.

    +

    N/A - No events are emitted by this method.

    +
      +
    • queue: An array of PokerPlayerInterface objects, each representing a player awaiting entry into the room’s PokerTable.
    • +
    +
      +
    • queue should be an array of valid PokerPlayerInterface instances.
    • +
    • If empty, the queue indicates that no players are currently waiting for entry.
    • +
    +
      +
    • Returns the queue array after updating it within the room.
    • +
    +

    Use this method to set or update the player queue in cases where player flow needs control, +ensuring smooth transitions as players are seated at the table.

    +

    Parameters

    • smallBlind: number

      The new list of players waiting to enter the table.

      +

    Returns number

      +
    • Returns the updated player queue.
    • +
    +
    const pokerRoom = new PokerRoom({ name: "Room2", tableSize: 6 });
    const queue = [new PokerPlayer("Alice"), new PokerPlayer("Bob")];
    pokerRoom.setQueue(queue); // Sets the player queue
    console.log(pokerRoom.getQueue()); // Logs the updated player queue +
    + +
  • size +Starts a new PokerGame if there are at least two active players at the PokerTable. +This method initiates the game flow, including assigning blinds and starting the rounds.

    +

    Returns number

  • Experimental

    Listens once to the abort event on the provided signal.

    +

    Listening to the abort event on abort signals is unsafe and may +lead to resource leaks since another third party with the signal can +call e.stopImmediatePropagation(). Unfortunately Node.js cannot change +this since it would violate the web standard. Additionally, the original +API makes it easy to forget to remove listeners.

    +

    This API allows safely using AbortSignals in Node.js APIs by solving these +two issues by listening to the event such that stopImmediatePropagation does +not prevent the listener from running.

    +

    Returns a disposable so that it may be unsubscribed from more easily.

    +
    import { addAbortListener } from 'node:events';

    function example(signal) {
    let disposable;
    try {
    signal.addEventListener('abort', (e) => e.stopImmediatePropagation());
    disposable = addAbortListener(signal, (e) => {
    // Do something when signal is aborted.
    });
    } finally {
    disposable?.[Symbol.dispose]();
    }
    } +
    + +

    Parameters

    • signal: AbortSignal
    • resource: ((event: Event) => void)
        • (event): void
        • Parameters

          • event: Event

          Returns void

    Returns Disposable

    Disposable that removes the abort listener.

    +

    v20.5.0

    +
  • Returns a copy of the array of listeners for the event named eventName.

    +

    For EventEmitters this behaves exactly the same as calling .listeners on +the emitter.

    +

    For EventTargets this is the only way to get the event listeners for the +event target. This is useful for debugging and diagnostic purposes.

    +
    import { getEventListeners, EventEmitter } from 'node:events';

    {
    const ee = new EventEmitter();
    const listener = () => console.log('Events are fun');
    ee.on('foo', listener);
    console.log(getEventListeners(ee, 'foo')); // [ [Function: listener] ]
    }
    {
    const et = new EventTarget();
    const listener = () => console.log('Events are fun');
    et.addEventListener('foo', listener);
    console.log(getEventListeners(et, 'foo')); // [ [Function: listener] ]
    } +
    + +

    Parameters

    • emitter: EventEmitter<DefaultEventMap> | EventTarget
    • name: string | symbol

    Returns Function[]

    v15.2.0, v14.17.0

    +
  • Returns the currently set max amount of listeners.

    +

    For EventEmitters this behaves exactly the same as calling .getMaxListeners on +the emitter.

    +

    For EventTargets this is the only way to get the max event listeners for the +event target. If the number of event handlers on a single EventTarget exceeds +the max set, the EventTarget will print a warning.

    +
    import { getMaxListeners, setMaxListeners, EventEmitter } from 'node:events';

    {
    const ee = new EventEmitter();
    console.log(getMaxListeners(ee)); // 10
    setMaxListeners(11, ee);
    console.log(getMaxListeners(ee)); // 11
    }
    {
    const et = new EventTarget();
    console.log(getMaxListeners(et)); // 10
    setMaxListeners(11, et);
    console.log(getMaxListeners(et)); // 11
    } +
    + +

    Parameters

    • emitter: EventEmitter<DefaultEventMap> | EventTarget

    Returns number

    v19.9.0

    +
  • A class method that returns the number of listeners for the given eventName registered on the given emitter.

    +
    import { EventEmitter, listenerCount } from 'node:events';

    const myEmitter = new EventEmitter();
    myEmitter.on('event', () => {});
    myEmitter.on('event', () => {});
    console.log(listenerCount(myEmitter, 'event'));
    // Prints: 2 +
    + +

    Parameters

    • emitter: EventEmitter<DefaultEventMap>

      The emitter to query

      +
    • eventName: string | symbol

      The event name

      +

    Returns number

    v0.9.12

    +

    Since v3.2.0 - Use listenerCount instead.

    +
  • import { on, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ee = new EventEmitter();

    // Emit later on
    process.nextTick(() => {
    ee.emit('foo', 'bar');
    ee.emit('foo', 42);
    });

    for await (const event of on(ee, 'foo')) {
    // The execution of this inner block is synchronous and it
    // processes one event at a time (even with await). Do not use
    // if concurrent execution is required.
    console.log(event); // prints ['bar'] [42]
    }
    // Unreachable here +
    + +

    Returns an AsyncIterator that iterates eventName events. It will throw +if the EventEmitter emits 'error'. It removes all listeners when +exiting the loop. The value returned by each iteration is an array +composed of the emitted event arguments.

    +

    An AbortSignal can be used to cancel waiting on events:

    +
    import { on, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ac = new AbortController();

    (async () => {
    const ee = new EventEmitter();

    // Emit later on
    process.nextTick(() => {
    ee.emit('foo', 'bar');
    ee.emit('foo', 42);
    });

    for await (const event of on(ee, 'foo', { signal: ac.signal })) {
    // The execution of this inner block is synchronous and it
    // processes one event at a time (even with await). Do not use
    // if concurrent execution is required.
    console.log(event); // prints ['bar'] [42]
    }
    // Unreachable here
    })();

    process.nextTick(() => ac.abort()); +
    + +

    Use the close option to specify an array of event names that will end the iteration:

    +
    import { on, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ee = new EventEmitter();

    // Emit later on
    process.nextTick(() => {
    ee.emit('foo', 'bar');
    ee.emit('foo', 42);
    ee.emit('close');
    });

    for await (const event of on(ee, 'foo', { close: ['close'] })) {
    console.log(event); // prints ['bar'] [42]
    }
    // the loop will exit after 'close' is emitted
    console.log('done'); // prints 'done' +
    + +

    Parameters

    • emitter: EventEmitter<DefaultEventMap>
    • eventName: string | symbol
    • Optionaloptions: StaticEventEmitterIteratorOptions

    Returns AsyncIterator<any[], any, any>

    An AsyncIterator that iterates eventName events emitted by the emitter

    +

    v13.6.0, v12.16.0

    +
  • Parameters

    • emitter: EventTarget
    • eventName: string
    • Optionaloptions: StaticEventEmitterIteratorOptions

    Returns AsyncIterator<any[], any, any>

  • Creates a Promise that is fulfilled when the EventEmitter emits the given +event or that is rejected if the EventEmitter emits 'error' while waiting. +The Promise will resolve with an array of all the arguments emitted to the +given event.

    +

    This method is intentionally generic and works with the web platform EventTarget interface, which has no special'error' event +semantics and does not listen to the 'error' event.

    +
    import { once, EventEmitter } from 'node:events';
    import process from 'node:process';

    const ee = new EventEmitter();

    process.nextTick(() => {
    ee.emit('myevent', 42);
    });

    const [value] = await once(ee, 'myevent');
    console.log(value);

    const err = new Error('kaboom');
    process.nextTick(() => {
    ee.emit('error', err);
    });

    try {
    await once(ee, 'myevent');
    } catch (err) {
    console.error('error happened', err);
    } +
    + +

    The special handling of the 'error' event is only used when events.once() is used to wait for another event. If events.once() is used to wait for the +'error' event itself, then it is treated as any other kind of event without +special handling:

    +
    import { EventEmitter, once } from 'node:events';

    const ee = new EventEmitter();

    once(ee, 'error')
    .then(([err]) => console.log('ok', err.message))
    .catch((err) => console.error('error', err.message));

    ee.emit('error', new Error('boom'));

    // Prints: ok boom +
    + +

    An AbortSignal can be used to cancel waiting for the event:

    +
    import { EventEmitter, once } from 'node:events';

    const ee = new EventEmitter();
    const ac = new AbortController();

    async function foo(emitter, event, signal) {
    try {
    await once(emitter, event, { signal });
    console.log('event emitted!');
    } catch (error) {
    if (error.name === 'AbortError') {
    console.error('Waiting for the event was canceled!');
    } else {
    console.error('There was an error', error.message);
    }
    }
    }

    foo(ee, 'foo', ac.signal);
    ac.abort(); // Abort waiting for the event
    ee.emit('foo'); // Prints: Waiting for the event was canceled! +
    + +

    Parameters

    • emitter: EventEmitter<DefaultEventMap>
    • eventName: string | symbol
    • Optionaloptions: StaticEventEmitterOptions

    Returns Promise<any[]>

    v11.13.0, v10.16.0

    +
  • Parameters

    • emitter: EventTarget
    • eventName: string
    • Optionaloptions: StaticEventEmitterOptions

    Returns Promise<any[]>

  • import { setMaxListeners, EventEmitter } from 'node:events';

    const target = new EventTarget();
    const emitter = new EventEmitter();

    setMaxListeners(5, target, emitter); +
    + +

    Parameters

    • Optionaln: number

      A non-negative number. The maximum number of listeners per EventTarget event.

      +
    • Rest...eventTargets: (EventEmitter<DefaultEventMap> | EventTarget)[]

      Zero or more {EventTarget} or {EventEmitter} instances. If none are specified, n is set as the default max for all newly created {EventTarget} and {EventEmitter} +objects.

      +

    Returns void

    v15.4.0

    +
diff --git a/docs/site/enums/enums_PokerPhaseNames.PokerPhaseName.html b/docs/site/enums/enums_PokerPhaseNames.PokerPhaseName.html new file mode 100644 index 0000000..a57a48e --- /dev/null +++ b/docs/site/enums/enums_PokerPhaseNames.PokerPhaseName.html @@ -0,0 +1,45 @@ +PokerPhaseName | casinojs

PokerPhaseName +Defines the various phases in a standard poker game. Each phase represents a distinct stage +within the game sequence, governing the number of community cards dealt and player actions.

+

PokerPhaseName is designed to provide a clear, standardized reference for each poker phase. +It simplifies managing the game flow and ensures that each phase can be easily referenced +within conditional statements and game logic.

+

The PokerPhaseName includes the following phases:

+
    +
  • PRE_FLOP: The initial phase before any community cards are dealt.
  • +
  • FLOP: The second phase, where the first three community cards are dealt.
  • +
  • TURN: The third phase, where a fourth community card is dealt.
  • +
  • RIVER: The fourth phase, where the fifth and final community card is dealt.
  • +
  • SHOWDOWN: The final phase where players reveal their hands and a winner is determined.
  • +
+

This enum standardizes the game flow, making it easy to transition between poker phases +and ensuring compatibility with various game modules and functions.

+
const currentPhase: PokerPhaseName = PokerPhaseName.PRE_FLOP;
console.log(currentPhase);
// Console Output: "Pre-Flop" +
+ +

Enumeration Members

Enumeration Members

FLOP

The second phase where the first three community cards are dealt.

+
const currentPhase: PokerPhaseName = PokerPhaseName.FLOP;
console.log(currentPhase);
// Console Output: "Flop" +
+ +
PRE_FLOP

The initial phase before any community cards are dealt.

+
const currentPhase: PokerPhaseName = PokerPhaseName.PRE_FLOP;
console.log(currentPhase);
// Console Output: "Pre-Flop" +
+ +
RIVER

The fourth phase where the fifth and final community card is dealt.

+
const currentPhase: PokerPhaseName = PokerPhaseName.RIVER;
console.log(currentPhase);
// Console Output: "River" +
+ +
SHOWDOWN

The final phase where players reveal their hands to determine the winner.

+
const currentPhase: PokerPhaseName = PokerPhaseName.SHOWDOWN;
console.log(currentPhase);
// Console Output: "ShowDown" +
+ +
TURN

The third phase where a fourth community card is dealt.

+
const currentPhase: PokerPhaseName = PokerPhaseName.TURN;
console.log(currentPhase);
// Console Output: "Turn" +
+ +
diff --git a/docs/site/enums/enums_events_casino.CasinoEvents.html b/docs/site/enums/enums_events_casino.CasinoEvents.html new file mode 100644 index 0000000..62fc579 --- /dev/null +++ b/docs/site/enums/enums_events_casino.CasinoEvents.html @@ -0,0 +1,22 @@ +CasinoEvents | casinojs

CasinoEvents +Defines the events emitted by the Casino class for mutable operations. +Events are triggered only for state-changing actions like creation, additions, updates, and deletions.

+
const eventName = CasinoEvents.ROOM_CREATED;
console.log(eventName);
// Output: "Casino:PokerRoomCreated" +
+ +

Enumeration Members

ROOM_ADDED

ROOM_ADDED - Emitted when a single room is added to the casino's list of managed rooms.

+

Allows listeners to respond when a new room is introduced into the Casino’s list of available rooms.

+
ROOM_CREATED

ROOM_CREATED - Emitted when a new room is created and added to the casino's list of managed rooms.

+

Notifies listeners when a new poker room has been successfully created and added to the Casino’s managed list.

+
ROOM_DELETED

ROOM_DELETED - Emitted when an existing room is removed from the casino's list of managed rooms.

+

Enables clean-up or resource reallocation processes by notifying listeners when a room is removed from the Casino.

+
ROOM_UPDATED

ROOM_UPDATED - Emitted when an existing room in the casino is modified.

+

Notifies listeners when a room’s configuration or attributes (e.g., blinds, player limits) have been updated.

+
ROOMS_SET

ROOMS_SET - Emitted when the casino’s managed list of rooms is set to a new batch of rooms.

+

Notifies listeners when the Casino’s full list of rooms has been reset or replaced with a new set of rooms.

+
diff --git a/docs/site/enums/enums_events_pokerSeat.PokerSeatEvents.html b/docs/site/enums/enums_events_pokerSeat.PokerSeatEvents.html new file mode 100644 index 0000000..656320a --- /dev/null +++ b/docs/site/enums/enums_events_pokerSeat.PokerSeatEvents.html @@ -0,0 +1,33 @@ +PokerSeatEvents | casinojs

PokerSeatEvents

+

Defines the events associated with a player's seat in a poker game. These events help manage seat availability +and player actions related to occupying or vacating seats at a poker table.

+

The PokerSeatEvents enum is designed to provide a standardized reference for seat-related events in the game. +It simplifies the handling of seat states, ensuring seat occupancy and vacancy can be tracked and updated +accurately within the game flow.

+

The PokerSeatEvents includes the following events:

+
    +
  • INITIALIZED: Indicates that the seat has been initialized and is ready for occupancy.
  • +
  • OCCUPIED: Indicates a seat has been occupied by a player.
  • +
  • VACATED: Indicates a seat has been vacated by a player.
  • +
+

This enum standardizes the handling of seat events, making it easier to manage player movements at the table and +ensuring compatibility with various game modules and event listeners.

+
const seatEvent: PokerSeatEvents = PokerSeatEvents.OCCUPIED;
console.log(seatEvent);
// Console Output: "PokerSeat:Occupied" +
+ +

Enumeration Members

Enumeration Members

INITIALIZED

Indicates that the seat has been initialized and is ready for occupancy.

+
const seatEvent: PokerSeatEvents = PokerSeatEvents.INITIALIZED;
console.log(seatEvent);
// Console Output: "PokerSeat:Initialized" +
+ +
OCCUPIED

Indicates a seat has been occupied by a player.

+
const seatEvent: PokerSeatEvents = PokerSeatEvents.OCCUPIED;
console.log(seatEvent);
// Console Output: "PokerSeat:Occupied" +
+ +
VACATED

Indicates a seat has been vacated by a player.

+
const seatEvent: PokerSeatEvents = PokerSeatEvents.VACATED;
console.log(seatEvent);
// Console Output: "PokerSeat:Vacated" +
+ +
diff --git a/docs/site/enums/enums_logLevel.LogLevel.html b/docs/site/enums/enums_logLevel.LogLevel.html new file mode 100644 index 0000000..3bf2a4a --- /dev/null +++ b/docs/site/enums/enums_logLevel.LogLevel.html @@ -0,0 +1,29 @@ +LogLevel | casinojs

Enumeration LogLevel

LogLevel

+

Represents the different levels of logging severity available within the library. +Each log level corresponds to a specific type of message, providing clarity on the nature and urgency of the log. +The levels are structured to allow for selective filtering based on severity and importance.

+

The LogLevel enum standardizes log severity levels, ensuring that log messages are consistently categorized. +This approach aids in debugging, monitoring, and organizing log data by its importance, making it easier to parse +and filter through logs in development, production, or auditing scenarios.

+

The LogLevel enum is used across the logging system to specify the severity of each log message. It includes:

+
    +
  • INFO: For general informational messages, routine operations, and non-urgent updates.
  • +
  • WARN: For warnings or potential issues that may not yet be errors but deserve attention.
  • +
  • ERROR: For serious issues that have occurred and require immediate attention.
  • +
+
const logLevel = LogLevel.INFO;
console.log(logLevel);
// Console Output: "info" +
+ +

Enumeration Members

Enumeration Members

ERROR
const level = LogLevel.ERROR;
console.log(level);
// Console Output: "error" +
+ +
INFO
const level = LogLevel.INFO;
console.log(level);
// Console Output: "info" +
+ +
WARN
const level = LogLevel.WARN;
console.log(level);
// Console Output: "warning" +
+ +
diff --git a/docs/site/enums/enums_rank.Rank.html b/docs/site/enums/enums_rank.Rank.html new file mode 100644 index 0000000..16225ce --- /dev/null +++ b/docs/site/enums/enums_rank.Rank.html @@ -0,0 +1,20 @@ +Rank | casinojs

Enumeration Rank

Rank +Represents the ranks of playing cards used in poker. +Each rank corresponds to a specific card value from 2 to Ace.

+
const rank = Rank.Ace;
console.log(rank);
//output: "A" +
+ +

Enumeration Members

Enumeration Members

Ace
Eight
Five
Four
Jack
King
Nine
Queen
Seven
Six
Ten
Three
Two
diff --git a/docs/site/enums/enums_source.Source.html b/docs/site/enums/enums_source.Source.html new file mode 100644 index 0000000..a648a5d --- /dev/null +++ b/docs/site/enums/enums_source.Source.html @@ -0,0 +1,76 @@ +Source | casinojs

Enumeration Source

Source +Defines the sources of various components and entities within the library, each representing a specific +entity or module that can emit events or interact within the system. This enum is used as a standardized +identifier for the origin of actions, events, or data across the library.

+

Source is designed to standardize the identification of each module or entity within the library, +facilitating tracing, logging, and debugging. Each value corresponds to a distinct source, making it +clear where specific events or actions originate.

+
    +
  • _BASE: Represents the BaseEventEmitter, the foundational emitter for events within the library.
  • +
  • CARD: Represents the Card model, corresponding to individual playing cards in the library.
  • +
  • CASINO: Refers to the Casino model, handling high-level operations related to game management.
  • +
  • DECK: Identifies the Deck, representing a collection or set of cards in a game context.
  • +
  • POKER_GAME: Corresponds to the PokerGame model, managing game-specific actions and states.
  • +
  • POKER_PHASE: Represents the PokerPhase model, indicating the stages or phases within a poker game.
  • +
  • POKER_PLAYER: Refers to the PokerPlayer model, encompassing player-specific data and actions.
  • +
  • POKER_ROOM: Corresponds to the PokerRoom model, representing rooms where games take place.
  • +
  • POKER_SEAT: Refers to the PokerSeat model, representing individual seats within a poker table.
  • +
  • POKER_TABLE: Represents the PokerTable model, handling table-specific settings and seating.
  • +
+

Source provides a standard set of identifiers used across the library for event emission and origin +tracking. Each entity or module can reference its corresponding Source value when emitting events or +logging actions, enhancing traceability and modularity.

+
const source = Source.POKER_GAME;
console.log(source);
// Console Output: "PokerGame" +
+ +

Enumeration Members

_BASE

Represents the BaseEventEmitter, the foundational event emitter for the library.

+
const source = Source._BASE;
console.log(source);
// Console Output: "BaseEventEmitter" +
+ +
CARD

Represents the Card model, corresponding to individual playing cards.

+
const source = Source.CARD;
console.log(source);
// Console Output: "Card" +
+ +
CASINO

Refers to the Casino model, which handles casino or game management operations.

+
const source = Source.CASINO;
console.log(source);
// Console Output: "Casino" +
+ +
DECK

Identifies the Deck, representing a collection of playing cards.

+
const source = Source.DECK;
console.log(source);
// Console Output: "Deck" +
+ +
POKER_GAME

Corresponds to the PokerGame model, responsible for managing the poker game actions and states.

+
const source = Source.POKER_GAME;
console.log(source);
// Console Output: "PokerGame" +
+ +
POKER_PHASE

Represents the PokerPhase model, indicating stages or phases within a poker game.

+
const source = Source.POKER_PHASE;
console.log(source);
// Console Output: "PokerPhase" +
+ +
POKER_PLAYER

Refers to the PokerPlayer model, encompassing player-specific data and actions.

+
const source = Source.POKER_PLAYER;
console.log(source);
// Console Output: "PokerPlayer" +
+ +
POKER_ROOM

Corresponds to the PokerRoom model, representing rooms where games take place.

+
const source = Source.POKER_ROOM;
console.log(source);
// Console Output: "PokerRoom" +
+ +
POKER_SEAT

Refers to the PokerSeat model, representing individual seats within a poker table.

+
const source = Source.POKER_SEAT;
console.log(source);
// Console Output: "PokerSeat" +
+ +
POKER_TABLE

Represents the PokerTable model, which handles table-specific settings and seating.

+
const source = Source.POKER_TABLE;
console.log(source);
// Console Output: "PokerTable" +
+ +
diff --git a/docs/site/enums/enums_suit.Suit.html b/docs/site/enums/enums_suit.Suit.html new file mode 100644 index 0000000..cf3f617 --- /dev/null +++ b/docs/site/enums/enums_suit.Suit.html @@ -0,0 +1,11 @@ +Suit | casinojs

Enumeration Suit

Suit +Represents the suits of playing cards used in poker. +Each suit corresponds to one of the four card suits: Hearts, Diamonds, Clubs, and Spades.

+
const suit = Suit.Hearts;
console.log(suit); // "Hearts" +
+ +

Enumeration Members

Enumeration Members

Clubs
Diamonds
Hearts
Spades
diff --git a/docs/site/enums/interfaces_rank.Rank.html b/docs/site/enums/interfaces_rank.Rank.html deleted file mode 100644 index 27e2357..0000000 --- a/docs/site/enums/interfaces_rank.Rank.html +++ /dev/null @@ -1,14 +0,0 @@ -Rank | pokerjs

Enumeration Members

Enumeration Members

Ace
Eight
Five
Four
Jack
King
Nine
Queen
Seven
Six
Ten
Three
Two
diff --git a/docs/site/enums/interfaces_suit.Suit.html b/docs/site/enums/interfaces_suit.Suit.html deleted file mode 100644 index 6ea25de..0000000 --- a/docs/site/enums/interfaces_suit.Suit.html +++ /dev/null @@ -1,5 +0,0 @@ -Suit | pokerjs

Enumeration Members

Enumeration Members

Clubs
Diamonds
Hearts
Spades
diff --git a/docs/site/functions/utils_generateUniqueId.generateUniqueId.html b/docs/site/functions/utils_generateUniqueId.generateUniqueId.html new file mode 100644 index 0000000..b91264a --- /dev/null +++ b/docs/site/functions/utils_generateUniqueId.generateUniqueId.html @@ -0,0 +1 @@ +generateUniqueId | casinojs
diff --git a/docs/site/hierarchy.html b/docs/site/hierarchy.html index 098e1cc..e5c3038 100644 --- a/docs/site/hierarchy.html +++ b/docs/site/hierarchy.html @@ -1 +1 @@ -pokerjs

pokerjs

Class Hierarchy

+casinojs
diff --git a/docs/site/index.html b/docs/site/index.html index 46a1906..36626c7 100644 --- a/docs/site/index.html +++ b/docs/site/index.html @@ -1,6 +1,6 @@ -pokerjs

pokerjs

nodejs-project-template

nodejs-project-template

+casinojs

casinojs

CasinoJs

CasinoJs

+
diff --git a/docs/site/interfaces/interfaces__base.BaseEventEmitterInterface.html b/docs/site/interfaces/interfaces__base.BaseEventEmitterInterface.html new file mode 100644 index 0000000..16f047b --- /dev/null +++ b/docs/site/interfaces/interfaces__base.BaseEventEmitterInterface.html @@ -0,0 +1,144 @@ +BaseEventEmitterInterface | casinojs

Interface BaseEventEmitterInterface

BaseEventEmitterInterface +Extends the standard Node.js EventEmitter, including listener management methods.

+
interface BaseEventEmitterInterface {
    [captureRejectionSymbol]?<K>(error: Error, event: string | symbol, ...args: AnyRest): void;
    addListener<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    emit<K>(eventName: string | symbol, ...args: AnyRest): boolean;
    eventNames(): (string | symbol)[];
    getMaxListeners(): number;
    listenerCount<K>(eventName: string | symbol, listener?: Function): number;
    listeners<K>(eventName: string | symbol): Function[];
    off<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    on<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    once<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    prependListener<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    prependOnceListener<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    rawListeners<K>(eventName: string | symbol): Function[];
    removeAllListeners(eventName?: string | symbol): this;
    removeListener<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    setMaxListeners(n: number): this;
}

Hierarchy (view full)

Implemented by

Methods

  • Type Parameters

    • K

    Parameters

    • error: Error
    • event: string | symbol
    • Rest...args: AnyRest

    Returns void

  • Alias for emitter.on(eventName, listener).

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.26

    +
  • Synchronously calls each of the listeners registered for the event named eventName, in the order they were registered, passing the supplied arguments +to each.

    +

    Returns true if the event had listeners, false otherwise.

    +
    import { EventEmitter } from 'node:events';
    const myEmitter = new EventEmitter();

    // First listener
    myEmitter.on('event', function firstListener() {
    console.log('Helloooo! first listener');
    });
    // Second listener
    myEmitter.on('event', function secondListener(arg1, arg2) {
    console.log(`event with parameters ${arg1}, ${arg2} in second listener`);
    });
    // Third listener
    myEmitter.on('event', function thirdListener(...args) {
    const parameters = args.join(', ');
    console.log(`event with parameters ${parameters} in third listener`);
    });

    console.log(myEmitter.listeners('event'));

    myEmitter.emit('event', 1, 2, 3, 4, 5);

    // Prints:
    // [
    // [Function: firstListener],
    // [Function: secondListener],
    // [Function: thirdListener]
    // ]
    // Helloooo! first listener
    // event with parameters 1, 2 in second listener
    // event with parameters 1, 2, 3, 4, 5 in third listener +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • Rest...args: AnyRest

    Returns boolean

    v0.1.26

    +
  • Returns an array listing the events for which the emitter has registered +listeners. The values in the array are strings or Symbols.

    +
    import { EventEmitter } from 'node:events';

    const myEE = new EventEmitter();
    myEE.on('foo', () => {});
    myEE.on('bar', () => {});

    const sym = Symbol('symbol');
    myEE.on(sym, () => {});

    console.log(myEE.eventNames());
    // Prints: [ 'foo', 'bar', Symbol(symbol) ] +
    + +

    Returns (string | symbol)[]

    v6.0.0

    +
  • Retrieves the maximum number of listeners allowed for this instance.

    +

    Returns number

    The maximum number of listeners, defaulting to Node.js’s EventEmitter.defaultMaxListeners.

    +
  • Returns the number of listeners listening for the event named eventName. +If listener is provided, it will return how many times the listener is found +in the list of the listeners of the event.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event being listened for

      +
    • Optionallistener: Function

      The event handler function

      +

    Returns number

    v3.2.0

    +
  • Returns a copy of the array of listeners for the event named eventName.

    +
    server.on('connection', (stream) => {
    console.log('someone connected!');
    });
    console.log(util.inspect(server.listeners('connection')));
    // Prints: [ [Function] ] +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

    Returns Function[]

    v0.1.26

    +
  • Alias for emitter.removeListener().

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v10.0.0

    +
  • Adds the listener function to the end of the listeners array for the event +named eventName. No checks are made to see if the listener has already +been added. Multiple calls passing the same combination of eventName and +listener will result in the listener being added, and called, multiple times.

    +
    server.on('connection', (stream) => {
    console.log('someone connected!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    By default, event listeners are invoked in the order they are added. The emitter.prependListener() method can be used as an alternative to add the +event listener to the beginning of the listeners array.

    +
    import { EventEmitter } from 'node:events';
    const myEE = new EventEmitter();
    myEE.on('foo', () => console.log('a'));
    myEE.prependListener('foo', () => console.log('b'));
    myEE.emit('foo');
    // Prints:
    // b
    // a +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.101

    +
  • Adds a one-time listener function for the event named eventName. The +next time eventName is triggered, this listener is removed and then invoked.

    +
    server.once('connection', (stream) => {
    console.log('Ah, we have our first user!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    By default, event listeners are invoked in the order they are added. The emitter.prependOnceListener() method can be used as an alternative to add the +event listener to the beginning of the listeners array.

    +
    import { EventEmitter } from 'node:events';
    const myEE = new EventEmitter();
    myEE.once('foo', () => console.log('a'));
    myEE.prependOnceListener('foo', () => console.log('b'));
    myEE.emit('foo');
    // Prints:
    // b
    // a +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.3.0

    +
  • Adds the listener function to the beginning of the listeners array for the +event named eventName. No checks are made to see if the listener has +already been added. Multiple calls passing the same combination of eventName +and listener will result in the listener being added, and called, multiple times.

    +
    server.prependListener('connection', (stream) => {
    console.log('someone connected!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v6.0.0

    +
  • Adds a one-timelistener function for the event named eventName to the beginning of the listeners array. The next time eventName is triggered, this +listener is removed, and then invoked.

    +
    server.prependOnceListener('connection', (stream) => {
    console.log('Ah, we have our first user!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v6.0.0

    +
  • Returns a copy of the array of listeners for the event named eventName, +including any wrappers (such as those created by .once()).

    +
    import { EventEmitter } from 'node:events';
    const emitter = new EventEmitter();
    emitter.once('log', () => console.log('log once'));

    // Returns a new Array with a function `onceWrapper` which has a property
    // `listener` which contains the original listener bound above
    const listeners = emitter.rawListeners('log');
    const logFnWrapper = listeners[0];

    // Logs "log once" to the console and does not unbind the `once` event
    logFnWrapper.listener();

    // Logs "log once" to the console and removes the listener
    logFnWrapper();

    emitter.on('log', () => console.log('log persistently'));
    // Will return a new Array with a single function bound by `.on()` above
    const newListeners = emitter.rawListeners('log');

    // Logs "log persistently" twice
    newListeners[0]();
    emitter.emit('log'); +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

    Returns Function[]

    v9.4.0

    +
  • Removes all listeners, or those of the specified eventName.

    +

    It is bad practice to remove listeners added elsewhere in the code, +particularly when the EventEmitter instance was created by some other +component or module (e.g. sockets or file streams).

    +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Parameters

    • OptionaleventName: string | symbol

    Returns this

    v0.1.26

    +
  • Removes the specified listener from the listener array for the event named eventName.

    +
    const callback = (stream) => {
    console.log('someone connected!');
    };
    server.on('connection', callback);
    // ...
    server.removeListener('connection', callback); +
    + +

    removeListener() will remove, at most, one instance of a listener from the +listener array. If any single listener has been added multiple times to the +listener array for the specified eventName, then removeListener() must be +called multiple times to remove each instance.

    +

    Once an event is emitted, all listeners attached to it at the +time of emitting are called in order. This implies that any removeListener() or removeAllListeners() calls after emitting and before the last listener finishes execution +will not remove them fromemit() in progress. Subsequent events behave as expected.

    +
    import { EventEmitter } from 'node:events';
    class MyEmitter extends EventEmitter {}
    const myEmitter = new MyEmitter();

    const callbackA = () => {
    console.log('A');
    myEmitter.removeListener('event', callbackB);
    };

    const callbackB = () => {
    console.log('B');
    };

    myEmitter.on('event', callbackA);

    myEmitter.on('event', callbackB);

    // callbackA removes listener callbackB but it will still be called.
    // Internal listener array at time of emit [callbackA, callbackB]
    myEmitter.emit('event');
    // Prints:
    // A
    // B

    // callbackB is now removed.
    // Internal listener array [callbackA]
    myEmitter.emit('event');
    // Prints:
    // A +
    + +

    Because listeners are managed using an internal array, calling this will +change the position indices of any listener registered after the listener +being removed. This will not impact the order in which listeners are called, +but it means that any copies of the listener array as returned by +the emitter.listeners() method will need to be recreated.

    +

    When a single function has been added as a handler multiple times for a single +event (as in the example below), removeListener() will remove the most +recently added instance. In the example the once('ping') listener is removed:

    +
    import { EventEmitter } from 'node:events';
    const ee = new EventEmitter();

    function pong() {
    console.log('pong');
    }

    ee.on('ping', pong);
    ee.once('ping', pong);
    ee.removeListener('ping', pong);

    ee.emit('ping');
    ee.emit('ping'); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.26

    +
  • By default EventEmitters will print a warning if more than 10 listeners are +added for a particular event. This is a useful default that helps finding +memory leaks. The emitter.setMaxListeners() method allows the limit to be +modified for this specific EventEmitter instance. The value can be set to Infinity (or 0) to indicate an unlimited number of listeners.

    +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Parameters

    • n: number

    Returns this

    v0.3.5

    +
diff --git a/docs/site/interfaces/interfaces_baseEvent.BaseEventInterface.html b/docs/site/interfaces/interfaces_baseEvent.BaseEventInterface.html new file mode 100644 index 0000000..e4043e6 --- /dev/null +++ b/docs/site/interfaces/interfaces_baseEvent.BaseEventInterface.html @@ -0,0 +1,60 @@ +BaseEventInterface | casinojs

Interface BaseEventInterface<T>

BaseEventInterface

+

Represents a foundational structure for events emitted within the library, ensuring consistency +across event types by standardizing metadata and event-specific payload sections.

+

The BaseEventInterface interface establishes a uniform format for all events within the library, promoting +a cohesive structure for both general event metadata and customizable data content. Designed for flexibility, +BaseEventInterface can be extended by more specific event types, allowing for additional properties as needed +by various components of the library.

+
    +
  • Metadata: Core fields such as id, name, source, and optional fields like status and priority +allow for tracking and categorizing events effectively.
  • +
  • Data: A dynamic content section specific to each event, adaptable based on the event’s requirements.
  • +
  • Extensibility: Supports optional metadata and additional custom fields, enabling event structure +adjustments based on diverse requirements.
  • +
+

BaseEventInterface provides a structured foundation for defining library-wide events. It can be extended by +event-specific interfaces that introduce additional data fields. This makes BaseEventInterface a versatile +base for a variety of events while ensuring a consistent structure across the library.

+
const event: BaseEventInterface = {
id: "unique-id-1234",
name: "Casino:RoomCreated",
source: "PokerRoom",
createdAt: new Date(),
data: { customData: "event-specific details" },
priority: 1,
customField: "extra info"
};
console.log(event);
// Console Output: { id: "unique-id-1234", name: "Casino:RoomCreated", source: "PokerRoom", createdAt: <Date>, data: { customData: "event-specific details" }, priority: 1, customField: "extra info" } +
+ +
interface BaseEventInterface<T> {
    createdAt: Date;
    data: T;
    id: string;
    lastModifiedAt?: Date;
    meta?: {
        [key: string]: any;
    };
    name: string;
    priority?: number;
    source: string;
    status?: string;
    [key: string]: any;
}

Type Parameters

  • T = any

Indexable

  • [key: string]: any

    Allows additional properties for further extensibility.

    +

    Enables flexible additions to event fields, supporting any custom key-value pair +that may be required for specific events.

    +

Properties

createdAt: Date
const creationTime = event.createdAt;
console.log(creationTime);
// Console Output: Date object representing the event's creation time. +
+ +
data: T
const seatEventData = event.data;
console.log(seatEventData);
// Console Output: Custom data object, e.g., { seatId: "123", playerId: "p789" } +
+ +
id: string
const eventId = event.id;
console.log(eventId);
// Console Output: "unique-id-1234" +
+ +
lastModifiedAt?: Date
const modificationTime = event.lastModifiedAt;
console.log(modificationTime);
// Console Output: Date object representing the event's last modification time, if set. +
+ +
meta?: {
    [key: string]: any;
}
const eventMetadata = event.metadata;
console.log(eventMetadata);
// Console Output: { customMetaKey: "customMetaValue" } +
+ +
name: string
const eventName = event.name;
console.log(eventName);
// Console Output: "Casino:RoomCreated" +
+ +
priority?: number
const eventPriority = event.priority;
console.log(eventPriority);
// Console Output: Integer representing event priority level. +
+ +
source: string
const eventSource = event.source;
console.log(eventSource);
// Console Output: "PokerRoom" or similar string value. +
+ +
status?: string
const eventStatus = event.status;
console.log(eventStatus);
// Console Output: "in-progress" or other string value indicating status. +
+ +
diff --git a/docs/site/interfaces/interfaces_card.CardConfig.html b/docs/site/interfaces/interfaces_card.CardConfig.html new file mode 100644 index 0000000..4ba89d5 --- /dev/null +++ b/docs/site/interfaces/interfaces_card.CardConfig.html @@ -0,0 +1,5 @@ +CardConfig | casinojs

CardConfig +Represents a Card Config.

+
interface CardConfig {
    rank: Rank;
    suit: Suit;
}

Properties

Properties

rank: Rank
suit: Suit
diff --git a/docs/site/interfaces/interfaces_card.CardInterface.html b/docs/site/interfaces/interfaces_card.CardInterface.html new file mode 100644 index 0000000..f224c14 --- /dev/null +++ b/docs/site/interfaces/interfaces_card.CardInterface.html @@ -0,0 +1,35 @@ +CardInterface | casinojs

CardInterface +Represents the structure of a card in a poker game. +The interface provides methods to retrieve the card's rank, suit, and other related details.

+
const card: CardInterface = new Card(Rank.Ace, Suit.Spades);
console.log(card.toString()); // "A of Spades" +
+ +
interface CardInterface {
    getRank(): Rank;
    getSuit(): Suit;
    toObj(): {
        rank: Rank;
        suit: Suit;
    };
    toString(): string;
}

Implemented by

Methods

  • getSuit

    +

    Returns the card's suit.

    +

    Returns Suit

    The card's suit.

    +
    const suit = card.getSuit();
    console.log(suit); // "Spades" +
    + +
  • toObj

    +

    Returns an object representation of the card, containing its rank and suit.

    +

    Returns {
        rank: Rank;
        suit: Suit;
    }

    The card's rank and suit as an object.

    +
    const cardObj = card.toObj();
    console.log(cardObj); // { rank: "A", suit: "Spades" } +
    + +
  • toString

    +

    Returns a string representation of the card, displaying its rank and suit.

    +

    Returns string

    The card's rank and suit as a formatted string.

    +
    const description = card.toString();
    console.log(description); // "A of Spades" +
    + +
diff --git a/docs/site/interfaces/interfaces_card.ICard.html b/docs/site/interfaces/interfaces_card.ICard.html deleted file mode 100644 index 29eee28..0000000 --- a/docs/site/interfaces/interfaces_card.ICard.html +++ /dev/null @@ -1,9 +0,0 @@ -ICard | pokerjs

ICard -Represents the structure of a card in a poker game.

-
interface ICard {
    rank: Rank;
    suit: Suit;
    toString(): string;
}

Properties

Methods

Properties

rank: Rank
suit: Suit

Methods

  • Returns string

    The card's rank and suit as a formatted string.

    -

    toString -Returns a string representation of the card, displaying its rank and suit.

    -
diff --git a/docs/site/interfaces/interfaces_casino.CasinoInterface.html b/docs/site/interfaces/interfaces_casino.CasinoInterface.html new file mode 100644 index 0000000..21c86c5 --- /dev/null +++ b/docs/site/interfaces/interfaces_casino.CasinoInterface.html @@ -0,0 +1,392 @@ +CasinoInterface | casinojs

CasinoInterface +Represents the core responsibilities and structure of a Casino entity within the system. It manages multiple PokerRoom instances and facilitates the organization of poker games through room creation, player allocation, and game tracking.

+

The CasinoInterface serves as a blueprint for any Casino class that manages multiple poker rooms. It defines room management methods, player allocation functions, and potentially methods for tracking player statistics or games across rooms.

+

This interface extends NodeJS.EventEmitter to emit events associated with key actions, such as room creation or removal, enhancing flexibility in managing event-driven operations across the Casino system.

+

The CasinoInterface includes essential methods to:

+
    +
  • Create new rooms with specified configurations.
  • +
  • Retrieve details of individual rooms or a complete list of active rooms.
  • +
  • Update rooms dynamically by adding or modifying existing rooms.
  • +
  • Delete specific rooms, ensuring the Casino environment remains organized.
  • +
+

The CasinoInterface supports event emissions for room-related actions. Events allow other parts of the application to subscribe to changes in the Casino, making it easier to handle notifications and updates.

+
const casino: CasinoInterface = new Casino();
casino.on('casino:roomCreated', (room) => console.log(`Room created: ${room.name}`));
const room = casino.createRoom({ name: "Room1", tableSize: 6, smallBlind: 10, bigBlind: 20 });
console.log(casino.listRooms()); +
+ +
interface CasinoInterface {
    [captureRejectionSymbol]?<K>(error: Error, event: string | symbol, ...args: AnyRest): void;
    addListener<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    addRoom(room: PokerRoomInterface): PokerRoomInterface[];
    addRooms(rooms: PokerRoomInterface[]): PokerRoomInterface[];
    createRoom(config: PokerRoomConfig): PokerRoomInterface;
    deleteRoom(index: number): PokerRoomInterface[];
    emit<K>(eventName: string | symbol, ...args: AnyRest): boolean;
    eventNames(): (string | symbol)[];
    getMaxListeners(): number;
    getRoom(index: number): PokerRoomInterface;
    getRooms(): PokerRoomInterface[];
    isValidIndex(index: number): boolean;
    listenerCount<K>(eventName: string | symbol, listener?: Function): number;
    listeners<K>(eventName: string | symbol): Function[];
    off<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    on<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    once<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    prependListener<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    prependOnceListener<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    rawListeners<K>(eventName: string | symbol): Function[];
    removeAllListeners(eventName?: string | symbol): this;
    removeListener<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    roomCount(): number;
    setMaxListeners(n: number): this;
    setRooms(rooms: PokerRoomInterface[]): PokerRoomInterface[];
}

Hierarchy (view full)

Implemented by

Methods

  • Type Parameters

    • K

    Parameters

    • error: Error
    • event: string | symbol
    • Rest...args: AnyRest

    Returns void

  • Alias for emitter.on(eventName, listener).

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.26

    +
  • Adds a new PokerRoom instance to the Casino's list of managed rooms, enabling dynamic expansion +of rooms within the Casino environment.

    +

    N/A

    +

    N/A

    +

    This method provides a flexible mechanism for expanding the Casino's room offerings by allowing new +rooms to be added as required, thereby supporting various gaming scenarios and player demand.

    +

    N/A

    +
      +
    • room - A PokerRoomInterface instance representing the room to be added to the Casino’s list.
    • +
    +
      +
    • The room parameter must be a valid instance implementing PokerRoomInterface.
    • +
    +
      +
    • Returns true to confirm that the room has been successfully added to the Casino.
    • +
    +

    Typically used in scenarios where the Casino environment needs to expand by adding more gaming rooms.

    +

    Parameters

    Returns PokerRoomInterface[]

      +
    • Returns true when the room has been added successfully.
    • +
    +
    const casino = new Casino();
    const room = new PokerRoom({ name: "HighRollers", tableSize: 6, smallBlind: 10, bigBlind: 20 });
    const success = casino.addRoom(room);
    console.log(success); // true +
    + +
  • Adds a new PokerRoom instance to the Casino's list of managed rooms, enabling dynamic expansion +of rooms within the Casino environment.

    +

    N/A

    +

    N/A

    +

    This method provides a flexible mechanism for expanding the Casino's room offerings by allowing new +rooms to be added as required, thereby supporting various gaming scenarios and player demand.

    +

    N/A

    +
      +
    • room - A PokerRoomInterface instance representing the room to be added to the Casino’s list.
    • +
    +
      +
    • The room parameter must be a valid instance implementing PokerRoomInterface.
    • +
    +
      +
    • Returns true to confirm that the room has been successfully added to the Casino.
    • +
    +

    Typically used in scenarios where the Casino environment needs to expand by adding more gaming rooms.

    +

    Parameters

    Returns PokerRoomInterface[]

      +
    • Returns true when the room has been added successfully.
    • +
    +
    const casino = new Casino();
    const room = new PokerRoom({ name: "HighRollers", tableSize: 6, smallBlind: 10, bigBlind: 20 });
    const success = casino.addRoom(room);
    console.log(success); // true +
    + +
  • Creates a new PokerRoom within the Casino and adds it to the list of rooms.

    +

    Implements the createRoom method of CasinoInterface.

    +

    N/A

    +

    Enables the dynamic creation and addition of a PokerRoom to the Casino, expanding the Casino’s managed rooms as required. +This facilitates flexible game setup and room management in response to user needs.

    +
      +
    • casino:roomCreated: This custom event is emitted once the room is successfully added. +Listeners to this event can respond with actions, such as logging or notifying users.
    • +
    +
      +
    • config: A configuration object containing details like the room’s name, table size, small blind, and big blind values.
    • +
    +
      +
    • The configuration object must include valid values for name, tableSize, smallBlind, and bigBlind.
    • +
    +
      +
    • Returns the newly created PokerRoom instance, confirming its addition to the Casino.
    • +
    +

    This method creates a new room based on the provided configuration, then pushes it into the Casino’s room list. +After adding the room, it emits a casino:roomCreated event for any listeners tracking room creation.

    +

    Parameters

    • config: PokerRoomConfig

      A configuration object with properties like the room name, table size, small blind, and big blind values.

      +

    Returns PokerRoomInterface

      +
    • Returns the newly created PokerRoom instance.
    • +
    +
    const casino = new Casino();
    const room = casino.createRoom({ name: "HighRollers", tableSize: 6, smallBlind: 10, bigBlind: 20 });
    console.log(casino.getRooms()); // Logs the new room within the array of rooms +
    + +
  • Removes a PokerRoom from the Casino's list of managed rooms based on the room's name, enabling dynamic +contraction of the Casino environment as required.

    +

    N/A

    +

    N/A

    +

    Allows the Casino environment to remain current by dynamically removing rooms that are no longer active +or needed. This supports a clean and manageable set of active rooms within the Casino.

    +
      +
    • Emits a casino:roomRemoved event when a room is successfully removed. This event can be used +to trigger updates, logging, or notifications.
    • +
    +
      +
    • roomName: A string representing the name of the PokerRoom to be removed from the Casino.
    • +
    +
      +
    • The roomName parameter should match the name property of an existing room for successful deletion.
    • +
    +
      +
    • Returns true if the room was successfully removed, or false if no room with the specified name was found.
    • +
    +

    Use this method when removing a room that is no longer active or required, ensuring that only +currently used rooms remain managed by the Casino.

    +

    Parameters

    • index: number

      The name of the PokerRoom to be removed.

      +

    Returns PokerRoomInterface[]

      +
    • Returns true if the room was removed; false if not found.
    • +
    +
    const casino = new Casino();
    casino.createRoom({ name: "HighRollers", tableSize: 6, smallBlind: 10, bigBlind: 20 });
    const success = casino.deleteRoom("HighRollers");
    console.log(success); // true if room was found and removed, false otherwise +
    + +
  • Synchronously calls each of the listeners registered for the event named eventName, in the order they were registered, passing the supplied arguments +to each.

    +

    Returns true if the event had listeners, false otherwise.

    +
    import { EventEmitter } from 'node:events';
    const myEmitter = new EventEmitter();

    // First listener
    myEmitter.on('event', function firstListener() {
    console.log('Helloooo! first listener');
    });
    // Second listener
    myEmitter.on('event', function secondListener(arg1, arg2) {
    console.log(`event with parameters ${arg1}, ${arg2} in second listener`);
    });
    // Third listener
    myEmitter.on('event', function thirdListener(...args) {
    const parameters = args.join(', ');
    console.log(`event with parameters ${parameters} in third listener`);
    });

    console.log(myEmitter.listeners('event'));

    myEmitter.emit('event', 1, 2, 3, 4, 5);

    // Prints:
    // [
    // [Function: firstListener],
    // [Function: secondListener],
    // [Function: thirdListener]
    // ]
    // Helloooo! first listener
    // event with parameters 1, 2 in second listener
    // event with parameters 1, 2, 3, 4, 5 in third listener +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • Rest...args: AnyRest

    Returns boolean

    v0.1.26

    +
  • Returns an array listing the events for which the emitter has registered +listeners. The values in the array are strings or Symbols.

    +
    import { EventEmitter } from 'node:events';

    const myEE = new EventEmitter();
    myEE.on('foo', () => {});
    myEE.on('bar', () => {});

    const sym = Symbol('symbol');
    myEE.on(sym, () => {});

    console.log(myEE.eventNames());
    // Prints: [ 'foo', 'bar', Symbol(symbol) ] +
    + +

    Returns (string | symbol)[]

    v6.0.0

    +
  • Retrieves a specific PokerRoom based on its position within the Casino’s list of rooms.

    +

    N/A

    +

    N/A

    +

    This method provides direct access to a single PokerRoom by index, allowing for targeted retrieval of rooms, +which can be useful for room-specific operations or when sequentially processing rooms.

    +

    N/A

    +
      +
    • index: A zero-based index representing the position of the desired PokerRoom in the Casino’s room list.
    • +
    +
      +
    • The index provided must be within the bounds of the __rooms array (i.e., 0 <= index < __rooms.length).
    • +
    • Passing an out-of-bounds index will result in an undefined return.
    • +
    +
      +
    • Returns the PokerRoomInterface instance located at the specified index.
    • +
    • Returns undefined if the provided index is out of bounds.
    • +
    +

    Use this method when you need to access a particular room directly by its index in the Casino’s list of rooms. +This can be useful in looped operations or when accessing rooms based on their position in the list.

    +

    Parameters

    • index: number

      The zero-based index of the desired room in the Casino’s room list.

      +

    Returns PokerRoomInterface

      +
    • The PokerRoom at the specified index or undefined if the index is out of bounds.
    • +
    +
    const casino = new Casino();
    const room = casino.getRoom(0); // Returns the first room or undefined if no rooms exist +
    + +
  • Retrieves the full list of rooms currently managed by the Casino.

    +

    Implements the getRooms method of CasinoInterface.

    +

    N/A

    +

    Provides access to the Casino's list of rooms, allowing external components or systems to retrieve and display +information on all currently managed poker rooms.

    +

    N/A

    +

    N/A

    +

    N/A

    +
      +
    • Returns an array containing all PokerRoomInterface instances currently managed by the Casino.
    • +
    • Returns an empty array if no rooms have been added to the Casino.
    • +
    +

    This method is useful when a complete list of active rooms is needed, such as when displaying the Casino's +available games or managing room states.

    +

    Returns PokerRoomInterface[]

      +
    • An array of all PokerRoom objects in the Casino.
    • +
    +
    const casino = new Casino();
    console.log(casino.getRooms()); // Output: [] +
    + +
  • Validates if a specified index is within the valid bounds of the Casino’s room list.

    +

    N/A

    +

    N/A

    +

    Prevents out-of-bounds errors by confirming that an index is within the acceptable range for the Casino’s +room list, ensuring that subsequent calls to access rooms by index have a valid target.

    +

    N/A

    +
      +
    • index: A zero-based integer specifying the position of a room within the Casino's managed room list.
    • +
    +
      +
    • The index must be a non-negative integer within the bounds of the __rooms array.
    • +
    +
      +
    • Returns true if the index is within bounds.
    • +
    • Throws an Error if the index is out of bounds.
    • +
    +

    Call this method before performing operations involving indexed access to rooms, ensuring the index +falls within valid boundaries.

    +

    Parameters

    • index: number

      The zero-based index to validate within the room list.

      +

    Returns boolean

      +
    • Returns true if the index is within bounds.
    • +
    +
      +
    • Throws an error with a descriptive message if the index is out of bounds.
    • +
    +
    const casino = new Casino();
    try {
    casino.isValidIndex(2); // Returns true if index 2 exists in the list of rooms
    } catch (error) {
    console.error(error.message); // Logs error if index 2 is invalid
    } +
    + +
  • Returns the number of listeners listening for the event named eventName. +If listener is provided, it will return how many times the listener is found +in the list of the listeners of the event.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event being listened for

      +
    • Optionallistener: Function

      The event handler function

      +

    Returns number

    v3.2.0

    +
  • Returns a copy of the array of listeners for the event named eventName.

    +
    server.on('connection', (stream) => {
    console.log('someone connected!');
    });
    console.log(util.inspect(server.listeners('connection')));
    // Prints: [ [Function] ] +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

    Returns Function[]

    v0.1.26

    +
  • Alias for emitter.removeListener().

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v10.0.0

    +
  • Adds the listener function to the end of the listeners array for the event +named eventName. No checks are made to see if the listener has already +been added. Multiple calls passing the same combination of eventName and +listener will result in the listener being added, and called, multiple times.

    +
    server.on('connection', (stream) => {
    console.log('someone connected!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    By default, event listeners are invoked in the order they are added. The emitter.prependListener() method can be used as an alternative to add the +event listener to the beginning of the listeners array.

    +
    import { EventEmitter } from 'node:events';
    const myEE = new EventEmitter();
    myEE.on('foo', () => console.log('a'));
    myEE.prependListener('foo', () => console.log('b'));
    myEE.emit('foo');
    // Prints:
    // b
    // a +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.101

    +
  • Adds a one-time listener function for the event named eventName. The +next time eventName is triggered, this listener is removed and then invoked.

    +
    server.once('connection', (stream) => {
    console.log('Ah, we have our first user!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    By default, event listeners are invoked in the order they are added. The emitter.prependOnceListener() method can be used as an alternative to add the +event listener to the beginning of the listeners array.

    +
    import { EventEmitter } from 'node:events';
    const myEE = new EventEmitter();
    myEE.once('foo', () => console.log('a'));
    myEE.prependOnceListener('foo', () => console.log('b'));
    myEE.emit('foo');
    // Prints:
    // b
    // a +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.3.0

    +
  • Adds the listener function to the beginning of the listeners array for the +event named eventName. No checks are made to see if the listener has +already been added. Multiple calls passing the same combination of eventName +and listener will result in the listener being added, and called, multiple times.

    +
    server.prependListener('connection', (stream) => {
    console.log('someone connected!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v6.0.0

    +
  • Adds a one-timelistener function for the event named eventName to the beginning of the listeners array. The next time eventName is triggered, this +listener is removed, and then invoked.

    +
    server.prependOnceListener('connection', (stream) => {
    console.log('Ah, we have our first user!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v6.0.0

    +
  • Returns a copy of the array of listeners for the event named eventName, +including any wrappers (such as those created by .once()).

    +
    import { EventEmitter } from 'node:events';
    const emitter = new EventEmitter();
    emitter.once('log', () => console.log('log once'));

    // Returns a new Array with a function `onceWrapper` which has a property
    // `listener` which contains the original listener bound above
    const listeners = emitter.rawListeners('log');
    const logFnWrapper = listeners[0];

    // Logs "log once" to the console and does not unbind the `once` event
    logFnWrapper.listener();

    // Logs "log once" to the console and removes the listener
    logFnWrapper();

    emitter.on('log', () => console.log('log persistently'));
    // Will return a new Array with a single function bound by `.on()` above
    const newListeners = emitter.rawListeners('log');

    // Logs "log persistently" twice
    newListeners[0]();
    emitter.emit('log'); +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

    Returns Function[]

    v9.4.0

    +
  • Removes all listeners, or those of the specified eventName.

    +

    It is bad practice to remove listeners added elsewhere in the code, +particularly when the EventEmitter instance was created by some other +component or module (e.g. sockets or file streams).

    +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Parameters

    • OptionaleventName: string | symbol

    Returns this

    v0.1.26

    +
  • Removes the specified listener from the listener array for the event named eventName.

    +
    const callback = (stream) => {
    console.log('someone connected!');
    };
    server.on('connection', callback);
    // ...
    server.removeListener('connection', callback); +
    + +

    removeListener() will remove, at most, one instance of a listener from the +listener array. If any single listener has been added multiple times to the +listener array for the specified eventName, then removeListener() must be +called multiple times to remove each instance.

    +

    Once an event is emitted, all listeners attached to it at the +time of emitting are called in order. This implies that any removeListener() or removeAllListeners() calls after emitting and before the last listener finishes execution +will not remove them fromemit() in progress. Subsequent events behave as expected.

    +
    import { EventEmitter } from 'node:events';
    class MyEmitter extends EventEmitter {}
    const myEmitter = new MyEmitter();

    const callbackA = () => {
    console.log('A');
    myEmitter.removeListener('event', callbackB);
    };

    const callbackB = () => {
    console.log('B');
    };

    myEmitter.on('event', callbackA);

    myEmitter.on('event', callbackB);

    // callbackA removes listener callbackB but it will still be called.
    // Internal listener array at time of emit [callbackA, callbackB]
    myEmitter.emit('event');
    // Prints:
    // A
    // B

    // callbackB is now removed.
    // Internal listener array [callbackA]
    myEmitter.emit('event');
    // Prints:
    // A +
    + +

    Because listeners are managed using an internal array, calling this will +change the position indices of any listener registered after the listener +being removed. This will not impact the order in which listeners are called, +but it means that any copies of the listener array as returned by +the emitter.listeners() method will need to be recreated.

    +

    When a single function has been added as a handler multiple times for a single +event (as in the example below), removeListener() will remove the most +recently added instance. In the example the once('ping') listener is removed:

    +
    import { EventEmitter } from 'node:events';
    const ee = new EventEmitter();

    function pong() {
    console.log('pong');
    }

    ee.on('ping', pong);
    ee.once('ping', pong);
    ee.removeListener('ping', pong);

    ee.emit('ping');
    ee.emit('ping'); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.26

    +
  • Retrieves the total number of PokerRoom instances currently managed by the Casino.

    +

    N/A

    +

    N/A

    +

    This method provides insight into the number of poker rooms that the Casino manages, supporting +validation for index-bound operations or general information on Casino state.

    +

    N/A

    +

    N/A

    +

    N/A

    +
      +
    • Returns the total count of rooms managed by the Casino.
    • +
    +

    Use this method to retrieve the total count of active poker rooms, which is helpful when iterating over +rooms or confirming index-bound conditions.

    +

    Returns number

      +
    • The current count of rooms in the Casino.
    • +
    +
    const casino = new Casino();
    const count = casino.roomCount();
    console.log(count); // Logs the total number of managed rooms, e.g., 5 +
    + +
  • By default EventEmitters will print a warning if more than 10 listeners are +added for a particular event. This is a useful default that helps finding +memory leaks. The emitter.setMaxListeners() method allows the limit to be +modified for this specific EventEmitter instance. The value can be set to Infinity (or 0) to indicate an unlimited number of listeners.

    +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Parameters

    • n: number

    Returns this

    v0.3.5

    +
  • Sets the list of rooms managed by the Casino. This method is typically used to replace or update +the entire list of poker rooms in the casino.

    +

    Implements the setRooms method of CasinoInterface.

    +

    N/A

    +

    Provides a way to update the current list of rooms managed by the Casino, ensuring a consistent and up-to-date +list of poker rooms as defined by the casino’s configuration.

    +
      +
    • N/A: No event is emitted by this method.
    • +
    +
      +
    • rooms: An array of PokerRoomInterface instances, representing individual poker rooms in the Casino.
    • +
    +
      +
    • The rooms array must contain at least one room (i.e., rooms.length >= 1).
    • +
    +
      +
    • Returns true when the rooms have been successfully set.
    • +
    +

    This method accepts an array of PokerRoomInterface objects, representing poker rooms to manage in the casino.

    +
      +
    • Replaces any existing rooms with the new provided list.
    • +
    • Calls the internal __setRooms method to update the private __rooms property securely.
    • +
    +

    Parameters

    Returns PokerRoomInterface[]

      +
    • Returns true when the rooms have been successfully set.
    • +
    +
    const casino = new Casino();
    const rooms: PokerRoomInterface[] = [
    new PokerRoom({ name: "Room1", tableSize: 6, smallBlind: 10, bigBlind: 20 })
    ];
    casino.setRooms(rooms);
    console.log(casino.getRooms()); // Logs an array with the newly set rooms +
    + +
diff --git a/docs/site/interfaces/interfaces_deck.DeckInterface.html b/docs/site/interfaces/interfaces_deck.DeckInterface.html new file mode 100644 index 0000000..0a92e1b --- /dev/null +++ b/docs/site/interfaces/interfaces_deck.DeckInterface.html @@ -0,0 +1,165 @@ +DeckInterface | casinojs

DeckInterface +Represents the structure of a deck in a poker game. +The interface provides methods to shuffle the deck and draw cards from the top.

+
const deck: DeckInterface = new Deck();
deck.shuffle();
const card = deck.draw();
console.log(card?.toString()); // "A of Spades" +
+ +
interface DeckInterface {
    [captureRejectionSymbol]?<K>(error: Error, event: string | symbol, ...args: AnyRest): void;
    addListener<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    draw(): undefined | CardInterface;
    emit<K>(eventName: string | symbol, ...args: AnyRest): boolean;
    eventNames(): (string | symbol)[];
    getCards(): CardInterface[];
    getMaxListeners(): number;
    listenerCount<K>(eventName: string | symbol, listener?: Function): number;
    listeners<K>(eventName: string | symbol): Function[];
    off<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    on<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    once<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    prependListener<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    prependOnceListener<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    rawListeners<K>(eventName: string | symbol): Function[];
    removeAllListeners(eventName?: string | symbol): this;
    removeListener<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    setMaxListeners(n: number): this;
    shuffle(): void;
}

Hierarchy (view full)

Implemented by

Methods

  • Type Parameters

    • K

    Parameters

    • error: Error
    • event: string | symbol
    • Rest...args: AnyRest

    Returns void

  • Alias for emitter.on(eventName, listener).

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.26

    +
  • draw +Draws a card from the top of the deck.

    +

    Returns undefined | CardInterface

    Returns the drawn card or undefined if no cards remain.

    +
    const drawnCard = deck.draw();
    console.log(drawnCard?.toString()); // "A of Spades" +
    + +
  • Synchronously calls each of the listeners registered for the event named eventName, in the order they were registered, passing the supplied arguments +to each.

    +

    Returns true if the event had listeners, false otherwise.

    +
    import { EventEmitter } from 'node:events';
    const myEmitter = new EventEmitter();

    // First listener
    myEmitter.on('event', function firstListener() {
    console.log('Helloooo! first listener');
    });
    // Second listener
    myEmitter.on('event', function secondListener(arg1, arg2) {
    console.log(`event with parameters ${arg1}, ${arg2} in second listener`);
    });
    // Third listener
    myEmitter.on('event', function thirdListener(...args) {
    const parameters = args.join(', ');
    console.log(`event with parameters ${parameters} in third listener`);
    });

    console.log(myEmitter.listeners('event'));

    myEmitter.emit('event', 1, 2, 3, 4, 5);

    // Prints:
    // [
    // [Function: firstListener],
    // [Function: secondListener],
    // [Function: thirdListener]
    // ]
    // Helloooo! first listener
    // event with parameters 1, 2 in second listener
    // event with parameters 1, 2, 3, 4, 5 in third listener +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • Rest...args: AnyRest

    Returns boolean

    v0.1.26

    +
  • Returns an array listing the events for which the emitter has registered +listeners. The values in the array are strings or Symbols.

    +
    import { EventEmitter } from 'node:events';

    const myEE = new EventEmitter();
    myEE.on('foo', () => {});
    myEE.on('bar', () => {});

    const sym = Symbol('symbol');
    myEE.on(sym, () => {});

    console.log(myEE.eventNames());
    // Prints: [ 'foo', 'bar', Symbol(symbol) ] +
    + +

    Returns (string | symbol)[]

    v6.0.0

    +
  • Returns the number of listeners listening for the event named eventName. +If listener is provided, it will return how many times the listener is found +in the list of the listeners of the event.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event being listened for

      +
    • Optionallistener: Function

      The event handler function

      +

    Returns number

    v3.2.0

    +
  • Returns a copy of the array of listeners for the event named eventName.

    +
    server.on('connection', (stream) => {
    console.log('someone connected!');
    });
    console.log(util.inspect(server.listeners('connection')));
    // Prints: [ [Function] ] +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

    Returns Function[]

    v0.1.26

    +
  • Alias for emitter.removeListener().

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v10.0.0

    +
  • Adds the listener function to the end of the listeners array for the event +named eventName. No checks are made to see if the listener has already +been added. Multiple calls passing the same combination of eventName and +listener will result in the listener being added, and called, multiple times.

    +
    server.on('connection', (stream) => {
    console.log('someone connected!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    By default, event listeners are invoked in the order they are added. The emitter.prependListener() method can be used as an alternative to add the +event listener to the beginning of the listeners array.

    +
    import { EventEmitter } from 'node:events';
    const myEE = new EventEmitter();
    myEE.on('foo', () => console.log('a'));
    myEE.prependListener('foo', () => console.log('b'));
    myEE.emit('foo');
    // Prints:
    // b
    // a +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.101

    +
  • Adds a one-time listener function for the event named eventName. The +next time eventName is triggered, this listener is removed and then invoked.

    +
    server.once('connection', (stream) => {
    console.log('Ah, we have our first user!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    By default, event listeners are invoked in the order they are added. The emitter.prependOnceListener() method can be used as an alternative to add the +event listener to the beginning of the listeners array.

    +
    import { EventEmitter } from 'node:events';
    const myEE = new EventEmitter();
    myEE.once('foo', () => console.log('a'));
    myEE.prependOnceListener('foo', () => console.log('b'));
    myEE.emit('foo');
    // Prints:
    // b
    // a +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.3.0

    +
  • Adds the listener function to the beginning of the listeners array for the +event named eventName. No checks are made to see if the listener has +already been added. Multiple calls passing the same combination of eventName +and listener will result in the listener being added, and called, multiple times.

    +
    server.prependListener('connection', (stream) => {
    console.log('someone connected!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v6.0.0

    +
  • Adds a one-timelistener function for the event named eventName to the beginning of the listeners array. The next time eventName is triggered, this +listener is removed, and then invoked.

    +
    server.prependOnceListener('connection', (stream) => {
    console.log('Ah, we have our first user!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v6.0.0

    +
  • Returns a copy of the array of listeners for the event named eventName, +including any wrappers (such as those created by .once()).

    +
    import { EventEmitter } from 'node:events';
    const emitter = new EventEmitter();
    emitter.once('log', () => console.log('log once'));

    // Returns a new Array with a function `onceWrapper` which has a property
    // `listener` which contains the original listener bound above
    const listeners = emitter.rawListeners('log');
    const logFnWrapper = listeners[0];

    // Logs "log once" to the console and does not unbind the `once` event
    logFnWrapper.listener();

    // Logs "log once" to the console and removes the listener
    logFnWrapper();

    emitter.on('log', () => console.log('log persistently'));
    // Will return a new Array with a single function bound by `.on()` above
    const newListeners = emitter.rawListeners('log');

    // Logs "log persistently" twice
    newListeners[0]();
    emitter.emit('log'); +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

    Returns Function[]

    v9.4.0

    +
  • Removes all listeners, or those of the specified eventName.

    +

    It is bad practice to remove listeners added elsewhere in the code, +particularly when the EventEmitter instance was created by some other +component or module (e.g. sockets or file streams).

    +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Parameters

    • OptionaleventName: string | symbol

    Returns this

    v0.1.26

    +
  • Removes the specified listener from the listener array for the event named eventName.

    +
    const callback = (stream) => {
    console.log('someone connected!');
    };
    server.on('connection', callback);
    // ...
    server.removeListener('connection', callback); +
    + +

    removeListener() will remove, at most, one instance of a listener from the +listener array. If any single listener has been added multiple times to the +listener array for the specified eventName, then removeListener() must be +called multiple times to remove each instance.

    +

    Once an event is emitted, all listeners attached to it at the +time of emitting are called in order. This implies that any removeListener() or removeAllListeners() calls after emitting and before the last listener finishes execution +will not remove them fromemit() in progress. Subsequent events behave as expected.

    +
    import { EventEmitter } from 'node:events';
    class MyEmitter extends EventEmitter {}
    const myEmitter = new MyEmitter();

    const callbackA = () => {
    console.log('A');
    myEmitter.removeListener('event', callbackB);
    };

    const callbackB = () => {
    console.log('B');
    };

    myEmitter.on('event', callbackA);

    myEmitter.on('event', callbackB);

    // callbackA removes listener callbackB but it will still be called.
    // Internal listener array at time of emit [callbackA, callbackB]
    myEmitter.emit('event');
    // Prints:
    // A
    // B

    // callbackB is now removed.
    // Internal listener array [callbackA]
    myEmitter.emit('event');
    // Prints:
    // A +
    + +

    Because listeners are managed using an internal array, calling this will +change the position indices of any listener registered after the listener +being removed. This will not impact the order in which listeners are called, +but it means that any copies of the listener array as returned by +the emitter.listeners() method will need to be recreated.

    +

    When a single function has been added as a handler multiple times for a single +event (as in the example below), removeListener() will remove the most +recently added instance. In the example the once('ping') listener is removed:

    +
    import { EventEmitter } from 'node:events';
    const ee = new EventEmitter();

    function pong() {
    console.log('pong');
    }

    ee.on('ping', pong);
    ee.once('ping', pong);
    ee.removeListener('ping', pong);

    ee.emit('ping');
    ee.emit('ping'); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.26

    +
  • By default EventEmitters will print a warning if more than 10 listeners are +added for a particular event. This is a useful default that helps finding +memory leaks. The emitter.setMaxListeners() method allows the limit to be +modified for this specific EventEmitter instance. The value can be set to Infinity (or 0) to indicate an unlimited number of listeners.

    +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Parameters

    • n: number

    Returns this

    v0.3.5

    +
  • shuffle +Shuffles the deck of cards.

    +

    Returns void

    const deck = new Deck();
    deck.shuffle(); +
    + +
diff --git a/docs/site/interfaces/interfaces_deck.IDeck.html b/docs/site/interfaces/interfaces_deck.IDeck.html deleted file mode 100644 index 9964beb..0000000 --- a/docs/site/interfaces/interfaces_deck.IDeck.html +++ /dev/null @@ -1,10 +0,0 @@ -IDeck | pokerjs

IDeck -Represents the structure of a deck in a poker game.

-
interface IDeck {
    draw(): undefined | ICard;
    shuffle(): void;
}

Implemented by

Methods

Methods

diff --git a/docs/site/interfaces/interfaces_logger.LoggerConfig.html b/docs/site/interfaces/interfaces_logger.LoggerConfig.html new file mode 100644 index 0000000..e80e57e --- /dev/null +++ b/docs/site/interfaces/interfaces_logger.LoggerConfig.html @@ -0,0 +1,16 @@ +LoggerConfig | casinojs

LoggerConfig

+

Provides configuration options for the Logger class, defining paths, output preferences, and general setup.

+

The LoggerConfig interface standardizes the configuration settings for the logger, ensuring a flexible setup. +This interface allows users to specify where logs should be stored (logDirPath) and whether logging should also +appear in the console (enableConsoleLogging), thus supporting various logging needs in both development and +production environments.

+

The LoggerConfig interface can be used when initializing a logger to define the configuration that aligns with +project-specific requirements.

+
const config: LoggerConfig = {
logDirPath: "./logs",
enableConsoleLogging: true
}; +
+ +
interface LoggerConfig {
    enableConsoleLogging?: boolean;
}

Properties

enableConsoleLogging?: boolean
const config: LoggerConfig = {
enableConsoleLogging: false
}; +
+ +
diff --git a/docs/site/interfaces/interfaces_logger.LoggerInterface.html b/docs/site/interfaces/interfaces_logger.LoggerInterface.html new file mode 100644 index 0000000..a4d2e62 --- /dev/null +++ b/docs/site/interfaces/interfaces_logger.LoggerInterface.html @@ -0,0 +1,45 @@ +LoggerInterface | casinojs

LoggerInterface

+

Defines the structure for logging functionality, ensuring a consistent format for message logging +across different log levels and supporting optional data context.

+

The LoggerInterface interface establishes the required method for logging in various components +within the application. It standardizes how log messages should be formatted and includes support +for different levels of logging (info, warn, error).

+
    +
  • log(level: LogLevel, message: string, data?: Record<string, any>): Promise<void>: +Logs a message with the specified level and optional additional data.
  • +
+

The LoggerInterface is implemented by the Logger class to standardize how logging is handled. +It can be used in classes and utilities where consistent logging behavior is necessary.

+
class MyLogger implements LoggerInterface {
async log(level: LogLevel, message: string, data?: Record<string, any>): Promise<void> {
// Implementation of log
}
}

const logger: LoggerInterface = new MyLogger();
logger.log("info", "Application started", { timestamp: new Date() }); +
+ +
interface LoggerInterface {
    log(level: LogLevel, message: string, data?: Record<string, any>): Promise<void>;
}

Implemented by

Methods

log +

Methods

  • Logs a message with the specified level and optional additional data context. This method +is asynchronous to allow for file I/O or remote logging without blocking the application.

    +

    Standardizes the logging of messages, allowing for log levels and structured data. +Provides flexibility in logging with additional context, such as an error stack or +metadata related to the log message.

    +
      +
    • level: LogLevel - The severity level of the log message (e.g., "info", "warn", "error").
    • +
    • message: string - The main message to be logged.
    • +
    • data?: Record<string, any> - Optional additional data that provides context for the log message.
    • +
    +
      +
    • level should be a valid log level defined in LogLevel.
    • +
    • message should clearly describe the event or action.
    • +
    +
      +
    • Promise<void> - Returns a promise that resolves once the log has been processed.
    • +
    +

    Use this method to log important events, errors, or debug information with optional +data for added context.

    +

    Parameters

    • level: LogLevel

      The severity level of the log message.

      +
    • message: string

      The main message to log.

      +
    • Optionaldata: Record<string, any>

      Additional context data for the log (optional).

      +

    Returns Promise<void>

      +
    • A promise that resolves when the logging is complete.
    • +
    +
    logger.log("error", "Failed to connect to the database", { errorCode: "DB_CONN_ERR", timestamp: new Date() });
    +
    + +
diff --git a/docs/site/interfaces/interfaces_pokerGame.PokerGameConfig.html b/docs/site/interfaces/interfaces_pokerGame.PokerGameConfig.html new file mode 100644 index 0000000..b3c3894 --- /dev/null +++ b/docs/site/interfaces/interfaces_pokerGame.PokerGameConfig.html @@ -0,0 +1,7 @@ +PokerGameConfig | casinojs

PokerGameConfig +Represents a Poker Game Config.

+
interface PokerGameConfig {
    bigBlind: number;
    id?: string;
    players: PokerPlayerInterface[];
    smallBlind: number;
}

Properties

bigBlind: number
id?: string
smallBlind: number
diff --git a/docs/site/interfaces/interfaces_pokerGame.PokerGameInterface.html b/docs/site/interfaces/interfaces_pokerGame.PokerGameInterface.html new file mode 100644 index 0000000..87e80d1 --- /dev/null +++ b/docs/site/interfaces/interfaces_pokerGame.PokerGameInterface.html @@ -0,0 +1,145 @@ +PokerGameInterface | casinojs

PokerGameInterface +Represents the current PokerGame being played at the PokerTable. +Manages the deck, community cards, and game phases, such as pre-flop, flop, turn, and river.

+
interface PokerGameInterface {
    [captureRejectionSymbol]?<K>(error: Error, event: string | symbol, ...args: AnyRest): void;
    addListener<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    emit<K>(eventName: string | symbol, ...args: AnyRest): boolean;
    eventNames(): (string | symbol)[];
    getMaxListeners(): number;
    listenerCount<K>(eventName: string | symbol, listener?: Function): number;
    listeners<K>(eventName: string | symbol): Function[];
    off<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    on<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    once<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    prependListener<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    prependOnceListener<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    rawListeners<K>(eventName: string | symbol): Function[];
    removeAllListeners(eventName?: string | symbol): this;
    removeListener<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    setMaxListeners(n: number): this;
}

Hierarchy (view full)

Implemented by

Methods

  • Type Parameters

    • K

    Parameters

    • error: Error
    • event: string | symbol
    • Rest...args: AnyRest

    Returns void

  • Alias for emitter.on(eventName, listener).

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.26

    +
  • Synchronously calls each of the listeners registered for the event named eventName, in the order they were registered, passing the supplied arguments +to each.

    +

    Returns true if the event had listeners, false otherwise.

    +
    import { EventEmitter } from 'node:events';
    const myEmitter = new EventEmitter();

    // First listener
    myEmitter.on('event', function firstListener() {
    console.log('Helloooo! first listener');
    });
    // Second listener
    myEmitter.on('event', function secondListener(arg1, arg2) {
    console.log(`event with parameters ${arg1}, ${arg2} in second listener`);
    });
    // Third listener
    myEmitter.on('event', function thirdListener(...args) {
    const parameters = args.join(', ');
    console.log(`event with parameters ${parameters} in third listener`);
    });

    console.log(myEmitter.listeners('event'));

    myEmitter.emit('event', 1, 2, 3, 4, 5);

    // Prints:
    // [
    // [Function: firstListener],
    // [Function: secondListener],
    // [Function: thirdListener]
    // ]
    // Helloooo! first listener
    // event with parameters 1, 2 in second listener
    // event with parameters 1, 2, 3, 4, 5 in third listener +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • Rest...args: AnyRest

    Returns boolean

    v0.1.26

    +
  • Returns an array listing the events for which the emitter has registered +listeners. The values in the array are strings or Symbols.

    +
    import { EventEmitter } from 'node:events';

    const myEE = new EventEmitter();
    myEE.on('foo', () => {});
    myEE.on('bar', () => {});

    const sym = Symbol('symbol');
    myEE.on(sym, () => {});

    console.log(myEE.eventNames());
    // Prints: [ 'foo', 'bar', Symbol(symbol) ] +
    + +

    Returns (string | symbol)[]

    v6.0.0

    +
  • Returns the number of listeners listening for the event named eventName. +If listener is provided, it will return how many times the listener is found +in the list of the listeners of the event.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event being listened for

      +
    • Optionallistener: Function

      The event handler function

      +

    Returns number

    v3.2.0

    +
  • Returns a copy of the array of listeners for the event named eventName.

    +
    server.on('connection', (stream) => {
    console.log('someone connected!');
    });
    console.log(util.inspect(server.listeners('connection')));
    // Prints: [ [Function] ] +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

    Returns Function[]

    v0.1.26

    +
  • Alias for emitter.removeListener().

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v10.0.0

    +
  • Adds the listener function to the end of the listeners array for the event +named eventName. No checks are made to see if the listener has already +been added. Multiple calls passing the same combination of eventName and +listener will result in the listener being added, and called, multiple times.

    +
    server.on('connection', (stream) => {
    console.log('someone connected!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    By default, event listeners are invoked in the order they are added. The emitter.prependListener() method can be used as an alternative to add the +event listener to the beginning of the listeners array.

    +
    import { EventEmitter } from 'node:events';
    const myEE = new EventEmitter();
    myEE.on('foo', () => console.log('a'));
    myEE.prependListener('foo', () => console.log('b'));
    myEE.emit('foo');
    // Prints:
    // b
    // a +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.101

    +
  • Adds a one-time listener function for the event named eventName. The +next time eventName is triggered, this listener is removed and then invoked.

    +
    server.once('connection', (stream) => {
    console.log('Ah, we have our first user!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    By default, event listeners are invoked in the order they are added. The emitter.prependOnceListener() method can be used as an alternative to add the +event listener to the beginning of the listeners array.

    +
    import { EventEmitter } from 'node:events';
    const myEE = new EventEmitter();
    myEE.once('foo', () => console.log('a'));
    myEE.prependOnceListener('foo', () => console.log('b'));
    myEE.emit('foo');
    // Prints:
    // b
    // a +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.3.0

    +
  • Adds the listener function to the beginning of the listeners array for the +event named eventName. No checks are made to see if the listener has +already been added. Multiple calls passing the same combination of eventName +and listener will result in the listener being added, and called, multiple times.

    +
    server.prependListener('connection', (stream) => {
    console.log('someone connected!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v6.0.0

    +
  • Adds a one-timelistener function for the event named eventName to the beginning of the listeners array. The next time eventName is triggered, this +listener is removed, and then invoked.

    +
    server.prependOnceListener('connection', (stream) => {
    console.log('Ah, we have our first user!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v6.0.0

    +
  • Returns a copy of the array of listeners for the event named eventName, +including any wrappers (such as those created by .once()).

    +
    import { EventEmitter } from 'node:events';
    const emitter = new EventEmitter();
    emitter.once('log', () => console.log('log once'));

    // Returns a new Array with a function `onceWrapper` which has a property
    // `listener` which contains the original listener bound above
    const listeners = emitter.rawListeners('log');
    const logFnWrapper = listeners[0];

    // Logs "log once" to the console and does not unbind the `once` event
    logFnWrapper.listener();

    // Logs "log once" to the console and removes the listener
    logFnWrapper();

    emitter.on('log', () => console.log('log persistently'));
    // Will return a new Array with a single function bound by `.on()` above
    const newListeners = emitter.rawListeners('log');

    // Logs "log persistently" twice
    newListeners[0]();
    emitter.emit('log'); +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

    Returns Function[]

    v9.4.0

    +
  • Removes all listeners, or those of the specified eventName.

    +

    It is bad practice to remove listeners added elsewhere in the code, +particularly when the EventEmitter instance was created by some other +component or module (e.g. sockets or file streams).

    +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Parameters

    • OptionaleventName: string | symbol

    Returns this

    v0.1.26

    +
  • Removes the specified listener from the listener array for the event named eventName.

    +
    const callback = (stream) => {
    console.log('someone connected!');
    };
    server.on('connection', callback);
    // ...
    server.removeListener('connection', callback); +
    + +

    removeListener() will remove, at most, one instance of a listener from the +listener array. If any single listener has been added multiple times to the +listener array for the specified eventName, then removeListener() must be +called multiple times to remove each instance.

    +

    Once an event is emitted, all listeners attached to it at the +time of emitting are called in order. This implies that any removeListener() or removeAllListeners() calls after emitting and before the last listener finishes execution +will not remove them fromemit() in progress. Subsequent events behave as expected.

    +
    import { EventEmitter } from 'node:events';
    class MyEmitter extends EventEmitter {}
    const myEmitter = new MyEmitter();

    const callbackA = () => {
    console.log('A');
    myEmitter.removeListener('event', callbackB);
    };

    const callbackB = () => {
    console.log('B');
    };

    myEmitter.on('event', callbackA);

    myEmitter.on('event', callbackB);

    // callbackA removes listener callbackB but it will still be called.
    // Internal listener array at time of emit [callbackA, callbackB]
    myEmitter.emit('event');
    // Prints:
    // A
    // B

    // callbackB is now removed.
    // Internal listener array [callbackA]
    myEmitter.emit('event');
    // Prints:
    // A +
    + +

    Because listeners are managed using an internal array, calling this will +change the position indices of any listener registered after the listener +being removed. This will not impact the order in which listeners are called, +but it means that any copies of the listener array as returned by +the emitter.listeners() method will need to be recreated.

    +

    When a single function has been added as a handler multiple times for a single +event (as in the example below), removeListener() will remove the most +recently added instance. In the example the once('ping') listener is removed:

    +
    import { EventEmitter } from 'node:events';
    const ee = new EventEmitter();

    function pong() {
    console.log('pong');
    }

    ee.on('ping', pong);
    ee.once('ping', pong);
    ee.removeListener('ping', pong);

    ee.emit('ping');
    ee.emit('ping'); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.26

    +
  • By default EventEmitters will print a warning if more than 10 listeners are +added for a particular event. This is a useful default that helps finding +memory leaks. The emitter.setMaxListeners() method allows the limit to be +modified for this specific EventEmitter instance. The value can be set to Infinity (or 0) to indicate an unlimited number of listeners.

    +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Parameters

    • n: number

    Returns this

    v0.3.5

    +
diff --git a/docs/site/interfaces/interfaces_pokerPhase.PokerPhaseConfig.html b/docs/site/interfaces/interfaces_pokerPhase.PokerPhaseConfig.html new file mode 100644 index 0000000..ad1f31b --- /dev/null +++ b/docs/site/interfaces/interfaces_pokerPhase.PokerPhaseConfig.html @@ -0,0 +1,11 @@ +PokerPhaseConfig | casinojs

PokerPhaseConfig +Represents a Poker Phase Config.

+
interface PokerPhaseConfig {
    bigBlindPos: number;
    communityCards?: CardInterface[];
    dealerPos: number;
    deck: DeckInterface;
    name: PokerPhaseName;
    players: PokerPlayerInterface[];
    pot?: number;
    smallBlindPos: number;
}

Properties

bigBlindPos: number
communityCards?: CardInterface[]
dealerPos: number
pot?: number
smallBlindPos: number
diff --git a/docs/site/interfaces/interfaces_pokerPhase.PokerPhaseInterface.html b/docs/site/interfaces/interfaces_pokerPhase.PokerPhaseInterface.html new file mode 100644 index 0000000..06a8205 --- /dev/null +++ b/docs/site/interfaces/interfaces_pokerPhase.PokerPhaseInterface.html @@ -0,0 +1,145 @@ +PokerPhaseInterface | casinojs

PokerPhaseInterface +Represents the current PokerPhase being played at the PokerTable. +Manages the deck, community cards, and game phases, such as pre-flop, flop, turn, and river.

+
interface PokerPhaseInterface {
    [captureRejectionSymbol]?<K>(error: Error, event: string | symbol, ...args: AnyRest): void;
    addListener<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    emit<K>(eventName: string | symbol, ...args: AnyRest): boolean;
    eventNames(): (string | symbol)[];
    getMaxListeners(): number;
    listenerCount<K>(eventName: string | symbol, listener?: Function): number;
    listeners<K>(eventName: string | symbol): Function[];
    off<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    on<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    once<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    prependListener<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    prependOnceListener<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    rawListeners<K>(eventName: string | symbol): Function[];
    removeAllListeners(eventName?: string | symbol): this;
    removeListener<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    setMaxListeners(n: number): this;
}

Hierarchy (view full)

Implemented by

Methods

  • Type Parameters

    • K

    Parameters

    • error: Error
    • event: string | symbol
    • Rest...args: AnyRest

    Returns void

  • Alias for emitter.on(eventName, listener).

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.26

    +
  • Synchronously calls each of the listeners registered for the event named eventName, in the order they were registered, passing the supplied arguments +to each.

    +

    Returns true if the event had listeners, false otherwise.

    +
    import { EventEmitter } from 'node:events';
    const myEmitter = new EventEmitter();

    // First listener
    myEmitter.on('event', function firstListener() {
    console.log('Helloooo! first listener');
    });
    // Second listener
    myEmitter.on('event', function secondListener(arg1, arg2) {
    console.log(`event with parameters ${arg1}, ${arg2} in second listener`);
    });
    // Third listener
    myEmitter.on('event', function thirdListener(...args) {
    const parameters = args.join(', ');
    console.log(`event with parameters ${parameters} in third listener`);
    });

    console.log(myEmitter.listeners('event'));

    myEmitter.emit('event', 1, 2, 3, 4, 5);

    // Prints:
    // [
    // [Function: firstListener],
    // [Function: secondListener],
    // [Function: thirdListener]
    // ]
    // Helloooo! first listener
    // event with parameters 1, 2 in second listener
    // event with parameters 1, 2, 3, 4, 5 in third listener +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • Rest...args: AnyRest

    Returns boolean

    v0.1.26

    +
  • Returns an array listing the events for which the emitter has registered +listeners. The values in the array are strings or Symbols.

    +
    import { EventEmitter } from 'node:events';

    const myEE = new EventEmitter();
    myEE.on('foo', () => {});
    myEE.on('bar', () => {});

    const sym = Symbol('symbol');
    myEE.on(sym, () => {});

    console.log(myEE.eventNames());
    // Prints: [ 'foo', 'bar', Symbol(symbol) ] +
    + +

    Returns (string | symbol)[]

    v6.0.0

    +
  • Returns the number of listeners listening for the event named eventName. +If listener is provided, it will return how many times the listener is found +in the list of the listeners of the event.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event being listened for

      +
    • Optionallistener: Function

      The event handler function

      +

    Returns number

    v3.2.0

    +
  • Returns a copy of the array of listeners for the event named eventName.

    +
    server.on('connection', (stream) => {
    console.log('someone connected!');
    });
    console.log(util.inspect(server.listeners('connection')));
    // Prints: [ [Function] ] +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

    Returns Function[]

    v0.1.26

    +
  • Alias for emitter.removeListener().

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v10.0.0

    +
  • Adds the listener function to the end of the listeners array for the event +named eventName. No checks are made to see if the listener has already +been added. Multiple calls passing the same combination of eventName and +listener will result in the listener being added, and called, multiple times.

    +
    server.on('connection', (stream) => {
    console.log('someone connected!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    By default, event listeners are invoked in the order they are added. The emitter.prependListener() method can be used as an alternative to add the +event listener to the beginning of the listeners array.

    +
    import { EventEmitter } from 'node:events';
    const myEE = new EventEmitter();
    myEE.on('foo', () => console.log('a'));
    myEE.prependListener('foo', () => console.log('b'));
    myEE.emit('foo');
    // Prints:
    // b
    // a +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.101

    +
  • Adds a one-time listener function for the event named eventName. The +next time eventName is triggered, this listener is removed and then invoked.

    +
    server.once('connection', (stream) => {
    console.log('Ah, we have our first user!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    By default, event listeners are invoked in the order they are added. The emitter.prependOnceListener() method can be used as an alternative to add the +event listener to the beginning of the listeners array.

    +
    import { EventEmitter } from 'node:events';
    const myEE = new EventEmitter();
    myEE.once('foo', () => console.log('a'));
    myEE.prependOnceListener('foo', () => console.log('b'));
    myEE.emit('foo');
    // Prints:
    // b
    // a +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.3.0

    +
  • Adds the listener function to the beginning of the listeners array for the +event named eventName. No checks are made to see if the listener has +already been added. Multiple calls passing the same combination of eventName +and listener will result in the listener being added, and called, multiple times.

    +
    server.prependListener('connection', (stream) => {
    console.log('someone connected!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v6.0.0

    +
  • Adds a one-timelistener function for the event named eventName to the beginning of the listeners array. The next time eventName is triggered, this +listener is removed, and then invoked.

    +
    server.prependOnceListener('connection', (stream) => {
    console.log('Ah, we have our first user!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v6.0.0

    +
  • Returns a copy of the array of listeners for the event named eventName, +including any wrappers (such as those created by .once()).

    +
    import { EventEmitter } from 'node:events';
    const emitter = new EventEmitter();
    emitter.once('log', () => console.log('log once'));

    // Returns a new Array with a function `onceWrapper` which has a property
    // `listener` which contains the original listener bound above
    const listeners = emitter.rawListeners('log');
    const logFnWrapper = listeners[0];

    // Logs "log once" to the console and does not unbind the `once` event
    logFnWrapper.listener();

    // Logs "log once" to the console and removes the listener
    logFnWrapper();

    emitter.on('log', () => console.log('log persistently'));
    // Will return a new Array with a single function bound by `.on()` above
    const newListeners = emitter.rawListeners('log');

    // Logs "log persistently" twice
    newListeners[0]();
    emitter.emit('log'); +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

    Returns Function[]

    v9.4.0

    +
  • Removes all listeners, or those of the specified eventName.

    +

    It is bad practice to remove listeners added elsewhere in the code, +particularly when the EventEmitter instance was created by some other +component or module (e.g. sockets or file streams).

    +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Parameters

    • OptionaleventName: string | symbol

    Returns this

    v0.1.26

    +
  • Removes the specified listener from the listener array for the event named eventName.

    +
    const callback = (stream) => {
    console.log('someone connected!');
    };
    server.on('connection', callback);
    // ...
    server.removeListener('connection', callback); +
    + +

    removeListener() will remove, at most, one instance of a listener from the +listener array. If any single listener has been added multiple times to the +listener array for the specified eventName, then removeListener() must be +called multiple times to remove each instance.

    +

    Once an event is emitted, all listeners attached to it at the +time of emitting are called in order. This implies that any removeListener() or removeAllListeners() calls after emitting and before the last listener finishes execution +will not remove them fromemit() in progress. Subsequent events behave as expected.

    +
    import { EventEmitter } from 'node:events';
    class MyEmitter extends EventEmitter {}
    const myEmitter = new MyEmitter();

    const callbackA = () => {
    console.log('A');
    myEmitter.removeListener('event', callbackB);
    };

    const callbackB = () => {
    console.log('B');
    };

    myEmitter.on('event', callbackA);

    myEmitter.on('event', callbackB);

    // callbackA removes listener callbackB but it will still be called.
    // Internal listener array at time of emit [callbackA, callbackB]
    myEmitter.emit('event');
    // Prints:
    // A
    // B

    // callbackB is now removed.
    // Internal listener array [callbackA]
    myEmitter.emit('event');
    // Prints:
    // A +
    + +

    Because listeners are managed using an internal array, calling this will +change the position indices of any listener registered after the listener +being removed. This will not impact the order in which listeners are called, +but it means that any copies of the listener array as returned by +the emitter.listeners() method will need to be recreated.

    +

    When a single function has been added as a handler multiple times for a single +event (as in the example below), removeListener() will remove the most +recently added instance. In the example the once('ping') listener is removed:

    +
    import { EventEmitter } from 'node:events';
    const ee = new EventEmitter();

    function pong() {
    console.log('pong');
    }

    ee.on('ping', pong);
    ee.once('ping', pong);
    ee.removeListener('ping', pong);

    ee.emit('ping');
    ee.emit('ping'); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.26

    +
  • By default EventEmitters will print a warning if more than 10 listeners are +added for a particular event. This is a useful default that helps finding +memory leaks. The emitter.setMaxListeners() method allows the limit to be +modified for this specific EventEmitter instance. The value can be set to Infinity (or 0) to indicate an unlimited number of listeners.

    +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Parameters

    • n: number

    Returns this

    v0.3.5

    +
diff --git a/docs/site/interfaces/interfaces_pokerPlayer.PokerPlayerConfig.html b/docs/site/interfaces/interfaces_pokerPlayer.PokerPlayerConfig.html new file mode 100644 index 0000000..4c9d51f --- /dev/null +++ b/docs/site/interfaces/interfaces_pokerPlayer.PokerPlayerConfig.html @@ -0,0 +1,5 @@ +PokerPlayerConfig | casinojs

PokerPlayerConfig +Represents a PokerPlayer Config.

+
interface PokerPlayerConfig {
    id?: string;
    name?: string;
}

Properties

Properties

id?: string
name?: string
diff --git a/docs/site/interfaces/interfaces_pokerPlayer.PokerPlayerInterface.html b/docs/site/interfaces/interfaces_pokerPlayer.PokerPlayerInterface.html new file mode 100644 index 0000000..f51cdd8 --- /dev/null +++ b/docs/site/interfaces/interfaces_pokerPlayer.PokerPlayerInterface.html @@ -0,0 +1,154 @@ +PokerPlayerInterface | casinojs

PokerPlayerInterface +Represents a player seated at the PokerTable. +The player can place bets, fold, and manage their chip stack during the game.

+
interface PokerPlayerInterface {
    [captureRejectionSymbol]?<K>(error: Error, event: string | symbol, ...args: AnyRest): void;
    addListener<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    bet(amount: number): boolean;
    emit<K>(eventName: string | symbol, ...args: AnyRest): boolean;
    eventNames(): (string | symbol)[];
    getId(): string;
    getMaxListeners(): number;
    listenerCount<K>(eventName: string | symbol, listener?: Function): number;
    listeners<K>(eventName: string | symbol): Function[];
    off<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    on<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    once<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    prependListener<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    prependOnceListener<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    rawListeners<K>(eventName: string | symbol): Function[];
    removeAllListeners(eventName?: string | symbol): this;
    removeListener<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    setIsFolded(bool: boolean): boolean;
    setMaxListeners(n: number): this;
}

Hierarchy (view full)

Implemented by

Methods

  • Type Parameters

    • K

    Parameters

    • error: Error
    • event: string | symbol
    • Rest...args: AnyRest

    Returns void

  • Alias for emitter.on(eventName, listener).

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.26

    +
  • Synchronously calls each of the listeners registered for the event named eventName, in the order they were registered, passing the supplied arguments +to each.

    +

    Returns true if the event had listeners, false otherwise.

    +
    import { EventEmitter } from 'node:events';
    const myEmitter = new EventEmitter();

    // First listener
    myEmitter.on('event', function firstListener() {
    console.log('Helloooo! first listener');
    });
    // Second listener
    myEmitter.on('event', function secondListener(arg1, arg2) {
    console.log(`event with parameters ${arg1}, ${arg2} in second listener`);
    });
    // Third listener
    myEmitter.on('event', function thirdListener(...args) {
    const parameters = args.join(', ');
    console.log(`event with parameters ${parameters} in third listener`);
    });

    console.log(myEmitter.listeners('event'));

    myEmitter.emit('event', 1, 2, 3, 4, 5);

    // Prints:
    // [
    // [Function: firstListener],
    // [Function: secondListener],
    // [Function: thirdListener]
    // ]
    // Helloooo! first listener
    // event with parameters 1, 2 in second listener
    // event with parameters 1, 2, 3, 4, 5 in third listener +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • Rest...args: AnyRest

    Returns boolean

    v0.1.26

    +
  • Returns an array listing the events for which the emitter has registered +listeners. The values in the array are strings or Symbols.

    +
    import { EventEmitter } from 'node:events';

    const myEE = new EventEmitter();
    myEE.on('foo', () => {});
    myEE.on('bar', () => {});

    const sym = Symbol('symbol');
    myEE.on(sym, () => {});

    console.log(myEE.eventNames());
    // Prints: [ 'foo', 'bar', Symbol(symbol) ] +
    + +

    Returns (string | symbol)[]

    v6.0.0

    +
  • getId

    +

    Returns the poker table's id.

    +

    Returns string

    The poker table's id.

    +
    const rank = card.getRank();
    console.log(rank); // "A" +
    + +
  • Returns the number of listeners listening for the event named eventName. +If listener is provided, it will return how many times the listener is found +in the list of the listeners of the event.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event being listened for

      +
    • Optionallistener: Function

      The event handler function

      +

    Returns number

    v3.2.0

    +
  • Returns a copy of the array of listeners for the event named eventName.

    +
    server.on('connection', (stream) => {
    console.log('someone connected!');
    });
    console.log(util.inspect(server.listeners('connection')));
    // Prints: [ [Function] ] +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

    Returns Function[]

    v0.1.26

    +
  • Alias for emitter.removeListener().

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v10.0.0

    +
  • Adds the listener function to the end of the listeners array for the event +named eventName. No checks are made to see if the listener has already +been added. Multiple calls passing the same combination of eventName and +listener will result in the listener being added, and called, multiple times.

    +
    server.on('connection', (stream) => {
    console.log('someone connected!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    By default, event listeners are invoked in the order they are added. The emitter.prependListener() method can be used as an alternative to add the +event listener to the beginning of the listeners array.

    +
    import { EventEmitter } from 'node:events';
    const myEE = new EventEmitter();
    myEE.on('foo', () => console.log('a'));
    myEE.prependListener('foo', () => console.log('b'));
    myEE.emit('foo');
    // Prints:
    // b
    // a +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.101

    +
  • Adds a one-time listener function for the event named eventName. The +next time eventName is triggered, this listener is removed and then invoked.

    +
    server.once('connection', (stream) => {
    console.log('Ah, we have our first user!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    By default, event listeners are invoked in the order they are added. The emitter.prependOnceListener() method can be used as an alternative to add the +event listener to the beginning of the listeners array.

    +
    import { EventEmitter } from 'node:events';
    const myEE = new EventEmitter();
    myEE.once('foo', () => console.log('a'));
    myEE.prependOnceListener('foo', () => console.log('b'));
    myEE.emit('foo');
    // Prints:
    // b
    // a +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.3.0

    +
  • Adds the listener function to the beginning of the listeners array for the +event named eventName. No checks are made to see if the listener has +already been added. Multiple calls passing the same combination of eventName +and listener will result in the listener being added, and called, multiple times.

    +
    server.prependListener('connection', (stream) => {
    console.log('someone connected!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v6.0.0

    +
  • Adds a one-timelistener function for the event named eventName to the beginning of the listeners array. The next time eventName is triggered, this +listener is removed, and then invoked.

    +
    server.prependOnceListener('connection', (stream) => {
    console.log('Ah, we have our first user!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v6.0.0

    +
  • Returns a copy of the array of listeners for the event named eventName, +including any wrappers (such as those created by .once()).

    +
    import { EventEmitter } from 'node:events';
    const emitter = new EventEmitter();
    emitter.once('log', () => console.log('log once'));

    // Returns a new Array with a function `onceWrapper` which has a property
    // `listener` which contains the original listener bound above
    const listeners = emitter.rawListeners('log');
    const logFnWrapper = listeners[0];

    // Logs "log once" to the console and does not unbind the `once` event
    logFnWrapper.listener();

    // Logs "log once" to the console and removes the listener
    logFnWrapper();

    emitter.on('log', () => console.log('log persistently'));
    // Will return a new Array with a single function bound by `.on()` above
    const newListeners = emitter.rawListeners('log');

    // Logs "log persistently" twice
    newListeners[0]();
    emitter.emit('log'); +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

    Returns Function[]

    v9.4.0

    +
  • Removes all listeners, or those of the specified eventName.

    +

    It is bad practice to remove listeners added elsewhere in the code, +particularly when the EventEmitter instance was created by some other +component or module (e.g. sockets or file streams).

    +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Parameters

    • OptionaleventName: string | symbol

    Returns this

    v0.1.26

    +
  • Removes the specified listener from the listener array for the event named eventName.

    +
    const callback = (stream) => {
    console.log('someone connected!');
    };
    server.on('connection', callback);
    // ...
    server.removeListener('connection', callback); +
    + +

    removeListener() will remove, at most, one instance of a listener from the +listener array. If any single listener has been added multiple times to the +listener array for the specified eventName, then removeListener() must be +called multiple times to remove each instance.

    +

    Once an event is emitted, all listeners attached to it at the +time of emitting are called in order. This implies that any removeListener() or removeAllListeners() calls after emitting and before the last listener finishes execution +will not remove them fromemit() in progress. Subsequent events behave as expected.

    +
    import { EventEmitter } from 'node:events';
    class MyEmitter extends EventEmitter {}
    const myEmitter = new MyEmitter();

    const callbackA = () => {
    console.log('A');
    myEmitter.removeListener('event', callbackB);
    };

    const callbackB = () => {
    console.log('B');
    };

    myEmitter.on('event', callbackA);

    myEmitter.on('event', callbackB);

    // callbackA removes listener callbackB but it will still be called.
    // Internal listener array at time of emit [callbackA, callbackB]
    myEmitter.emit('event');
    // Prints:
    // A
    // B

    // callbackB is now removed.
    // Internal listener array [callbackA]
    myEmitter.emit('event');
    // Prints:
    // A +
    + +

    Because listeners are managed using an internal array, calling this will +change the position indices of any listener registered after the listener +being removed. This will not impact the order in which listeners are called, +but it means that any copies of the listener array as returned by +the emitter.listeners() method will need to be recreated.

    +

    When a single function has been added as a handler multiple times for a single +event (as in the example below), removeListener() will remove the most +recently added instance. In the example the once('ping') listener is removed:

    +
    import { EventEmitter } from 'node:events';
    const ee = new EventEmitter();

    function pong() {
    console.log('pong');
    }

    ee.on('ping', pong);
    ee.once('ping', pong);
    ee.removeListener('ping', pong);

    ee.emit('ping');
    ee.emit('ping'); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.26

    +
  • By default EventEmitters will print a warning if more than 10 listeners are +added for a particular event. This is a useful default that helps finding +memory leaks. The emitter.setMaxListeners() method allows the limit to be +modified for this specific EventEmitter instance. The value can be set to Infinity (or 0) to indicate an unlimited number of listeners.

    +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Parameters

    • n: number

    Returns this

    v0.3.5

    +
diff --git a/docs/site/interfaces/interfaces_pokerRoom.PokerRoomConfig.html b/docs/site/interfaces/interfaces_pokerRoom.PokerRoomConfig.html new file mode 100644 index 0000000..339c2df --- /dev/null +++ b/docs/site/interfaces/interfaces_pokerRoom.PokerRoomConfig.html @@ -0,0 +1,36 @@ +PokerRoomConfig | casinojs

PokerRoomConfig

+

Represents the configuration settings necessary to create a PokerRoom within the Casino system. +This interface defines core properties such as a unique identifier (id), room name (name), +and an array of table configurations (tableConfigs) that standardize room setup and ensure consistent +properties across all PokerRoom instances.

+

The PokerRoomConfig interface serves as a blueprint for initializing PokerRoom instances. +By defining required properties upfront, this configuration helps streamline room creation, +reduce errors, and maintain uniformity across room instances within the Casino system.

+

The interface includes:

+
    +
  • Room Identification: id and name properties for unique identification and naming of the room.
  • +
  • Table Configurations: An array, tableConfigs, that holds one or more configurations detailing each table's settings within the room.
  • +
+

Primarily used as an input for the PokerRoom constructor, PokerRoomConfig allows developers +to define each room’s essential properties during instantiation. This structure helps prevent +setup errors and ensures consistency among multiple rooms in the Casino.

+
    +
  • tableConfigs: Must be a valid array containing one or more PokerTableConfig objects.
  • +
  • id and name (optional): Enhance room uniqueness and readability, if provided.
  • +
+
const roomConfig: PokerRoomConfig = {
id: "room42",
name: "High Stakes",
tableConfigs: [
{ tableSize: 6, smallBlind: 50, bigBlind: 100 },
{ tableSize: 8, smallBlind: 100, bigBlind: 200 }
]
};
const pokerRoom = new PokerRoom(roomConfig); // Initializes a new PokerRoom with the specified configuration +
+ +
interface PokerRoomConfig {
    id?: string;
    name?: string;
    tableConfigs?: PokerTableConfig[];
}

Properties

Properties

id?: string
const roomConfig: PokerRoomConfig = {
id: "room1",
name: "High Rollers",
tableConfigs: [{ tableSize: 6, smallBlind: 10, bigBlind: 20 }]
};
console.log(roomConfig.id);

// Output: "room1" +
+ +
name?: string
const roomConfig: PokerRoomConfig = {
id: "room2",
name: "VIP Suite",
tableConfigs: [{ tableSize: 8, smallBlind: 50, bigBlind: 100 }]
};
console.log(roomConfig.name);

// Output: "VIP Suite" +
+ +
tableConfigs?: PokerTableConfig[]
const roomConfig: PokerRoomConfig = {
id: "room3",
name: "Beginner's Lounge",
tableConfigs: [
{ tableSize: 4, smallBlind: 5, bigBlind: 10 },
{ tableSize: 6, smallBlind: 10, bigBlind: 20 }
]
};
console.log(roomConfig.tableConfigs);
// Output: [{ tableSize: 4, smallBlind: 5, bigBlind: 10 }, { tableSize: 6, smallBlind: 10, bigBlind: 20 }] +
+ +
diff --git a/docs/site/interfaces/interfaces_pokerRoom.PokerRoomInterface.html b/docs/site/interfaces/interfaces_pokerRoom.PokerRoomInterface.html new file mode 100644 index 0000000..8711eba --- /dev/null +++ b/docs/site/interfaces/interfaces_pokerRoom.PokerRoomInterface.html @@ -0,0 +1,332 @@ +PokerRoomInterface | casinojs

PokerRoomInterface

+

Defines the responsibilities and structure for managing a PokerRoom within the Casino system. This interface is +essential for implementing operations such as room setup, player queue management, and table configuration, thereby +organizing and facilitating smooth poker game management.

+

The PokerRoomInterface serves as a standardized blueprint for any PokerRoom class, detailing essential methods +for room configuration, player management, and table access. By following this structure, the system ensures that each +poker room is identifiable, manageable, and consistent in functionality.

+

This interface extends NodeJS.EventEmitter to allow event-driven management of room actions like table updates, +player entry, or exit events, enhancing flexibility in asynchronous operations across the Casino system.

+

The PokerRoomInterface includes the following methods:

+
    +
  • setName: Sets or updates the room’s name.
  • +
  • setTables: Configures the tables in the room, setting attributes such as table size and blinds.
  • +
+

The PokerRoomInterface includes the following events:

+
    +
  • roomUpdated: Emitted whenever the room’s settings are updated, such as when tables are reconfigured.
  • +
+

This interface is designed to standardize the management of PokerRoom instances, offering a complete structure for +both client-facing interactions (like displaying room details) and internal operations (like seating players or adjusting +tables).

+
const pokerRoom: PokerRoomInterface = new PokerRoom();
pokerRoom.on('roomUpdated', () => console.log(`Room updated with new settings`));
pokerRoom.setName("HighRollers");
console.log(pokerRoom.getName()); // Logs "HighRollers" +
+ +
interface PokerRoomInterface {
    [captureRejectionSymbol]?<K>(error: Error, event: string | symbol, ...args: AnyRest): void;
    addListener<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    emit<K>(eventName: string | symbol, ...args: AnyRest): boolean;
    eventNames(): (string | symbol)[];
    getId(): string;
    getMaxListeners(): number;
    getName(): string;
    getTables(): PokerTableInterface[];
    isValidIndex(index: number): boolean;
    listenerCount<K>(eventName: string | symbol, listener?: Function): number;
    listeners<K>(eventName: string | symbol): Function[];
    off<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    on<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    once<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    prependListener<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    prependOnceListener<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    rawListeners<K>(eventName: string | symbol): Function[];
    removeAllListeners(eventName?: string | symbol): this;
    removeListener<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    setMaxListeners(n: number): this;
    setName(name: string): string;
    setTables(tables: PokerTableInterface[]): PokerTableInterface[];
    tableCount(): number;
}

Hierarchy (view full)

Implemented by

Methods

  • Type Parameters

    • K

    Parameters

    • error: Error
    • event: string | symbol
    • Rest...args: AnyRest

    Returns void

  • Alias for emitter.on(eventName, listener).

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.26

    +
  • Synchronously calls each of the listeners registered for the event named eventName, in the order they were registered, passing the supplied arguments +to each.

    +

    Returns true if the event had listeners, false otherwise.

    +
    import { EventEmitter } from 'node:events';
    const myEmitter = new EventEmitter();

    // First listener
    myEmitter.on('event', function firstListener() {
    console.log('Helloooo! first listener');
    });
    // Second listener
    myEmitter.on('event', function secondListener(arg1, arg2) {
    console.log(`event with parameters ${arg1}, ${arg2} in second listener`);
    });
    // Third listener
    myEmitter.on('event', function thirdListener(...args) {
    const parameters = args.join(', ');
    console.log(`event with parameters ${parameters} in third listener`);
    });

    console.log(myEmitter.listeners('event'));

    myEmitter.emit('event', 1, 2, 3, 4, 5);

    // Prints:
    // [
    // [Function: firstListener],
    // [Function: secondListener],
    // [Function: thirdListener]
    // ]
    // Helloooo! first listener
    // event with parameters 1, 2 in second listener
    // event with parameters 1, 2, 3, 4, 5 in third listener +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • Rest...args: AnyRest

    Returns boolean

    v0.1.26

    +
  • Returns an array listing the events for which the emitter has registered +listeners. The values in the array are strings or Symbols.

    +
    import { EventEmitter } from 'node:events';

    const myEE = new EventEmitter();
    myEE.on('foo', () => {});
    myEE.on('bar', () => {});

    const sym = Symbol('symbol');
    myEE.on(sym, () => {});

    console.log(myEE.eventNames());
    // Prints: [ 'foo', 'bar', Symbol(symbol) ] +
    + +

    Returns (string | symbol)[]

    v6.0.0

    +
  • Retrieves the unique identifier of the PokerRoom.

    +

    N/A - This method is defined within the PokerRoomInterface without implementing external methods.

    +

    N/A - This method does not override any superclass or parent methods.

    +

    The getId method enables access to the unique id of a PokerRoom, which is essential for identifying +and referencing specific rooms within the system.

    +

    N/A - No events are emitted by this method.

    +

    N/A - This method does not require any parameters.

    +

    N/A - This method simply returns the id as set by the setId method.

    +
      +
    • Returns the unique id of the PokerRoom as a string.
    • +
    +

    Use this method to retrieve the identifier of a PokerRoom. This is particularly useful for managing, +searching, or displaying room information.

    +

    Returns string

      +
    • The unique identifier of the PokerRoom.
    • +
    +
    const pokerRoom = new PokerRoom({ id: "Room123", name: "VIP Room", tableSize: 6 });
    console.log(pokerRoom.getId()); // Logs "Room123" +
    + +
  • Retrieves the current name of the PokerRoom.

    +

    N/A - This method is defined within PokerRoomInterface and is implemented by any class adhering to this interface.

    +

    N/A - This method does not override any superclass or parent methods.

    +

    The getName method enables access to the current name of a PokerRoom, which can be essential for +identification, logging, and displaying room information to users.

    +

    N/A - No events are emitted by this method.

    +

    N/A - This method does not require any parameters.

    +

    N/A - This method simply returns the current name as set by setName.

    +
      +
    • Returns the current name of the PokerRoom as a string.
    • +
    +

    Use this method to fetch the current name of a PokerRoom. This can be particularly helpful for displaying +or verifying the room name during operations.

    +

    Returns string

      +
    • The current name of the PokerRoom.
    • +
    +
    const pokerRoom = new PokerRoom({ name: "VIP Room", tableSize: 6 });
    console.log(pokerRoom.getName()); // Logs "VIP Room" +
    + +
  • Retrieves the associated PokerTable instance within the PokerRoom.

    +

    N/A - This method does not implement external interfaces.

    +

    N/A - This method does not override any superclass or parent methods.

    +

    The getTable method provides access to the PokerTable instance that is actively managed by the PokerRoom. +This can be used to view table configuration, status, and player seating arrangements.

    +

    N/A - This method does not emit any events.

    +

    N/A - No parameters are required for this method.

    +

    N/A - This method does not modify the table, only retrieves it.

    +
      +
    • Returns the PokerTableInterface instance currently set for the room.
    • +
    +

    Use this method to access the poker table associated with a specific room. This allows for table-specific +operations and inquiries.

    +

    Returns PokerTableInterface[]

      +
    • The PokerTable instance associated with this room.
    • +
    +
    const pokerRoom = new PokerRoom({ name: "High Stakes", tableSize: 6 });
    const table = pokerRoom.getTable();
    console.log(table); // Logs the PokerTable instance associated with "High Stakes" room +
    + +
  • Validates if a specified index is within the valid bounds of the Casino’s room list.

    +

    N/A

    +

    N/A

    +

    Prevents out-of-bounds errors by confirming that an index is within the acceptable range for the Casino’s +room list, ensuring that subsequent calls to access rooms by index have a valid target.

    +

    N/A

    +
      +
    • index: A zero-based integer specifying the position of a room within the Casino's managed room list.
    • +
    +
      +
    • The index must be a non-negative integer within the bounds of the __rooms array.
    • +
    +
      +
    • Returns true if the index is within bounds.
    • +
    • Throws an Error if the index is out of bounds.
    • +
    +

    Call this method before performing operations involving indexed access to rooms, ensuring the index +falls within valid boundaries.

    +

    Parameters

    • index: number

      The zero-based index to validate within the room list.

      +

    Returns boolean

      +
    • Returns true if the index is within bounds.
    • +
    +
      +
    • Throws an error with a descriptive message if the index is out of bounds.
    • +
    +
    const casino = new Casino();
    try {
    casino.isValidIndex(2); // Returns true if index 2 exists in the list of rooms
    } catch (error) {
    console.error(error.message); // Logs error if index 2 is invalid
    } +
    + +
  • Returns the number of listeners listening for the event named eventName. +If listener is provided, it will return how many times the listener is found +in the list of the listeners of the event.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event being listened for

      +
    • Optionallistener: Function

      The event handler function

      +

    Returns number

    v3.2.0

    +
  • Returns a copy of the array of listeners for the event named eventName.

    +
    server.on('connection', (stream) => {
    console.log('someone connected!');
    });
    console.log(util.inspect(server.listeners('connection')));
    // Prints: [ [Function] ] +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

    Returns Function[]

    v0.1.26

    +
  • Alias for emitter.removeListener().

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v10.0.0

    +
  • Adds the listener function to the end of the listeners array for the event +named eventName. No checks are made to see if the listener has already +been added. Multiple calls passing the same combination of eventName and +listener will result in the listener being added, and called, multiple times.

    +
    server.on('connection', (stream) => {
    console.log('someone connected!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    By default, event listeners are invoked in the order they are added. The emitter.prependListener() method can be used as an alternative to add the +event listener to the beginning of the listeners array.

    +
    import { EventEmitter } from 'node:events';
    const myEE = new EventEmitter();
    myEE.on('foo', () => console.log('a'));
    myEE.prependListener('foo', () => console.log('b'));
    myEE.emit('foo');
    // Prints:
    // b
    // a +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.101

    +
  • Adds a one-time listener function for the event named eventName. The +next time eventName is triggered, this listener is removed and then invoked.

    +
    server.once('connection', (stream) => {
    console.log('Ah, we have our first user!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    By default, event listeners are invoked in the order they are added. The emitter.prependOnceListener() method can be used as an alternative to add the +event listener to the beginning of the listeners array.

    +
    import { EventEmitter } from 'node:events';
    const myEE = new EventEmitter();
    myEE.once('foo', () => console.log('a'));
    myEE.prependOnceListener('foo', () => console.log('b'));
    myEE.emit('foo');
    // Prints:
    // b
    // a +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.3.0

    +
  • Adds the listener function to the beginning of the listeners array for the +event named eventName. No checks are made to see if the listener has +already been added. Multiple calls passing the same combination of eventName +and listener will result in the listener being added, and called, multiple times.

    +
    server.prependListener('connection', (stream) => {
    console.log('someone connected!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v6.0.0

    +
  • Adds a one-timelistener function for the event named eventName to the beginning of the listeners array. The next time eventName is triggered, this +listener is removed, and then invoked.

    +
    server.prependOnceListener('connection', (stream) => {
    console.log('Ah, we have our first user!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v6.0.0

    +
  • Returns a copy of the array of listeners for the event named eventName, +including any wrappers (such as those created by .once()).

    +
    import { EventEmitter } from 'node:events';
    const emitter = new EventEmitter();
    emitter.once('log', () => console.log('log once'));

    // Returns a new Array with a function `onceWrapper` which has a property
    // `listener` which contains the original listener bound above
    const listeners = emitter.rawListeners('log');
    const logFnWrapper = listeners[0];

    // Logs "log once" to the console and does not unbind the `once` event
    logFnWrapper.listener();

    // Logs "log once" to the console and removes the listener
    logFnWrapper();

    emitter.on('log', () => console.log('log persistently'));
    // Will return a new Array with a single function bound by `.on()` above
    const newListeners = emitter.rawListeners('log');

    // Logs "log persistently" twice
    newListeners[0]();
    emitter.emit('log'); +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

    Returns Function[]

    v9.4.0

    +
  • Removes all listeners, or those of the specified eventName.

    +

    It is bad practice to remove listeners added elsewhere in the code, +particularly when the EventEmitter instance was created by some other +component or module (e.g. sockets or file streams).

    +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Parameters

    • OptionaleventName: string | symbol

    Returns this

    v0.1.26

    +
  • Removes the specified listener from the listener array for the event named eventName.

    +
    const callback = (stream) => {
    console.log('someone connected!');
    };
    server.on('connection', callback);
    // ...
    server.removeListener('connection', callback); +
    + +

    removeListener() will remove, at most, one instance of a listener from the +listener array. If any single listener has been added multiple times to the +listener array for the specified eventName, then removeListener() must be +called multiple times to remove each instance.

    +

    Once an event is emitted, all listeners attached to it at the +time of emitting are called in order. This implies that any removeListener() or removeAllListeners() calls after emitting and before the last listener finishes execution +will not remove them fromemit() in progress. Subsequent events behave as expected.

    +
    import { EventEmitter } from 'node:events';
    class MyEmitter extends EventEmitter {}
    const myEmitter = new MyEmitter();

    const callbackA = () => {
    console.log('A');
    myEmitter.removeListener('event', callbackB);
    };

    const callbackB = () => {
    console.log('B');
    };

    myEmitter.on('event', callbackA);

    myEmitter.on('event', callbackB);

    // callbackA removes listener callbackB but it will still be called.
    // Internal listener array at time of emit [callbackA, callbackB]
    myEmitter.emit('event');
    // Prints:
    // A
    // B

    // callbackB is now removed.
    // Internal listener array [callbackA]
    myEmitter.emit('event');
    // Prints:
    // A +
    + +

    Because listeners are managed using an internal array, calling this will +change the position indices of any listener registered after the listener +being removed. This will not impact the order in which listeners are called, +but it means that any copies of the listener array as returned by +the emitter.listeners() method will need to be recreated.

    +

    When a single function has been added as a handler multiple times for a single +event (as in the example below), removeListener() will remove the most +recently added instance. In the example the once('ping') listener is removed:

    +
    import { EventEmitter } from 'node:events';
    const ee = new EventEmitter();

    function pong() {
    console.log('pong');
    }

    ee.on('ping', pong);
    ee.once('ping', pong);
    ee.removeListener('ping', pong);

    ee.emit('ping');
    ee.emit('ping'); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.26

    +
  • By default EventEmitters will print a warning if more than 10 listeners are +added for a particular event. This is a useful default that helps finding +memory leaks. The emitter.setMaxListeners() method allows the limit to be +modified for this specific EventEmitter instance. The value can be set to Infinity (or 0) to indicate an unlimited number of listeners.

    +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Parameters

    • n: number

    Returns this

    v0.3.5

    +
  • Sets the name of the PokerRoom, allowing the name to be updated or customized.

    +

    N/A - This method is part of the PokerRoomInterface and does not implement any external methods.

    +

    N/A - This method does not override any superclass or parent methods.

    +

    The setName method is used to assign a specific name to a PokerRoom, which helps distinguish it within the system. +This is essential for systems where rooms need to be identifiable and manageable through a unique name.

    +

    N/A - No events are emitted by this method.

    +
      +
    • name: A string representing the new name for the room. It must be a valid, non-empty string to ensure +the room has a clear, identifiable label.
    • +
    +
      +
    • The name parameter should be a non-empty string to provide meaningful identification.
    • +
    • Passing an empty or invalid value could result in future misidentification of rooms if validation is implemented.
    • +
    +
      +
    • Returns the name that was set for the PokerRoom.
    • +
    +

    Use this method to set or update the name of a room in a system where unique or identifiable room names +are necessary for reference.

    +

    Parameters

    • name: string

      The new name for the PokerRoom.

      +

    Returns string

      +
    • Returns the name of the room that was set.
    • +
    +
    const pokerRoom = new PokerRoom({ name: "Room1", tableSize: 6 });
    pokerRoom.setName("HighRollers"); // Sets the name of the room to "HighRollers"
    console.log(pokerRoom.getName()); // Logs "HighRollers" +
    + +
  • Sets the configuration for multiple tables within the PokerRoom. Each table configuration specifies +key attributes like table size, small blind, and big blind values, supporting multi-table configurations +within a single room.

    +

    N/A - This method is part of the PokerRoomInterface and does not implement any external methods.

    +

    N/A - This method does not override any superclass or parent methods.

    +

    The setTables method is crucial for defining or updating the configuration of multiple tables in a room. +Properly configured tables are essential for ensuring smooth gameplay and an organized player experience.

    +
      +
    • roomUpdated: This event is emitted whenever the table configurations are successfully set or updated, +allowing external components to respond to changes in the room’s setup.
    • +
    +
      +
    • tables: An array of PokerTableInterface objects, each containing configuration details for a table.
    • +
    +
      +
    • tables must be a non-empty array of PokerTableInterface instances, each configured with necessary game parameters.
    • +
    +
      +
    • Returns the array of PokerTableInterface instances after successfully setting them within the room.
    • +
    +

    Call this method to configure or update multiple tables in a poker room, ensuring the settings align with +room requirements and player needs.

    +

    Parameters

    Returns PokerTableInterface[]

      +
    • Returns the updated table configurations for the room.
    • +
    +
    const pokerRoom = new PokerRoom({ name: "Room3", tableSize: 8 });
    const tableConfigs = [
    new PokerTable({ tableSize: 8, smallBlind: 10, bigBlind: 20 }),
    new PokerTable({ tableSize: 10, smallBlind: 20, bigBlind: 40 })
    ];
    pokerRoom.setTables(tableConfigs); // Sets multiple table configurations in the room
    console.log(pokerRoom.getTables()); // Logs the table configurations +
    + +
  • Retrieves the total number of PokerRoom instances currently managed by the Casino.

    +

    N/A

    +

    N/A

    +

    This method provides insight into the number of poker rooms that the Casino manages, supporting +validation for index-bound operations or general information on Casino state.

    +

    N/A

    +

    N/A

    +

    N/A

    +
      +
    • Returns the total count of rooms managed by the Casino.
    • +
    +

    Use this method to retrieve the total count of active poker rooms, which is helpful when iterating over +rooms or confirming index-bound conditions.

    +

    Returns number

      +
    • The current count of rooms in the Casino.
    • +
    +
    const casino = new Casino();
    const count = casino.roomCount();
    console.log(count); // Logs the total number of managed rooms, e.g., 5 +
    + +
diff --git a/docs/site/interfaces/interfaces_pokerSeat.PokerSeatConfig.html b/docs/site/interfaces/interfaces_pokerSeat.PokerSeatConfig.html new file mode 100644 index 0000000..d7bf1c0 --- /dev/null +++ b/docs/site/interfaces/interfaces_pokerSeat.PokerSeatConfig.html @@ -0,0 +1,7 @@ +PokerSeatConfig | casinojs

PokerSeatConfig +Represents a PokerTable Config.

+
interface PokerSeatConfig {
    id?: string;
    isDealer?: boolean;
    player?: PokerPlayerInterface;
    position: number;
}

Properties

Properties

id?: string
isDealer?: boolean
position: number
diff --git a/docs/site/interfaces/interfaces_pokerSeat.PokerSeatInterface.html b/docs/site/interfaces/interfaces_pokerSeat.PokerSeatInterface.html new file mode 100644 index 0000000..34ba69f --- /dev/null +++ b/docs/site/interfaces/interfaces_pokerSeat.PokerSeatInterface.html @@ -0,0 +1,187 @@ +PokerSeatInterface | casinojs

PokerSeatInterface +Represents a PokerTable within a PokerRoom. +The PokerTable manages player seats, tracks the dealer, small blind, and big blind positions, +and handles the start and stop of the PokerGame.

+
interface PokerSeatInterface {
    [captureRejectionSymbol]?<K>(error: Error, event: string | symbol, ...args: AnyRest): void;
    addListener<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    emit<K>(eventName: string | symbol, ...args: AnyRest): boolean;
    eventNames(): (string | symbol)[];
    getId(): string;
    getMaxListeners(): number;
    getPlayer(): undefined | PokerPlayerInterface;
    getPosition(): number;
    isDealer(): boolean;
    isOccupied(): boolean;
    listenerCount<K>(eventName: string | symbol, listener?: Function): number;
    listeners<K>(eventName: string | symbol): Function[];
    occupy(player: PokerPlayerInterface): void;
    off<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    on<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    once<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    prependListener<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    prependOnceListener<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    rawListeners<K>(eventName: string | symbol): Function[];
    removeAllListeners(eventName?: string | symbol): this;
    removeListener<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    setDealer(bool: boolean): boolean;
    setMaxListeners(n: number): this;
    vacate(): void;
}

Hierarchy (view full)

Implemented by

Methods

  • Type Parameters

    • K

    Parameters

    • error: Error
    • event: string | symbol
    • Rest...args: AnyRest

    Returns void

  • Alias for emitter.on(eventName, listener).

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.26

    +
  • Synchronously calls each of the listeners registered for the event named eventName, in the order they were registered, passing the supplied arguments +to each.

    +

    Returns true if the event had listeners, false otherwise.

    +
    import { EventEmitter } from 'node:events';
    const myEmitter = new EventEmitter();

    // First listener
    myEmitter.on('event', function firstListener() {
    console.log('Helloooo! first listener');
    });
    // Second listener
    myEmitter.on('event', function secondListener(arg1, arg2) {
    console.log(`event with parameters ${arg1}, ${arg2} in second listener`);
    });
    // Third listener
    myEmitter.on('event', function thirdListener(...args) {
    const parameters = args.join(', ');
    console.log(`event with parameters ${parameters} in third listener`);
    });

    console.log(myEmitter.listeners('event'));

    myEmitter.emit('event', 1, 2, 3, 4, 5);

    // Prints:
    // [
    // [Function: firstListener],
    // [Function: secondListener],
    // [Function: thirdListener]
    // ]
    // Helloooo! first listener
    // event with parameters 1, 2 in second listener
    // event with parameters 1, 2, 3, 4, 5 in third listener +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • Rest...args: AnyRest

    Returns boolean

    v0.1.26

    +
  • Returns an array listing the events for which the emitter has registered +listeners. The values in the array are strings or Symbols.

    +
    import { EventEmitter } from 'node:events';

    const myEE = new EventEmitter();
    myEE.on('foo', () => {});
    myEE.on('bar', () => {});

    const sym = Symbol('symbol');
    myEE.on(sym, () => {});

    console.log(myEE.eventNames());
    // Prints: [ 'foo', 'bar', Symbol(symbol) ] +
    + +

    Returns (string | symbol)[]

    v6.0.0

    +
  • getId

    +

    Returns the poker table's id.

    +

    Returns string

    The poker table's id.

    +
    const rank = card.getRank();
    console.log(rank); // "A" +
    + +
  • getPosition

    +

    Returns the poker table's id.

    +

    Returns number

    The poker table's id.

    +
    const rank = card.getRank();
    console.log(rank); // "A" +
    + +
  • isDealer

    +

    Returns the poker table's id.

    +

    Returns boolean

    The poker table's id.

    +
    const rank = card.getRank();
    console.log(rank); // "A" +
    + +
  • Returns the number of listeners listening for the event named eventName. +If listener is provided, it will return how many times the listener is found +in the list of the listeners of the event.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event being listened for

      +
    • Optionallistener: Function

      The event handler function

      +

    Returns number

    v3.2.0

    +
  • Returns a copy of the array of listeners for the event named eventName.

    +
    server.on('connection', (stream) => {
    console.log('someone connected!');
    });
    console.log(util.inspect(server.listeners('connection')));
    // Prints: [ [Function] ] +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

    Returns Function[]

    v0.1.26

    +
  • Alias for emitter.removeListener().

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v10.0.0

    +
  • Adds the listener function to the end of the listeners array for the event +named eventName. No checks are made to see if the listener has already +been added. Multiple calls passing the same combination of eventName and +listener will result in the listener being added, and called, multiple times.

    +
    server.on('connection', (stream) => {
    console.log('someone connected!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    By default, event listeners are invoked in the order they are added. The emitter.prependListener() method can be used as an alternative to add the +event listener to the beginning of the listeners array.

    +
    import { EventEmitter } from 'node:events';
    const myEE = new EventEmitter();
    myEE.on('foo', () => console.log('a'));
    myEE.prependListener('foo', () => console.log('b'));
    myEE.emit('foo');
    // Prints:
    // b
    // a +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.101

    +
  • Adds a one-time listener function for the event named eventName. The +next time eventName is triggered, this listener is removed and then invoked.

    +
    server.once('connection', (stream) => {
    console.log('Ah, we have our first user!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    By default, event listeners are invoked in the order they are added. The emitter.prependOnceListener() method can be used as an alternative to add the +event listener to the beginning of the listeners array.

    +
    import { EventEmitter } from 'node:events';
    const myEE = new EventEmitter();
    myEE.once('foo', () => console.log('a'));
    myEE.prependOnceListener('foo', () => console.log('b'));
    myEE.emit('foo');
    // Prints:
    // b
    // a +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.3.0

    +
  • Adds the listener function to the beginning of the listeners array for the +event named eventName. No checks are made to see if the listener has +already been added. Multiple calls passing the same combination of eventName +and listener will result in the listener being added, and called, multiple times.

    +
    server.prependListener('connection', (stream) => {
    console.log('someone connected!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v6.0.0

    +
  • Adds a one-timelistener function for the event named eventName to the beginning of the listeners array. The next time eventName is triggered, this +listener is removed, and then invoked.

    +
    server.prependOnceListener('connection', (stream) => {
    console.log('Ah, we have our first user!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v6.0.0

    +
  • Returns a copy of the array of listeners for the event named eventName, +including any wrappers (such as those created by .once()).

    +
    import { EventEmitter } from 'node:events';
    const emitter = new EventEmitter();
    emitter.once('log', () => console.log('log once'));

    // Returns a new Array with a function `onceWrapper` which has a property
    // `listener` which contains the original listener bound above
    const listeners = emitter.rawListeners('log');
    const logFnWrapper = listeners[0];

    // Logs "log once" to the console and does not unbind the `once` event
    logFnWrapper.listener();

    // Logs "log once" to the console and removes the listener
    logFnWrapper();

    emitter.on('log', () => console.log('log persistently'));
    // Will return a new Array with a single function bound by `.on()` above
    const newListeners = emitter.rawListeners('log');

    // Logs "log persistently" twice
    newListeners[0]();
    emitter.emit('log'); +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

    Returns Function[]

    v9.4.0

    +
  • Removes all listeners, or those of the specified eventName.

    +

    It is bad practice to remove listeners added elsewhere in the code, +particularly when the EventEmitter instance was created by some other +component or module (e.g. sockets or file streams).

    +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Parameters

    • OptionaleventName: string | symbol

    Returns this

    v0.1.26

    +
  • Removes the specified listener from the listener array for the event named eventName.

    +
    const callback = (stream) => {
    console.log('someone connected!');
    };
    server.on('connection', callback);
    // ...
    server.removeListener('connection', callback); +
    + +

    removeListener() will remove, at most, one instance of a listener from the +listener array. If any single listener has been added multiple times to the +listener array for the specified eventName, then removeListener() must be +called multiple times to remove each instance.

    +

    Once an event is emitted, all listeners attached to it at the +time of emitting are called in order. This implies that any removeListener() or removeAllListeners() calls after emitting and before the last listener finishes execution +will not remove them fromemit() in progress. Subsequent events behave as expected.

    +
    import { EventEmitter } from 'node:events';
    class MyEmitter extends EventEmitter {}
    const myEmitter = new MyEmitter();

    const callbackA = () => {
    console.log('A');
    myEmitter.removeListener('event', callbackB);
    };

    const callbackB = () => {
    console.log('B');
    };

    myEmitter.on('event', callbackA);

    myEmitter.on('event', callbackB);

    // callbackA removes listener callbackB but it will still be called.
    // Internal listener array at time of emit [callbackA, callbackB]
    myEmitter.emit('event');
    // Prints:
    // A
    // B

    // callbackB is now removed.
    // Internal listener array [callbackA]
    myEmitter.emit('event');
    // Prints:
    // A +
    + +

    Because listeners are managed using an internal array, calling this will +change the position indices of any listener registered after the listener +being removed. This will not impact the order in which listeners are called, +but it means that any copies of the listener array as returned by +the emitter.listeners() method will need to be recreated.

    +

    When a single function has been added as a handler multiple times for a single +event (as in the example below), removeListener() will remove the most +recently added instance. In the example the once('ping') listener is removed:

    +
    import { EventEmitter } from 'node:events';
    const ee = new EventEmitter();

    function pong() {
    console.log('pong');
    }

    ee.on('ping', pong);
    ee.once('ping', pong);
    ee.removeListener('ping', pong);

    ee.emit('ping');
    ee.emit('ping'); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.26

    +
  • setIsDealer

    +

    Returns the poker table's id.

    +

    Parameters

    • bool: boolean

    Returns boolean

    The poker table's id.

    +
    const rank = card.getRank();
    console.log(rank); // "A" +
    + +
  • By default EventEmitters will print a warning if more than 10 listeners are +added for a particular event. This is a useful default that helps finding +memory leaks. The emitter.setMaxListeners() method allows the limit to be +modified for this specific EventEmitter instance. The value can be set to Infinity (or 0) to indicate an unlimited number of listeners.

    +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Parameters

    • n: number

    Returns this

    v0.3.5

    +
diff --git a/docs/site/interfaces/interfaces_pokerTable.PokerTableConfig.html b/docs/site/interfaces/interfaces_pokerTable.PokerTableConfig.html new file mode 100644 index 0000000..23ec757 --- /dev/null +++ b/docs/site/interfaces/interfaces_pokerTable.PokerTableConfig.html @@ -0,0 +1,43 @@ +PokerTableConfig | casinojs

PokerTableConfig

+

Represents the configuration settings necessary to define a poker table within a PokerRoom. This interface +standardizes essential properties such as unique identifiers, table size, and betting values, ensuring each +table is set up with consistent and clear parameters.

+

The PokerTableConfig interface provides a structured configuration for each table within a poker room. By defining +specific parameters for table size, small blind, and big blind amounts, this interface supports accurate table setup +and improves the consistency of poker gameplay within the Casino system.

+
    +
  • Identification: The id and name properties enable unique identification and labeling of tables.
  • +
  • Betting Structure: smallBlind specify the betting increments for the table.
  • +
  • Seating Capacity: size defines the maximum number of players per table.
  • +
+

PokerTableConfig objects are typically used during table creation or setup, offering a clear and consistent way +to configure and manage individual poker tables within a room.

+
    +
  • Optional: id,name, size and smallBlind are not strictly required.
  • +
  • Mandatory: No Mandatory.
  • +
+
const tableConfig: PokerTableConfig = {
id: "table1",
name: "VIP Table",
size: 8,
smallBlind: 50
}; +
+ +
interface PokerTableConfig {
    id?: string;
    name?: string;
    size?: number;
    smallBlind?: number;
}

Properties

Properties

id?: string

Example 1:

+
const tableConfig: PokerTableConfig = {
id: "table42",
name: "High Stakes Table",
size: 6,
smallBlind: 100
};
console.log(tableConfig.id);
// Console Output: "table42" +
+ +

Example 2:

+
const tableConfig: PokerTableConfig = {
id: undefined,
name: "Standard Table",
size: 4,
smallBlind: 10
};
console.log(tableConfig.id);
// Console Output: undefined +
+ +
name?: string
const tableConfig: PokerTableConfig = {
id: "table2",
name: "VIP Suite",
size: 8,
smallBlind: 50
};
console.log(tableConfig.name);
// Console Output: "VIP Suite" +
+ +
size?: number
const tableConfig: PokerTableConfig = {
id: "table3",
name: "Standard Table",
size: 6,
smallBlind: 10
};
console.log(tableConfig.size);
// Console Output: 6 +
+ +
smallBlind?: number
const tableConfig: PokerTableConfig = {
id: "table4",
name: "Training Table",
size: 4,
smallBlind: 5
};
console.log(tableConfig.smallBlind);
// Console Output: 5 +
+ +
diff --git a/docs/site/interfaces/interfaces_pokerTable.PokerTableInterface.html b/docs/site/interfaces/interfaces_pokerTable.PokerTableInterface.html new file mode 100644 index 0000000..e01088b --- /dev/null +++ b/docs/site/interfaces/interfaces_pokerTable.PokerTableInterface.html @@ -0,0 +1,233 @@ +PokerTableInterface | casinojs

PokerTableInterface +Represents a PokerTable within a PokerRoom. +The PokerTable manages player seats, tracks the dealer, small blind, and big blind positions, +and handles the start and stop of the PokerGame.

+
interface PokerTableInterface {
    [captureRejectionSymbol]?<K>(error: Error, event: string | symbol, ...args: AnyRest): void;
    addListener<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    emit<K>(eventName: string | symbol, ...args: AnyRest): boolean;
    eventNames(): (string | symbol)[];
    getId(): string;
    getMaxListeners(): number;
    getSeats(): PokerSeatInterface[];
    isValidIndex(index: number): boolean;
    listenerCount<K>(eventName: string | symbol, listener?: Function): number;
    listeners<K>(eventName: string | symbol): Function[];
    off<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    on<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    once<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    prependListener<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    prependOnceListener<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    rawListeners<K>(eventName: string | symbol): Function[];
    removeAllListeners(eventName?: string | symbol): this;
    removeListener<K>(eventName: string | symbol, listener: ((...args: any[]) => void)): this;
    seatCount(): number;
    setMaxListeners(n: number): this;
    setName(name: string): string;
}

Hierarchy (view full)

Implemented by

Methods

  • Type Parameters

    • K

    Parameters

    • error: Error
    • event: string | symbol
    • Rest...args: AnyRest

    Returns void

  • Alias for emitter.on(eventName, listener).

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.26

    +
  • Synchronously calls each of the listeners registered for the event named eventName, in the order they were registered, passing the supplied arguments +to each.

    +

    Returns true if the event had listeners, false otherwise.

    +
    import { EventEmitter } from 'node:events';
    const myEmitter = new EventEmitter();

    // First listener
    myEmitter.on('event', function firstListener() {
    console.log('Helloooo! first listener');
    });
    // Second listener
    myEmitter.on('event', function secondListener(arg1, arg2) {
    console.log(`event with parameters ${arg1}, ${arg2} in second listener`);
    });
    // Third listener
    myEmitter.on('event', function thirdListener(...args) {
    const parameters = args.join(', ');
    console.log(`event with parameters ${parameters} in third listener`);
    });

    console.log(myEmitter.listeners('event'));

    myEmitter.emit('event', 1, 2, 3, 4, 5);

    // Prints:
    // [
    // [Function: firstListener],
    // [Function: secondListener],
    // [Function: thirdListener]
    // ]
    // Helloooo! first listener
    // event with parameters 1, 2 in second listener
    // event with parameters 1, 2, 3, 4, 5 in third listener +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • Rest...args: AnyRest

    Returns boolean

    v0.1.26

    +
  • Returns an array listing the events for which the emitter has registered +listeners. The values in the array are strings or Symbols.

    +
    import { EventEmitter } from 'node:events';

    const myEE = new EventEmitter();
    myEE.on('foo', () => {});
    myEE.on('bar', () => {});

    const sym = Symbol('symbol');
    myEE.on(sym, () => {});

    console.log(myEE.eventNames());
    // Prints: [ 'foo', 'bar', Symbol(symbol) ] +
    + +

    Returns (string | symbol)[]

    v6.0.0

    +
  • getId

    +

    Returns the poker table's id.

    +

    Returns string

    The poker table's id.

    +
    const rank = card.getRank();
    console.log(rank); // "A" +
    + +
  • Validates if a specified index is within the valid bounds of the Casino’s room list.

    +

    N/A

    +

    N/A

    +

    Prevents out-of-bounds errors by confirming that an index is within the acceptable range for the Casino’s +room list, ensuring that subsequent calls to access rooms by index have a valid target.

    +

    N/A

    +
      +
    • index: A zero-based integer specifying the position of a room within the Casino's managed room list.
    • +
    +
      +
    • The index must be a non-negative integer within the bounds of the __rooms array.
    • +
    +
      +
    • Returns true if the index is within bounds.
    • +
    • Throws an Error if the index is out of bounds.
    • +
    +

    Call this method before performing operations involving indexed access to rooms, ensuring the index +falls within valid boundaries.

    +

    Parameters

    • index: number

      The zero-based index to validate within the room list.

      +

    Returns boolean

      +
    • Returns true if the index is within bounds.
    • +
    +
      +
    • Throws an error with a descriptive message if the index is out of bounds.
    • +
    +
    const casino = new Casino();
    try {
    casino.isValidIndex(2); // Returns true if index 2 exists in the list of rooms
    } catch (error) {
    console.error(error.message); // Logs error if index 2 is invalid
    } +
    + +
  • Returns the number of listeners listening for the event named eventName. +If listener is provided, it will return how many times the listener is found +in the list of the listeners of the event.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event being listened for

      +
    • Optionallistener: Function

      The event handler function

      +

    Returns number

    v3.2.0

    +
  • Returns a copy of the array of listeners for the event named eventName.

    +
    server.on('connection', (stream) => {
    console.log('someone connected!');
    });
    console.log(util.inspect(server.listeners('connection')));
    // Prints: [ [Function] ] +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

    Returns Function[]

    v0.1.26

    +
  • Alias for emitter.removeListener().

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v10.0.0

    +
  • Adds the listener function to the end of the listeners array for the event +named eventName. No checks are made to see if the listener has already +been added. Multiple calls passing the same combination of eventName and +listener will result in the listener being added, and called, multiple times.

    +
    server.on('connection', (stream) => {
    console.log('someone connected!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    By default, event listeners are invoked in the order they are added. The emitter.prependListener() method can be used as an alternative to add the +event listener to the beginning of the listeners array.

    +
    import { EventEmitter } from 'node:events';
    const myEE = new EventEmitter();
    myEE.on('foo', () => console.log('a'));
    myEE.prependListener('foo', () => console.log('b'));
    myEE.emit('foo');
    // Prints:
    // b
    // a +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.101

    +
  • Adds a one-time listener function for the event named eventName. The +next time eventName is triggered, this listener is removed and then invoked.

    +
    server.once('connection', (stream) => {
    console.log('Ah, we have our first user!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    By default, event listeners are invoked in the order they are added. The emitter.prependOnceListener() method can be used as an alternative to add the +event listener to the beginning of the listeners array.

    +
    import { EventEmitter } from 'node:events';
    const myEE = new EventEmitter();
    myEE.once('foo', () => console.log('a'));
    myEE.prependOnceListener('foo', () => console.log('b'));
    myEE.emit('foo');
    // Prints:
    // b
    // a +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.3.0

    +
  • Adds the listener function to the beginning of the listeners array for the +event named eventName. No checks are made to see if the listener has +already been added. Multiple calls passing the same combination of eventName +and listener will result in the listener being added, and called, multiple times.

    +
    server.prependListener('connection', (stream) => {
    console.log('someone connected!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v6.0.0

    +
  • Adds a one-timelistener function for the event named eventName to the beginning of the listeners array. The next time eventName is triggered, this +listener is removed, and then invoked.

    +
    server.prependOnceListener('connection', (stream) => {
    console.log('Ah, we have our first user!');
    }); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

      The name of the event.

      +
    • listener: ((...args: any[]) => void)

      The callback function

      +
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v6.0.0

    +
  • Returns a copy of the array of listeners for the event named eventName, +including any wrappers (such as those created by .once()).

    +
    import { EventEmitter } from 'node:events';
    const emitter = new EventEmitter();
    emitter.once('log', () => console.log('log once'));

    // Returns a new Array with a function `onceWrapper` which has a property
    // `listener` which contains the original listener bound above
    const listeners = emitter.rawListeners('log');
    const logFnWrapper = listeners[0];

    // Logs "log once" to the console and does not unbind the `once` event
    logFnWrapper.listener();

    // Logs "log once" to the console and removes the listener
    logFnWrapper();

    emitter.on('log', () => console.log('log persistently'));
    // Will return a new Array with a single function bound by `.on()` above
    const newListeners = emitter.rawListeners('log');

    // Logs "log persistently" twice
    newListeners[0]();
    emitter.emit('log'); +
    + +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol

    Returns Function[]

    v9.4.0

    +
  • Removes all listeners, or those of the specified eventName.

    +

    It is bad practice to remove listeners added elsewhere in the code, +particularly when the EventEmitter instance was created by some other +component or module (e.g. sockets or file streams).

    +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Parameters

    • OptionaleventName: string | symbol

    Returns this

    v0.1.26

    +
  • Removes the specified listener from the listener array for the event named eventName.

    +
    const callback = (stream) => {
    console.log('someone connected!');
    };
    server.on('connection', callback);
    // ...
    server.removeListener('connection', callback); +
    + +

    removeListener() will remove, at most, one instance of a listener from the +listener array. If any single listener has been added multiple times to the +listener array for the specified eventName, then removeListener() must be +called multiple times to remove each instance.

    +

    Once an event is emitted, all listeners attached to it at the +time of emitting are called in order. This implies that any removeListener() or removeAllListeners() calls after emitting and before the last listener finishes execution +will not remove them fromemit() in progress. Subsequent events behave as expected.

    +
    import { EventEmitter } from 'node:events';
    class MyEmitter extends EventEmitter {}
    const myEmitter = new MyEmitter();

    const callbackA = () => {
    console.log('A');
    myEmitter.removeListener('event', callbackB);
    };

    const callbackB = () => {
    console.log('B');
    };

    myEmitter.on('event', callbackA);

    myEmitter.on('event', callbackB);

    // callbackA removes listener callbackB but it will still be called.
    // Internal listener array at time of emit [callbackA, callbackB]
    myEmitter.emit('event');
    // Prints:
    // A
    // B

    // callbackB is now removed.
    // Internal listener array [callbackA]
    myEmitter.emit('event');
    // Prints:
    // A +
    + +

    Because listeners are managed using an internal array, calling this will +change the position indices of any listener registered after the listener +being removed. This will not impact the order in which listeners are called, +but it means that any copies of the listener array as returned by +the emitter.listeners() method will need to be recreated.

    +

    When a single function has been added as a handler multiple times for a single +event (as in the example below), removeListener() will remove the most +recently added instance. In the example the once('ping') listener is removed:

    +
    import { EventEmitter } from 'node:events';
    const ee = new EventEmitter();

    function pong() {
    console.log('pong');
    }

    ee.on('ping', pong);
    ee.once('ping', pong);
    ee.removeListener('ping', pong);

    ee.emit('ping');
    ee.emit('ping'); +
    + +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Type Parameters

    • K

    Parameters

    • eventName: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns this

    v0.1.26

    +
  • Retrieves the total number of PokerRoom instances currently managed by the Casino.

    +

    N/A

    +

    N/A

    +

    This method provides insight into the number of poker rooms that the Casino manages, supporting +validation for index-bound operations or general information on Casino state.

    +

    N/A

    +

    N/A

    +

    N/A

    +
      +
    • Returns the total count of rooms managed by the Casino.
    • +
    +

    Use this method to retrieve the total count of active poker rooms, which is helpful when iterating over +rooms or confirming index-bound conditions.

    +

    Returns number

      +
    • The current count of rooms in the Casino.
    • +
    +
    const casino = new Casino();
    const count = casino.roomCount();
    console.log(count); // Logs the total number of managed rooms, e.g., 5 +
    + +
  • By default EventEmitters will print a warning if more than 10 listeners are +added for a particular event. This is a useful default that helps finding +memory leaks. The emitter.setMaxListeners() method allows the limit to be +modified for this specific EventEmitter instance. The value can be set to Infinity (or 0) to indicate an unlimited number of listeners.

    +

    Returns a reference to the EventEmitter, so that calls can be chained.

    +

    Parameters

    • n: number

    Returns this

    v0.3.5

    +
  • Sets the name of the PokerRoom, allowing the name to be updated or customized.

    +

    N/A - This method is part of the PokerRoomInterface and does not implement any external methods.

    +

    N/A - This method does not override any superclass or parent methods.

    +

    The setName method is used to assign a specific name to a PokerRoom, which helps distinguish it within the system. +This is essential for systems where rooms need to be identifiable and manageable through a unique name.

    +

    N/A - No events are emitted by this method.

    +
      +
    • name: A string representing the new name for the room. It must be a valid, non-empty string to ensure +the room has a clear, identifiable label.
    • +
    +
      +
    • The name parameter should be a non-empty string to provide meaningful identification.
    • +
    • Passing an empty or invalid value could result in future misidentification of rooms if validation is implemented.
    • +
    +
      +
    • Returns the name that was set for the PokerRoom.
    • +
    +

    Use this method to set or update the name of a room in a system where unique or identifiable room names +are necessary for reference.

    +

    Parameters

    • name: string

      The new name for the PokerRoom.

      +

    Returns string

      +
    • Returns the name of the room that was set.
    • +
    +
    const pokerRoom = new PokerRoom({ name: "Room1", tableSize: 6 });
    pokerRoom.setName("HighRollers"); // Sets the name of the room to "HighRollers"
    console.log(pokerRoom.getName()); // Logs "HighRollers" +
    + +
diff --git a/docs/site/modules.html b/docs/site/modules.html index 44990b3..42357dd 100644 --- a/docs/site/modules.html +++ b/docs/site/modules.html @@ -1,10 +1,39 @@ -pokerjs

pokerjs

Index

Modules

index +casinojs
+models/logger +models/pokerGame +models/pokerPhase +models/pokerPlayer +models/pokerRoom +models/pokerSeat +models/pokerTable +utils +utils/generateUniqueId +utils/logger +
diff --git a/docs/site/modules/enums.html b/docs/site/modules/enums.html new file mode 100644 index 0000000..1ac5fb1 --- /dev/null +++ b/docs/site/modules/enums.html @@ -0,0 +1,19 @@ +enums | casinojs

Module enums

// Import all enums from the centralized module
import { CasinoEventName, CasinoEventNamesEnum, PokerPhaseName, PokerPhaseNamesEnum, Rank, RanksEnum, Suit, SuitsEnum } from './enums'; +
+ +

References

Re-exports CasinoEvents
Renames and re-exports enums/events/casino
Renames and re-exports enums/events
Re-exports LogLevel
Renames and re-exports enums/logLevel
Re-exports PokerPhaseName
Renames and re-exports enums/pokerPhaseNames
Re-exports PokerSeatEvents
Renames and re-exports enums/events/pokerSeat
Re-exports Rank
Renames and re-exports enums/rank
Re-exports Source
Renames and re-exports enums/source
Re-exports Suit
Renames and re-exports enums/suit
diff --git a/docs/site/modules/enums_PokerPhaseNames.html b/docs/site/modules/enums_PokerPhaseNames.html new file mode 100644 index 0000000..6d1f75b --- /dev/null +++ b/docs/site/modules/enums_PokerPhaseNames.html @@ -0,0 +1,2 @@ +enums/pokerPhaseNames | casinojs

Module enums/pokerPhaseNames

Index

Enumerations

diff --git a/docs/site/modules/enums_events.html b/docs/site/modules/enums_events.html new file mode 100644 index 0000000..38c5121 --- /dev/null +++ b/docs/site/modules/enums_events.html @@ -0,0 +1,8 @@ +enums/events | casinojs

Module enums/events

// Import all enums from the centralized module
import { CasinoEvents, CasinoEventsEnumModule } from './enums'; +
+ +

References

Re-exports CasinoEvents
Renames and re-exports enums/events/casino
Re-exports PokerSeatEvents
Renames and re-exports enums/events/pokerSeat
diff --git a/docs/site/modules/enums_events_casino.html b/docs/site/modules/enums_events_casino.html new file mode 100644 index 0000000..0e61dd9 --- /dev/null +++ b/docs/site/modules/enums_events_casino.html @@ -0,0 +1,2 @@ +enums/events/casino | casinojs

Module enums/events/casino

Index

Enumerations

diff --git a/docs/site/modules/enums_events_pokerSeat.html b/docs/site/modules/enums_events_pokerSeat.html new file mode 100644 index 0000000..8f03277 --- /dev/null +++ b/docs/site/modules/enums_events_pokerSeat.html @@ -0,0 +1,2 @@ +enums/events/pokerSeat | casinojs

Module enums/events/pokerSeat

Index

Enumerations

diff --git a/docs/site/modules/enums_logLevel.html b/docs/site/modules/enums_logLevel.html new file mode 100644 index 0000000..42a54c3 --- /dev/null +++ b/docs/site/modules/enums_logLevel.html @@ -0,0 +1,2 @@ +enums/logLevel | casinojs

Module enums/logLevel

Index

Enumerations

diff --git a/docs/site/modules/enums_rank.html b/docs/site/modules/enums_rank.html new file mode 100644 index 0000000..883032e --- /dev/null +++ b/docs/site/modules/enums_rank.html @@ -0,0 +1,2 @@ +enums/rank | casinojs

Module enums/rank

Index

Enumerations

diff --git a/docs/site/modules/enums_source.html b/docs/site/modules/enums_source.html new file mode 100644 index 0000000..3f7a09f --- /dev/null +++ b/docs/site/modules/enums_source.html @@ -0,0 +1,2 @@ +enums/source | casinojs

Module enums/source

Index

Enumerations

diff --git a/docs/site/modules/enums_suit.html b/docs/site/modules/enums_suit.html new file mode 100644 index 0000000..b1aaa49 --- /dev/null +++ b/docs/site/modules/enums_suit.html @@ -0,0 +1,2 @@ +enums/suit | casinojs

Module enums/suit

Index

Enumerations

diff --git a/docs/site/modules/index.html b/docs/site/modules/index.html index 1f2d2e3..34b3998 100644 --- a/docs/site/modules/index.html +++ b/docs/site/modules/index.html @@ -1,7 +1,80 @@ -index | pokerjs

Module index

References

Card +index | casinojs

Module index

// Importing from the centralized library module
import { CardInterface, Card, Deck, Rank, Suit } from 'pokerjs';

const deck = new Deck();
deck.shuffle();
const card = deck.draw();
console.log(card?.toString()); +
+ +

References

Re-exports Card
Re-exports Deck
Re-exports ICard
Re-exports IDeck
Re-exports Rank
Re-exports Suit
+SuitsEnumModule +Utils +

References

Re-exports BaseEventEmitter
Re-exports BaseEventEmitterInterface
Re-exports BaseEventInterface
Renames and re-exports interfaces/baseEvent
Renames and re-exports interfaces/_base
Renames and re-exports models/_base
Re-exports Card
Re-exports CardConfig
Re-exports CardInterface
Renames and re-exports interfaces/card
Renames and re-exports models/card
Re-exports Casino
Re-exports CasinoEvents
Renames and re-exports enums/events/casino
Re-exports CasinoInterface
Renames and re-exports interfaces/casino
Renames and re-exports models/casino
Re-exports Deck
Re-exports DeckInterface

+

WRAPPER METHODS (UTILITY & CONVENIENCE)

+
+
Renames and re-exports interfaces/deck
Renames and re-exports models/deck
Renames and re-exports enums
Renames and re-exports enums/events
Re-exports generateUniqueId
Renames and re-exports interfaces
Re-exports logger
Re-exports Logger
Re-exports LoggerConfig
Re-exports LoggerInterface
Renames and re-exports interfaces/logger
Renames and re-exports models/logger
Re-exports LogLevel
Renames and re-exports enums/logLevel
Renames and re-exports models
Re-exports PokerGame
Re-exports PokerGameConfig
Re-exports PokerGameInterface
Renames and re-exports interfaces/pokerGame
Renames and re-exports models/pokerGame
Re-exports PokerPhaseConfig
Re-exports PokerPhaseInterface
Renames and re-exports interfaces/pokerPhase
Re-exports PokerPhaseName
Renames and re-exports enums/pokerPhaseNames
Re-exports PokerPlayer
Re-exports PokerPlayerConfig
Re-exports PokerPlayerInterface
Renames and re-exports interfaces/pokerPlayer
Renames and re-exports models/pokerPlayer
Re-exports PokerRoom
Re-exports PokerRoomConfig
Re-exports PokerRoomInterface
Renames and re-exports interfaces/pokerRoom
Renames and re-exports models/pokerRoom
Re-exports PokerSeat
Re-exports PokerSeatConfig
Re-exports PokerSeatEvents
Renames and re-exports enums/events/pokerSeat
Re-exports PokerSeatInterface
Renames and re-exports interfaces/pokerSeat
Renames and re-exports models/pokerSeat
Re-exports PokerTable
Re-exports PokerTableConfig
Re-exports PokerTableInterface
Renames and re-exports interfaces/pokerTable
Renames and re-exports models/pokerTable
Re-exports Rank
Renames and re-exports enums/rank
Re-exports Source
Renames and re-exports enums/source
Re-exports Suit
Renames and re-exports enums/suit
Renames and re-exports utils
diff --git a/docs/site/modules/interfaces.html b/docs/site/modules/interfaces.html index 570f6e9..26f8ff9 100644 --- a/docs/site/modules/interfaces.html +++ b/docs/site/modules/interfaces.html @@ -1,5 +1,39 @@ -interfaces | pokerjs

Module interfaces

References

References

Re-exports ICard
Re-exports IDeck
Re-exports Rank
Re-exports Suit
+interfaces | casinojs

Module interfaces

// Import all interfaces and types from the centralized module
import { CardInterface, DeckInterface } from './interfaces'; +
+ +

References

Re-exports BaseEventEmitterInterface
Re-exports BaseEventInterface
Renames and re-exports interfaces/baseEvent
Renames and re-exports interfaces/_base
Re-exports CardConfig
Re-exports CardInterface
Renames and re-exports interfaces/card
Re-exports CasinoInterface
Renames and re-exports interfaces/casino
Re-exports DeckInterface

+

WRAPPER METHODS (UTILITY & CONVENIENCE)

+
+
Renames and re-exports interfaces/deck
Re-exports LoggerConfig
Re-exports LoggerInterface
Renames and re-exports interfaces/logger
Re-exports PokerGameConfig
Re-exports PokerGameInterface
Renames and re-exports interfaces/pokerGame
Re-exports PokerPhaseConfig
Re-exports PokerPhaseInterface
Renames and re-exports interfaces/pokerPhase
Re-exports PokerPlayerConfig
Re-exports PokerPlayerInterface
Renames and re-exports interfaces/pokerPlayer
Re-exports PokerRoomConfig
Re-exports PokerRoomInterface
Renames and re-exports interfaces/pokerRoom
Re-exports PokerSeatConfig
Re-exports PokerSeatInterface
Renames and re-exports interfaces/pokerSeat
Re-exports PokerTableConfig
Re-exports PokerTableInterface
Renames and re-exports interfaces/pokerTable
diff --git a/docs/site/modules/interfaces__base.html b/docs/site/modules/interfaces__base.html new file mode 100644 index 0000000..2c92cfd --- /dev/null +++ b/docs/site/modules/interfaces__base.html @@ -0,0 +1,2 @@ +interfaces/_base | casinojs
diff --git a/docs/site/modules/interfaces_baseEvent.html b/docs/site/modules/interfaces_baseEvent.html new file mode 100644 index 0000000..667dff6 --- /dev/null +++ b/docs/site/modules/interfaces_baseEvent.html @@ -0,0 +1,2 @@ +interfaces/baseEvent | casinojs

Module interfaces/baseEvent

Index

Interfaces

diff --git a/docs/site/modules/interfaces_card.html b/docs/site/modules/interfaces_card.html index 101153f..7cbe96f 100644 --- a/docs/site/modules/interfaces_card.html +++ b/docs/site/modules/interfaces_card.html @@ -1,2 +1,3 @@ -interfaces/card | pokerjs

Module interfaces/card

Index

Interfaces

+interfaces/card | casinojs

Module interfaces/card

Index

Interfaces

diff --git a/docs/site/modules/interfaces_casino.html b/docs/site/modules/interfaces_casino.html new file mode 100644 index 0000000..bb4a94c --- /dev/null +++ b/docs/site/modules/interfaces_casino.html @@ -0,0 +1,2 @@ +interfaces/casino | casinojs

Module interfaces/casino

Index

Interfaces

diff --git a/docs/site/modules/interfaces_deck.html b/docs/site/modules/interfaces_deck.html index 678d571..032196d 100644 --- a/docs/site/modules/interfaces_deck.html +++ b/docs/site/modules/interfaces_deck.html @@ -1,2 +1,2 @@ -interfaces/deck | pokerjs

Module interfaces/deck

Index

Interfaces

+interfaces/deck | casinojs

Module interfaces/deck

Index

Interfaces

diff --git a/docs/site/modules/interfaces_logger.html b/docs/site/modules/interfaces_logger.html new file mode 100644 index 0000000..7c229a0 --- /dev/null +++ b/docs/site/modules/interfaces_logger.html @@ -0,0 +1,3 @@ +interfaces/logger | casinojs
diff --git a/docs/site/modules/interfaces_pokerGame.html b/docs/site/modules/interfaces_pokerGame.html new file mode 100644 index 0000000..d437224 --- /dev/null +++ b/docs/site/modules/interfaces_pokerGame.html @@ -0,0 +1,3 @@ +interfaces/pokerGame | casinojs
diff --git a/docs/site/modules/interfaces_pokerPhase.html b/docs/site/modules/interfaces_pokerPhase.html new file mode 100644 index 0000000..67a2268 --- /dev/null +++ b/docs/site/modules/interfaces_pokerPhase.html @@ -0,0 +1,3 @@ +interfaces/pokerPhase | casinojs
diff --git a/docs/site/modules/interfaces_pokerPlayer.html b/docs/site/modules/interfaces_pokerPlayer.html new file mode 100644 index 0000000..4b50269 --- /dev/null +++ b/docs/site/modules/interfaces_pokerPlayer.html @@ -0,0 +1,3 @@ +interfaces/pokerPlayer | casinojs
diff --git a/docs/site/modules/interfaces_pokerRoom.html b/docs/site/modules/interfaces_pokerRoom.html new file mode 100644 index 0000000..57c9649 --- /dev/null +++ b/docs/site/modules/interfaces_pokerRoom.html @@ -0,0 +1,3 @@ +interfaces/pokerRoom | casinojs
diff --git a/docs/site/modules/interfaces_pokerSeat.html b/docs/site/modules/interfaces_pokerSeat.html new file mode 100644 index 0000000..9a24f7b --- /dev/null +++ b/docs/site/modules/interfaces_pokerSeat.html @@ -0,0 +1,3 @@ +interfaces/pokerSeat | casinojs
diff --git a/docs/site/modules/interfaces_pokerTable.html b/docs/site/modules/interfaces_pokerTable.html new file mode 100644 index 0000000..b08df19 --- /dev/null +++ b/docs/site/modules/interfaces_pokerTable.html @@ -0,0 +1,3 @@ +interfaces/pokerTable | casinojs
diff --git a/docs/site/modules/models.html b/docs/site/modules/models.html index 016d4e4..10082bf 100644 --- a/docs/site/modules/models.html +++ b/docs/site/modules/models.html @@ -1,3 +1,24 @@ -models | pokerjs

Module models

References

Card +models | casinojs

Module models

// Import models from the centralized module
import { Card, Deck } from './models'; +
+ +

References

Re-exports Card
Re-exports Deck
+DeckModel +Logger +LoggerModel +PokerGame +PokerGameModel +PokerPlayer +PokerPlayerModel +PokerRoom +PokerRoomModel +PokerSeat +PokerSeatModel +PokerTable +PokerTableModel +

References

Re-exports BaseEventEmitter
Renames and re-exports models/_base
Re-exports Card
Renames and re-exports models/card
Re-exports Casino
Renames and re-exports models/casino
Re-exports Deck
Renames and re-exports models/deck
Re-exports Logger
Renames and re-exports models/logger
Re-exports PokerGame
Renames and re-exports models/pokerGame
Re-exports PokerPlayer
Renames and re-exports models/pokerPlayer
Re-exports PokerRoom
Renames and re-exports models/pokerRoom
Re-exports PokerSeat
Renames and re-exports models/pokerSeat
Re-exports PokerTable
Renames and re-exports models/pokerTable
diff --git a/docs/site/modules/models__base.html b/docs/site/modules/models__base.html new file mode 100644 index 0000000..70c9ccb --- /dev/null +++ b/docs/site/modules/models__base.html @@ -0,0 +1,2 @@ +models/_base | casinojs

Module models/_base

Index

Classes

diff --git a/docs/site/modules/models_card.html b/docs/site/modules/models_card.html index f95d79d..9897933 100644 --- a/docs/site/modules/models_card.html +++ b/docs/site/modules/models_card.html @@ -1,2 +1,2 @@ -models/card | pokerjs

Module models/card

Index

Classes

+models/card | casinojs

Module models/card

Index

Classes

diff --git a/docs/site/modules/interfaces_rank.html b/docs/site/modules/models_casino.html similarity index 69% rename from docs/site/modules/interfaces_rank.html rename to docs/site/modules/models_casino.html index 41c293f..d0bdd85 100644 --- a/docs/site/modules/interfaces_rank.html +++ b/docs/site/modules/models_casino.html @@ -1,2 +1,2 @@ -interfaces/rank | pokerjs

Module interfaces/rank

Index

Enumerations

+models/casino | casinojs

Module models/casino

Index

Classes

diff --git a/docs/site/modules/models_deck.html b/docs/site/modules/models_deck.html index 9f2d301..6b3f958 100644 --- a/docs/site/modules/models_deck.html +++ b/docs/site/modules/models_deck.html @@ -1,2 +1,2 @@ -models/deck | pokerjs

Module models/deck

Index

Classes

+models/deck | casinojs

Module models/deck

Index

Classes

diff --git a/docs/site/modules/interfaces_suit.html b/docs/site/modules/models_logger.html similarity index 69% rename from docs/site/modules/interfaces_suit.html rename to docs/site/modules/models_logger.html index 0b3b67c..1adf567 100644 --- a/docs/site/modules/interfaces_suit.html +++ b/docs/site/modules/models_logger.html @@ -1,2 +1,2 @@ -interfaces/suit | pokerjs

Module interfaces/suit

Index

Enumerations

+models/logger | casinojs

Module models/logger

Index

Classes

diff --git a/docs/site/modules/models_pokerGame.html b/docs/site/modules/models_pokerGame.html new file mode 100644 index 0000000..11b0cd9 --- /dev/null +++ b/docs/site/modules/models_pokerGame.html @@ -0,0 +1,2 @@ +models/pokerGame | casinojs

Module models/pokerGame

Index

Classes

diff --git a/docs/site/modules/models_pokerPhase.html b/docs/site/modules/models_pokerPhase.html new file mode 100644 index 0000000..711a163 --- /dev/null +++ b/docs/site/modules/models_pokerPhase.html @@ -0,0 +1,2 @@ +models/pokerPhase | casinojs

Module models/pokerPhase

Index

Classes

diff --git a/docs/site/modules/models_pokerPlayer.html b/docs/site/modules/models_pokerPlayer.html new file mode 100644 index 0000000..ef62dc8 --- /dev/null +++ b/docs/site/modules/models_pokerPlayer.html @@ -0,0 +1,2 @@ +models/pokerPlayer | casinojs

Module models/pokerPlayer

Index

Classes

diff --git a/docs/site/modules/models_pokerRoom.html b/docs/site/modules/models_pokerRoom.html new file mode 100644 index 0000000..ddeb56e --- /dev/null +++ b/docs/site/modules/models_pokerRoom.html @@ -0,0 +1,2 @@ +models/pokerRoom | casinojs

Module models/pokerRoom

Index

Classes

diff --git a/docs/site/modules/models_pokerSeat.html b/docs/site/modules/models_pokerSeat.html new file mode 100644 index 0000000..74f94f8 --- /dev/null +++ b/docs/site/modules/models_pokerSeat.html @@ -0,0 +1,2 @@ +models/pokerSeat | casinojs

Module models/pokerSeat

Index

Classes

diff --git a/docs/site/modules/models_pokerTable.html b/docs/site/modules/models_pokerTable.html new file mode 100644 index 0000000..11c49f4 --- /dev/null +++ b/docs/site/modules/models_pokerTable.html @@ -0,0 +1,2 @@ +models/pokerTable | casinojs

Module models/pokerTable

Index

Classes

diff --git a/docs/site/modules/utils.html b/docs/site/modules/utils.html new file mode 100644 index 0000000..c58bdd1 --- /dev/null +++ b/docs/site/modules/utils.html @@ -0,0 +1,6 @@ +utils | casinojs

Module utils

// Import models from the centralized module
import { Card, Deck } from './models'; +
+ +

References

Re-exports generateUniqueId
Re-exports logger
diff --git a/docs/site/modules/utils_generateUniqueId.html b/docs/site/modules/utils_generateUniqueId.html new file mode 100644 index 0000000..5192e17 --- /dev/null +++ b/docs/site/modules/utils_generateUniqueId.html @@ -0,0 +1,2 @@ +utils/generateUniqueId | casinojs

Module utils/generateUniqueId

Index

Functions

diff --git a/docs/site/modules/utils_logger.html b/docs/site/modules/utils_logger.html new file mode 100644 index 0000000..8ad1aa7 --- /dev/null +++ b/docs/site/modules/utils_logger.html @@ -0,0 +1,2 @@ +utils/logger | casinojs

Module utils/logger

Index

Variables

diff --git a/docs/site/variables/utils_logger.logger.html b/docs/site/variables/utils_logger.logger.html new file mode 100644 index 0000000..7b7953d --- /dev/null +++ b/docs/site/variables/utils_logger.logger.html @@ -0,0 +1,10 @@ +logger | casinojs

Variable loggerConst

logger: Logger = ...

logger

+

A singleton instance of the Logger class. This instance is initialized once with the configuration provided by the config +constant. The instance provides centralized logging across the application.

+

The logger singleton offers consistent access to logging functionality, ensuring that all logs follow the specified +configuration settings, such as the directory for log files and whether to enable console logging.

+

Import the logger singleton directly wherever logging is required in the application.

+
import { logger } from "./path/to/utils/logger";

logger.log(LogLevel.INFO, "Application started"); +
+ +
diff --git a/jest.config.js b/jest.config.js new file mode 100644 index 0000000..1be2472 --- /dev/null +++ b/jest.config.js @@ -0,0 +1,12 @@ +//@collapse + +/** @type {import('ts-jest').JestConfigWithTsJest} **/ +export default { + preset: "ts-jest", + testEnvironment: "node", + moduleFileExtensions: ["ts", "js"], + testMatch: ["**/tests/**/*.test.ts"], + transform: { + "^.+\\.ts$": "ts-jest", + }, +}; diff --git a/package-lock.json b/package-lock.json index e5ae261..afb2efc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,326 +1,3503 @@ { - "name": "pokerjs", + "name": "casinojs", "version": "0.1.0-alpha", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "pokerjs", + "name": "casinojs", "version": "0.1.0-alpha", "license": "SEE LICENSE IN LICENSE", "devDependencies": { "@types/events": "^3.0.3", + "@types/jest": "^29.5.14", "@types/node": "^22.7.6", + "jest": "^29.7.0", + "ts-jest": "^29.2.5", + "ts-node": "^10.9.2", "typedoc": "^0.26.10", "typescript": "^5.6.3" } }, - "node_modules/@shikijs/core": { - "version": "1.22.0", - "resolved": "https://registry.npmjs.org/@shikijs/core/-/core-1.22.0.tgz", - "integrity": "sha512-S8sMe4q71TJAW+qG93s5VaiihujRK6rqDFqBnxqvga/3LvqHEnxqBIOPkt//IdXVtHkQWKu4nOQNk0uBGicU7Q==", + "node_modules/@ampproject/remapping": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.3.0.tgz", + "integrity": "sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==", "dev": true, - "license": "MIT", + "license": "Apache-2.0", "dependencies": { - "@shikijs/engine-javascript": "1.22.0", - "@shikijs/engine-oniguruma": "1.22.0", - "@shikijs/types": "1.22.0", - "@shikijs/vscode-textmate": "^9.3.0", - "@types/hast": "^3.0.4", - "hast-util-to-html": "^9.0.3" + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.24" + }, + "engines": { + "node": ">=6.0.0" } }, - "node_modules/@shikijs/engine-javascript": { - "version": "1.22.0", - "resolved": "https://registry.npmjs.org/@shikijs/engine-javascript/-/engine-javascript-1.22.0.tgz", - "integrity": "sha512-AeEtF4Gcck2dwBqCFUKYfsCq0s+eEbCEbkUuFou53NZ0sTGnJnJ/05KHQFZxpii5HMXbocV9URYVowOP2wH5kw==", + "node_modules/@ampproject/remapping/node_modules/@jridgewell/trace-mapping": { + "version": "0.3.25", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz", + "integrity": "sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==", "dev": true, "license": "MIT", "dependencies": { - "@shikijs/types": "1.22.0", - "@shikijs/vscode-textmate": "^9.3.0", - "oniguruma-to-js": "0.4.3" + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" } }, - "node_modules/@shikijs/engine-oniguruma": { - "version": "1.22.0", - "resolved": "https://registry.npmjs.org/@shikijs/engine-oniguruma/-/engine-oniguruma-1.22.0.tgz", - "integrity": "sha512-5iBVjhu/DYs1HB0BKsRRFipRrD7rqjxlWTj4F2Pf+nQSPqc3kcyqFFeZXnBMzDf0HdqaFVvhDRAGiYNvyLP+Mw==", + "node_modules/@babel/code-frame": { + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.25.9.tgz", + "integrity": "sha512-z88xeGxnzehn2sqZ8UdGQEvYErF1odv2CftxInpSYJt6uHuPe9YjahKZITGs3l5LeI9d2ROG+obuDAoSlqbNfQ==", "dev": true, "license": "MIT", "dependencies": { - "@shikijs/types": "1.22.0", - "@shikijs/vscode-textmate": "^9.3.0" + "@babel/highlight": "^7.25.9", + "picocolors": "^1.0.0" + }, + "engines": { + "node": ">=6.9.0" } }, - "node_modules/@shikijs/types": { - "version": "1.22.0", - "resolved": "https://registry.npmjs.org/@shikijs/types/-/types-1.22.0.tgz", - "integrity": "sha512-Fw/Nr7FGFhlQqHfxzZY8Cwtwk5E9nKDUgeLjZgt3UuhcM3yJR9xj3ZGNravZZok8XmEZMiYkSMTPlPkULB8nww==", + "node_modules/@babel/compat-data": { + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.25.9.tgz", + "integrity": "sha512-yD+hEuJ/+wAJ4Ox2/rpNv5HIuPG82x3ZlQvYVn8iYCprdxzE7P1udpGF1jyjQVBU4dgznN+k2h103vxZ7NdPyw==", "dev": true, "license": "MIT", - "dependencies": { - "@shikijs/vscode-textmate": "^9.3.0", - "@types/hast": "^3.0.4" + "engines": { + "node": ">=6.9.0" } }, - "node_modules/@shikijs/vscode-textmate": { - "version": "9.3.0", - "resolved": "https://registry.npmjs.org/@shikijs/vscode-textmate/-/vscode-textmate-9.3.0.tgz", - "integrity": "sha512-jn7/7ky30idSkd/O5yDBfAnVt+JJpepofP/POZ1iMOxK59cOfqIgg/Dj0eFsjOTMw+4ycJN0uhZH/Eb0bs/EUA==", - "dev": true, - "license": "MIT" - }, - "node_modules/@types/events": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/@types/events/-/events-3.0.3.tgz", - "integrity": "sha512-trOc4AAUThEz9hapPtSd7wf5tiQKvTtu5b371UxXdTuqzIh0ArcRspRP0i0Viu+LXstIQ1z96t1nsPxT9ol01g==", - "dev": true, - "license": "MIT" - }, - "node_modules/@types/hast": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/@types/hast/-/hast-3.0.4.tgz", - "integrity": "sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ==", + "node_modules/@babel/core": { + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.25.9.tgz", + "integrity": "sha512-WYvQviPw+Qyib0v92AwNIrdLISTp7RfDkM7bPqBvpbnhY4wq8HvHBZREVdYDXk98C8BkOIVnHAY3yvj7AVISxQ==", "dev": true, "license": "MIT", "dependencies": { - "@types/unist": "*" + "@ampproject/remapping": "^2.2.0", + "@babel/code-frame": "^7.25.9", + "@babel/generator": "^7.25.9", + "@babel/helper-compilation-targets": "^7.25.9", + "@babel/helper-module-transforms": "^7.25.9", + "@babel/helpers": "^7.25.9", + "@babel/parser": "^7.25.9", + "@babel/template": "^7.25.9", + "@babel/traverse": "^7.25.9", + "@babel/types": "^7.25.9", + "convert-source-map": "^2.0.0", + "debug": "^4.1.0", + "gensync": "^1.0.0-beta.2", + "json5": "^2.2.3", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/babel" } }, - "node_modules/@types/mdast": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-4.0.4.tgz", - "integrity": "sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA==", + "node_modules/@babel/generator": { + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.25.9.tgz", + "integrity": "sha512-omlUGkr5EaoIJrhLf9CJ0TvjBRpd9+AXRG//0GEQ9THSo8wPiTlbpy1/Ow8ZTrbXpjd9FHXfbFQx32I04ht0FA==", "dev": true, "license": "MIT", "dependencies": { - "@types/unist": "*" + "@babel/types": "^7.25.9", + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.25", + "jsesc": "^3.0.2" + }, + "engines": { + "node": ">=6.9.0" } }, - "node_modules/@types/node": { - "version": "22.7.6", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.7.6.tgz", - "integrity": "sha512-/d7Rnj0/ExXDMcioS78/kf1lMzYk4BZV8MZGTBKzTGZ6/406ukkbYlIsZmMPhcR5KlkunDHQLrtAVmSq7r+mSw==", + "node_modules/@babel/generator/node_modules/@jridgewell/trace-mapping": { + "version": "0.3.25", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz", + "integrity": "sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==", "dev": true, "license": "MIT", "dependencies": { - "undici-types": "~6.19.2" + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" } }, - "node_modules/@types/unist": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz", - "integrity": "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==", + "node_modules/@babel/helper-compilation-targets": { + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.25.9.tgz", + "integrity": "sha512-j9Db8Suy6yV/VHa4qzrj9yZfZxhLWQdVnRlXxmKLYlhWUVB1sB2G5sxuWYXk/whHD9iW76PmNzxZ4UCnTQTVEQ==", "dev": true, - "license": "MIT" + "license": "MIT", + "dependencies": { + "@babel/compat-data": "^7.25.9", + "@babel/helper-validator-option": "^7.25.9", + "browserslist": "^4.24.0", + "lru-cache": "^5.1.1", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + } }, - "node_modules/@ungap/structured-clone": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.2.0.tgz", - "integrity": "sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==", + "node_modules/@babel/helper-module-imports": { + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.25.9.tgz", + "integrity": "sha512-tnUA4RsrmflIM6W6RFTLFSXITtl0wKjgpnLgXyowocVPrbYrLUXSBXDgTs8BlbmIzIdlBySRQjINYs2BAkiLtw==", "dev": true, - "license": "ISC" + "license": "MIT", + "dependencies": { + "@babel/traverse": "^7.25.9", + "@babel/types": "^7.25.9" + }, + "engines": { + "node": ">=6.9.0" + } }, - "node_modules/argparse": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "node_modules/@babel/helper-module-transforms": { + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.25.9.tgz", + "integrity": "sha512-TvLZY/F3+GvdRYFZFyxMvnsKi+4oJdgZzU3BoGN9Uc2d9C6zfNwJcKKhjqLAhK8i46mv93jsO74fDh3ih6rpHA==", "dev": true, - "license": "Python-2.0" + "license": "MIT", + "dependencies": { + "@babel/helper-module-imports": "^7.25.9", + "@babel/helper-simple-access": "^7.25.9", + "@babel/helper-validator-identifier": "^7.25.9", + "@babel/traverse": "^7.25.9" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } }, - "node_modules/balanced-match": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "node_modules/@babel/helper-plugin-utils": { + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.25.9.tgz", + "integrity": "sha512-kSMlyUVdWe25rEsRGviIgOWnoT/nfABVWlqt9N19/dIPWViAOW2s9wznP5tURbs/IDuNk4gPy3YdYRgH3uxhBw==", "dev": true, - "license": "MIT" + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } }, - "node_modules/brace-expansion": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "node_modules/@babel/helper-simple-access": { + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.25.9.tgz", + "integrity": "sha512-c6WHXuiaRsJTyHYLJV75t9IqsmTbItYfdj99PnzYGQZkYKvan5/2jKJ7gu31J3/BJ/A18grImSPModuyG/Eo0Q==", "dev": true, "license": "MIT", "dependencies": { - "balanced-match": "^1.0.0" + "@babel/traverse": "^7.25.9", + "@babel/types": "^7.25.9" + }, + "engines": { + "node": ">=6.9.0" } }, - "node_modules/ccount": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/ccount/-/ccount-2.0.1.tgz", - "integrity": "sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg==", + "node_modules/@babel/helper-string-parser": { + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.25.9.tgz", + "integrity": "sha512-4A/SCr/2KLd5jrtOMFzaKjVtAei3+2r/NChoBNoZ3EyP/+GlhoaEGoWOZUmFmoITP7zOJyHIMm+DYRd8o3PvHA==", "dev": true, "license": "MIT", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" + "engines": { + "node": ">=6.9.0" } }, - "node_modules/character-entities-html4": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/character-entities-html4/-/character-entities-html4-2.1.0.tgz", - "integrity": "sha512-1v7fgQRj6hnSwFpq1Eu0ynr/CDEw0rXo2B61qXrLNdHZmPKgb7fqS1a2JwF0rISo9q77jDI8VMEHoApn8qDoZA==", + "node_modules/@babel/helper-validator-identifier": { + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.25.9.tgz", + "integrity": "sha512-Ed61U6XJc3CVRfkERJWDz4dJwKe7iLmmJsbOGu9wSloNSFttHV0I8g6UAgb7qnK5ly5bGLPd4oXZlxCdANBOWQ==", "dev": true, "license": "MIT", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" + "engines": { + "node": ">=6.9.0" } }, - "node_modules/character-entities-legacy": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/character-entities-legacy/-/character-entities-legacy-3.0.0.tgz", - "integrity": "sha512-RpPp0asT/6ufRm//AJVwpViZbGM/MkjQFxJccQRHmISF/22NBtsHqAWmL+/pmkPWoIUJdWyeVleTl1wydHATVQ==", + "node_modules/@babel/helper-validator-option": { + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.25.9.tgz", + "integrity": "sha512-e/zv1co8pp55dNdEcCynfj9X7nyUKUXoUEwfXqaZt0omVOmDe9oOTdKStH4GmAw6zxMFs50ZayuMfHDKlO7Tfw==", "dev": true, "license": "MIT", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" + "engines": { + "node": ">=6.9.0" } }, - "node_modules/comma-separated-tokens": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/comma-separated-tokens/-/comma-separated-tokens-2.0.3.tgz", - "integrity": "sha512-Fu4hJdvzeylCfQPp9SGWidpzrMs7tTrlu6Vb8XGaRGck8QSNZJJp538Wrb60Lax4fPwR64ViY468OIUTbRlGZg==", + "node_modules/@babel/helpers": { + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.25.9.tgz", + "integrity": "sha512-oKWp3+usOJSzDZOucZUAMayhPz/xVjzymyDzUN8dk0Wd3RWMlGLXi07UCQ/CgQVb8LvXx3XBajJH4XGgkt7H7g==", "dev": true, "license": "MIT", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" + "dependencies": { + "@babel/template": "^7.25.9", + "@babel/types": "^7.25.9" + }, + "engines": { + "node": ">=6.9.0" } }, - "node_modules/dequal": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz", - "integrity": "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==", + "node_modules/@babel/highlight": { + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.25.9.tgz", + "integrity": "sha512-llL88JShoCsth8fF8R4SJnIn+WLvR6ccFxu1H3FlMhDontdcmZWf2HgIZ7AIqV3Xcck1idlohrN4EUBQz6klbw==", "dev": true, "license": "MIT", + "dependencies": { + "@babel/helper-validator-identifier": "^7.25.9", + "chalk": "^2.4.2", + "js-tokens": "^4.0.0", + "picocolors": "^1.0.0" + }, "engines": { - "node": ">=6" + "node": ">=6.9.0" } }, - "node_modules/devlop": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/devlop/-/devlop-1.1.0.tgz", - "integrity": "sha512-RWmIqhcFf1lRYBvNmr7qTNuyCt/7/ns2jbpp1+PalgE/rDQcBT0fioSMUpJ93irlUhC5hrg4cYqe6U+0ImW0rA==", + "node_modules/@babel/highlight/node_modules/ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "dev": true, "license": "MIT", "dependencies": { - "dequal": "^2.0.0" + "color-convert": "^1.9.0" }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" + "engines": { + "node": ">=4" } }, - "node_modules/entities": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", - "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", + "node_modules/@babel/highlight/node_modules/chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", "dev": true, - "license": "BSD-2-Clause", - "engines": { - "node": ">=0.12" + "license": "MIT", + "dependencies": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" }, - "funding": { - "url": "https://github.com/fb55/entities?sponsor=1" + "engines": { + "node": ">=4" } }, - "node_modules/hast-util-to-html": { - "version": "9.0.3", - "resolved": "https://registry.npmjs.org/hast-util-to-html/-/hast-util-to-html-9.0.3.tgz", - "integrity": "sha512-M17uBDzMJ9RPCqLMO92gNNUDuBSq10a25SDBI08iCCxmorf4Yy6sYHK57n9WAbRAAaU+DuR4W6GN9K4DFZesYg==", + "node_modules/@babel/highlight/node_modules/color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", "dev": true, "license": "MIT", "dependencies": { - "@types/hast": "^3.0.0", - "@types/unist": "^3.0.0", - "ccount": "^2.0.0", - "comma-separated-tokens": "^2.0.0", - "hast-util-whitespace": "^3.0.0", - "html-void-elements": "^3.0.0", - "mdast-util-to-hast": "^13.0.0", - "property-information": "^6.0.0", - "space-separated-tokens": "^2.0.0", - "stringify-entities": "^4.0.0", - "zwitch": "^2.0.4" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" + "color-name": "1.1.3" } }, - "node_modules/hast-util-whitespace": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/hast-util-whitespace/-/hast-util-whitespace-3.0.0.tgz", - "integrity": "sha512-88JUN06ipLwsnv+dVn+OIYOvAuvBMy/Qoi6O7mQHxdPXpjy+Cd6xRkWwux7DKO+4sYILtLBRIKgsdpS2gQc7qw==", + "node_modules/@babel/highlight/node_modules/color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@babel/highlight/node_modules/escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", "dev": true, "license": "MIT", - "dependencies": { - "@types/hast": "^3.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" + "engines": { + "node": ">=0.8.0" } }, - "node_modules/html-void-elements": { + "node_modules/@babel/highlight/node_modules/has-flag": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/html-void-elements/-/html-void-elements-3.0.0.tgz", - "integrity": "sha512-bEqo66MRXsUGxWHV5IP0PUiAWwoEjba4VCzg0LjFJBpchPaTfyfCKTG6bc5F8ucKec3q5y6qOdGyYTSBEvhCrg==", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", "dev": true, "license": "MIT", - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" + "engines": { + "node": ">=4" } }, - "node_modules/linkify-it": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-5.0.0.tgz", - "integrity": "sha512-5aHCbzQRADcdP+ATqnDuhhJ/MRIqDkZX5pyjFHRRysS8vZ5AbqGEoFIb6pYHPZ+L/OC2Lc+xT8uHVVR5CAK/wQ==", + "node_modules/@babel/highlight/node_modules/supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", "dev": true, "license": "MIT", "dependencies": { - "uc.micro": "^2.0.0" + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" } }, - "node_modules/lunr": { - "version": "2.3.9", - "resolved": "https://registry.npmjs.org/lunr/-/lunr-2.3.9.tgz", - "integrity": "sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow==", - "dev": true, - "license": "MIT" - }, - "node_modules/markdown-it": { - "version": "14.1.0", - "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-14.1.0.tgz", - "integrity": "sha512-a54IwgWPaeBCAAsv13YgmALOF1elABB08FxO9i+r4VFk5Vl4pKokRPeX8u5TCgSsPi6ec1otfLjdOpVcgbpshg==", + "node_modules/@babel/parser": { + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.25.9.tgz", + "integrity": "sha512-aI3jjAAO1fh7vY/pBGsn1i9LDbRP43+asrRlkPuTXW5yHXtd1NgTEMudbBoDDxrf1daEEfPJqR+JBMakzrR4Dg==", "dev": true, "license": "MIT", "dependencies": { - "argparse": "^2.0.1", - "entities": "^4.4.0", - "linkify-it": "^5.0.0", - "mdurl": "^2.0.0", - "punycode.js": "^2.3.1", - "uc.micro": "^2.1.0" + "@babel/types": "^7.25.9" }, "bin": { - "markdown-it": "bin/markdown-it.mjs" + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" } }, - "node_modules/mdast-util-to-hast": { - "version": "13.2.0", - "resolved": "https://registry.npmjs.org/mdast-util-to-hast/-/mdast-util-to-hast-13.2.0.tgz", - "integrity": "sha512-QGYKEuUsYT9ykKBCMOEDLsU5JRObWQusAolFMeko/tYPufNkRffBAQjIE+99jbA87xv6FgmjLtwjh9wBWajwAA==", + "node_modules/@babel/plugin-syntax-async-generators": { + "version": "7.8.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-async-generators/-/plugin-syntax-async-generators-7.8.4.tgz", + "integrity": "sha512-tycmZxkGfZaxhMRbXlPXuVFpdWlXpir2W4AMhSJgRKzk/eDlIXOhb2LHWoLpDF7TEHylV5zNhykX6KAgHJmTNw==", "dev": true, "license": "MIT", "dependencies": { - "@types/hast": "^3.0.0", - "@types/mdast": "^4.0.0", - "@ungap/structured-clone": "^1.0.0", + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-bigint": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-bigint/-/plugin-syntax-bigint-7.8.3.tgz", + "integrity": "sha512-wnTnFlG+YxQm3vDxpGE57Pj0srRU4sHE/mDkt1qv2YJJSeUAec2ma4WLUnUPeKjyrfntVwe/N6dCXpU+zL3Npg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-class-properties": { + "version": "7.12.13", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-class-properties/-/plugin-syntax-class-properties-7.12.13.tgz", + "integrity": "sha512-fm4idjKla0YahUNgFNLCB0qySdsoPiZP3iQE3rky0mBUtMZ23yDJ9SJdg6dXTSDnulOVqiF3Hgr9nbXvXTQZYA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.12.13" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-class-static-block": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-class-static-block/-/plugin-syntax-class-static-block-7.14.5.tgz", + "integrity": "sha512-b+YyPmr6ldyNnM6sqYeMWE+bgJcJpO6yS4QD7ymxgH34GBPNDM/THBh8iunyvKIZztiwLH4CJZ0RxTk9emgpjw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-import-attributes": { + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-attributes/-/plugin-syntax-import-attributes-7.25.9.tgz", + "integrity": "sha512-u3EN9ub8LyYvgTnrgp8gboElouayiwPdnM7x5tcnW3iSt09/lQYPwMNK40I9IUxo7QOZhAsPHCmmuO7EPdruqg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.25.9" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-import-meta": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-meta/-/plugin-syntax-import-meta-7.10.4.tgz", + "integrity": "sha512-Yqfm+XDx0+Prh3VSeEQCPU81yC+JWZ2pDPFSS4ZdpfZhp4MkFMaDC1UqseovEKwSUpnIL7+vK+Clp7bfh0iD7g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.10.4" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-json-strings": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-json-strings/-/plugin-syntax-json-strings-7.8.3.tgz", + "integrity": "sha512-lY6kdGpWHvjoe2vk4WrAapEuBR69EMxZl+RoGRhrFGNYVK8mOPAW8VfbT/ZgrFbXlDNiiaxQnAtgVCZ6jv30EA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-jsx": { + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.25.9.tgz", + "integrity": "sha512-ld6oezHQMZsZfp6pWtbjaNDF2tiiCYYDqQszHt5VV437lewP9aSi2Of99CK0D0XB21k7FLgnLcmQKyKzynfeAA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.25.9" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-logical-assignment-operators": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-logical-assignment-operators/-/plugin-syntax-logical-assignment-operators-7.10.4.tgz", + "integrity": "sha512-d8waShlpFDinQ5MtvGU9xDAOzKH47+FFoney2baFIoMr952hKOLp1HR7VszoZvOsV/4+RRszNY7D17ba0te0ig==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.10.4" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-nullish-coalescing-operator": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-nullish-coalescing-operator/-/plugin-syntax-nullish-coalescing-operator-7.8.3.tgz", + "integrity": "sha512-aSff4zPII1u2QD7y+F8oDsz19ew4IGEJg9SVW+bqwpwtfFleiQDMdzA/R+UlWDzfnHFCxxleFT0PMIrR36XLNQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-numeric-separator": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-numeric-separator/-/plugin-syntax-numeric-separator-7.10.4.tgz", + "integrity": "sha512-9H6YdfkcK/uOnY/K7/aA2xpzaAgkQn37yzWUMRK7OaPOqOpGS1+n0H5hxT9AUw9EsSjPW8SVyMJwYRtWs3X3ug==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.10.4" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-object-rest-spread": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-object-rest-spread/-/plugin-syntax-object-rest-spread-7.8.3.tgz", + "integrity": "sha512-XoqMijGZb9y3y2XskN+P1wUGiVwWZ5JmoDRwx5+3GmEplNyVM2s2Dg8ILFQm8rWM48orGy5YpI5Bl8U1y7ydlA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-optional-catch-binding": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-catch-binding/-/plugin-syntax-optional-catch-binding-7.8.3.tgz", + "integrity": "sha512-6VPD0Pc1lpTqw0aKoeRTMiB+kWhAoT24PA+ksWSBrFtl5SIRVpZlwN3NNPQjehA2E/91FV3RjLWoVTglWcSV3Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-optional-chaining": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-chaining/-/plugin-syntax-optional-chaining-7.8.3.tgz", + "integrity": "sha512-KoK9ErH1MBlCPxV0VANkXW2/dw4vlbGDrFgz8bmUsBGYkFRcbRwMh6cIJubdPrkxRwuGdtCk0v/wPTKbQgBjkg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-private-property-in-object": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-private-property-in-object/-/plugin-syntax-private-property-in-object-7.14.5.tgz", + "integrity": "sha512-0wVnp9dxJ72ZUJDV27ZfbSj6iHLoytYZmh3rFcxNnvsJF3ktkzLDZPy/mA17HGsaQT3/DQsWYX1f1QGWkCoVUg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-top-level-await": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-top-level-await/-/plugin-syntax-top-level-await-7.14.5.tgz", + "integrity": "sha512-hx++upLv5U1rgYfwe1xBQUhRmU41NEvpUvrp8jkrSCdvGSnM5/qdRMtylJ6PG5OFkBaHkbTAKTnd3/YyESRHFw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-typescript": { + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.25.9.tgz", + "integrity": "sha512-hjMgRy5hb8uJJjUcdWunWVcoi9bGpJp8p5Ol1229PoN6aytsLwNMgmdftO23wnCLMfVmTwZDWMPNq/D1SY60JQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.25.9" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/template": { + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.25.9.tgz", + "integrity": "sha512-9DGttpmPvIxBb/2uwpVo3dqJ+O6RooAFOS+lB+xDqoE2PVCE8nfoHMdZLpfCQRLwvohzXISPZcgxt80xLfsuwg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.25.9", + "@babel/parser": "^7.25.9", + "@babel/types": "^7.25.9" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/traverse": { + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.25.9.tgz", + "integrity": "sha512-ZCuvfwOwlz/bawvAuvcj8rrithP2/N55Tzz342AkTvq4qaWbGfmCk/tKhNaV2cthijKrPAA8SRJV5WWe7IBMJw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.25.9", + "@babel/generator": "^7.25.9", + "@babel/parser": "^7.25.9", + "@babel/template": "^7.25.9", + "@babel/types": "^7.25.9", + "debug": "^4.3.1", + "globals": "^11.1.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/types": { + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.25.9.tgz", + "integrity": "sha512-OwS2CM5KocvQ/k7dFJa8i5bNGJP0hXWfVCfDkqRFP1IreH1JDC7wG6eCYCi0+McbfT8OR/kNqsI0UU0xP9H6PQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-string-parser": "^7.25.9", + "@babel/helper-validator-identifier": "^7.25.9" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@bcoe/v8-coverage": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz", + "integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@cspotcode/source-map-support": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", + "dev": true, + "dependencies": { + "@jridgewell/trace-mapping": "0.3.9" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@istanbuljs/load-nyc-config": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz", + "integrity": "sha512-VjeHSlIzpv/NyD3N0YuHfXOPDIixcA1q2ZV98wsMqcYlPmv2n3Yb2lYP9XMElnaFVXg5A7YLTeLu6V84uQDjmQ==", + "dev": true, + "license": "ISC", + "dependencies": { + "camelcase": "^5.3.1", + "find-up": "^4.1.0", + "get-package-type": "^0.1.0", + "js-yaml": "^3.13.1", + "resolve-from": "^5.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@istanbuljs/schema": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.3.tgz", + "integrity": "sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/@jest/console": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/console/-/console-29.7.0.tgz", + "integrity": "sha512-5Ni4CU7XHQi32IJ398EEP4RrB8eV09sXP2ROqD4bksHrnTree52PsxvX8tpL8LvTZ3pFzXyPbNQReSN41CAhOg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/types": "^29.6.3", + "@types/node": "*", + "chalk": "^4.0.0", + "jest-message-util": "^29.7.0", + "jest-util": "^29.7.0", + "slash": "^3.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/core": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/core/-/core-29.7.0.tgz", + "integrity": "sha512-n7aeXWKMnGtDA48y8TLWJPJmLmmZ642Ceo78cYWEpiD7FzDgmNDV/GCVRorPABdXLJZ/9wzzgZAlHjXjxDHGsg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/console": "^29.7.0", + "@jest/reporters": "^29.7.0", + "@jest/test-result": "^29.7.0", + "@jest/transform": "^29.7.0", + "@jest/types": "^29.6.3", + "@types/node": "*", + "ansi-escapes": "^4.2.1", + "chalk": "^4.0.0", + "ci-info": "^3.2.0", + "exit": "^0.1.2", + "graceful-fs": "^4.2.9", + "jest-changed-files": "^29.7.0", + "jest-config": "^29.7.0", + "jest-haste-map": "^29.7.0", + "jest-message-util": "^29.7.0", + "jest-regex-util": "^29.6.3", + "jest-resolve": "^29.7.0", + "jest-resolve-dependencies": "^29.7.0", + "jest-runner": "^29.7.0", + "jest-runtime": "^29.7.0", + "jest-snapshot": "^29.7.0", + "jest-util": "^29.7.0", + "jest-validate": "^29.7.0", + "jest-watcher": "^29.7.0", + "micromatch": "^4.0.4", + "pretty-format": "^29.7.0", + "slash": "^3.0.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" + }, + "peerDependenciesMeta": { + "node-notifier": { + "optional": true + } + } + }, + "node_modules/@jest/environment": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/environment/-/environment-29.7.0.tgz", + "integrity": "sha512-aQIfHDq33ExsN4jP1NWGXhxgQ/wixs60gDiKO+XVMd8Mn0NWPWgc34ZQDTb2jKaUWQ7MuwoitXAsN2XVXNMpAw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/fake-timers": "^29.7.0", + "@jest/types": "^29.6.3", + "@types/node": "*", + "jest-mock": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/expect": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/expect/-/expect-29.7.0.tgz", + "integrity": "sha512-8uMeAMycttpva3P1lBHB8VciS9V0XAr3GymPpipdyQXbBcuhkLQOSe8E/p92RyAdToS6ZD1tFkX+CkhoECE0dQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "expect": "^29.7.0", + "jest-snapshot": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/expect-utils": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/expect-utils/-/expect-utils-29.7.0.tgz", + "integrity": "sha512-GlsNBWiFQFCVi9QVSx7f5AgMeLxe9YCCs5PuP2O2LdjDAA8Jh9eX7lA1Jq/xdXw3Wb3hyvlFNfZIfcRetSzYcA==", + "dev": true, + "license": "MIT", + "dependencies": { + "jest-get-type": "^29.6.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/fake-timers": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/fake-timers/-/fake-timers-29.7.0.tgz", + "integrity": "sha512-q4DH1Ha4TTFPdxLsqDXK1d3+ioSL7yL5oCMJZgDYm6i+6CygW5E5xVr/D1HdsGxjt1ZWSfUAs9OxSB/BNelWrQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/types": "^29.6.3", + "@sinonjs/fake-timers": "^10.0.2", + "@types/node": "*", + "jest-message-util": "^29.7.0", + "jest-mock": "^29.7.0", + "jest-util": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/globals": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/globals/-/globals-29.7.0.tgz", + "integrity": "sha512-mpiz3dutLbkW2MNFubUGUEVLkTGiqW6yLVTA+JbP6fI6J5iL9Y0Nlg8k95pcF8ctKwCS7WVxteBs29hhfAotzQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/environment": "^29.7.0", + "@jest/expect": "^29.7.0", + "@jest/types": "^29.6.3", + "jest-mock": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/reporters": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/reporters/-/reporters-29.7.0.tgz", + "integrity": "sha512-DApq0KJbJOEzAFYjHADNNxAE3KbhxQB1y5Kplb5Waqw6zVbuWatSnMjE5gs8FUgEPmNsnZA3NCWl9NG0ia04Pg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@bcoe/v8-coverage": "^0.2.3", + "@jest/console": "^29.7.0", + "@jest/test-result": "^29.7.0", + "@jest/transform": "^29.7.0", + "@jest/types": "^29.6.3", + "@jridgewell/trace-mapping": "^0.3.18", + "@types/node": "*", + "chalk": "^4.0.0", + "collect-v8-coverage": "^1.0.0", + "exit": "^0.1.2", + "glob": "^7.1.3", + "graceful-fs": "^4.2.9", + "istanbul-lib-coverage": "^3.0.0", + "istanbul-lib-instrument": "^6.0.0", + "istanbul-lib-report": "^3.0.0", + "istanbul-lib-source-maps": "^4.0.0", + "istanbul-reports": "^3.1.3", + "jest-message-util": "^29.7.0", + "jest-util": "^29.7.0", + "jest-worker": "^29.7.0", + "slash": "^3.0.0", + "string-length": "^4.0.1", + "strip-ansi": "^6.0.0", + "v8-to-istanbul": "^9.0.1" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" + }, + "peerDependenciesMeta": { + "node-notifier": { + "optional": true + } + } + }, + "node_modules/@jest/reporters/node_modules/@jridgewell/trace-mapping": { + "version": "0.3.25", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz", + "integrity": "sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@jest/schemas": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.6.3.tgz", + "integrity": "sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@sinclair/typebox": "^0.27.8" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/source-map": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/source-map/-/source-map-29.6.3.tgz", + "integrity": "sha512-MHjT95QuipcPrpLM+8JMSzFx6eHp5Bm+4XeFDJlwsvVBjmKNiIAvasGK2fxz2WbGRlnvqehFbh07MMa7n3YJnw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/trace-mapping": "^0.3.18", + "callsites": "^3.0.0", + "graceful-fs": "^4.2.9" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/source-map/node_modules/@jridgewell/trace-mapping": { + "version": "0.3.25", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz", + "integrity": "sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@jest/test-result": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/test-result/-/test-result-29.7.0.tgz", + "integrity": "sha512-Fdx+tv6x1zlkJPcWXmMDAG2HBnaR9XPSd5aDWQVsfrZmLVT3lU1cwyxLgRmXR9yrq4NBoEm9BMsfgFzTQAbJYA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/console": "^29.7.0", + "@jest/types": "^29.6.3", + "@types/istanbul-lib-coverage": "^2.0.0", + "collect-v8-coverage": "^1.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/test-sequencer": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/test-sequencer/-/test-sequencer-29.7.0.tgz", + "integrity": "sha512-GQwJ5WZVrKnOJuiYiAF52UNUJXgTZx1NHjFSEB0qEMmSZKAkdMoIzw/Cj6x6NF4AvV23AUqDpFzQkN/eYCYTxw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/test-result": "^29.7.0", + "graceful-fs": "^4.2.9", + "jest-haste-map": "^29.7.0", + "slash": "^3.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/transform": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/@jest/transform/-/transform-29.7.0.tgz", + "integrity": "sha512-ok/BTPFzFKVMwO5eOHRrvnBVHdRy9IrsrW1GpMaQ9MCnilNLXQKmAX8s1YXDFaai9xJpac2ySzV0YeRRECr2Vw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/core": "^7.11.6", + "@jest/types": "^29.6.3", + "@jridgewell/trace-mapping": "^0.3.18", + "babel-plugin-istanbul": "^6.1.1", + "chalk": "^4.0.0", + "convert-source-map": "^2.0.0", + "fast-json-stable-stringify": "^2.1.0", + "graceful-fs": "^4.2.9", + "jest-haste-map": "^29.7.0", + "jest-regex-util": "^29.6.3", + "jest-util": "^29.7.0", + "micromatch": "^4.0.4", + "pirates": "^4.0.4", + "slash": "^3.0.0", + "write-file-atomic": "^4.0.2" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/transform/node_modules/@jridgewell/trace-mapping": { + "version": "0.3.25", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz", + "integrity": "sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@jest/types": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.6.3.tgz", + "integrity": "sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/schemas": "^29.6.3", + "@types/istanbul-lib-coverage": "^2.0.0", + "@types/istanbul-reports": "^3.0.0", + "@types/node": "*", + "@types/yargs": "^17.0.8", + "chalk": "^4.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.5.tgz", + "integrity": "sha512-IzL8ZoEDIBRWEzlCcRhOaCupYyN5gdIK+Q6fbFdPDg6HqX6jpkItn7DFIpW9LQzXG6Df9sA7+OKnq0qlz/GaQg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/set-array": "^1.2.1", + "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/trace-mapping": "^0.3.24" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/gen-mapping/node_modules/@jridgewell/trace-mapping": { + "version": "0.3.25", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz", + "integrity": "sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "dev": true, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/set-array": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.2.1.tgz", + "integrity": "sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz", + "integrity": "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==", + "dev": true + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "dev": true, + "dependencies": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, + "node_modules/@shikijs/core": { + "version": "1.22.0", + "resolved": "https://registry.npmjs.org/@shikijs/core/-/core-1.22.0.tgz", + "integrity": "sha512-S8sMe4q71TJAW+qG93s5VaiihujRK6rqDFqBnxqvga/3LvqHEnxqBIOPkt//IdXVtHkQWKu4nOQNk0uBGicU7Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@shikijs/engine-javascript": "1.22.0", + "@shikijs/engine-oniguruma": "1.22.0", + "@shikijs/types": "1.22.0", + "@shikijs/vscode-textmate": "^9.3.0", + "@types/hast": "^3.0.4", + "hast-util-to-html": "^9.0.3" + } + }, + "node_modules/@shikijs/engine-javascript": { + "version": "1.22.0", + "resolved": "https://registry.npmjs.org/@shikijs/engine-javascript/-/engine-javascript-1.22.0.tgz", + "integrity": "sha512-AeEtF4Gcck2dwBqCFUKYfsCq0s+eEbCEbkUuFou53NZ0sTGnJnJ/05KHQFZxpii5HMXbocV9URYVowOP2wH5kw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@shikijs/types": "1.22.0", + "@shikijs/vscode-textmate": "^9.3.0", + "oniguruma-to-js": "0.4.3" + } + }, + "node_modules/@shikijs/engine-oniguruma": { + "version": "1.22.0", + "resolved": "https://registry.npmjs.org/@shikijs/engine-oniguruma/-/engine-oniguruma-1.22.0.tgz", + "integrity": "sha512-5iBVjhu/DYs1HB0BKsRRFipRrD7rqjxlWTj4F2Pf+nQSPqc3kcyqFFeZXnBMzDf0HdqaFVvhDRAGiYNvyLP+Mw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@shikijs/types": "1.22.0", + "@shikijs/vscode-textmate": "^9.3.0" + } + }, + "node_modules/@shikijs/types": { + "version": "1.22.0", + "resolved": "https://registry.npmjs.org/@shikijs/types/-/types-1.22.0.tgz", + "integrity": "sha512-Fw/Nr7FGFhlQqHfxzZY8Cwtwk5E9nKDUgeLjZgt3UuhcM3yJR9xj3ZGNravZZok8XmEZMiYkSMTPlPkULB8nww==", + "dev": true, + "license": "MIT", + "dependencies": { + "@shikijs/vscode-textmate": "^9.3.0", + "@types/hast": "^3.0.4" + } + }, + "node_modules/@shikijs/vscode-textmate": { + "version": "9.3.0", + "resolved": "https://registry.npmjs.org/@shikijs/vscode-textmate/-/vscode-textmate-9.3.0.tgz", + "integrity": "sha512-jn7/7ky30idSkd/O5yDBfAnVt+JJpepofP/POZ1iMOxK59cOfqIgg/Dj0eFsjOTMw+4ycJN0uhZH/Eb0bs/EUA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@sinclair/typebox": { + "version": "0.27.8", + "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", + "integrity": "sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@sinonjs/commons": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-3.0.1.tgz", + "integrity": "sha512-K3mCHKQ9sVh8o1C9cxkwxaOmXoAMlDxC1mYyHrjqOWEcBjYr76t96zL2zlj5dUGZ3HSw240X1qgH3Mjf1yJWpQ==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "type-detect": "4.0.8" + } + }, + "node_modules/@sinonjs/fake-timers": { + "version": "10.3.0", + "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-10.3.0.tgz", + "integrity": "sha512-V4BG07kuYSUkTCSBHG8G8TNhM+F19jXFWnQtzj+we8DrkpSBCee9Z3Ms8yiGer/dlmhe35/Xdgyo3/0rQKg7YA==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "@sinonjs/commons": "^3.0.0" + } + }, + "node_modules/@tsconfig/node10": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.11.tgz", + "integrity": "sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw==", + "dev": true + }, + "node_modules/@tsconfig/node12": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", + "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", + "dev": true + }, + "node_modules/@tsconfig/node14": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", + "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", + "dev": true + }, + "node_modules/@tsconfig/node16": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", + "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", + "dev": true + }, + "node_modules/@types/babel__core": { + "version": "7.20.5", + "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.5.tgz", + "integrity": "sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.20.7", + "@babel/types": "^7.20.7", + "@types/babel__generator": "*", + "@types/babel__template": "*", + "@types/babel__traverse": "*" + } + }, + "node_modules/@types/babel__generator": { + "version": "7.6.8", + "resolved": "https://registry.npmjs.org/@types/babel__generator/-/babel__generator-7.6.8.tgz", + "integrity": "sha512-ASsj+tpEDsEiFr1arWrlN6V3mdfjRMZt6LtK/Vp/kreFLnr5QH5+DhvD5nINYZXzwJvXeGq+05iUXcAzVrqWtw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.0.0" + } + }, + "node_modules/@types/babel__template": { + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@types/babel__template/-/babel__template-7.4.4.tgz", + "integrity": "sha512-h/NUaSyG5EyxBIp8YRxo4RMe2/qQgvyowRwVMzhYhBCONbW8PUsg4lkFMrhgZhUe5z3L3MiLDuvyJ/CaPa2A8A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.1.0", + "@babel/types": "^7.0.0" + } + }, + "node_modules/@types/babel__traverse": { + "version": "7.20.6", + "resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.20.6.tgz", + "integrity": "sha512-r1bzfrm0tomOI8g1SzvCaQHo6Lcv6zu0EA+W2kHrt8dyrHQxGzBBL4kdkzIS+jBMV+EYcMAEAqXqYaLJq5rOZg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.20.7" + } + }, + "node_modules/@types/events": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/events/-/events-3.0.3.tgz", + "integrity": "sha512-trOc4AAUThEz9hapPtSd7wf5tiQKvTtu5b371UxXdTuqzIh0ArcRspRP0i0Viu+LXstIQ1z96t1nsPxT9ol01g==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/graceful-fs": { + "version": "4.1.9", + "resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.9.tgz", + "integrity": "sha512-olP3sd1qOEe5dXTSaFvQG+02VdRXcdytWLAZsAq1PecU8uqQAhkrnbli7DagjtXKW/Bl7YJbUsa8MPcuc8LHEQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/hast": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/@types/hast/-/hast-3.0.4.tgz", + "integrity": "sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/unist": "*" + } + }, + "node_modules/@types/istanbul-lib-coverage": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.6.tgz", + "integrity": "sha512-2QF/t/auWm0lsy8XtKVPG19v3sSOQlJe/YHZgfjb/KBBHOGSV+J2q/S671rcq9uTBrLAXmZpqJiaQbMT+zNU1w==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/istanbul-lib-report": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/istanbul-lib-report/-/istanbul-lib-report-3.0.3.tgz", + "integrity": "sha512-NQn7AHQnk/RSLOxrBbGyJM/aVQ+pjj5HCgasFxc0K/KhoATfQ/47AyUl15I2yBUpihjmas+a+VJBOqecrFH+uA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/istanbul-lib-coverage": "*" + } + }, + "node_modules/@types/istanbul-reports": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/@types/istanbul-reports/-/istanbul-reports-3.0.4.tgz", + "integrity": "sha512-pk2B1NWalF9toCRu6gjBzR69syFjP4Od8WRAX+0mmf9lAjCRicLOWc+ZrxZHx/0XRjotgkF9t6iaMJ+aXcOdZQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/istanbul-lib-report": "*" + } + }, + "node_modules/@types/jest": { + "version": "29.5.14", + "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.14.tgz", + "integrity": "sha512-ZN+4sdnLUbo8EVvVc2ao0GFW6oVrQRPn4K2lglySj7APvSrgzxHiNNK99us4WDMi57xxA2yggblIAMNhXOotLQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "expect": "^29.0.0", + "pretty-format": "^29.0.0" + } + }, + "node_modules/@types/mdast": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-4.0.4.tgz", + "integrity": "sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/unist": "*" + } + }, + "node_modules/@types/node": { + "version": "22.7.6", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.7.6.tgz", + "integrity": "sha512-/d7Rnj0/ExXDMcioS78/kf1lMzYk4BZV8MZGTBKzTGZ6/406ukkbYlIsZmMPhcR5KlkunDHQLrtAVmSq7r+mSw==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~6.19.2" + } + }, + "node_modules/@types/stack-utils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.3.tgz", + "integrity": "sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/unist": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz", + "integrity": "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/yargs": { + "version": "17.0.33", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.33.tgz", + "integrity": "sha512-WpxBCKWPLr4xSsHgz511rFJAM+wS28w2zEO1QDNY5zM/S8ok70NNfztH0xwhqKyaK0OHCbN98LDAZuy1ctxDkA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/yargs-parser": "*" + } + }, + "node_modules/@types/yargs-parser": { + "version": "21.0.3", + "resolved": "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-21.0.3.tgz", + "integrity": "sha512-I4q9QU9MQv4oEOz4tAHJtNz1cwuLxn2F3xcc2iV5WdqLPpUnj30aUuxt1mAxYTG+oe8CZMV/+6rU4S4gRDzqtQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@ungap/structured-clone": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.2.0.tgz", + "integrity": "sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/acorn": { + "version": "8.13.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.13.0.tgz", + "integrity": "sha512-8zSiw54Oxrdym50NlZ9sUusyO1Z1ZchgRLWRaK6c86XJFClyCgFKetdowBg5bKxyp/u+CDBJG4Mpp0m3HLZl9w==", + "dev": true, + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-walk": { + "version": "8.3.4", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.4.tgz", + "integrity": "sha512-ueEepnujpqee2o5aIYnvHU6C0A42MNdsIDeqy5BydrkuC5R1ZuUFnm27EeFJGoEHJQgn3uleRvmTXaJgfXbt4g==", + "dev": true, + "dependencies": { + "acorn": "^8.11.0" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/ansi-escapes": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.2.tgz", + "integrity": "sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "type-fest": "^0.21.3" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "dev": true, + "license": "ISC", + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/arg": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", + "dev": true + }, + "node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true, + "license": "Python-2.0" + }, + "node_modules/async": { + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/async/-/async-3.2.6.tgz", + "integrity": "sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==", + "dev": true, + "license": "MIT" + }, + "node_modules/babel-jest": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-29.7.0.tgz", + "integrity": "sha512-BrvGY3xZSwEcCzKvKsCi2GgHqDqsYkOP4/by5xCgIwGXQxIEh+8ew3gmrE1y7XRR6LHZIj6yLYnUi/mm2KXKBg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/transform": "^29.7.0", + "@types/babel__core": "^7.1.14", + "babel-plugin-istanbul": "^6.1.1", + "babel-preset-jest": "^29.6.3", + "chalk": "^4.0.0", + "graceful-fs": "^4.2.9", + "slash": "^3.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "@babel/core": "^7.8.0" + } + }, + "node_modules/babel-plugin-istanbul": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/babel-plugin-istanbul/-/babel-plugin-istanbul-6.1.1.tgz", + "integrity": "sha512-Y1IQok9821cC9onCx5otgFfRm7Lm+I+wwxOx738M/WLPZ9Q42m4IG5W0FNX8WLL2gYMZo3JkuXIH2DOpWM+qwA==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "@babel/helper-plugin-utils": "^7.0.0", + "@istanbuljs/load-nyc-config": "^1.0.0", + "@istanbuljs/schema": "^0.1.2", + "istanbul-lib-instrument": "^5.0.4", + "test-exclude": "^6.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/babel-plugin-istanbul/node_modules/istanbul-lib-instrument": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-5.2.1.tgz", + "integrity": "sha512-pzqtp31nLv/XFOzXGuvhCb8qhjmTVo5vjVk19XE4CRlSWz0KoeJ3bw9XsA7nOp9YBf4qHjwBxkDzKcME/J29Yg==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "@babel/core": "^7.12.3", + "@babel/parser": "^7.14.7", + "@istanbuljs/schema": "^0.1.2", + "istanbul-lib-coverage": "^3.2.0", + "semver": "^6.3.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/babel-plugin-jest-hoist": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-29.6.3.tgz", + "integrity": "sha512-ESAc/RJvGTFEzRwOTT4+lNDk/GNHMkKbNzsvT0qKRfDyyYTskxB5rnU2njIDYVxXCBHHEI1c0YwHob3WaYujOg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/template": "^7.3.3", + "@babel/types": "^7.3.3", + "@types/babel__core": "^7.1.14", + "@types/babel__traverse": "^7.0.6" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/babel-preset-current-node-syntax": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/babel-preset-current-node-syntax/-/babel-preset-current-node-syntax-1.1.0.tgz", + "integrity": "sha512-ldYss8SbBlWva1bs28q78Ju5Zq1F+8BrqBZZ0VFhLBvhh6lCpC2o3gDJi/5DRLs9FgYZCnmPYIVFU4lRXCkyUw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/plugin-syntax-async-generators": "^7.8.4", + "@babel/plugin-syntax-bigint": "^7.8.3", + "@babel/plugin-syntax-class-properties": "^7.12.13", + "@babel/plugin-syntax-class-static-block": "^7.14.5", + "@babel/plugin-syntax-import-attributes": "^7.24.7", + "@babel/plugin-syntax-import-meta": "^7.10.4", + "@babel/plugin-syntax-json-strings": "^7.8.3", + "@babel/plugin-syntax-logical-assignment-operators": "^7.10.4", + "@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3", + "@babel/plugin-syntax-numeric-separator": "^7.10.4", + "@babel/plugin-syntax-object-rest-spread": "^7.8.3", + "@babel/plugin-syntax-optional-catch-binding": "^7.8.3", + "@babel/plugin-syntax-optional-chaining": "^7.8.3", + "@babel/plugin-syntax-private-property-in-object": "^7.14.5", + "@babel/plugin-syntax-top-level-await": "^7.14.5" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/babel-preset-jest": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/babel-preset-jest/-/babel-preset-jest-29.6.3.tgz", + "integrity": "sha512-0B3bhxR6snWXJZtR/RliHTDPRgn1sNHOR0yVtq/IiQFyuOVjFS+wuio/R4gSNkyYmKmJB4wGZv2NZanmKmTnNA==", + "dev": true, + "license": "MIT", + "dependencies": { + "babel-plugin-jest-hoist": "^29.6.3", + "babel-preset-current-node-syntax": "^1.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/braces": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", + "dev": true, + "license": "MIT", + "dependencies": { + "fill-range": "^7.1.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/browserslist": { + "version": "4.24.2", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.24.2.tgz", + "integrity": "sha512-ZIc+Q62revdMcqC6aChtW4jz3My3klmCO1fEmINZY/8J3EpBg5/A/D0AKmBveUh6pgoeycoMkVMko84tuYS+Gg==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "caniuse-lite": "^1.0.30001669", + "electron-to-chromium": "^1.5.41", + "node-releases": "^2.0.18", + "update-browserslist-db": "^1.1.1" + }, + "bin": { + "browserslist": "cli.js" + }, + "engines": { + "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" + } + }, + "node_modules/bs-logger": { + "version": "0.2.6", + "resolved": "https://registry.npmjs.org/bs-logger/-/bs-logger-0.2.6.tgz", + "integrity": "sha512-pd8DCoxmbgc7hyPKOvxtqNcjYoOsABPQdcCUjGp3d42VR2CX1ORhk2A87oqqu5R1kk+76nsxZupkmyd+MVtCog==", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-json-stable-stringify": "2.x" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/bser": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/bser/-/bser-2.1.1.tgz", + "integrity": "sha512-gQxTNE/GAfIIrmHLUE3oJyp5FO6HRBfhjnw4/wMmA63ZGDJnWBmgY/lyQBpnDUkGmAhbSe39tx2d/iTOAfglwQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "node-int64": "^0.4.0" + } + }, + "node_modules/buffer-from": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/caniuse-lite": { + "version": "1.0.30001669", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001669.tgz", + "integrity": "sha512-DlWzFDJqstqtIVx1zeSpIMLjunf5SmwOw0N2Ck/QSQdS8PLS4+9HrLaYei4w8BIAL7IB/UEDu889d8vhCTPA0w==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "CC-BY-4.0" + }, + "node_modules/ccount": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/ccount/-/ccount-2.0.1.tgz", + "integrity": "sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg==", + "dev": true, + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/char-regex": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/char-regex/-/char-regex-1.0.2.tgz", + "integrity": "sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + } + }, + "node_modules/character-entities-html4": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/character-entities-html4/-/character-entities-html4-2.1.0.tgz", + "integrity": "sha512-1v7fgQRj6hnSwFpq1Eu0ynr/CDEw0rXo2B61qXrLNdHZmPKgb7fqS1a2JwF0rISo9q77jDI8VMEHoApn8qDoZA==", + "dev": true, + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/character-entities-legacy": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/character-entities-legacy/-/character-entities-legacy-3.0.0.tgz", + "integrity": "sha512-RpPp0asT/6ufRm//AJVwpViZbGM/MkjQFxJccQRHmISF/22NBtsHqAWmL+/pmkPWoIUJdWyeVleTl1wydHATVQ==", + "dev": true, + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/ci-info": { + "version": "3.9.0", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.9.0.tgz", + "integrity": "sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/sibiraj-s" + } + ], + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/cjs-module-lexer": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/cjs-module-lexer/-/cjs-module-lexer-1.4.1.tgz", + "integrity": "sha512-cuSVIHi9/9E/+821Qjdvngor+xpnlwnuwIyZOaLmHBVdXL+gP+I6QQB9VkO7RI77YIcTV+S1W9AreJ5eN63JBA==", + "dev": true, + "license": "MIT" + }, + "node_modules/cliui": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", + "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", + "dev": true, + "license": "ISC", + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.1", + "wrap-ansi": "^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/co": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", + "integrity": "sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ==", + "dev": true, + "license": "MIT", + "engines": { + "iojs": ">= 1.0.0", + "node": ">= 0.12.0" + } + }, + "node_modules/collect-v8-coverage": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/collect-v8-coverage/-/collect-v8-coverage-1.0.2.tgz", + "integrity": "sha512-lHl4d5/ONEbLlJvaJNtsF/Lz+WvB07u2ycqTYbdrq7UypDXailES4valYb2eWiJFxZlVmpGekfqoxQhzyFdT4Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true, + "license": "MIT" + }, + "node_modules/comma-separated-tokens": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/comma-separated-tokens/-/comma-separated-tokens-2.0.3.tgz", + "integrity": "sha512-Fu4hJdvzeylCfQPp9SGWidpzrMs7tTrlu6Vb8XGaRGck8QSNZJJp538Wrb60Lax4fPwR64ViY468OIUTbRlGZg==", + "dev": true, + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true, + "license": "MIT" + }, + "node_modules/convert-source-map": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", + "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", + "dev": true, + "license": "MIT" + }, + "node_modules/create-jest": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/create-jest/-/create-jest-29.7.0.tgz", + "integrity": "sha512-Adz2bdH0Vq3F53KEMJOoftQFutWCukm6J24wbPWRO4k1kMY7gS7ds/uoJkNuV8wDCtWWnuwGcJwpWcih+zEW1Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/types": "^29.6.3", + "chalk": "^4.0.0", + "exit": "^0.1.2", + "graceful-fs": "^4.2.9", + "jest-config": "^29.7.0", + "jest-util": "^29.7.0", + "prompts": "^2.0.1" + }, + "bin": { + "create-jest": "bin/create-jest.js" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/create-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", + "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", + "dev": true + }, + "node_modules/cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dev": true, + "license": "MIT", + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/debug": { + "version": "4.3.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz", + "integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/dedent": { + "version": "1.5.3", + "resolved": "https://registry.npmjs.org/dedent/-/dedent-1.5.3.tgz", + "integrity": "sha512-NHQtfOOW68WD8lgypbLA5oT+Bt0xXJhiYvoR6SmmNXZfpzOGXwdKWmcwG8N7PwVVWV3eF/68nmD9BaJSsTBhyQ==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "babel-plugin-macros": "^3.1.0" + }, + "peerDependenciesMeta": { + "babel-plugin-macros": { + "optional": true + } + } + }, + "node_modules/deepmerge": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz", + "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/dequal": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz", + "integrity": "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/detect-newline": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/detect-newline/-/detect-newline-3.1.0.tgz", + "integrity": "sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/devlop": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/devlop/-/devlop-1.1.0.tgz", + "integrity": "sha512-RWmIqhcFf1lRYBvNmr7qTNuyCt/7/ns2jbpp1+PalgE/rDQcBT0fioSMUpJ93irlUhC5hrg4cYqe6U+0ImW0rA==", + "dev": true, + "license": "MIT", + "dependencies": { + "dequal": "^2.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "dev": true, + "engines": { + "node": ">=0.3.1" + } + }, + "node_modules/diff-sequences": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-29.6.3.tgz", + "integrity": "sha512-EjePK1srD3P08o2j4f0ExnylqRs5B9tJjcp9t1krH2qRi8CCdsYfwe9JgSLurFBWwq4uOlipzfk5fHNvwFKr8Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/ejs": { + "version": "3.1.10", + "resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.10.tgz", + "integrity": "sha512-UeJmFfOrAQS8OJWPZ4qtgHyWExa088/MtK5UEyoJGFH67cDEXkZSviOiKRCZ4Xij0zxI3JECgYs3oKx+AizQBA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "jake": "^10.8.5" + }, + "bin": { + "ejs": "bin/cli.js" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/electron-to-chromium": { + "version": "1.5.44", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.44.tgz", + "integrity": "sha512-Lz3POUa7wANQA8G+9btKAdH+cqkfWCBdkotvQZJVOqRXMYGm1tTD835Z01iCjWpEBf0RInPBWuPfzhGbxOCULw==", + "dev": true, + "license": "ISC" + }, + "node_modules/emittery": { + "version": "0.13.1", + "resolved": "https://registry.npmjs.org/emittery/-/emittery-0.13.1.tgz", + "integrity": "sha512-DeWwawk6r5yR9jFgnDKYt4sLS0LmHJJi3ZOnb5/JdbYwj3nW+FxQnHIjhBKz8YLC7oRNPVM9NQ47I3CVx34eqQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sindresorhus/emittery?sponsor=1" + } + }, + "node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true, + "license": "MIT" + }, + "node_modules/entities": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", + "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, + "node_modules/error-ex": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", + "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-arrayish": "^0.2.1" + } + }, + "node_modules/escalade": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", + "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/escape-string-regexp": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", + "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true, + "license": "BSD-2-Clause", + "bin": { + "esparse": "bin/esparse.js", + "esvalidate": "bin/esvalidate.js" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/execa": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/execa/-/execa-5.1.1.tgz", + "integrity": "sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==", + "dev": true, + "license": "MIT", + "dependencies": { + "cross-spawn": "^7.0.3", + "get-stream": "^6.0.0", + "human-signals": "^2.1.0", + "is-stream": "^2.0.0", + "merge-stream": "^2.0.0", + "npm-run-path": "^4.0.1", + "onetime": "^5.1.2", + "signal-exit": "^3.0.3", + "strip-final-newline": "^2.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sindresorhus/execa?sponsor=1" + } + }, + "node_modules/exit": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", + "integrity": "sha512-Zk/eNKV2zbjpKzrsQ+n1G6poVbErQxJ0LBOJXaKZ1EViLzH+hrLu9cdXI4zw9dBQJslwBEpbQ2P1oS7nDxs6jQ==", + "dev": true, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/expect": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/expect/-/expect-29.7.0.tgz", + "integrity": "sha512-2Zks0hf1VLFYI1kbh0I5jP3KHHyCHpkfyHBzsSXRFgl/Bg9mWYfMW8oD+PdMPlEwy5HNsR9JutYy6pMeOh61nw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/expect-utils": "^29.7.0", + "jest-get-type": "^29.6.3", + "jest-matcher-utils": "^29.7.0", + "jest-message-util": "^29.7.0", + "jest-util": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "dev": true, + "license": "MIT" + }, + "node_modules/fb-watchman": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/fb-watchman/-/fb-watchman-2.0.2.tgz", + "integrity": "sha512-p5161BqbuCaSnB8jIbzQHOlpgsPmK5rJVDfDKO91Axs5NC1uu3HRQm6wt9cd9/+GtQQIO53JdGXXoyDpTAsgYA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "bser": "2.1.1" + } + }, + "node_modules/filelist": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.4.tgz", + "integrity": "sha512-w1cEuf3S+DrLCQL7ET6kz+gmlJdbq9J7yXCSjK/OZCPA+qEN1WyF4ZAf0YYJa4/shHJra2t/d/r8SV4Ji+x+8Q==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "minimatch": "^5.0.1" + } + }, + "node_modules/filelist/node_modules/minimatch": { + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", + "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/fill-range": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", + "dev": true, + "license": "MIT", + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "license": "MIT", + "dependencies": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", + "dev": true, + "license": "ISC" + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/gensync": { + "version": "1.0.0-beta.2", + "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", + "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true, + "license": "ISC", + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, + "node_modules/get-package-type": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/get-package-type/-/get-package-type-0.1.0.tgz", + "integrity": "sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/get-stream": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz", + "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "deprecated": "Glob versions prior to v9 are no longer supported", + "dev": true, + "license": "ISC", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/glob/node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/glob/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/globals": { + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", + "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/graceful-fs": { + "version": "4.2.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", + "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/hasown": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", + "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/hast-util-to-html": { + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/hast-util-to-html/-/hast-util-to-html-9.0.3.tgz", + "integrity": "sha512-M17uBDzMJ9RPCqLMO92gNNUDuBSq10a25SDBI08iCCxmorf4Yy6sYHK57n9WAbRAAaU+DuR4W6GN9K4DFZesYg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0", + "@types/unist": "^3.0.0", + "ccount": "^2.0.0", + "comma-separated-tokens": "^2.0.0", + "hast-util-whitespace": "^3.0.0", + "html-void-elements": "^3.0.0", + "mdast-util-to-hast": "^13.0.0", + "property-information": "^6.0.0", + "space-separated-tokens": "^2.0.0", + "stringify-entities": "^4.0.0", + "zwitch": "^2.0.4" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/hast-util-whitespace": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/hast-util-whitespace/-/hast-util-whitespace-3.0.0.tgz", + "integrity": "sha512-88JUN06ipLwsnv+dVn+OIYOvAuvBMy/Qoi6O7mQHxdPXpjy+Cd6xRkWwux7DKO+4sYILtLBRIKgsdpS2gQc7qw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/html-escaper": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", + "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", + "dev": true, + "license": "MIT" + }, + "node_modules/html-void-elements": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/html-void-elements/-/html-void-elements-3.0.0.tgz", + "integrity": "sha512-bEqo66MRXsUGxWHV5IP0PUiAWwoEjba4VCzg0LjFJBpchPaTfyfCKTG6bc5F8ucKec3q5y6qOdGyYTSBEvhCrg==", + "dev": true, + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/human-signals": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz", + "integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=10.17.0" + } + }, + "node_modules/import-local": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/import-local/-/import-local-3.2.0.tgz", + "integrity": "sha512-2SPlun1JUPWoM6t3F0dw0FkCF/jWY8kttcY4f599GLTSjh2OCuuhdTkJQsEcZzBqbXZGKMK2OqW1oZsjtf/gQA==", + "dev": true, + "license": "MIT", + "dependencies": { + "pkg-dir": "^4.2.0", + "resolve-cwd": "^3.0.0" + }, + "bin": { + "import-local-fixture": "fixtures/cli.js" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.8.19" + } + }, + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "deprecated": "This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.", + "dev": true, + "license": "ISC", + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/is-arrayish": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", + "integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==", + "dev": true, + "license": "MIT" + }, + "node_modules/is-core-module": { + "version": "2.15.1", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.15.1.tgz", + "integrity": "sha512-z0vtXSwucUJtANQWldhbtbt7BnL0vxiFjIdDLAatwhDYty2bad6s+rijD6Ri4YuYJubLzIJLUidCh09e1djEVQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/is-generator-fn": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-generator-fn/-/is-generator-fn-2.1.0.tgz", + "integrity": "sha512-cTIB4yPYL/Grw0EaSzASzg6bBy9gqCofvWN8okThAYIxKJZC+udlRAmGbM0XLeniEJSs8uEgHPGuHSe1XsOLSQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/is-stream": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", + "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true, + "license": "ISC" + }, + "node_modules/istanbul-lib-coverage": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.2.tgz", + "integrity": "sha512-O8dpsF+r0WV/8MNRKfnmrtCWhuKjxrq2w+jpzBL5UZKTi2LeVWnWOmWRxFlesJONmc+wLAGvKQZEOanko0LFTg==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-instrument": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-6.0.3.tgz", + "integrity": "sha512-Vtgk7L/R2JHyyGW07spoFlB8/lpjiOLTjMdms6AFMraYt3BaJauod/NGrfnVG/y4Ix1JEuMRPDPEj2ua+zz1/Q==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "@babel/core": "^7.23.9", + "@babel/parser": "^7.23.9", + "@istanbuljs/schema": "^0.1.3", + "istanbul-lib-coverage": "^3.2.0", + "semver": "^7.5.4" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-lib-instrument/node_modules/semver": { + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-lib-report": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz", + "integrity": "sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "istanbul-lib-coverage": "^3.0.0", + "make-dir": "^4.0.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-lib-source-maps": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-source-maps/-/istanbul-lib-source-maps-4.0.1.tgz", + "integrity": "sha512-n3s8EwkdFIJCG3BPKBYvskgXGoy88ARzvegkitk60NxRdwltLOTaH7CUiMRXvwYorl0Q712iEjcWB+fK/MrWVw==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "debug": "^4.1.1", + "istanbul-lib-coverage": "^3.0.0", + "source-map": "^0.6.1" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-reports": { + "version": "3.1.7", + "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.1.7.tgz", + "integrity": "sha512-BewmUXImeuRk2YY0PVbxgKAysvhRPUQE0h5QRM++nVWyubKGV0l8qQ5op8+B2DOmwSe63Jivj0BjkPQVf8fP5g==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "html-escaper": "^2.0.0", + "istanbul-lib-report": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/jake": { + "version": "10.9.2", + "resolved": "https://registry.npmjs.org/jake/-/jake-10.9.2.tgz", + "integrity": "sha512-2P4SQ0HrLQ+fw6llpLnOaGAvN2Zu6778SJMrCUwns4fOoG9ayrTiZk3VV8sCPkVZF8ab0zksVpS8FDY5pRCNBA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "async": "^3.2.3", + "chalk": "^4.0.2", + "filelist": "^1.0.4", + "minimatch": "^3.1.2" + }, + "bin": { + "jake": "bin/cli.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/jake/node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/jake/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/jest": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest/-/jest-29.7.0.tgz", + "integrity": "sha512-NIy3oAFp9shda19hy4HK0HRTWKtPJmGdnvywu01nOqNC2vZg+Z+fvJDxpMQA88eb2I9EcafcdjYgsDthnYTvGw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/core": "^29.7.0", + "@jest/types": "^29.6.3", + "import-local": "^3.0.2", + "jest-cli": "^29.7.0" + }, + "bin": { + "jest": "bin/jest.js" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" + }, + "peerDependenciesMeta": { + "node-notifier": { + "optional": true + } + } + }, + "node_modules/jest-changed-files": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-changed-files/-/jest-changed-files-29.7.0.tgz", + "integrity": "sha512-fEArFiwf1BpQ+4bXSprcDc3/x4HSzL4al2tozwVpDFpsxALjLYdyiIK4e5Vz66GQJIbXJ82+35PtysofptNX2w==", + "dev": true, + "license": "MIT", + "dependencies": { + "execa": "^5.0.0", + "jest-util": "^29.7.0", + "p-limit": "^3.1.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-circus": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-circus/-/jest-circus-29.7.0.tgz", + "integrity": "sha512-3E1nCMgipcTkCocFwM90XXQab9bS+GMsjdpmPrlelaxwD93Ad8iVEjX/vvHPdLPnFf+L40u+5+iutRdA1N9myw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/environment": "^29.7.0", + "@jest/expect": "^29.7.0", + "@jest/test-result": "^29.7.0", + "@jest/types": "^29.6.3", + "@types/node": "*", + "chalk": "^4.0.0", + "co": "^4.6.0", + "dedent": "^1.0.0", + "is-generator-fn": "^2.0.0", + "jest-each": "^29.7.0", + "jest-matcher-utils": "^29.7.0", + "jest-message-util": "^29.7.0", + "jest-runtime": "^29.7.0", + "jest-snapshot": "^29.7.0", + "jest-util": "^29.7.0", + "p-limit": "^3.1.0", + "pretty-format": "^29.7.0", + "pure-rand": "^6.0.0", + "slash": "^3.0.0", + "stack-utils": "^2.0.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-cli": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-cli/-/jest-cli-29.7.0.tgz", + "integrity": "sha512-OVVobw2IubN/GSYsxETi+gOe7Ka59EFMR/twOU3Jb2GnKKeMGJB5SGUUrEz3SFVmJASUdZUzy83sLNNQ2gZslg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/core": "^29.7.0", + "@jest/test-result": "^29.7.0", + "@jest/types": "^29.6.3", + "chalk": "^4.0.0", + "create-jest": "^29.7.0", + "exit": "^0.1.2", + "import-local": "^3.0.2", + "jest-config": "^29.7.0", + "jest-util": "^29.7.0", + "jest-validate": "^29.7.0", + "yargs": "^17.3.1" + }, + "bin": { + "jest": "bin/jest.js" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" + }, + "peerDependenciesMeta": { + "node-notifier": { + "optional": true + } + } + }, + "node_modules/jest-config": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-config/-/jest-config-29.7.0.tgz", + "integrity": "sha512-uXbpfeQ7R6TZBqI3/TxCU4q4ttk3u0PJeC+E0zbfSoSjq6bJ7buBPxzQPL0ifrkY4DNu4JUdk0ImlBUYi840eQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/core": "^7.11.6", + "@jest/test-sequencer": "^29.7.0", + "@jest/types": "^29.6.3", + "babel-jest": "^29.7.0", + "chalk": "^4.0.0", + "ci-info": "^3.2.0", + "deepmerge": "^4.2.2", + "glob": "^7.1.3", + "graceful-fs": "^4.2.9", + "jest-circus": "^29.7.0", + "jest-environment-node": "^29.7.0", + "jest-get-type": "^29.6.3", + "jest-regex-util": "^29.6.3", + "jest-resolve": "^29.7.0", + "jest-runner": "^29.7.0", + "jest-util": "^29.7.0", + "jest-validate": "^29.7.0", + "micromatch": "^4.0.4", + "parse-json": "^5.2.0", + "pretty-format": "^29.7.0", + "slash": "^3.0.0", + "strip-json-comments": "^3.1.1" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "@types/node": "*", + "ts-node": ">=9.0.0" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "ts-node": { + "optional": true + } + } + }, + "node_modules/jest-diff": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-29.7.0.tgz", + "integrity": "sha512-LMIgiIrhigmPrs03JHpxUh2yISK3vLFPkAodPeo0+BuF7wA2FoQbkEg1u8gBYBThncu7e1oEDUfIXVuTqLRUjw==", + "dev": true, + "license": "MIT", + "dependencies": { + "chalk": "^4.0.0", + "diff-sequences": "^29.6.3", + "jest-get-type": "^29.6.3", + "pretty-format": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-docblock": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-docblock/-/jest-docblock-29.7.0.tgz", + "integrity": "sha512-q617Auw3A612guyaFgsbFeYpNP5t2aoUNLwBUbc/0kD1R4t9ixDbyFTHd1nok4epoVFpr7PmeWHrhvuV3XaJ4g==", + "dev": true, + "license": "MIT", + "dependencies": { + "detect-newline": "^3.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-each": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-each/-/jest-each-29.7.0.tgz", + "integrity": "sha512-gns+Er14+ZrEoC5fhOfYCY1LOHHr0TI+rQUHZS8Ttw2l7gl+80eHc/gFf2Ktkw0+SIACDTeWvpFcv3B04VembQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/types": "^29.6.3", + "chalk": "^4.0.0", + "jest-get-type": "^29.6.3", + "jest-util": "^29.7.0", + "pretty-format": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-environment-node": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-environment-node/-/jest-environment-node-29.7.0.tgz", + "integrity": "sha512-DOSwCRqXirTOyheM+4d5YZOrWcdu0LNZ87ewUoywbcb2XR4wKgqiG8vNeYwhjFMbEkfju7wx2GYH0P2gevGvFw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/environment": "^29.7.0", + "@jest/fake-timers": "^29.7.0", + "@jest/types": "^29.6.3", + "@types/node": "*", + "jest-mock": "^29.7.0", + "jest-util": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-get-type": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-29.6.3.tgz", + "integrity": "sha512-zrteXnqYxfQh7l5FHyL38jL39di8H8rHoecLH3JNxH3BwOrBsNeabdap5e0I23lD4HHI8W5VFBZqG4Eaq5LNcw==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-haste-map": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-haste-map/-/jest-haste-map-29.7.0.tgz", + "integrity": "sha512-fP8u2pyfqx0K1rGn1R9pyE0/KTn+G7PxktWidOBTqFPLYX0b9ksaMFkhK5vrS3DVun09pckLdlx90QthlW7AmA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/types": "^29.6.3", + "@types/graceful-fs": "^4.1.3", + "@types/node": "*", + "anymatch": "^3.0.3", + "fb-watchman": "^2.0.0", + "graceful-fs": "^4.2.9", + "jest-regex-util": "^29.6.3", + "jest-util": "^29.7.0", + "jest-worker": "^29.7.0", + "micromatch": "^4.0.4", + "walker": "^1.0.8" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "optionalDependencies": { + "fsevents": "^2.3.2" + } + }, + "node_modules/jest-leak-detector": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-leak-detector/-/jest-leak-detector-29.7.0.tgz", + "integrity": "sha512-kYA8IJcSYtST2BY9I+SMC32nDpBT3J2NvWJx8+JCuCdl/CR1I4EKUJROiP8XtCcxqgTTBGJNdbB1A8XRKbTetw==", + "dev": true, + "license": "MIT", + "dependencies": { + "jest-get-type": "^29.6.3", + "pretty-format": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-matcher-utils": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-29.7.0.tgz", + "integrity": "sha512-sBkD+Xi9DtcChsI3L3u0+N0opgPYnCRPtGcQYrgXmR+hmt/fYfWAL0xRXYU8eWOdfuLgBe0YCW3AFtnRLagq/g==", + "dev": true, + "license": "MIT", + "dependencies": { + "chalk": "^4.0.0", + "jest-diff": "^29.7.0", + "jest-get-type": "^29.6.3", + "pretty-format": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-message-util": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-29.7.0.tgz", + "integrity": "sha512-GBEV4GRADeP+qtB2+6u61stea8mGcOT4mCtrYISZwfu9/ISHFJ/5zOMXYbpBE9RsS5+Gb63DW4FgmnKJ79Kf6w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.12.13", + "@jest/types": "^29.6.3", + "@types/stack-utils": "^2.0.0", + "chalk": "^4.0.0", + "graceful-fs": "^4.2.9", + "micromatch": "^4.0.4", + "pretty-format": "^29.7.0", + "slash": "^3.0.0", + "stack-utils": "^2.0.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-mock": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-mock/-/jest-mock-29.7.0.tgz", + "integrity": "sha512-ITOMZn+UkYS4ZFh83xYAOzWStloNzJFO2s8DWrE4lhtGD+AorgnbkiKERe4wQVBydIGPx059g6riW5Btp6Llnw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/types": "^29.6.3", + "@types/node": "*", + "jest-util": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-pnp-resolver": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/jest-pnp-resolver/-/jest-pnp-resolver-1.2.3.tgz", + "integrity": "sha512-+3NpwQEnRoIBtx4fyhblQDPgJI0H1IEIkX7ShLUjPGA7TtUTvI1oiKi3SR4oBR0hQhQR80l4WAe5RrXBwWMA8w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + }, + "peerDependencies": { + "jest-resolve": "*" + }, + "peerDependenciesMeta": { + "jest-resolve": { + "optional": true + } + } + }, + "node_modules/jest-regex-util": { + "version": "29.6.3", + "resolved": "https://registry.npmjs.org/jest-regex-util/-/jest-regex-util-29.6.3.tgz", + "integrity": "sha512-KJJBsRCyyLNWCNBOvZyRDnAIfUiRJ8v+hOBQYGn8gDyF3UegwiP4gwRR3/SDa42g1YbVycTidUF3rKjyLFDWbg==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-resolve": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-resolve/-/jest-resolve-29.7.0.tgz", + "integrity": "sha512-IOVhZSrg+UvVAshDSDtHyFCCBUl/Q3AAJv8iZ6ZjnZ74xzvwuzLXid9IIIPgTnY62SJjfuupMKZsZQRsCvxEgA==", + "dev": true, + "license": "MIT", + "dependencies": { + "chalk": "^4.0.0", + "graceful-fs": "^4.2.9", + "jest-haste-map": "^29.7.0", + "jest-pnp-resolver": "^1.2.2", + "jest-util": "^29.7.0", + "jest-validate": "^29.7.0", + "resolve": "^1.20.0", + "resolve.exports": "^2.0.0", + "slash": "^3.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-resolve-dependencies": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-resolve-dependencies/-/jest-resolve-dependencies-29.7.0.tgz", + "integrity": "sha512-un0zD/6qxJ+S0et7WxeI3H5XSe9lTBBR7bOHCHXkKR6luG5mwDDlIzVQ0V5cZCuoTgEdcdwzTghYkTWfubi+nA==", + "dev": true, + "license": "MIT", + "dependencies": { + "jest-regex-util": "^29.6.3", + "jest-snapshot": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-runner": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-runner/-/jest-runner-29.7.0.tgz", + "integrity": "sha512-fsc4N6cPCAahybGBfTRcq5wFR6fpLznMg47sY5aDpsoejOcVYFb07AHuSnR0liMcPTgBsA3ZJL6kFOjPdoNipQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/console": "^29.7.0", + "@jest/environment": "^29.7.0", + "@jest/test-result": "^29.7.0", + "@jest/transform": "^29.7.0", + "@jest/types": "^29.6.3", + "@types/node": "*", + "chalk": "^4.0.0", + "emittery": "^0.13.1", + "graceful-fs": "^4.2.9", + "jest-docblock": "^29.7.0", + "jest-environment-node": "^29.7.0", + "jest-haste-map": "^29.7.0", + "jest-leak-detector": "^29.7.0", + "jest-message-util": "^29.7.0", + "jest-resolve": "^29.7.0", + "jest-runtime": "^29.7.0", + "jest-util": "^29.7.0", + "jest-watcher": "^29.7.0", + "jest-worker": "^29.7.0", + "p-limit": "^3.1.0", + "source-map-support": "0.5.13" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-runtime": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-runtime/-/jest-runtime-29.7.0.tgz", + "integrity": "sha512-gUnLjgwdGqW7B4LvOIkbKs9WGbn+QLqRQQ9juC6HndeDiezIwhDP+mhMwHWCEcfQ5RUXa6OPnFF8BJh5xegwwQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/environment": "^29.7.0", + "@jest/fake-timers": "^29.7.0", + "@jest/globals": "^29.7.0", + "@jest/source-map": "^29.6.3", + "@jest/test-result": "^29.7.0", + "@jest/transform": "^29.7.0", + "@jest/types": "^29.6.3", + "@types/node": "*", + "chalk": "^4.0.0", + "cjs-module-lexer": "^1.0.0", + "collect-v8-coverage": "^1.0.0", + "glob": "^7.1.3", + "graceful-fs": "^4.2.9", + "jest-haste-map": "^29.7.0", + "jest-message-util": "^29.7.0", + "jest-mock": "^29.7.0", + "jest-regex-util": "^29.6.3", + "jest-resolve": "^29.7.0", + "jest-snapshot": "^29.7.0", + "jest-util": "^29.7.0", + "slash": "^3.0.0", + "strip-bom": "^4.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-snapshot": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-snapshot/-/jest-snapshot-29.7.0.tgz", + "integrity": "sha512-Rm0BMWtxBcioHr1/OX5YCP8Uov4riHvKPknOGs804Zg9JGZgmIBkbtlxJC/7Z4msKYVbIJtfU+tKb8xlYNfdkw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/core": "^7.11.6", + "@babel/generator": "^7.7.2", + "@babel/plugin-syntax-jsx": "^7.7.2", + "@babel/plugin-syntax-typescript": "^7.7.2", + "@babel/types": "^7.3.3", + "@jest/expect-utils": "^29.7.0", + "@jest/transform": "^29.7.0", + "@jest/types": "^29.6.3", + "babel-preset-current-node-syntax": "^1.0.0", + "chalk": "^4.0.0", + "expect": "^29.7.0", + "graceful-fs": "^4.2.9", + "jest-diff": "^29.7.0", + "jest-get-type": "^29.6.3", + "jest-matcher-utils": "^29.7.0", + "jest-message-util": "^29.7.0", + "jest-util": "^29.7.0", + "natural-compare": "^1.4.0", + "pretty-format": "^29.7.0", + "semver": "^7.5.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-snapshot/node_modules/semver": { + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/jest-util": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.7.0.tgz", + "integrity": "sha512-z6EbKajIpqGKU56y5KBUgy1dt1ihhQJgWzUlZHArA/+X2ad7Cb5iF+AK1EWVL/Bo7Rz9uurpqw6SiBCefUbCGA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/types": "^29.6.3", + "@types/node": "*", + "chalk": "^4.0.0", + "ci-info": "^3.2.0", + "graceful-fs": "^4.2.9", + "picomatch": "^2.2.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-validate": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-validate/-/jest-validate-29.7.0.tgz", + "integrity": "sha512-ZB7wHqaRGVw/9hST/OuFUReG7M8vKeq0/J2egIGLdvjHCmYqGARhzXmtgi+gVeZ5uXFF219aOc3Ls2yLg27tkw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/types": "^29.6.3", + "camelcase": "^6.2.0", + "chalk": "^4.0.0", + "jest-get-type": "^29.6.3", + "leven": "^3.1.0", + "pretty-format": "^29.7.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-validate/node_modules/camelcase": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", + "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/jest-watcher": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-watcher/-/jest-watcher-29.7.0.tgz", + "integrity": "sha512-49Fg7WXkU3Vl2h6LbLtMQ/HyB6rXSIX7SqvBLQmssRBGN9I0PNvPmAmCWSOY6SOvrjhI/F7/bGAv9RtnsPA03g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/test-result": "^29.7.0", + "@jest/types": "^29.6.3", + "@types/node": "*", + "ansi-escapes": "^4.2.1", + "chalk": "^4.0.0", + "emittery": "^0.13.1", + "jest-util": "^29.7.0", + "string-length": "^4.0.1" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-worker": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-29.7.0.tgz", + "integrity": "sha512-eIz2msL/EzL9UFTFFx7jBTkeZfku0yUAyZZZmJ93H2TYEiroIx2PQjEXcwYtYl8zXCxb+PAmA2hLIt/6ZEkPHw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*", + "jest-util": "^29.7.0", + "merge-stream": "^2.0.0", + "supports-color": "^8.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-worker/node_modules/supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, + "node_modules/js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/js-yaml": { + "version": "3.14.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", + "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", + "dev": true, + "license": "MIT", + "dependencies": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/js-yaml/node_modules/argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, + "license": "MIT", + "dependencies": { + "sprintf-js": "~1.0.2" + } + }, + "node_modules/jsesc": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.0.2.tgz", + "integrity": "sha512-xKqzzWXDttJuOcawBt4KnKHHIf5oQ/Cxax+0PWFG+DFDgHNAdi+TXECADI+RYiFUMmx8792xsMbbgXj4CwnP4g==", + "dev": true, + "license": "MIT", + "bin": { + "jsesc": "bin/jsesc" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/json-parse-even-better-errors": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz", + "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==", + "dev": true, + "license": "MIT" + }, + "node_modules/json5": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", + "dev": true, + "license": "MIT", + "bin": { + "json5": "lib/cli.js" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/kleur": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz", + "integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/leven": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/leven/-/leven-3.1.0.tgz", + "integrity": "sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/lines-and-columns": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz", + "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==", + "dev": true, + "license": "MIT" + }, + "node_modules/linkify-it": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-5.0.0.tgz", + "integrity": "sha512-5aHCbzQRADcdP+ATqnDuhhJ/MRIqDkZX5pyjFHRRysS8vZ5AbqGEoFIb6pYHPZ+L/OC2Lc+xT8uHVVR5CAK/wQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "uc.micro": "^2.0.0" + } + }, + "node_modules/locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-locate": "^4.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/lodash.memoize": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz", + "integrity": "sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag==", + "dev": true, + "license": "MIT" + }, + "node_modules/lru-cache": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", + "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", + "dev": true, + "license": "ISC", + "dependencies": { + "yallist": "^3.0.2" + } + }, + "node_modules/lunr": { + "version": "2.3.9", + "resolved": "https://registry.npmjs.org/lunr/-/lunr-2.3.9.tgz", + "integrity": "sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow==", + "dev": true, + "license": "MIT" + }, + "node_modules/make-dir": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz", + "integrity": "sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==", + "dev": true, + "license": "MIT", + "dependencies": { + "semver": "^7.5.3" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/make-dir/node_modules/semver": { + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/make-error": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", + "dev": true + }, + "node_modules/makeerror": { + "version": "1.0.12", + "resolved": "https://registry.npmjs.org/makeerror/-/makeerror-1.0.12.tgz", + "integrity": "sha512-JmqCvUhmt43madlpFzG4BQzG2Z3m6tvQDNKdClZnO3VbIudJYmxsT0FNJMeiB2+JTSlTQTSbU8QdesVmwJcmLg==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "tmpl": "1.0.5" + } + }, + "node_modules/markdown-it": { + "version": "14.1.0", + "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-14.1.0.tgz", + "integrity": "sha512-a54IwgWPaeBCAAsv13YgmALOF1elABB08FxO9i+r4VFk5Vl4pKokRPeX8u5TCgSsPi6ec1otfLjdOpVcgbpshg==", + "dev": true, + "license": "MIT", + "dependencies": { + "argparse": "^2.0.1", + "entities": "^4.4.0", + "linkify-it": "^5.0.0", + "mdurl": "^2.0.0", + "punycode.js": "^2.3.1", + "uc.micro": "^2.1.0" + }, + "bin": { + "markdown-it": "bin/markdown-it.mjs" + } + }, + "node_modules/mdast-util-to-hast": { + "version": "13.2.0", + "resolved": "https://registry.npmjs.org/mdast-util-to-hast/-/mdast-util-to-hast-13.2.0.tgz", + "integrity": "sha512-QGYKEuUsYT9ykKBCMOEDLsU5JRObWQusAolFMeko/tYPufNkRffBAQjIE+99jbA87xv6FgmjLtwjh9wBWajwAA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.0", + "@types/mdast": "^4.0.0", + "@ungap/structured-clone": "^1.0.0", "devlop": "^1.0.0", "micromark-util-sanitize-uri": "^2.0.0", "trim-lines": "^3.0.0", @@ -329,207 +3506,854 @@ "vfile": "^6.0.0" }, "funding": { - "type": "opencollective", - "url": "https://opencollective.com/unified" + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdurl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-2.0.0.tgz", + "integrity": "sha512-Lf+9+2r+Tdp5wXDXC4PcIBjTDtq4UKjCPMQhKIuzpJNW0b96kVqSwW0bT7FhRSfmAiFYgP+SCRvdrDozfh0U5w==", + "dev": true, + "license": "MIT" + }, + "node_modules/merge-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", + "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", + "dev": true, + "license": "MIT" + }, + "node_modules/micromark-util-character": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.0.tgz", + "integrity": "sha512-KvOVV+X1yLBfs9dCBSopq/+G1PcgT3lAK07mC4BzXi5E7ahzMAF8oIupDDJ6mievI6F+lAATkbQQlQixJfT3aQ==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-util-encode": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/micromark-util-encode/-/micromark-util-encode-2.0.0.tgz", + "integrity": "sha512-pS+ROfCXAGLWCOc8egcBvT0kf27GoWMqtdarNfDcjb6YLuV5cM3ioG45Ys2qOVqeqSbjaKg72vU+Wby3eddPsA==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT" + }, + "node_modules/micromark-util-sanitize-uri": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/micromark-util-sanitize-uri/-/micromark-util-sanitize-uri-2.0.0.tgz", + "integrity": "sha512-WhYv5UEcZrbAtlsnPuChHUAsu/iBPOVaEVsntLBIdpibO0ddy8OzavZz3iL2xVvBZOpolujSliP65Kq0/7KIYw==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-character": "^2.0.0", + "micromark-util-encode": "^2.0.0", + "micromark-util-symbol": "^2.0.0" + } + }, + "node_modules/micromark-util-symbol": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.0.tgz", + "integrity": "sha512-8JZt9ElZ5kyTnO94muPxIGS8oyElRJaiJO8EzV6ZSyGQ1Is8xwl4Q45qU5UOg+bGH4AikWziz0iN4sFLWs8PGw==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT" + }, + "node_modules/micromark-util-types": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.0.tgz", + "integrity": "sha512-oNh6S2WMHWRZrmutsRmDDfkzKtxF+bc2VxLC9dvtrDIRFln627VsFP6fLMgTryGDljgLPjkrzQSDcPrjPyDJ5w==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT" + }, + "node_modules/micromatch": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", + "dev": true, + "license": "MIT", + "dependencies": { + "braces": "^3.0.3", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=8.6" + } + }, + "node_modules/mimic-fn": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true, + "license": "MIT" + }, + "node_modules/natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", + "dev": true, + "license": "MIT" + }, + "node_modules/node-int64": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz", + "integrity": "sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw==", + "dev": true, + "license": "MIT" + }, + "node_modules/node-releases": { + "version": "2.0.18", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.18.tgz", + "integrity": "sha512-d9VeXT4SJ7ZeOqGX6R5EM022wpL+eWPooLI+5UpWn2jCT1aosUQEhQP214x33Wkwx3JQMvIm+tIoVOdodFS40g==", + "dev": true, + "license": "MIT" + }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/npm-run-path": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz", + "integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==", + "dev": true, + "license": "MIT", + "dependencies": { + "path-key": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dev": true, + "license": "ISC", + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/onetime": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", + "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", + "dev": true, + "license": "MIT", + "dependencies": { + "mimic-fn": "^2.1.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/oniguruma-to-js": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/oniguruma-to-js/-/oniguruma-to-js-0.4.3.tgz", + "integrity": "sha512-X0jWUcAlxORhOqqBREgPMgnshB7ZGYszBNspP+tS9hPD3l13CdaXcHbgImoHUHlrvGx/7AvFEkTRhAGYh+jzjQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "regex": "^4.3.2" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + } + }, + "node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-limit": "^2.2.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/p-locate/node_modules/p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-try": "^2.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/parse-json": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz", + "integrity": "sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.0.0", + "error-ex": "^1.3.1", + "json-parse-even-better-errors": "^2.3.0", + "lines-and-columns": "^1.1.6" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "dev": true, + "license": "MIT" + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "dev": true, + "license": "ISC" + }, + "node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" } }, - "node_modules/mdurl": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-2.0.0.tgz", - "integrity": "sha512-Lf+9+2r+Tdp5wXDXC4PcIBjTDtq4UKjCPMQhKIuzpJNW0b96kVqSwW0bT7FhRSfmAiFYgP+SCRvdrDozfh0U5w==", + "node_modules/pirates": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/pirates/-/pirates-4.0.6.tgz", + "integrity": "sha512-saLsH7WeYYPiD25LDuLRRY/i+6HaPYr6G1OUlN39otzkSTxKnubR9RTxS3/Kk50s1g2JTgFwWQDQyplC5/SHZg==", "dev": true, - "license": "MIT" + "license": "MIT", + "engines": { + "node": ">= 6" + } }, - "node_modules/micromark-util-character": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.0.tgz", - "integrity": "sha512-KvOVV+X1yLBfs9dCBSopq/+G1PcgT3lAK07mC4BzXi5E7ahzMAF8oIupDDJ6mievI6F+lAATkbQQlQixJfT3aQ==", + "node_modules/pkg-dir": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", + "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", "dev": true, - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], "license": "MIT", "dependencies": { - "micromark-util-symbol": "^2.0.0", - "micromark-util-types": "^2.0.0" + "find-up": "^4.0.0" + }, + "engines": { + "node": ">=8" } }, - "node_modules/micromark-util-encode": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-encode/-/micromark-util-encode-2.0.0.tgz", - "integrity": "sha512-pS+ROfCXAGLWCOc8egcBvT0kf27GoWMqtdarNfDcjb6YLuV5cM3ioG45Ys2qOVqeqSbjaKg72vU+Wby3eddPsA==", + "node_modules/pretty-format": { + "version": "29.7.0", + "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.7.0.tgz", + "integrity": "sha512-Pdlw/oPxN+aXdmM9R00JVC9WVFoCLTKJvDVLgmJ+qAffBMxsV85l/Lu7sNx4zSzPyoL2euImuEwHhOXdEgNFZQ==", "dev": true, - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], - "license": "MIT" + "license": "MIT", + "dependencies": { + "@jest/schemas": "^29.6.3", + "ansi-styles": "^5.0.0", + "react-is": "^18.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } }, - "node_modules/micromark-util-sanitize-uri": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-sanitize-uri/-/micromark-util-sanitize-uri-2.0.0.tgz", - "integrity": "sha512-WhYv5UEcZrbAtlsnPuChHUAsu/iBPOVaEVsntLBIdpibO0ddy8OzavZz3iL2xVvBZOpolujSliP65Kq0/7KIYw==", + "node_modules/pretty-format/node_modules/ansi-styles": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", + "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/prompts": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.4.2.tgz", + "integrity": "sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q==", "dev": true, - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], "license": "MIT", "dependencies": { - "micromark-util-character": "^2.0.0", - "micromark-util-encode": "^2.0.0", - "micromark-util-symbol": "^2.0.0" + "kleur": "^3.0.3", + "sisteransi": "^1.0.5" + }, + "engines": { + "node": ">= 6" } }, - "node_modules/micromark-util-symbol": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.0.tgz", - "integrity": "sha512-8JZt9ElZ5kyTnO94muPxIGS8oyElRJaiJO8EzV6ZSyGQ1Is8xwl4Q45qU5UOg+bGH4AikWziz0iN4sFLWs8PGw==", + "node_modules/property-information": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/property-information/-/property-information-6.5.0.tgz", + "integrity": "sha512-PgTgs/BlvHxOu8QuEN7wi5A0OmXaBcHpmCSTehcs6Uuu9IkDIEo13Hy7n898RHfrQ49vKCoGeWZSaAK01nwVig==", + "dev": true, + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/punycode.js": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode.js/-/punycode.js-2.3.1.tgz", + "integrity": "sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/pure-rand": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/pure-rand/-/pure-rand-6.1.0.tgz", + "integrity": "sha512-bVWawvoZoBYpp6yIoQtQXHZjmz35RSVHnUOTefl8Vcjr8snTPY1wnpSPMWekcFwbxI6gtmT7rSYPFvz71ldiOA==", "dev": true, "funding": [ { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" + "type": "individual", + "url": "https://github.com/sponsors/dubzzz" }, { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" + "type": "opencollective", + "url": "https://opencollective.com/fast-check" } ], "license": "MIT" }, - "node_modules/micromark-util-types": { + "node_modules/react-is": { + "version": "18.3.1", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.3.1.tgz", + "integrity": "sha512-/LLMVyas0ljjAtoYiPqYiL8VWXzUUdThrmU5+n20DZv+a+ClRoevUzw5JxU+Ieh5/c87ytoTBV9G1FiKfNJdmg==", + "dev": true, + "license": "MIT" + }, + "node_modules/regex": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/regex/-/regex-4.3.3.tgz", + "integrity": "sha512-r/AadFO7owAq1QJVeZ/nq9jNS1vyZt+6t1p/E59B56Rn2GCya+gr1KSyOzNL/er+r+B7phv5jG2xU2Nz1YkmJg==", + "dev": true, + "license": "MIT" + }, + "node_modules/require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/resolve": { + "version": "1.22.8", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.8.tgz", + "integrity": "sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-core-module": "^2.13.0", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + }, + "bin": { + "resolve": "bin/resolve" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/resolve-cwd": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/resolve-cwd/-/resolve-cwd-3.0.0.tgz", + "integrity": "sha512-OrZaX2Mb+rJCpH/6CpSqt9xFVpN++x01XnN2ie9g6P5/3xelLAkXWVADpdz1IHD/KFfEXyE6V0U01OQ3UO2rEg==", + "dev": true, + "license": "MIT", + "dependencies": { + "resolve-from": "^5.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/resolve-from": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", + "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/resolve.exports": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/resolve.exports/-/resolve.exports-2.0.2.tgz", + "integrity": "sha512-X2UW6Nw3n/aMgDVy+0rSqgHlv39WZAlZrXCdnbyEiKm17DSqHX4MmQMaST3FbeWR5FTuRcUwYAziZajji0Y7mg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + } + }, + "node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/shebang-command": { "version": "2.0.0", - "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.0.tgz", - "integrity": "sha512-oNh6S2WMHWRZrmutsRmDDfkzKtxF+bc2VxLC9dvtrDIRFln627VsFP6fLMgTryGDljgLPjkrzQSDcPrjPyDJ5w==", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "license": "MIT", + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/shiki": { + "version": "1.22.0", + "resolved": "https://registry.npmjs.org/shiki/-/shiki-1.22.0.tgz", + "integrity": "sha512-/t5LlhNs+UOKQCYBtl5ZsH/Vclz73GIqT2yQsCBygr8L/ppTdmpL4w3kPLoZJbMKVWtoG77Ue1feOjZfDxvMkw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@shikijs/core": "1.22.0", + "@shikijs/engine-javascript": "1.22.0", + "@shikijs/engine-oniguruma": "1.22.0", + "@shikijs/types": "1.22.0", + "@shikijs/vscode-textmate": "^9.3.0", + "@types/hast": "^3.0.4" + } + }, + "node_modules/signal-exit": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/sisteransi": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.5.tgz", + "integrity": "sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==", "dev": true, - "funding": [ - { - "type": "GitHub Sponsors", - "url": "https://github.com/sponsors/unifiedjs" - }, - { - "type": "OpenCollective", - "url": "https://opencollective.com/unified" - } - ], "license": "MIT" }, - "node_modules/minimatch": { - "version": "9.0.5", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", - "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "node_modules/slash": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/source-map-support": { + "version": "0.5.13", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.13.tgz", + "integrity": "sha512-SHSKFHadjVA5oR4PPqhtAVdcBWwRYVd6g6cAXnIbRiIwc2EhPrTuKUBdSLvlEKyIP3GCf89fltvcZiP9MMFA1w==", + "dev": true, + "license": "MIT", + "dependencies": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, + "node_modules/space-separated-tokens": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/space-separated-tokens/-/space-separated-tokens-2.0.2.tgz", + "integrity": "sha512-PEGlAwrG8yXGXRjW32fGbg66JAlOAwbObuqVoJpv/mRgoWDQfgH1wDPvtzWyUSNAXBGSk8h755YDbbcEy3SH2Q==", + "dev": true, + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==", + "dev": true, + "license": "BSD-3-Clause" + }, + "node_modules/stack-utils": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/stack-utils/-/stack-utils-2.0.6.tgz", + "integrity": "sha512-XlkWvfIm6RmsWtNJx+uqtKLS8eqFbxUg0ZzLXqY0caEy9l7hruX8IpiDnjsLavoBgqCCR71TqWO8MaXYheJ3RQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "escape-string-regexp": "^2.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/string-length": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/string-length/-/string-length-4.0.2.tgz", + "integrity": "sha512-+l6rNN5fYHNhZZy41RXsYptCjA2Igmq4EG7kZAYFQI1E1VTXarr6ZPXBg6eq7Y6eK4FEhY6AJlyuFIb/v/S0VQ==", "dev": true, - "license": "ISC", + "license": "MIT", "dependencies": { - "brace-expansion": "^2.0.1" + "char-regex": "^1.0.2", + "strip-ansi": "^6.0.0" }, "engines": { - "node": ">=16 || 14 >=14.17" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" + "node": ">=10" } }, - "node_modules/oniguruma-to-js": { - "version": "0.4.3", - "resolved": "https://registry.npmjs.org/oniguruma-to-js/-/oniguruma-to-js-0.4.3.tgz", - "integrity": "sha512-X0jWUcAlxORhOqqBREgPMgnshB7ZGYszBNspP+tS9hPD3l13CdaXcHbgImoHUHlrvGx/7AvFEkTRhAGYh+jzjQ==", + "node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", "dev": true, "license": "MIT", "dependencies": { - "regex": "^4.3.2" + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" }, - "funding": { - "url": "https://github.com/sponsors/antfu" + "engines": { + "node": ">=8" } }, - "node_modules/property-information": { - "version": "6.5.0", - "resolved": "https://registry.npmjs.org/property-information/-/property-information-6.5.0.tgz", - "integrity": "sha512-PgTgs/BlvHxOu8QuEN7wi5A0OmXaBcHpmCSTehcs6Uuu9IkDIEo13Hy7n898RHfrQ49vKCoGeWZSaAK01nwVig==", + "node_modules/stringify-entities": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/stringify-entities/-/stringify-entities-4.0.4.tgz", + "integrity": "sha512-IwfBptatlO+QCJUo19AqvrPNqlVMpW9YEL2LIVY+Rpv2qsjCGxaDLNRgeGsQWJhfItebuJhsGSLjaBbNSQ+ieg==", "dev": true, "license": "MIT", + "dependencies": { + "character-entities-html4": "^2.0.0", + "character-entities-legacy": "^3.0.0" + }, "funding": { "type": "github", "url": "https://github.com/sponsors/wooorm" } }, - "node_modules/punycode.js": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/punycode.js/-/punycode.js-2.3.1.tgz", - "integrity": "sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA==", + "node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-bom": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-4.0.0.tgz", + "integrity": "sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-final-newline": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz", + "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==", "dev": true, "license": "MIT", "engines": { "node": ">=6" } }, - "node_modules/regex": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/regex/-/regex-4.3.3.tgz", - "integrity": "sha512-r/AadFO7owAq1QJVeZ/nq9jNS1vyZt+6t1p/E59B56Rn2GCya+gr1KSyOzNL/er+r+B7phv5jG2xU2Nz1YkmJg==", + "node_modules/strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", "dev": true, - "license": "MIT" + "license": "MIT", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } }, - "node_modules/shiki": { - "version": "1.22.0", - "resolved": "https://registry.npmjs.org/shiki/-/shiki-1.22.0.tgz", - "integrity": "sha512-/t5LlhNs+UOKQCYBtl5ZsH/Vclz73GIqT2yQsCBygr8L/ppTdmpL4w3kPLoZJbMKVWtoG77Ue1feOjZfDxvMkw==", + "node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "dev": true, "license": "MIT", "dependencies": { - "@shikijs/core": "1.22.0", - "@shikijs/engine-javascript": "1.22.0", - "@shikijs/engine-oniguruma": "1.22.0", - "@shikijs/types": "1.22.0", - "@shikijs/vscode-textmate": "^9.3.0", - "@types/hast": "^3.0.4" + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" } }, - "node_modules/space-separated-tokens": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/space-separated-tokens/-/space-separated-tokens-2.0.2.tgz", - "integrity": "sha512-PEGlAwrG8yXGXRjW32fGbg66JAlOAwbObuqVoJpv/mRgoWDQfgH1wDPvtzWyUSNAXBGSk8h755YDbbcEy3SH2Q==", + "node_modules/supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", "dev": true, "license": "MIT", + "engines": { + "node": ">= 0.4" + }, "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" + "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/stringify-entities": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/stringify-entities/-/stringify-entities-4.0.4.tgz", - "integrity": "sha512-IwfBptatlO+QCJUo19AqvrPNqlVMpW9YEL2LIVY+Rpv2qsjCGxaDLNRgeGsQWJhfItebuJhsGSLjaBbNSQ+ieg==", + "node_modules/test-exclude": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz", + "integrity": "sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==", + "dev": true, + "license": "ISC", + "dependencies": { + "@istanbuljs/schema": "^0.1.2", + "glob": "^7.1.4", + "minimatch": "^3.0.4" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/test-exclude/node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "license": "MIT", "dependencies": { - "character-entities-html4": "^2.0.0", - "character-entities-legacy": "^3.0.0" + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/test-exclude/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/wooorm" + "engines": { + "node": "*" + } + }, + "node_modules/tmpl": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.5.tgz", + "integrity": "sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw==", + "dev": true, + "license": "BSD-3-Clause" + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" } }, "node_modules/trim-lines": { @@ -543,6 +4367,135 @@ "url": "https://github.com/sponsors/wooorm" } }, + "node_modules/ts-jest": { + "version": "29.2.5", + "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.2.5.tgz", + "integrity": "sha512-KD8zB2aAZrcKIdGk4OwpJggeLcH1FgrICqDSROWqlnJXGCXK4Mn6FcdK2B6670Xr73lHMG1kHw8R87A0ecZ+vA==", + "dev": true, + "license": "MIT", + "dependencies": { + "bs-logger": "^0.2.6", + "ejs": "^3.1.10", + "fast-json-stable-stringify": "^2.1.0", + "jest-util": "^29.0.0", + "json5": "^2.2.3", + "lodash.memoize": "^4.1.2", + "make-error": "^1.3.6", + "semver": "^7.6.3", + "yargs-parser": "^21.1.1" + }, + "bin": { + "ts-jest": "cli.js" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || ^18.0.0 || >=20.0.0" + }, + "peerDependencies": { + "@babel/core": ">=7.0.0-beta.0 <8", + "@jest/transform": "^29.0.0", + "@jest/types": "^29.0.0", + "babel-jest": "^29.0.0", + "jest": "^29.0.0", + "typescript": ">=4.3 <6" + }, + "peerDependenciesMeta": { + "@babel/core": { + "optional": true + }, + "@jest/transform": { + "optional": true + }, + "@jest/types": { + "optional": true + }, + "babel-jest": { + "optional": true + }, + "esbuild": { + "optional": true + } + } + }, + "node_modules/ts-jest/node_modules/semver": { + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/ts-node": { + "version": "10.9.2", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", + "integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@cspotcode/source-map-support": "^0.8.0", + "@tsconfig/node10": "^1.0.7", + "@tsconfig/node12": "^1.0.7", + "@tsconfig/node14": "^1.0.0", + "@tsconfig/node16": "^1.0.2", + "acorn": "^8.4.1", + "acorn-walk": "^8.1.1", + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "v8-compile-cache-lib": "^3.0.1", + "yn": "3.1.1" + }, + "bin": { + "ts-node": "dist/bin.js", + "ts-node-cwd": "dist/bin-cwd.js", + "ts-node-esm": "dist/bin-esm.js", + "ts-node-script": "dist/bin-script.js", + "ts-node-transpile-only": "dist/bin-transpile.js", + "ts-script": "dist/bin-script-deprecated.js" + }, + "peerDependencies": { + "@swc/core": ">=1.2.50", + "@swc/wasm": ">=1.2.50", + "@types/node": "*", + "typescript": ">=2.7" + }, + "peerDependenciesMeta": { + "@swc/core": { + "optional": true + }, + "@swc/wasm": { + "optional": true + } + } + }, + "node_modules/type-detect": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/type-fest": { + "version": "0.21.3", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.21.3.tgz", + "integrity": "sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==", + "dev": true, + "license": "(MIT OR CC0-1.0)", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/typedoc": { "version": "0.26.10", "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.26.10.tgz", @@ -667,6 +4620,69 @@ "url": "https://opencollective.com/unified" } }, + "node_modules/update-browserslist-db": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.1.1.tgz", + "integrity": "sha512-R8UzCaa9Az+38REPiJ1tXlImTJXlVfgHZsglwBD/k6nj76ctsH1E3q4doGrukiLQd3sGQYu56r5+lo5r94l29A==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "escalade": "^3.2.0", + "picocolors": "^1.1.0" + }, + "bin": { + "update-browserslist-db": "cli.js" + }, + "peerDependencies": { + "browserslist": ">= 4.21.0" + } + }, + "node_modules/v8-compile-cache-lib": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", + "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", + "dev": true + }, + "node_modules/v8-to-istanbul": { + "version": "9.3.0", + "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.3.0.tgz", + "integrity": "sha512-kiGUalWN+rgBJ/1OHZsBtU4rXZOfj/7rKQxULKlIzwzQSvMJUUNgPwJEEh7gU6xEVxC0ahoOBvN2YI8GH6FNgA==", + "dev": true, + "license": "ISC", + "dependencies": { + "@jridgewell/trace-mapping": "^0.3.12", + "@types/istanbul-lib-coverage": "^2.0.1", + "convert-source-map": "^2.0.0" + }, + "engines": { + "node": ">=10.12.0" + } + }, + "node_modules/v8-to-istanbul/node_modules/@jridgewell/trace-mapping": { + "version": "0.3.25", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz", + "integrity": "sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, "node_modules/vfile": { "version": "6.0.3", "resolved": "https://registry.npmjs.org/vfile/-/vfile-6.0.3.tgz", @@ -697,6 +4713,88 @@ "url": "https://opencollective.com/unified" } }, + "node_modules/walker": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/walker/-/walker-1.0.8.tgz", + "integrity": "sha512-ts/8E8l5b7kY0vlWLewOkDXMmPdLcVV4GmOQLyxuSswIJsweeFZtAsMF7k1Nszz+TYBQrlYRmzOnr398y1JemQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "makeerror": "1.0.12" + } + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "license": "ISC", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/write-file-atomic": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-4.0.2.tgz", + "integrity": "sha512-7KxauUdBmSdWnmpaGFg+ppNjKF8uNLry8LyzjauQDOVONfFLNKrKvQOxZ/VuTIcS/gge/YNahf5RIIQWTSarlg==", + "dev": true, + "license": "ISC", + "dependencies": { + "imurmurhash": "^0.1.4", + "signal-exit": "^3.0.7" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + } + }, + "node_modules/y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=10" + } + }, + "node_modules/yallist": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", + "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", + "dev": true, + "license": "ISC" + }, "node_modules/yaml": { "version": "2.6.0", "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.6.0.tgz", @@ -710,6 +4808,57 @@ "node": ">= 14" } }, + "node_modules/yargs": { + "version": "17.7.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", + "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", + "dev": true, + "license": "MIT", + "dependencies": { + "cliui": "^8.0.1", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.3", + "y18n": "^5.0.5", + "yargs-parser": "^21.1.1" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/yargs-parser": { + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/zwitch": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/zwitch/-/zwitch-2.0.4.tgz", diff --git a/package.json b/package.json index fba8ce2..f35974a 100644 --- a/package.json +++ b/package.json @@ -1,23 +1,25 @@ { - "name": "pokerjs", + "name": "casinojs", "version": "0.1.0-alpha", - "description": "A Poker Js Library.", - "main": "dist/index.js", - "module": "dist/index.mjs", + "description": "A Casino Js Library.", + "main": "dist/cjs/index.js", + "module": "dist/esm/index.js", + "type": "module", "directories": { "doc": "docs" }, "scripts": { - "build": "tsc", - "test": "jest", - "docify": "typedoc --entryPointStrategy expand src --out docs/site", - "start": "node dist/index.js" + "build": "tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json", + "test": "jest --coverage", + "docify": "typedoc --entryPointStrategy expand src --out docs/site" }, "repository": { "type": "git", - "url": "git+https://github.com/astitvsingh/pokerjs.git" + "url": "git+https://github.com/astitvsingh/CasinoJs.git" }, "keywords": [ + "casinojs", + "casino", "pokerjs", "poker", "lib" @@ -25,13 +27,22 @@ "author": "Astitv Singh ", "license": "SEE LICENSE IN LICENSE", "bugs": { - "url": "https://github.com/astitvsingh/pokerjs/issues" + "url": "https://github.com/astitvsingh/CasinoJs/issues" }, - "homepage": "https://github.com/astitvsingh/pokerjs#readme", + "homepage": "https://github.com/astitvsingh/CasinoJs#readme", "devDependencies": { "@types/events": "^3.0.3", + "@types/jest": "^29.5.14", "@types/node": "^22.7.6", + "jest": "^29.7.0", + "ts-jest": "^29.2.5", + "ts-node": "^10.9.2", "typedoc": "^0.26.10", "typescript": "^5.6.3" - } + }, + "files": [ + "dist", + "docs", + "README.md" + ] } diff --git a/src/enums/events/casino/index.ts b/src/enums/events/casino/index.ts new file mode 100644 index 0000000..fc48448 --- /dev/null +++ b/src/enums/events/casino/index.ts @@ -0,0 +1,57 @@ +//@collapse + +/** + * @enum {string} `CasinoEvents` + * Defines the events emitted by the `Casino` class for mutable operations. + * Events are triggered only for state-changing actions like creation, additions, updates, and deletions. + * + * @example + * ```typescript + * const eventName = CasinoEvents.ROOM_CREATED; + * console.log(eventName); + * // Output: "Casino:PokerRoomCreated" + * ``` + */ +enum CasinoEvents { + /** + * `ROOM_CREATED` - Emitted when a new room is created and added to the casino's list of managed rooms. + * + * #### Purpose + * Notifies listeners when a new poker room has been successfully created and added to the Casino’s managed list. + */ + ROOM_CREATED = "Casino:PokerRoomCreated", + + /** + * `ROOM_ADDED` - Emitted when a single room is added to the casino's list of managed rooms. + * + * #### Purpose + * Allows listeners to respond when a new room is introduced into the Casino’s list of available rooms. + */ + ROOM_ADDED = "Casino:PokerRoomAdded", + + /** + * `ROOM_UPDATED` - Emitted when an existing room in the casino is modified. + * + * #### Purpose + * Notifies listeners when a room’s configuration or attributes (e.g., blinds, player limits) have been updated. + */ + ROOM_UPDATED = "Casino:PokerRoomUpdated", + + /** + * `ROOM_DELETED` - Emitted when an existing room is removed from the casino's list of managed rooms. + * + * #### Purpose + * Enables clean-up or resource reallocation processes by notifying listeners when a room is removed from the Casino. + */ + ROOM_DELETED = "Casino:PokerRoomDeleted", + + /** + * `ROOMS_SET` - Emitted when the casino’s managed list of rooms is set to a new batch of rooms. + * + * #### Purpose + * Notifies listeners when the Casino’s full list of rooms has been reset or replaced with a new set of rooms. + */ + ROOMS_SET = "Casino:PokerRoomsSet", +} + +export { CasinoEvents }; diff --git a/src/enums/events/deck/index.ts b/src/enums/events/deck/index.ts new file mode 100644 index 0000000..62b2771 --- /dev/null +++ b/src/enums/events/deck/index.ts @@ -0,0 +1,45 @@ +//@collapse + +/** + * @enum `DeckEvents` + * + * Defines the events associated with a player's seat in a poker game. These events help manage seat availability + * and player actions related to occupying or vacating seats at a poker table. + * + * #### Purpose + * The `DeckEvents` enum is designed to provide a standardized reference for seat-related events in the game. + * It simplifies the handling of seat states, ensuring seat occupancy and vacancy can be tracked and updated + * accurately within the game flow. + * + * #### Events Overview + * The `DeckEvents` includes the following events: + * - **INITIALIZED**: Indicates that the seat has been initialized and is ready for occupancy. + * - **OCCUPIED**: Indicates a seat has been occupied by a player. + * - **VACATED**: Indicates a seat has been vacated by a player. + * + * #### Usage + * This enum standardizes the handling of seat events, making it easier to manage player movements at the table and + * ensuring compatibility with various game modules and event listeners. + * + * @example + * ```typescript + * const seatEvent: DeckEvents = DeckEvents.OCCUPIED; + * console.log(seatEvent); + * // Console Output: "Deck:Occupied" + * ``` + */ +enum DeckEvents { + /** + * Indicates that the seat has been initialized and is ready for occupancy. + * + * @example + * ```typescript + * const seatEvent: DeckEvents = DeckEvents.INITIALIZED; + * console.log(seatEvent); + * // Console Output: "Deck:Initialized" + * ``` + */ + INITIALIZED = "Deck:Initialized", +} + +export { DeckEvents }; diff --git a/src/enums/events/index.ts b/src/enums/events/index.ts new file mode 100644 index 0000000..2ec9dad --- /dev/null +++ b/src/enums/events/index.ts @@ -0,0 +1,23 @@ +//@collapse + +/** + * @module `EventsEnumModule` + * Centralized export for all poker-related enums. + * This module gathers and exports enums for `Rank` and `Suit`, + * which represent the ranks and suits of playing cards in poker. + * + * By centralizing these enums, other modules can import them easily + * for consistent use across the library. + * + * @example + * // Import all enums from the centralized module + * import { CasinoEvents, CasinoEventsEnumModule } from './enums'; + */ +export * as CasinoEventsEnumModule from "./casino"; +export * from "./casino"; +export * as DeckEventsEnumModule from "./deck"; +export * from "./deck"; +export * as PokerSeatEventsEnumModule from "./pokerSeat"; +export * from "./pokerSeat"; +export * as PokerTableEventsEnumModule from "./pokerTable"; +export * from "./pokerTable"; diff --git a/src/enums/events/pokerGame/index.ts b/src/enums/events/pokerGame/index.ts new file mode 100644 index 0000000..96064d3 --- /dev/null +++ b/src/enums/events/pokerGame/index.ts @@ -0,0 +1,45 @@ +//@collapse + +/** + * @enum `PokerGameEvents` + * + * Defines the events associated with a player's seat in a poker game. These events help manage seat availability + * and player actions related to occupying or vacating seats at a poker table. + * + * #### Purpose + * The `PokerGameEvents` enum is designed to provide a standardized reference for seat-related events in the game. + * It simplifies the handling of seat states, ensuring seat occupancy and vacancy can be tracked and updated + * accurately within the game flow. + * + * #### Events Overview + * The `PokerGameEvents` includes the following events: + * - **INITIALIZED**: Indicates that the seat has been initialized and is ready for occupancy. + * - **OCCUPIED**: Indicates a seat has been occupied by a player. + * - **VACATED**: Indicates a seat has been vacated by a player. + * + * #### Usage + * This enum standardizes the handling of seat events, making it easier to manage player movements at the table and + * ensuring compatibility with various game modules and event listeners. + * + * @example + * ```typescript + * const seatEvent: PokerGameEvents = PokerGameEvents.OCCUPIED; + * console.log(seatEvent); + * // Console Output: "PokerGame:Occupied" + * ``` + */ +enum PokerGameEvents { + /** + * Indicates that the seat has been initialized and is ready for occupancy. + * + * @example + * ```typescript + * const seatEvent: PokerGameEvents = PokerGameEvents.INITIALIZED; + * console.log(seatEvent); + * // Console Output: "PokerGame:Initialized" + * ``` + */ + INITIALIZED = "PokerGame:Initialized", +} + +export { PokerGameEvents }; diff --git a/src/enums/events/pokerPhase/index.ts b/src/enums/events/pokerPhase/index.ts new file mode 100644 index 0000000..24dfb5c --- /dev/null +++ b/src/enums/events/pokerPhase/index.ts @@ -0,0 +1,45 @@ +//@collapse + +/** + * @enum `PokerPhaseEvents` + * + * Defines the events associated with a player's seat in a poker game. These events help manage seat availability + * and player actions related to occupying or vacating seats at a poker table. + * + * #### Purpose + * The `PokerPhaseEvents` enum is designed to provide a standardized reference for seat-related events in the game. + * It simplifies the handling of seat states, ensuring seat occupancy and vacancy can be tracked and updated + * accurately within the game flow. + * + * #### Events Overview + * The `PokerPhaseEvents` includes the following events: + * - **INITIALIZED**: Indicates that the seat has been initialized and is ready for occupancy. + * - **OCCUPIED**: Indicates a seat has been occupied by a player. + * - **VACATED**: Indicates a seat has been vacated by a player. + * + * #### Usage + * This enum standardizes the handling of seat events, making it easier to manage player movements at the table and + * ensuring compatibility with various game modules and event listeners. + * + * @example + * ```typescript + * const seatEvent: PokerPhaseEvents = PokerPhaseEvents.OCCUPIED; + * console.log(seatEvent); + * // Console Output: "PokerPhase:Occupied" + * ``` + */ +enum PokerPhaseEvents { + /** + * Indicates that the seat has been initialized and is ready for occupancy. + * + * @example + * ```typescript + * const seatEvent: PokerPhaseEvents = PokerPhaseEvents.INITIALIZED; + * console.log(seatEvent); + * // Console Output: "PokerPhase:Initialized" + * ``` + */ + INITIALIZED = "PokerPhase:Initialized", +} + +export { PokerPhaseEvents }; diff --git a/src/enums/events/pokerPlayer/index.ts b/src/enums/events/pokerPlayer/index.ts new file mode 100644 index 0000000..347043a --- /dev/null +++ b/src/enums/events/pokerPlayer/index.ts @@ -0,0 +1,45 @@ +//@collapse + +/** + * @enum `PokerPlayerEvents` + * + * Defines the events associated with a player's seat in a poker game. These events help manage seat availability + * and player actions related to occupying or vacating seats at a poker table. + * + * #### Purpose + * The `PokerPlayerEvents` enum is designed to provide a standardized reference for seat-related events in the game. + * It simplifies the handling of seat states, ensuring seat occupancy and vacancy can be tracked and updated + * accurately within the game flow. + * + * #### Events Overview + * The `PokerPlayerEvents` includes the following events: + * - **INITIALIZED**: Indicates that the seat has been initialized and is ready for occupancy. + * - **OCCUPIED**: Indicates a seat has been occupied by a player. + * - **VACATED**: Indicates a seat has been vacated by a player. + * + * #### Usage + * This enum standardizes the handling of seat events, making it easier to manage player movements at the table and + * ensuring compatibility with various game modules and event listeners. + * + * @example + * ```typescript + * const seatEvent: PokerPlayerEvents = PokerPlayerEvents.OCCUPIED; + * console.log(seatEvent); + * // Console Output: "PokerPlayer:Occupied" + * ``` + */ +enum PokerPlayerEvents { + /** + * Indicates that the seat has been initialized and is ready for occupancy. + * + * @example + * ```typescript + * const seatEvent: PokerPlayerEvents = PokerPlayerEvents.INITIALIZED; + * console.log(seatEvent); + * // Console Output: "PokerPlayer:Initialized" + * ``` + */ + INITIALIZED = "PokerPlayer:Initialized", +} + +export { PokerPlayerEvents }; diff --git a/src/enums/events/pokerRoom/index.ts b/src/enums/events/pokerRoom/index.ts new file mode 100644 index 0000000..814e3a5 --- /dev/null +++ b/src/enums/events/pokerRoom/index.ts @@ -0,0 +1,45 @@ +//@collapse + +/** + * @enum `PokerRoomEvents` + * + * Defines the events associated with a player's seat in a poker game. These events help manage seat availability + * and player actions related to occupying or vacating seats at a poker table. + * + * #### Purpose + * The `PokerRoomEvents` enum is designed to provide a standardized reference for seat-related events in the game. + * It simplifies the handling of seat states, ensuring seat occupancy and vacancy can be tracked and updated + * accurately within the game flow. + * + * #### Events Overview + * The `PokerRoomEvents` includes the following events: + * - **INITIALIZED**: Indicates that the seat has been initialized and is ready for occupancy. + * - **OCCUPIED**: Indicates a seat has been occupied by a player. + * - **VACATED**: Indicates a seat has been vacated by a player. + * + * #### Usage + * This enum standardizes the handling of seat events, making it easier to manage player movements at the table and + * ensuring compatibility with various game modules and event listeners. + * + * @example + * ```typescript + * const seatEvent: PokerRoomEvents = PokerRoomEvents.OCCUPIED; + * console.log(seatEvent); + * // Console Output: "PokerRoom:Occupied" + * ``` + */ +enum PokerRoomEvents { + /** + * Indicates that the seat has been initialized and is ready for occupancy. + * + * @example + * ```typescript + * const seatEvent: PokerRoomEvents = PokerRoomEvents.INITIALIZED; + * console.log(seatEvent); + * // Console Output: "PokerRoom:Initialized" + * ``` + */ + INITIALIZED = "PokerRoom:Initialized", +} + +export { PokerRoomEvents }; diff --git a/src/enums/events/pokerSeat/index.ts b/src/enums/events/pokerSeat/index.ts new file mode 100644 index 0000000..fa8906a --- /dev/null +++ b/src/enums/events/pokerSeat/index.ts @@ -0,0 +1,69 @@ +//@collapse + +/** + * @enum `PokerSeatEvents` + * + * Defines the events associated with a player's seat in a poker game. These events help manage seat availability + * and player actions related to occupying or vacating seats at a poker table. + * + * #### Purpose + * The `PokerSeatEvents` enum is designed to provide a standardized reference for seat-related events in the game. + * It simplifies the handling of seat states, ensuring seat occupancy and vacancy can be tracked and updated + * accurately within the game flow. + * + * #### Events Overview + * The `PokerSeatEvents` includes the following events: + * - **INITIALIZED**: Indicates that the seat has been initialized and is ready for occupancy. + * - **OCCUPIED**: Indicates a seat has been occupied by a player. + * - **VACATED**: Indicates a seat has been vacated by a player. + * + * #### Usage + * This enum standardizes the handling of seat events, making it easier to manage player movements at the table and + * ensuring compatibility with various game modules and event listeners. + * + * @example + * ```typescript + * const seatEvent: PokerSeatEvents = PokerSeatEvents.OCCUPIED; + * console.log(seatEvent); + * // Console Output: "PokerSeat:Occupied" + * ``` + */ +enum PokerSeatEvents { + /** + * Indicates that the seat has been initialized and is ready for occupancy. + * + * @example + * ```typescript + * const seatEvent: PokerSeatEvents = PokerSeatEvents.INITIALIZED; + * console.log(seatEvent); + * // Console Output: "PokerSeat:Initialized" + * ``` + */ + INITIALIZED = "PokerSeat:Initialized", + + /** + * Indicates a seat has been occupied by a player. + * + * @example + * ```typescript + * const seatEvent: PokerSeatEvents = PokerSeatEvents.OCCUPIED; + * console.log(seatEvent); + * // Console Output: "PokerSeat:Occupied" + * ``` + */ + OCCUPIED = "PokerSeat:Occupied", + + /** + * Indicates a seat has been vacated by a player. + * + * @example + * ```typescript + * const seatEvent: PokerSeatEvents = PokerSeatEvents.VACATED; + * console.log(seatEvent); + * // Console Output: "PokerSeat:Vacated" + * ``` + */ + VACATED = "PokerSeat:Vacated", +} + +export { PokerSeatEvents }; diff --git a/src/enums/events/pokerTable/index.ts b/src/enums/events/pokerTable/index.ts new file mode 100644 index 0000000..77b2037 --- /dev/null +++ b/src/enums/events/pokerTable/index.ts @@ -0,0 +1,45 @@ +//@collapse + +/** + * @enum `PokerTableEvents` + * + * Defines the events associated with a player's seat in a poker game. These events help manage seat availability + * and player actions related to occupying or vacating seats at a poker table. + * + * #### Purpose + * The `PokerTableEvents` enum is designed to provide a standardized reference for seat-related events in the game. + * It simplifies the handling of seat states, ensuring seat occupancy and vacancy can be tracked and updated + * accurately within the game flow. + * + * #### Events Overview + * The `PokerTableEvents` includes the following events: + * - **INITIALIZED**: Indicates that the seat has been initialized and is ready for occupancy. + * - **OCCUPIED**: Indicates a seat has been occupied by a player. + * - **VACATED**: Indicates a seat has been vacated by a player. + * + * #### Usage + * This enum standardizes the handling of seat events, making it easier to manage player movements at the table and + * ensuring compatibility with various game modules and event listeners. + * + * @example + * ```typescript + * const seatEvent: PokerTableEvents = PokerTableEvents.OCCUPIED; + * console.log(seatEvent); + * // Console Output: "PokerTable:Occupied" + * ``` + */ +enum PokerTableEvents { + /** + * Indicates that the seat has been initialized and is ready for occupancy. + * + * @example + * ```typescript + * const seatEvent: PokerTableEvents = PokerTableEvents.INITIALIZED; + * console.log(seatEvent); + * // Console Output: "PokerTable:Initialized" + * ``` + */ + INITIALIZED = "PokerTable:Initialized", +} + +export { PokerTableEvents }; diff --git a/src/enums/index.ts b/src/enums/index.ts new file mode 100644 index 0000000..c55d17d --- /dev/null +++ b/src/enums/index.ts @@ -0,0 +1,27 @@ +//@collapse + +/** + * @module `Enums` + * Centralized export for all poker-related enums. + * This module gathers and exports enums for `Rank` and `Suit`, + * which represent the ranks and suits of playing cards in poker. + * + * By centralizing these enums, other modules can import them easily + * for consistent use across the library. + * + * @example + * // Import all enums from the centralized module + * import { CasinoEventName, CasinoEventNamesEnum, PokerPhaseName, PokerPhasesEnum, Rank, RanksEnum, Suit, SuitsEnum } from './enums'; + */ +export * as EventsEnumModule from "./events"; +export * from "./events"; +export * as LogLevelsEnumModule from "./logLevels"; +export * from "./logLevels"; +export * as PokerPhasesEnumModule from "./pokerPhases"; +export * from "./pokerPhases"; +export * as RanksEnumModule from "./ranks"; +export * from "./ranks"; +export * as SourcesEnumModule from "./sources"; +export * from "./sources"; +export * as SuitsEnumModule from "./suits"; +export * from "./suits"; diff --git a/src/enums/logLevels/index.ts b/src/enums/logLevels/index.ts new file mode 100644 index 0000000..5533364 --- /dev/null +++ b/src/enums/logLevels/index.ts @@ -0,0 +1,86 @@ +//@collapse + +/** + * @enum {string} `LogLevel` + * + * Represents the different levels of logging severity available within the library. + * Each log level corresponds to a specific type of message, providing clarity on the nature and urgency of the log. + * The levels are structured to allow for selective filtering based on severity and importance. + * + * #### Purpose + * The `LogLevel` enum standardizes log severity levels, ensuring that log messages are consistently categorized. + * This approach aids in debugging, monitoring, and organizing log data by its importance, making it easier to parse + * and filter through logs in development, production, or auditing scenarios. + * + * #### Usage + * The `LogLevel` enum is used across the logging system to specify the severity of each log message. It includes: + * - **INFO**: For general informational messages, routine operations, and non-urgent updates. + * - **WARN**: For warnings or potential issues that may not yet be errors but deserve attention. + * - **ERROR**: For serious issues that have occurred and require immediate attention. + * + * @example + * ```typescript + * const logLevel = LogLevel.INFO; + * console.log(logLevel); + * // Console Output: "info" + * ``` + */ +enum LogLevel { + /** + * @property {string} INFO + * + * Indicates an informational message. Typically used for routine logs that help track the flow of execution + * without implying any issues. Ideal for logs that document standard operations, function calls, or + * non-critical messages. + * + * #### Purpose + * Helps developers or system operators understand the application flow and record operational steps. + * + * @example + * ```typescript + * const level = LogLevel.INFO; + * console.log(level); + * // Console Output: "info" + * ``` + */ + INFO = "info", + + /** + * @property {string} WARN + * + * Denotes a warning message. Used for situations that might lead to errors if not addressed, + * such as deprecated function usage, unexpected states, or recoverable issues. + * + * #### Purpose + * Allows developers to identify and monitor areas of the application that might require future action + * to prevent errors or enhance performance. + * + * @example + * ```typescript + * const level = LogLevel.WARN; + * console.log(level); + * // Console Output: "warning" + * ``` + */ + WARN = "warning", + + /** + * @property {string} ERROR + * + * Represents an error message, indicating a failure that disrupts functionality or prevents a process from completing. + * This level of logging is reserved for serious issues that demand immediate attention and correction. + * + * #### Purpose + * Used to signal critical failures, alerting developers or operators to take immediate action to resolve the issue. + * + * @example + * ```typescript + * const level = LogLevel.ERROR; + * console.log(level); + * // Console Output: "error" + * ``` + */ + ERROR = "error", +} + +export { LogLevel }; diff --git a/src/enums/pokerPhases/index.ts b/src/enums/pokerPhases/index.ts new file mode 100644 index 0000000..31b3fb0 --- /dev/null +++ b/src/enums/pokerPhases/index.ts @@ -0,0 +1,90 @@ +//@collapse + +/** + * @enum `PokerPhases` + * Defines the various phases in a standard poker game. Each phase represents a distinct stage + * within the game sequence, governing the number of community cards dealt and player actions. + * + * #### Purpose + * `PokerPhases` is designed to provide a clear, standardized reference for each poker phase. + * It simplifies managing the game flow and ensures that each phase can be easily referenced + * within conditional statements and game logic. + * + * #### Phases Overview + * The `PokerPhases` includes the following phases: + * - **PRE_FLOP**: The initial phase before any community cards are dealt. + * - **FLOP**: The second phase, where the first three community cards are dealt. + * - **TURN**: The third phase, where a fourth community card is dealt. + * - **RIVER**: The fourth phase, where the fifth and final community card is dealt. + * - **SHOWDOWN**: The final phase where players reveal their hands and a winner is determined. + * + * #### Usage + * This enum standardizes the game flow, making it easy to transition between poker phases + * and ensuring compatibility with various game modules and functions. + * + * @example + * ```typescript + * const currentPhase: PokerPhases = PokerPhases.PRE_FLOP; + * console.log(currentPhase); + * // Console Output: "Pre-Flop" + * ``` + */ +enum PokerPhases { + /** + * The initial phase before any community cards are dealt. + * + * @example + * ```typescript + * const currentPhase: PokerPhases = PokerPhases.PRE_FLOP; + * console.log(currentPhase); + * // Console Output: "Pre-Flop" + * ``` + */ + PRE_FLOP = "Pre-Flop", + + /** The second phase where the first three community cards are dealt. + * + * @example + * ```typescript + * const currentPhase: PokerPhases = PokerPhases.FLOP; + * console.log(currentPhase); + * // Console Output: "Flop" + * ``` + */ + FLOP = "Flop", + + /** The third phase where a fourth community card is dealt. + * + * @example + * ```typescript + * const currentPhase: PokerPhases = PokerPhases.TURN; + * console.log(currentPhase); + * // Console Output: "Turn" + * ``` + */ + TURN = "Turn", + + /** The fourth phase where the fifth and final community card is dealt. + * + * @example + * ```typescript + * const currentPhase: PokerPhases = PokerPhases.RIVER; + * console.log(currentPhase); + * // Console Output: "River" + * ``` + */ + RIVER = "River", + + /** The final phase where players reveal their hands to determine the winner. + * + * @example + * ```typescript + * const currentPhase: PokerPhases = PokerPhases.SHOWDOWN; + * console.log(currentPhase); + * // Console Output: "ShowDown" + * ``` + */ + SHOWDOWN = "ShowDown", +} + +export { PokerPhases }; diff --git a/src/enums/ranks/index.ts b/src/enums/ranks/index.ts new file mode 100644 index 0000000..999ef0b --- /dev/null +++ b/src/enums/ranks/index.ts @@ -0,0 +1,31 @@ +//@collapse + +/** + * @enum {string} `Rank` + * Represents the ranks of playing cards used in poker. + * Each rank corresponds to a specific card value from 2 to Ace. + * + * @example + * ```typescript + * const rank = Rank.Ace; + * console.log(rank); + * //output: "A" + * ``` + */ +enum Rank { + Two = "2", + Three = "3", + Four = "4", + Five = "5", + Six = "6", + Seven = "7", + Eight = "8", + Nine = "9", + Ten = "10", + Jack = "J", + Queen = "Q", + King = "K", + Ace = "A", +} + +export { Rank }; diff --git a/src/enums/sources/index.ts b/src/enums/sources/index.ts new file mode 100644 index 0000000..2171e82 --- /dev/null +++ b/src/enums/sources/index.ts @@ -0,0 +1,160 @@ +//@collapse + +/** + * @enum {string} `Source` + * Defines the sources of various components and entities within the library, each representing a specific + * entity or module that can emit events or interact within the system. This enum is used as a standardized + * identifier for the origin of actions, events, or data across the library. + * + * #### Purpose + * `Source` is designed to standardize the identification of each module or entity within the library, + * facilitating tracing, logging, and debugging. Each value corresponds to a distinct source, making it + * clear where specific events or actions originate. + * + * #### Enum Values + * - **_BASE**: Represents the `BaseEventEmitter`, the foundational emitter for events within the library. + * - **CARD**: Represents the `Card` model, corresponding to individual playing cards in the library. + * - **CASINO**: Refers to the `Casino` model, handling high-level operations related to game management. + * - **DECK**: Identifies the `Deck`, representing a collection or set of cards in a game context. + * - **POKER_GAME**: Corresponds to the `PokerGame` model, managing game-specific actions and states. + * - **POKER_PHASE**: Represents the `PokerPhase` model, indicating the stages or phases within a poker game. + * - **POKER_PLAYER**: Refers to the `PokerPlayer` model, encompassing player-specific data and actions. + * - **POKER_ROOM**: Corresponds to the `PokerRoom` model, representing rooms where games take place. + * - **POKER_SEAT**: Refers to the `PokerSeat` model, representing individual seats within a poker table. + * - **POKER_TABLE**: Represents the `PokerTable` model, handling table-specific settings and seating. + * + * #### Usage + * `Source` provides a standard set of identifiers used across the library for event emission and origin + * tracking. Each entity or module can reference its corresponding `Source` value when emitting events or + * logging actions, enhancing traceability and modularity. + * + * @example + * ```typescript + * const source = Source.POKER_GAME; + * console.log(source); + * // Console Output: "PokerGame" + * ``` + */ +enum Source { + /** + * Represents the `BaseEventEmitter`, the foundational event emitter for the library. + * + * @example + * ```typescript + * const source = Source._BASE; + * console.log(source); + * // Console Output: "BaseEventEmitter" + * ``` + */ + _BASE = "BaseEventEmitter", + + /** + * Represents the `Card` model, corresponding to individual playing cards. + * + * @example + * ```typescript + * const source = Source.CARD; + * console.log(source); + * // Console Output: "Card" + * ``` + */ + CARD = "Card", + + /** + * Refers to the `Casino` model, which handles casino or game management operations. + * + * @example + * ```typescript + * const source = Source.CASINO; + * console.log(source); + * // Console Output: "Casino" + * ``` + */ + CASINO = "Casino", + + /** + * Identifies the `Deck`, representing a collection of playing cards. + * + * @example + * ```typescript + * const source = Source.DECK; + * console.log(source); + * // Console Output: "Deck" + * ``` + */ + DECK = "Deck", + + /** + * Corresponds to the `PokerGame` model, responsible for managing the poker game actions and states. + * + * @example + * ```typescript + * const source = Source.POKER_GAME; + * console.log(source); + * // Console Output: "PokerGame" + * ``` + */ + POKER_GAME = "PokerGame", + + /** + * Represents the `PokerPhase` model, indicating stages or phases within a poker game. + * + * @example + * ```typescript + * const source = Source.POKER_PHASE; + * console.log(source); + * // Console Output: "PokerPhase" + * ``` + */ + POKER_PHASE = "PokerPhase", + + /** + * Refers to the `PokerPlayer` model, encompassing player-specific data and actions. + * + * @example + * ```typescript + * const source = Source.POKER_PLAYER; + * console.log(source); + * // Console Output: "PokerPlayer" + * ``` + */ + POKER_PLAYER = "PokerPlayer", + + /** + * Corresponds to the `PokerRoom` model, representing rooms where games take place. + * + * @example + * ```typescript + * const source = Source.POKER_ROOM; + * console.log(source); + * // Console Output: "PokerRoom" + * ``` + */ + POKER_ROOM = "PokerRoom", + + /** + * Refers to the `PokerSeat` model, representing individual seats within a poker table. + * + * @example + * ```typescript + * const source = Source.POKER_SEAT; + * console.log(source); + * // Console Output: "PokerSeat" + * ``` + */ + POKER_SEAT = "PokerSeat", + + /** + * Represents the `PokerTable` model, which handles table-specific settings and seating. + * + * @example + * ```typescript + * const source = Source.POKER_TABLE; + * console.log(source); + * // Console Output: "PokerTable" + * ``` + */ + POKER_TABLE = "PokerTable", +} + +export { Source }; diff --git a/src/enums/suits/index.ts b/src/enums/suits/index.ts new file mode 100644 index 0000000..e27f8d8 --- /dev/null +++ b/src/enums/suits/index.ts @@ -0,0 +1,19 @@ +//@collapse + +/** + * @enum `Suit` + * Represents the suits of playing cards used in poker. + * Each suit corresponds to one of the four card suits: Hearts, Diamonds, Clubs, and Spades. + * + * @example + * const suit = Suit.Hearts; + * console.log(suit); // "Hearts" + */ +enum Suit { + Hearts = "Hearts", + Diamonds = "Diamonds", + Clubs = "Clubs", + Spades = "Spades", +} + +export { Suit }; diff --git a/src/index.ts b/src/index.ts index 36bf406..745ce4e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,18 +1,17 @@ -import { ICard, IDeck, Rank, Suit } from "./interfaces"; -import { Card, Deck } from "./models"; +//@collapse /** - * @module `pokerjs` + * @module `casinojs` * Centralized export for the entire `pokerjs` library, providing access to interfaces, models, and types. * * This module exports all necessary components for working with poker games, including: - * - Interfaces (`ICard`, `IDeck`) + * - Interfaces (`CardInterface`, `DeckInterface`) * - Models (`Card`, `Deck`) * - Enums (`Rank`, `Suit`) * * @example * // Importing from the centralized library module - * import { ICard, Card, Deck, Rank, Suit } from 'pokerjs'; + * import { CardInterface, Card, Deck, Rank, Suit } from 'pokerjs'; * * const deck = new Deck(); * deck.shuffle(); @@ -20,4 +19,11 @@ import { Card, Deck } from "./models"; * console.log(card?.toString()); */ -export { ICard, IDeck, Rank, Suit, Card, Deck }; +export * as Enums from "./enums"; +export * from "./enums"; +export * as Interfaces from "./interfaces"; +export * from "./interfaces"; +export * as Models from "./models"; +export * from "./models"; +export * as Utils from "./utils"; +export * from "./utils"; diff --git a/src/interfaces/_base/index.ts b/src/interfaces/_base/index.ts new file mode 100644 index 0000000..6d24567 --- /dev/null +++ b/src/interfaces/_base/index.ts @@ -0,0 +1,15 @@ +// @collapse + +/** + * @interface BaseEventEmitterInterface + * Extends the standard Node.js EventEmitter, including listener management methods. + */ +interface BaseEventEmitterInterface extends NodeJS.EventEmitter { + /** + * Retrieves the maximum number of listeners allowed for this instance. + * @returns {number} The maximum number of listeners, defaulting to Node.js’s `EventEmitter.defaultMaxListeners`. + */ + getMaxListeners(): number; +} + +export { BaseEventEmitterInterface }; diff --git a/src/interfaces/baseEvent/index.ts b/src/interfaces/baseEvent/index.ts new file mode 100644 index 0000000..8ffdc8e --- /dev/null +++ b/src/interfaces/baseEvent/index.ts @@ -0,0 +1,245 @@ +// @collapse + +/** + * @interface `BaseEventInterface` + * + * Represents a foundational structure for events emitted within the library, ensuring consistency + * across event types by standardizing metadata and event-specific payload sections. + * + * #### Purpose + * The `BaseEventInterface` interface establishes a uniform format for all events within the library, promoting + * a cohesive structure for both general event metadata and customizable data content. Designed for flexibility, + * `BaseEventInterface` can be extended by more specific event types, allowing for additional properties as needed + * by various components of the library. + * + * #### Structure + * - **Metadata**: Core fields such as `id`, `name`, `source`, and optional fields like `status` and `priority` + * allow for tracking and categorizing events effectively. + * - **Data**: A dynamic content section specific to each event, adaptable based on the event’s requirements. + * - **Extensibility**: Supports optional metadata and additional custom fields, enabling event structure + * adjustments based on diverse requirements. + * + * #### Usage + * `BaseEventInterface` provides a structured foundation for defining library-wide events. It can be extended by + * event-specific interfaces that introduce additional data fields. This makes `BaseEventInterface` a versatile + * base for a variety of events while ensuring a consistent structure across the library. + * + * @example + * ```typescript + * const event: BaseEventInterface = { + * id: "unique-id-1234", + * name: "Casino:RoomCreated", + * source: "PokerRoom", + * createdAt: new Date(), + * data: { customData: "event-specific details" }, + * priority: 1, + * customField: "extra info" + * }; + * console.log(event); + * // Console Output: { id: "unique-id-1234", name: "Casino:RoomCreated", source: "PokerRoom", createdAt: , data: { customData: "event-specific details" }, priority: 1, customField: "extra info" } + * ``` + */ +interface BaseEventInterface { + /************************************************************************************************************** + * PROPERTIES + **************************************************************************************************************/ + + /** + * @property {string} id + * + * Unique identifier for the event instance, ensuring traceability across emitted events. + * + * #### Purpose + * Used for tracking the event instance, especially useful in scenarios with multiple simultaneous events. + * + * #### Requirements + * - Should be a unique string. + * + * @example + * ```typescript + * const eventId = event.id; + * console.log(eventId); + * // Console Output: "unique-id-1234" + * ``` + */ + id: string; + + /** + * @property {string} name + * + * Identifies the name of the event, which specifies the nature and purpose of the event + * within the library. + * + * #### Purpose + * Used by event listeners to filter and categorize events. + * + * #### Requirements + * - Should be a descriptive name that provides a clear indication of the event's purpose, + * such as `"Casino:RoomCreated"` or `"PokerSeat:Occupied"`. + * + * @example + * ```typescript + * const eventName = event.name; + * console.log(eventName); + * // Console Output: "Casino:RoomCreated" + * ``` + */ + name: string; + + /** + * @property {Date} createdAt + * + * Timestamp indicating when the event was created. + * + * #### Purpose + * Used for tracking the exact time of event emission, which is essential for sequencing, + * logging, and auditing purposes. + * + * #### Requirements + * - Should be a valid `Date` object. + * + * @example + * ```typescript + * const creationTime = event.createdAt; + * console.log(creationTime); + * // Console Output: Date object representing the event's creation time. + * ``` + */ + createdAt: Date; + + /** + * @property {Date} lastModifiedAt + * + * Timestamp indicating the last time the event was modified, if applicable. + * + * #### Purpose + * Useful for tracking updates to the event after initial creation, particularly in cases + * where the event's data might change as it is processed. + * + * #### Optional + * - This field is optional and should be a valid `Date` object if present. + * + * @example + * ```typescript + * const modificationTime = event.lastModifiedAt; + * console.log(modificationTime); + * // Console Output: Date object representing the event's last modification time, if set. + * ``` + */ + lastModifiedAt?: Date; + + /** + * @property {string} status + * + * Current processing status of the event. + * + * #### Purpose + * Indicates the event's state, useful for monitoring and debugging the event's lifecycle. + * + * #### Optional + * - Possible values include `"initiated"`, `"in-progress"`, `"completed"`, or custom statuses. + * + * @example + * ```typescript + * const eventStatus = event.status; + * console.log(eventStatus); + * // Console Output: "in-progress" or other string value indicating status. + * ``` + */ + status?: string; + + /** + * @property {number} priority + * + * Priority level of the event, where higher numbers indicate higher priority. + * + * #### Purpose + * Helps in prioritizing event handling, especially when multiple events are emitted + * and processed in sequence. + * + * #### Optional + * - This field is optional, and values can range from `0` (lowest) to any positive integer. + * + * @example + * ```typescript + * const eventPriority = event.priority; + * console.log(eventPriority); + * // Console Output: Integer representing event priority level. + * ``` + */ + priority?: number; + + /** + * @property {string} source + * + * Identifier or name of the component or module that generated the event. + * + * #### Purpose + * Used for tracing the origin of the event, especially useful in larger applications + * with multiple modules. + * + * @example + * ```typescript + * const eventSource = event.source; + * console.log(eventSource); + * // Console Output: "PokerRoom" or similar string value. + * ``` + */ + source: string; + + /** + * @property {Record} meta + * + * Contains additional metadata for the event, supporting extensibility for any custom + * properties that may be added. + * + * #### Purpose + * Enables flexible additions to event metadata, supporting any custom key-value pair + * that may be required for specific events. + * + * #### Optional + * - This field is optional and can store any additional event metadata as key-value pairs. + * + * @example + * ```typescript + * const eventMetadata = event.metadata; + * console.log(eventMetadata); + * // Console Output: { customMetaKey: "customMetaValue" } + * ``` + */ + meta?: { + [key: string]: any; + }; + + /** + * @property {T} data + * + * Contains event-specific details, dynamically adapted based on the type `T`, which can represent any structure. + * + * #### Purpose + * Carries unique data associated with the event, allowing specific identifiers, payloads, or any other + * information relevant to each type of event. + * + * #### Requirements + * - `data` should be structured as per the requirements of each derived event type. + * + * @example + * ```typescript + * const seatEventData = event.data; + * console.log(seatEventData); + * // Console Output: Custom data object, e.g., { seatId: "123", playerId: "p789" } + * ``` + */ + data: T; + + /** + * Allows additional properties for further extensibility. + * + * #### Usage + * Enables flexible additions to event fields, supporting any custom key-value pair + * that may be required for specific events. + */ + [key: string]: any; +} + +export { BaseEventInterface }; diff --git a/src/interfaces/card/index.ts b/src/interfaces/card/index.ts index 490c488..8de1115 100644 --- a/src/interfaces/card/index.ts +++ b/src/interfaces/card/index.ts @@ -1,29 +1,109 @@ -import { Rank } from "../rank"; -import { Suit } from "../suit"; +//collapse + +import { Rank, Suit } from "../../enums"; /** - * @interface `ICard` - * Represents the structure of a card in a poker game. + * @interface `CardConfig` + * Represents a Card Config. */ -interface ICard { +interface CardConfig { + +/************************************************************************************************************** + * PROPERTIES + **************************************************************************************************************/ + /** - * @property {Rank} rank - * The rank of the card (e.g., Ace, Two, King). + * @property {string | undefined} rank + * The maximum number of players that can be seated at the PokerTable[2-14]. */ rank: Rank; /** - * @property {Suit} suit - * The suit of the card (e.g., Hearts, Spades). + * @property {string | undefined} suit + * The maximum number of players that can be seated at the PokerTable[2-14]. */ suit: Suit; +} + +/** + * @interface `CardInterface` + * Represents the structure of a card in a poker game. + * The interface provides methods to retrieve the card's rank, suit, and other related details. + * + * @example + * const card: CardInterface = new Card(Rank.Ace, Suit.Spades); + * console.log(card.toString()); // "A of Spades" + */ +interface CardInterface { + +/************************************************************************************************************** + * CREATE METHODS (SETTERS & OBJECT CREATION) + **************************************************************************************************************/ + +/************************************************************************************************************** + * READ METHODS (GETTERS & DATA RETRIEVAL) + **************************************************************************************************************/ + + /** + * `getRank` + * @public + * Returns the card's rank. + * @returns {Rank} The card's rank. + * + * @example + * const rank = card.getRank(); + * console.log(rank); // "A" + */ + getRank(): Rank; /** - * @method `toString` + * `getSuit` + * @public + * Returns the card's suit. + * @returns {Suit} The card's suit. + * + * @example + * const suit = card.getSuit(); + * console.log(suit); // "Spades" + */ + getSuit(): Suit; + + +/************************************************************************************************************** + * UPDATE METHODS (MODIFYING EXISTING OBJECTS) + **************************************************************************************************************/ + +/************************************************************************************************************** + * DELETE METHODS (REMOVING OBJECTS) + **************************************************************************************************************/ + +/************************************************************************************************************** + * BUSINESS-LOGIC METHODS (LOGIC & CALCULATIONS) + **************************************************************************************************************/ + + /** + * `toString` + * @public * Returns a string representation of the card, displaying its rank and suit. * @returns {string} The card's rank and suit as a formatted string. + * + * @example + * const description = card.toString(); + * console.log(description); // "A of Spades" */ toString(): string; + + /** + * `toObj` + * @public + * Returns an object representation of the card, containing its rank and suit. + * @returns {object<{ rank: Rank; suit: Suit }>} The card's rank and suit as an object. + * + * @example + * const cardObj = card.toObj(); + * console.log(cardObj); // { rank: "A", suit: "Spades" } + */ + toObj(): { rank: Rank; suit: Suit }; } -export { ICard }; +export { CardConfig, CardInterface }; diff --git a/src/interfaces/casino/index.ts b/src/interfaces/casino/index.ts new file mode 100644 index 0000000..bf85bb2 --- /dev/null +++ b/src/interfaces/casino/index.ts @@ -0,0 +1,456 @@ +//@collapse + +import { BaseEventEmitterInterface } from "../_base"; +import { PokerRoomConfig, PokerRoomInterface } from "../pokerRoom"; + +/** + * @interface `CasinoInterface` + * Represents the core responsibilities and structure of a Casino entity within the system. It manages multiple `PokerRoom` instances and facilitates the organization of poker games through room creation, player allocation, and game tracking. + * + * #### Purpose + * The `CasinoInterface` serves as a blueprint for any `Casino` class that manages multiple poker rooms. It defines room management methods, player allocation functions, and potentially methods for tracking player statistics or games across rooms. + * + * #### Extends + * This interface extends `NodeJS.EventEmitter` to emit events associated with key actions, such as room creation or removal, enhancing flexibility in managing event-driven operations across the Casino system. + * + * #### Methods Overview + * The `CasinoInterface` includes essential methods to: + * - **Create** new rooms with specified configurations. + * - **Retrieve** details of individual rooms or a complete list of active rooms. + * - **Update** rooms dynamically by adding or modifying existing rooms. + * - **Delete** specific rooms, ensuring the Casino environment remains organized. + * + * #### Events + * The `CasinoInterface` supports event emissions for room-related actions. Events allow other parts of the application to subscribe to changes in the Casino, making it easier to handle notifications and updates. + * + * @extends NodeJS.EventEmitter + * + * @example + * ```typescript + * const casino: CasinoInterface = new Casino(); + * casino.on('casino:roomCreated', (room) => console.log(`Room created: ${room.name}`)); + * const room = casino.createRoom({ name: "Room1", tableSize: 6, smallBlind: 10, bigBlind: 20 }); + * console.log(casino.listRooms()); + * ``` + */ +interface CasinoInterface extends BaseEventEmitterInterface { + /************************************************************************************************************** + * CREATE METHODS (SETTERS & OBJECT CREATION) + **************************************************************************************************************/ + + /** + * #### Description + * Sets the list of rooms managed by the Casino. This method is typically used to replace or update + * the entire list of poker rooms in the casino. + * + * #### Implements + * Implements the `setRooms` method of `CasinoInterface`. + * + * #### Overrides + * `N/A` + * + * #### Purpose + * Provides a way to update the current list of rooms managed by the Casino, ensuring a consistent and up-to-date + * list of poker rooms as defined by the casino’s configuration. + * + * #### Events + * - `N/A`: No `event` is emitted by this method. + * + * #### Parameters + * - `rooms`: An array of `PokerRoomInterface` instances, representing individual poker rooms in the Casino. + * + * #### Requirements + * - The `rooms` array must contain at least one room (i.e., `rooms.length >= 1`). + * + * #### Returns + * - Returns `true` when the rooms have been successfully set. + * + * #### Usage + * This method accepts an array of `PokerRoomInterface` objects, representing poker rooms to manage in the casino. + * - Replaces any existing rooms with the new provided list. + * - Calls the internal `__setRooms` method to update the private `__rooms` property securely. + * + * @param {PokerRoomInterface[]} rooms - The new list of poker rooms to be managed by the Casino. + * @returns {boolean} - Returns `true` when the rooms have been successfully set. + * + * @example + * ```typescript + * const casino = new Casino(); + * const rooms: PokerRoomInterface[] = [ + * new PokerRoom({ name: "Room1", tableSize: 6, smallBlind: 10, bigBlind: 20 }) + * ]; + * casino.setRooms(rooms); + * console.log(casino.getRooms()); // Logs an array with the newly set rooms + * ``` + */ + setRooms(rooms: PokerRoomInterface[]): PokerRoomInterface[]; + + /** + * #### Description + * Creates a new `PokerRoom` within the Casino and adds it to the list of rooms. + * + * #### Implements + * Implements the `createRoom` method of `CasinoInterface`. + * + * #### Overrides + * `N/A` + * + * #### Purpose + * Enables the dynamic creation and addition of a `PokerRoom` to the Casino, expanding the Casino’s managed rooms as required. + * This facilitates flexible game setup and room management in response to user needs. + * + * #### Events + * - `casino:roomCreated`: This custom event is emitted once the room is successfully added. + * Listeners to this event can respond with actions, such as logging or notifying users. + * + * #### Parameters + * - `config`: A configuration object containing details like the room’s name, table size, small blind, and big blind values. + * + * #### Requirements + * - The configuration object must include valid values for `name`, `tableSize`, `smallBlind`, and `bigBlind`. + * + * #### Returns + * - Returns the newly created `PokerRoom` instance, confirming its addition to the Casino. + * + * #### Usage + * This method creates a new room based on the provided configuration, then pushes it into the Casino’s room list. + * After adding the room, it emits a `casino:roomCreated` event for any listeners tracking room creation. + * + * @param {PokerRoomConfig} config - A configuration object with properties like the room name, table size, small blind, and big blind values. + * @returns {PokerRoomInterface} - Returns the newly created `PokerRoom` instance. + * + * @example + * ```typescript + * const casino = new Casino(); + * const room = casino.createRoom({ name: "HighRollers", tableSize: 6, smallBlind: 10, bigBlind: 20 }); + * console.log(casino.getRooms()); // Logs the new room within the array of rooms + * ``` + */ + createRoom(config: PokerRoomConfig): PokerRoomInterface; + + /************************************************************************************************************** + * READ METHODS (GETTERS & DATA RETRIEVAL) + **************************************************************************************************************/ + + /** + * #### Description + * Retrieves a specific `PokerRoom` based on its position within the Casino’s list of rooms. + * + * #### Implements + * `N/A` + * + * #### Overrides + * `N/A` + * + * #### Purpose + * This method provides direct access to a single `PokerRoom` by index, allowing for targeted retrieval of rooms, + * which can be useful for room-specific operations or when sequentially processing rooms. + * + * #### Events + * `N/A` + * + * #### Parameters + * - `index`: A zero-based index representing the position of the desired `PokerRoom` in the Casino’s room list. + * + * #### Requirements + * - The index provided must be within the bounds of the `__rooms` array (i.e., `0 <= index < __rooms.length`). + * - Passing an out-of-bounds index will result in an `undefined` return. + * + * #### Returns + * - Returns the `PokerRoomInterface` instance located at the specified index. + * - Returns `undefined` if the provided index is out of bounds. + * + * #### Usage + * Use this method when you need to access a particular room directly by its index in the Casino’s list of rooms. + * This can be useful in looped operations or when accessing rooms based on their position in the list. + * + * @param {number} index - The zero-based index of the desired room in the Casino’s room list. + * @returns {PokerRoomInterface | undefined} - The `PokerRoom` at the specified index or `undefined` if the index is out of bounds. + * + * @example + * ```typescript + * const casino = new Casino(); + * const room = casino.getRoom(0); // Returns the first room or undefined if no rooms exist + * ``` + */ + getRoom(index: number): PokerRoomInterface; + + /** + * #### Description + * Retrieves the full list of rooms currently managed by the Casino. + * + * #### Implements + * Implements the `getRooms` method of `CasinoInterface`. + * + * #### Overrides + * `N/A` + * + * #### Purpose + * Provides access to the Casino's list of rooms, allowing external components or systems to retrieve and display + * information on all currently managed poker rooms. + * + * #### Events + * `N/A` + * + * #### Parameters + * `N/A` + * + * #### Requirements + * `N/A` + * + * #### Returns + * - Returns an array containing all `PokerRoomInterface` instances currently managed by the Casino. + * - Returns an empty array if no rooms have been added to the Casino. + * + * #### Usage + * This method is useful when a complete list of active rooms is needed, such as when displaying the Casino's + * available games or managing room states. + * + * @returns {PokerRoomInterface[]} - An array of all `PokerRoom` objects in the Casino. + * + * @example + * ```typescript + * const casino = new Casino(); + * console.log(casino.getRooms()); // Output: [] + * ``` + */ + getRooms(): PokerRoomInterface[]; + + /************************************************************************************************************** + * UPDATE METHODS (MODIFYING EXISTING OBJECTS) + **************************************************************************************************************/ + + /** + * #### Description + * Adds a new `PokerRoom` instance to the Casino's list of managed rooms, enabling dynamic expansion + * of rooms within the Casino environment. + * + * #### Implements + * `N/A` + * + * #### Overrides + * `N/A` + * + * #### Purpose + * This method provides a flexible mechanism for expanding the Casino's room offerings by allowing new + * rooms to be added as required, thereby supporting various gaming scenarios and player demand. + * + * #### Events + * `N/A` + * + * #### Parameters + * - `room` - A `PokerRoomInterface` instance representing the room to be added to the Casino’s list. + * + * #### Requirements + * - The `room` parameter must be a valid instance implementing `PokerRoomInterface`. + * + * #### Returns + * - Returns `true` to confirm that the room has been successfully added to the Casino. + * + * #### Usage + * Typically used in scenarios where the Casino environment needs to expand by adding more gaming rooms. + * + * @param {PokerRoomInterface} room - The `PokerRoom` instance to add. + * @returns {boolean} - Returns `true` when the room has been added successfully. + * + * @example + * ```typescript + * const casino = new Casino(); + * const room = new PokerRoom({ name: "HighRollers", tableSize: 6, smallBlind: 10, bigBlind: 20 }); + * const success = casino.addRoom(room); + * console.log(success); // true + * ``` + */ + addRoom(room: PokerRoomInterface): PokerRoomInterface[]; + + /** + * #### Description + * Adds a new `PokerRoom` instance to the Casino's list of managed rooms, enabling dynamic expansion + * of rooms within the Casino environment. + * + * #### Implements + * `N/A` + * + * #### Overrides + * `N/A` + * + * #### Purpose + * This method provides a flexible mechanism for expanding the Casino's room offerings by allowing new + * rooms to be added as required, thereby supporting various gaming scenarios and player demand. + * + * #### Events + * `N/A` + * + * #### Parameters + * - `room` - A `PokerRoomInterface` instance representing the room to be added to the Casino’s list. + * + * #### Requirements + * - The `room` parameter must be a valid instance implementing `PokerRoomInterface`. + * + * #### Returns + * - Returns `true` to confirm that the room has been successfully added to the Casino. + * + * #### Usage + * Typically used in scenarios where the Casino environment needs to expand by adding more gaming rooms. + * + * @param {PokerRoomInterface[]} rooms - The `PokerRoom` instance to add. + * @returns {boolean} - Returns `true` when the room has been added successfully. + * + * @example + * ```typescript + * const casino = new Casino(); + * const room = new PokerRoom({ name: "HighRollers", tableSize: 6, smallBlind: 10, bigBlind: 20 }); + * const success = casino.addRoom(room); + * console.log(success); // true + * ``` + */ + addRooms(rooms: PokerRoomInterface[]): PokerRoomInterface[]; + + /************************************************************************************************************** + * DELETE METHODS (REMOVING OBJECTS) + **************************************************************************************************************/ + + /** + * #### Description + * Removes a `PokerRoom` from the Casino's list of managed rooms based on the room's name, enabling dynamic + * contraction of the Casino environment as required. + * + * #### Implements + * `N/A` + * + * #### Overrides + * `N/A` + * + * #### Purpose + * Allows the Casino environment to remain current by dynamically removing rooms that are no longer active + * or needed. This supports a clean and manageable set of active rooms within the Casino. + * + * #### Events + * - Emits a `casino:roomRemoved` event when a room is successfully removed. This event can be used + * to trigger updates, logging, or notifications. + * + * #### Parameters + * - `roomName`: A string representing the name of the `PokerRoom` to be removed from the Casino. + * + * #### Requirements + * - The `roomName` parameter should match the `name` property of an existing room for successful deletion. + * + * #### Returns + * - Returns `true` if the room was successfully removed, or `false` if no room with the specified name was found. + * + * #### Usage + * Use this method when removing a room that is no longer active or required, ensuring that only + * currently used rooms remain managed by the Casino. + * + * @param {number} index - The name of the `PokerRoom` to be removed. + * @returns {PokerRoomInterface[]} - Returns `true` if the room was removed; `false` if not found. + * + * @example + * ```typescript + * const casino = new Casino(); + * casino.createRoom({ name: "HighRollers", tableSize: 6, smallBlind: 10, bigBlind: 20 }); + * const success = casino.deleteRoom("HighRollers"); + * console.log(success); // true if room was found and removed, false otherwise + * ``` + */ + deleteRoom(index: number): PokerRoomInterface[]; + + /************************************************************************************************************** + * BUSINESS-LOGIC METHODS (LOGIC & CALCULATIONS) + **************************************************************************************************************/ + + /************************************************************************************************************** + * WRAPPER METHODS (UTILITY & CONVENIENCE) + **************************************************************************************************************/ + + /** + * #### Description + * Retrieves the total number of `PokerRoom` instances currently managed by the Casino. + * + * #### Implements + * `N/A` + * + * #### Overrides + * `N/A` + * + * #### Purpose + * This method provides insight into the number of poker rooms that the Casino manages, supporting + * validation for index-bound operations or general information on Casino state. + * + * #### Events + * `N/A` + * + * #### Parameters + * `N/A` + * + * #### Requirements + * `N/A` + * + * #### Returns + * - Returns the total count of rooms managed by the Casino. + * + * #### Usage + * Use this method to retrieve the total count of active poker rooms, which is helpful when iterating over + * rooms or confirming index-bound conditions. + * + * @returns {number} - The current count of rooms in the Casino. + * + * @example + * ```typescript + * const casino = new Casino(); + * const count = casino.roomCount(); + * console.log(count); // Logs the total number of managed rooms, e.g., 5 + * ``` + */ + roomCount(): number; + + /** + * #### Description + * Validates if a specified index is within the valid bounds of the Casino’s room list. + * + * #### Implements + * `N/A` + * + * #### Overrides + * `N/A` + * + * #### Purpose + * Prevents out-of-bounds errors by confirming that an index is within the acceptable range for the Casino’s + * room list, ensuring that subsequent calls to access rooms by index have a valid target. + * + * #### Events + * `N/A` + * + * #### Parameters + * - `index`: A zero-based integer specifying the position of a room within the Casino's managed room list. + * + * #### Requirements + * - The `index` must be a non-negative integer within the bounds of the `__rooms` array. + * + * #### Returns + * - Returns `true` if the index is within bounds. + * - Throws an `Error` if the index is out of bounds. + * + * #### Usage + * Call this method before performing operations involving indexed access to rooms, ensuring the index + * falls within valid boundaries. + * + * @param {number} index - The zero-based index to validate within the room list. + * @returns {boolean} - Returns `true` if the index is within bounds. + * + * @throws {Error} - Throws an error with a descriptive message if the index is out of bounds. + * + * @example + * ```typescript + * const casino = new Casino(); + * try { + * casino.isValidIndex(2); // Returns true if index 2 exists in the list of rooms + * } catch (error) { + * console.error(error.message); // Logs error if index 2 is invalid + * } + * ``` + */ + isValidIndex(index: number): boolean; +} + +export { CasinoInterface }; diff --git a/src/interfaces/deck/index.ts b/src/interfaces/deck/index.ts index 8642a15..e07c568 100644 --- a/src/interfaces/deck/index.ts +++ b/src/interfaces/deck/index.ts @@ -1,22 +1,69 @@ -import { ICard } from "../card"; +//@collapse + +import { BaseEventEmitterInterface } from "../_base"; +import { CardInterface } from "../card"; /** - * @interface `IDeck` + * @interface `DeckInterface` * Represents the structure of a deck in a poker game. + * The interface provides methods to shuffle the deck and draw cards from the top. + * + * @extends NodeJS.EventEmitter + * + * @example + * const deck: DeckInterface = new Deck(); + * deck.shuffle(); + * const card = deck.draw(); + * console.log(card?.toString()); // "A of Spades" */ -interface IDeck { +interface DeckInterface extends BaseEventEmitterInterface { + /************************************************************************************************************** + * CREATE METHODS (SETTERS & OBJECT CREATION) + **************************************************************************************************************/ + + /************************************************************************************************************** + * READ METHODS (GETTERS & DATA RETRIEVAL) + **************************************************************************************************************/ + + getCards(): CardInterface[]; + + /************************************************************************************************************** + * UPDATE METHODS (MODIFYING EXISTING OBJECTS) + **************************************************************************************************************/ + + /************************************************************************************************************** + * DELETE METHODS (REMOVING OBJECTS) + **************************************************************************************************************/ + + /************************************************************************************************************** + * BUSINESS-LOGIC METHODS (LOGIC & CALCULATIONS) + **************************************************************************************************************/ + /** - * @method `shuffle` + * `shuffle` * Shuffles the deck of cards. + * + * @example + * const deck = new Deck(); + * deck.shuffle(); */ shuffle(): void; /** - * @method `draw` + * `draw` * Draws a card from the top of the deck. - * @returns {ICard | undefined} Returns the drawn card or `undefined` if no cards remain. + * + * @returns {CardInterface | undefined} Returns the drawn card or `undefined` if no cards remain. + * + * @example + * const drawnCard = deck.draw(); + * console.log(drawnCard?.toString()); // "A of Spades" */ - draw(): ICard | undefined; + draw(): CardInterface | undefined; } -export { IDeck }; +/************************************************************************************************************** + * WRAPPER METHODS (UTILITY & CONVENIENCE) + **************************************************************************************************************/ + +export { DeckInterface }; diff --git a/src/interfaces/index.ts b/src/interfaces/index.ts index 502fb21..a8857c1 100644 --- a/src/interfaces/index.ts +++ b/src/interfaces/index.ts @@ -1,18 +1,37 @@ -import { ICard } from "./card"; -import { IDeck } from "./deck"; -import { Rank } from "./rank"; -import { Suit } from "./suit"; +//@collapse /** * @module `Interfaces` * Centralized export for all poker-related interfaces and types. - * This module gathers and exports interfaces and types for `Card`, `Deck`, `Rank`, and `Suit`. + * This module gathers and exports interfaces and types for `Card`, `Deck`. * This allows for streamlined imports in other modules, ensuring that all poker-related interfaces * and types can be accessed from a single location. * * @example * // Import all interfaces and types from the centralized module - * import { ICard, IDeck, Rank, Suit } from './interfaces'; + * import { CardInterface, DeckInterface } from './interfaces'; */ - -export { ICard, IDeck, Rank, Suit }; +export * as BaseInterfaceModule from "./_base"; +export * from "./_base"; +export * as BaseEventInterfaceModule from "./baseEvent"; +export * from "./baseEvent"; +export * as CardInterfaceModule from "./card"; +export * from "./card"; +export * as CasinoInterfaceModule from "./casino"; +export * from "./casino"; +export * as DeckInterfaceModule from "./deck"; +export * from "./deck"; +export * as LoggerInterfaceModule from "./logger"; +export * from "./logger"; +export * as PokerGameInterfaceModule from "./pokerGame"; +export * from "./pokerGame"; +export * as PokerPhaseInterfaceModule from "./pokerPhase"; +export * from "./pokerPhase"; +export * as PokerPlayerInterfaceModule from "./pokerPlayer"; +export * from "./pokerPlayer"; +export * as PokerRoomInterfaceModule from "./pokerRoom"; +export * from "./pokerRoom"; +export * as PokerSeatInterfaceModule from "./pokerSeat"; +export * from "./pokerSeat"; +export * as PokerTableInterfaceModule from "./pokerTable"; +export * from "./pokerTable"; diff --git a/src/interfaces/logger/index.ts b/src/interfaces/logger/index.ts new file mode 100644 index 0000000..cb35aba --- /dev/null +++ b/src/interfaces/logger/index.ts @@ -0,0 +1,128 @@ +//@collapse + +// Import Enums +import { LogLevel } from "../../enums"; + +/** + * @interface `LoggerConfig` + * + * Provides configuration options for the `Logger` class, defining paths, output preferences, and general setup. + * + * #### Purpose + * The `LoggerConfig` interface standardizes the configuration settings for the logger, ensuring a flexible setup. + * This interface allows users to specify where logs should be stored (`logDirPath`) and whether logging should also + * appear in the console (`enableConsoleLogging`), thus supporting various logging needs in both development and + * production environments. + * + * #### Usage + * The `LoggerConfig` interface can be used when initializing a logger to define the configuration that aligns with + * project-specific requirements. + * + * @example + * ```typescript + * const config: LoggerConfig = { + * logDirPath: "./logs", + * enableConsoleLogging: true + * }; + * ``` + */ +interface LoggerConfig { + /** + * @property {boolean} [enableConsoleLogging] + * + * Enables or disables console output of logs in addition to file storage. + * + * #### Purpose + * Allows developers to toggle console logging, which can be helpful in development environments while + * potentially disabled in production. + * + * #### Requirements + * - Optional: Default behavior may be true for development and false for production if not explicitly set. + * + * @example + * ```typescript + * const config: LoggerConfig = { + * enableConsoleLogging: false + * }; + * ``` + */ + enableConsoleLogging?: boolean; +} + +/** + * @interface `LoggerInterface` + * + * Defines the structure for logging functionality, ensuring a consistent format for message logging + * across different log levels and supporting optional data context. + * + * #### Purpose + * The `LoggerInterface` interface establishes the required method for logging in various components + * within the application. It standardizes how log messages should be formatted and includes support + * for different levels of logging (info, warn, error). + * + * #### Methods Overview + * - `log(level: LogLevel, message: string, data?: Record): Promise`: + * Logs a message with the specified level and optional additional data. + * + * #### Usage + * The `LoggerInterface` is implemented by the `Logger` class to standardize how logging is handled. + * It can be used in classes and utilities where consistent logging behavior is necessary. + * + * @example + * ```typescript + * class MyLogger implements LoggerInterface { + * async log(level: LogLevel, message: string, data?: Record): Promise { + * // Implementation of log + * } + * } + * + * const logger: LoggerInterface = new MyLogger(); + * logger.log("info", "Application started", { timestamp: new Date() }); + * ``` + */ +interface LoggerInterface { + /** + * #### Description + * Logs a message with the specified level and optional additional data context. This method + * is asynchronous to allow for file I/O or remote logging without blocking the application. + * + * #### Purpose + * Standardizes the logging of messages, allowing for log levels and structured data. + * Provides flexibility in logging with additional context, such as an error stack or + * metadata related to the log message. + * + * #### Parameters + * - `level: LogLevel` - The severity level of the log message (e.g., "info", "warn", "error"). + * - `message: string` - The main message to be logged. + * - `data?: Record` - Optional additional data that provides context for the log message. + * + * #### Requirements + * - `level` should be a valid log level defined in `LogLevel`. + * - `message` should clearly describe the event or action. + * + * #### Returns + * - `Promise` - Returns a promise that resolves once the log has been processed. + * + * #### Usage + * Use this method to log important events, errors, or debug information with optional + * data for added context. + * + * @param {LogLevel} level - The severity level of the log message. + * @param {string} message - The main message to log. + * @param {Record} [data] - Additional context data for the log (optional). + * + * @returns {Promise} - A promise that resolves when the logging is complete. + * + * @example + * ```typescript + * logger.log("error", "Failed to connect to the database", { errorCode: "DB_CONN_ERR", timestamp: new Date() }); + * ``` + */ + log( + level: LogLevel, + message: string, + data?: Record + ): Promise; +} + +export { LoggerConfig, LoggerInterface }; diff --git a/src/interfaces/pokerGame/index.ts b/src/interfaces/pokerGame/index.ts new file mode 100644 index 0000000..4816bc3 --- /dev/null +++ b/src/interfaces/pokerGame/index.ts @@ -0,0 +1,45 @@ +//@collapse + +import { BaseEventEmitterInterface } from "../_base"; +import { PokerPlayerInterface } from "../pokerPlayer"; + +/** + * @interface `PokerGameConfig` + * Represents a Poker Game Config. + */ +interface PokerGameConfig { + /** + * @property {string} id + * The maximum number of players that can be seated at the PokerTable[2-14]. + */ + id?: string; + + /** + * @property {number} smallBlind + * The maximum number of players that can be seated at the PokerTable[2-14]. + */ + smallBlind: number; + + /** + * @property {number} bigBlind + * The maximum number of players that can be seated at the PokerTable[2-14]. + */ + bigBlind: number; + + /** + * @property {string | undefined} name + * The maximum number of players that can be seated at the PokerTable[2-14]. + */ + players: PokerPlayerInterface[]; +} + +/** + * @interface `PokerGameInterface` + * Represents the current PokerGame being played at the PokerTable. + * Manages the deck, community cards, and game phases, such as pre-flop, flop, turn, and river. + * + * @extends NodeJS.EventEmitter + */ +interface PokerGameInterface extends BaseEventEmitterInterface {} + +export { PokerGameConfig, PokerGameInterface }; diff --git a/src/interfaces/pokerPhase/index.ts b/src/interfaces/pokerPhase/index.ts new file mode 100644 index 0000000..a69b498 --- /dev/null +++ b/src/interfaces/pokerPhase/index.ts @@ -0,0 +1,72 @@ +//@collapse + +import { BaseEventEmitterInterface } from "../_base"; +import { DeckInterface } from "../deck"; +import { PokerPlayerInterface } from "../pokerPlayer"; +import { PokerPhaseName } from "../../enums"; +import { CardInterface } from "../card"; + +/** + * @interface `PokerPhaseConfig` + * Represents a Poker Phase Config. + */ +interface PokerPhaseConfig { + /** + * @property {PokerPhaseName} name + * The deck of cards used in the current PokerPhase. + */ + name: PokerPhaseName; + + /** + * @property {DeckInterface} deck + * The deck of cards used in the current PokerPhase. + */ + deck: DeckInterface; + + /** + * @property {PokerPlayerInterface[]} players + * The maximum number of players that can be seated at the PokerTable[2-14]. + */ + players: PokerPlayerInterface[]; + + /** + * @property {number} pot + * The maximum number of players that can be seated at the PokerTable[2-14]. + */ + pot?: number; + + /** + * @property {number} pot + * The maximum number of players that can be seated at the PokerTable[2-14]. + */ + dealerPos: number; + + /** + * @property {number} pot + * The maximum number of players that can be seated at the PokerTable[2-14]. + */ + smallBlindPos: number; + + /** + * @property {number} pot + * The maximum number of players that can be seated at the PokerTable[2-14]. + */ + bigBlindPos: number; + + /** + * @property {number} communityCards + * The maximum number of players that can be seated at the PokerTable[2-14]. + */ + communityCards?: CardInterface[]; +} + +/** + * @interface `PokerPhaseInterface` + * Represents the current PokerPhase being played at the PokerTable. + * Manages the deck, community cards, and game phases, such as pre-flop, flop, turn, and river. + * + * @extends NodeJS.EventEmitter + */ +interface PokerPhaseInterface extends BaseEventEmitterInterface {} + +export { PokerPhaseConfig, PokerPhaseInterface }; diff --git a/src/interfaces/pokerPlayer/index.ts b/src/interfaces/pokerPlayer/index.ts new file mode 100644 index 0000000..9b558d3 --- /dev/null +++ b/src/interfaces/pokerPlayer/index.ts @@ -0,0 +1,74 @@ +//@collapse + +import { BaseEventEmitterInterface } from "../_base"; +import { CardInterface } from "../card"; + +/** + * @interface `PokerPlayerConfig` + * Represents a PokerPlayer Config. + */ +interface PokerPlayerConfig { + /** + * @property {string} id + * The maximum number of players that can be seated at the PokerTable[2-14]. + */ + id?: string; + + /** + * @property {string} name + * The maximum number of players that can be seated at the PokerTable[2-14]. + */ + name?: string; + + /** + * @property {number} chips + * @private + * The number of chips the player currently has. + */ + chips?: number; + + /** + * @property {CardInterface[]} hand + * @private + * The player's hole cards (the two cards dealt to the player at the start of the game). + */ + hand?: CardInterface[]; + + /** + * @property {boolean} isFolded + * @private + * Indicates whether the player is still active in the current round or has folded. + */ + isFolded?: boolean; +} + +/** + * @interface `PokerPlayerInterface` + * Represents a player seated at the PokerTable. + * The player can place bets, fold, and manage their chip stack during the game. + * + * @extends NodeJS.EventEmitter + */ +interface PokerPlayerInterface extends BaseEventEmitterInterface { + /************************************************************************************************************** + * READ METHODS (GETTERS & DATA RETRIEVAL) + **************************************************************************************************************/ + + /** + * `getId` + * @public + * Returns the poker table's `id`. + * @returns {string} The poker table's `id`. + * + * @example + * const rank = card.getRank(); + * console.log(rank); // "A" + */ + getId(): string; + + bet(amount: number): boolean; + + setIsFolded(bool: boolean): boolean; +} + +export { PokerPlayerConfig, PokerPlayerInterface }; diff --git a/src/interfaces/pokerRoom/index.ts b/src/interfaces/pokerRoom/index.ts new file mode 100644 index 0000000..c7d9d0d --- /dev/null +++ b/src/interfaces/pokerRoom/index.ts @@ -0,0 +1,500 @@ +//@collapse + +import { BaseEventEmitterInterface } from "../_base"; +import { PokerTableConfig, PokerTableInterface } from "../pokerTable"; + +/** + * @interface `PokerRoomConfig` + * + * Represents the configuration settings necessary to create a `PokerRoom` within the Casino system. + * This interface defines core properties such as a unique identifier (`id`), room name (`name`), + * and an array of table configurations (`tableConfigs`) that standardize room setup and ensure consistent + * properties across all `PokerRoom` instances. + * + * #### Purpose + * The `PokerRoomConfig` interface serves as a blueprint for initializing `PokerRoom` instances. + * By defining required properties upfront, this configuration helps streamline room creation, + * reduce errors, and maintain uniformity across room instances within the Casino system. + * + * #### Structure Overview + * The interface includes: + * - **Room Identification**: `id` and `name` properties for unique identification and naming of the room. + * - **Table Configurations**: An array, `tableConfigs`, that holds one or more configurations detailing each table's settings within the room. + * + * #### Usage + * Primarily used as an input for the `PokerRoom` constructor, `PokerRoomConfig` allows developers + * to define each room’s essential properties during instantiation. This structure helps prevent + * setup errors and ensures consistency among multiple rooms in the Casino. + * + * #### Requirements + * - **`tableConfigs`**: Must be a valid array containing one or more `PokerTableConfig` objects. + * - **`id` and `name` (optional)**: Enhance room uniqueness and readability, if provided. + * + * @example + * ```typescript + * const roomConfig: PokerRoomConfig = { + * id: "room42", + * name: "High Stakes", + * tableConfigs: [ + * { tableSize: 6, smallBlind: 50, bigBlind: 100 }, + * { tableSize: 8, smallBlind: 100, bigBlind: 200 } + * ] + * }; + * const pokerRoom = new PokerRoom(roomConfig); // Initializes a new PokerRoom with the specified configuration + * ``` + */ +interface PokerRoomConfig { + /************************************************************************************************************** + * PROPERTIES + **************************************************************************************************************/ + + /** + * @property {string | undefined} id + * + * A unique identifier for the poker room, allowing for easy reference and management within the Casino system. + * + * #### Purpose + * Used to uniquely identify each `PokerRoom` within the Casino, providing a direct reference for room-specific operations. + * + * #### Requirements + * - **Optional**: If provided, `id` must be a unique, non-empty string to avoid conflicts. + * + * @example + * ```typescript + * const roomConfig: PokerRoomConfig = { + * id: "room1", + * name: "High Rollers", + * tableConfigs: [{ tableSize: 6, smallBlind: 10, bigBlind: 20 }] + * }; + * console.log(roomConfig.id); + * + * // Output: "room1" + * ``` + */ + id?: string; + + /** + * @property {string | undefined} name + * + * A descriptive name for the poker room, often displayed in user interfaces or logs to enhance human readability. + * + * #### Purpose + * Serves as a user-friendly label for the poker room, assisting administrators and players in identifying the room easily. + * + * #### Requirements + * - **Optional**: `name` should be a non-empty string if defined, providing a clear label for the room. + * + * @example + * ```typescript + * const roomConfig: PokerRoomConfig = { + * id: "room2", + * name: "VIP Suite", + * tableConfigs: [{ tableSize: 8, smallBlind: 50, bigBlind: 100 }] + * }; + * console.log(roomConfig.name); + * + * // Output: "VIP Suite" + * ``` + */ + name?: string; + + /** + * @property {PokerTableConfig[]} tableConfigs + * + * An array of `PokerTableConfig` objects, each defining settings for individual tables within the poker room. + * Essential configurations include properties like `tableSize`, `smallBlind`, and `bigBlind`. + * + * #### Purpose + * Defines the structure and game settings for each table in the room, supporting multiple table configurations + * under one `PokerRoom` instance. + * + * #### Requirements + * - **Required**: `tableConfigs` must contain one or more `PokerTableConfig` objects to provide valid game settings. + * + * @example + * ```typescript + * const roomConfig: PokerRoomConfig = { + * id: "room3", + * name: "Beginner's Lounge", + * tableConfigs: [ + * { tableSize: 4, smallBlind: 5, bigBlind: 10 }, + * { tableSize: 6, smallBlind: 10, bigBlind: 20 } + * ] + * }; + * console.log(roomConfig.tableConfigs); + * // Output: [{ tableSize: 4, smallBlind: 5, bigBlind: 10 }, { tableSize: 6, smallBlind: 10, bigBlind: 20 }] + * ``` + */ + tableConfigs?: PokerTableConfig[]; +} + +/** + * @interface `PokerRoomInterface` + * + * Defines the responsibilities and structure for managing a `PokerRoom` within the Casino system. This interface is + * essential for implementing operations such as room setup, player queue management, and table configuration, thereby + * organizing and facilitating smooth poker game management. + * + * #### Purpose + * The `PokerRoomInterface` serves as a standardized blueprint for any `PokerRoom` class, detailing essential methods + * for room configuration, player management, and table access. By following this structure, the system ensures that each + * poker room is identifiable, manageable, and consistent in functionality. + * + * #### Extends + * This interface extends `NodeJS.EventEmitter` to allow event-driven management of room actions like table updates, + * player entry, or exit events, enhancing flexibility in asynchronous operations across the Casino system. + * + * #### Methods Overview + * The `PokerRoomInterface` includes the following methods: + * - **setName**: Sets or updates the room’s name. + * - **setTables**: Configures the tables in the room, setting attributes such as table size and blinds. + * + * #### Events Overview + * The `PokerRoomInterface` includes the following events: + * - **roomUpdated**: Emitted whenever the room’s settings are updated, such as when tables are reconfigured. + * + * #### Usage + * This interface is designed to standardize the management of `PokerRoom` instances, offering a complete structure for + * both client-facing interactions (like displaying room details) and internal operations (like seating players or adjusting + * tables). + * + * @extends NodeJS.EventEmitter + * + * @example + * ```typescript + * const pokerRoom: PokerRoomInterface = new PokerRoom(); + * pokerRoom.on('roomUpdated', () => console.log(`Room updated with new settings`)); + * pokerRoom.setName("HighRollers"); + * console.log(pokerRoom.getName()); // Logs "HighRollers" + * ``` + */ +interface PokerRoomInterface extends BaseEventEmitterInterface { + /************************************************************************************************************** + * CREATE METHODS (SETTERS & OBJECT CREATION) + **************************************************************************************************************/ + + /** + * #### Description + * Sets the name of the `PokerRoom`, allowing the name to be updated or customized. + * + * #### Implements + * `N/A` - This method is part of the `PokerRoomInterface` and does not implement any external methods. + * + * #### Overrides + * `N/A` - This method does not override any superclass or parent methods. + * + * #### Purpose + * The `setName` method is used to assign a specific name to a `PokerRoom`, which helps distinguish it within the system. + * This is essential for systems where rooms need to be identifiable and manageable through a unique name. + * + * #### Events + * `N/A` - No events are emitted by this method. + * + * #### Parameters + * - `name`: A string representing the new name for the room. It must be a valid, non-empty string to ensure + * the room has a clear, identifiable label. + * + * #### Requirements + * - The `name` parameter should be a non-empty string to provide meaningful identification. + * - Passing an empty or invalid value could result in future misidentification of rooms if validation is implemented. + * + * #### Returns + * - Returns the `name` that was set for the `PokerRoom`. + * + * #### Usage + * Use this method to set or update the name of a room in a system where unique or identifiable room names + * are necessary for reference. + * + * @param {string} name - The new name for the `PokerRoom`. + * @returns {string} - Returns the name of the room that was set. + * + * @example + * ```typescript + * const pokerRoom = new PokerRoom({ name: "Room1", tableSize: 6 }); + * pokerRoom.setName("HighRollers"); // Sets the name of the room to "HighRollers" + * console.log(pokerRoom.getName()); // Logs "HighRollers" + * ``` + */ + setName(name: string): string; + + /** + * #### Description + * Sets the configuration for multiple tables within the `PokerRoom`. Each table configuration specifies + * key attributes like table size, small blind, and big blind values, supporting multi-table configurations + * within a single room. + * + * #### Implements + * `N/A` - This method is part of the `PokerRoomInterface` and does not implement any external methods. + * + * #### Overrides + * `N/A` - This method does not override any superclass or parent methods. + * + * #### Purpose + * The `setTables` method is crucial for defining or updating the configuration of multiple tables in a room. + * Properly configured tables are essential for ensuring smooth gameplay and an organized player experience. + * + * #### Events + * - **roomUpdated**: This event is emitted whenever the table configurations are successfully set or updated, + * allowing external components to respond to changes in the room’s setup. + * + * #### Parameters + * - `tables`: An array of `PokerTableInterface` objects, each containing configuration details for a table. + * + * #### Requirements + * - `tables` must be a non-empty array of `PokerTableInterface` instances, each configured with necessary game parameters. + * + * #### Returns + * - Returns the array of `PokerTableInterface` instances after successfully setting them within the room. + * + * #### Usage + * Call this method to configure or update multiple tables in a poker room, ensuring the settings align with + * room requirements and player needs. + * + * @param {PokerTableInterface[]} tables - The list of table configurations for the poker room. + * @returns {PokerTableInterface[]} - Returns the updated table configurations for the room. + * + * @example + * ```typescript + * const pokerRoom = new PokerRoom({ name: "Room3", tableSize: 8 }); + * const tableConfigs = [ + * new PokerTable({ tableSize: 8, smallBlind: 10, bigBlind: 20 }), + * new PokerTable({ tableSize: 10, smallBlind: 20, bigBlind: 40 }) + * ]; + * pokerRoom.setTables(tableConfigs); // Sets multiple table configurations in the room + * console.log(pokerRoom.getTables()); // Logs the table configurations + * ``` + */ + setTables(tables: PokerTableInterface[]): PokerTableInterface[]; + + /************************************************************************************************************** + * READ METHODS (GETTERS & DATA RETRIEVAL) + **************************************************************************************************************/ + + /** + * #### Description + * Retrieves the unique identifier of the `PokerRoom`. + * + * #### Implements + * `N/A` - This method is defined within the `PokerRoomInterface` without implementing external methods. + * + * #### Overrides + * `N/A` - This method does not override any superclass or parent methods. + * + * #### Purpose + * The `getId` method enables access to the unique `id` of a `PokerRoom`, which is essential for identifying + * and referencing specific rooms within the system. + * + * #### Events + * `N/A` - No events are emitted by this method. + * + * #### Parameters + * `N/A` - This method does not require any parameters. + * + * #### Requirements + * `N/A` - This method simply returns the `id` as set by the `setId` method. + * + * #### Returns + * - Returns the unique `id` of the `PokerRoom` as a string. + * + * #### Usage + * Use this method to retrieve the identifier of a `PokerRoom`. This is particularly useful for managing, + * searching, or displaying room information. + * + * @returns {string} - The unique identifier of the `PokerRoom`. + * + * @example + * ```typescript + * const pokerRoom = new PokerRoom({ id: "Room123", name: "VIP Room", tableSize: 6 }); + * console.log(pokerRoom.getId()); // Logs "Room123" + * ``` + */ + getId(): string; + + /** + * #### Description + * Retrieves the current name of the `PokerRoom`. + * + * #### Implements + * `N/A` - This method is defined within `PokerRoomInterface` and is implemented by any class adhering to this interface. + * + * #### Overrides + * `N/A` - This method does not override any superclass or parent methods. + * + * #### Purpose + * The `getName` method enables access to the current name of a `PokerRoom`, which can be essential for + * identification, logging, and displaying room information to users. + * + * #### Events + * `N/A` - No events are emitted by this method. + * + * #### Parameters + * `N/A` - This method does not require any parameters. + * + * #### Requirements + * `N/A` - This method simply returns the current name as set by `setName`. + * + * #### Returns + * - Returns the current name of the `PokerRoom` as a string. + * + * #### Usage + * Use this method to fetch the current name of a `PokerRoom`. This can be particularly helpful for displaying + * or verifying the room name during operations. + * + * @returns {string} - The current name of the `PokerRoom`. + * + * @example + * ```typescript + * const pokerRoom = new PokerRoom({ name: "VIP Room", tableSize: 6 }); + * console.log(pokerRoom.getName()); // Logs "VIP Room" + * ``` + */ + getName(): string; + + /** + * #### Description + * Retrieves the associated `PokerTable` instance within the `PokerRoom`. + * + * #### Implements + * `N/A` - This method does not implement external interfaces. + * + * #### Overrides + * `N/A` - This method does not override any superclass or parent methods. + * + * #### Purpose + * The `getTable` method provides access to the `PokerTable` instance that is actively managed by the `PokerRoom`. + * This can be used to view table configuration, status, and player seating arrangements. + * + * #### Events + * `N/A` - This method does not emit any events. + * + * #### Parameters + * `N/A` - No parameters are required for this method. + * + * #### Requirements + * `N/A` - This method does not modify the table, only retrieves it. + * + * #### Returns + * - Returns the `PokerTableInterface` instance currently set for the room. + * + * #### Usage + * Use this method to access the poker table associated with a specific room. This allows for table-specific + * operations and inquiries. + * + * @returns {PokerTableInterface} - The `PokerTable` instance associated with this room. + * + * @example + * ```typescript + * const pokerRoom = new PokerRoom({ name: "High Stakes", tableSize: 6 }); + * const table = pokerRoom.getTable(); + * console.log(table); // Logs the PokerTable instance associated with "High Stakes" room + * ``` + */ + getTables(): PokerTableInterface[]; + + /************************************************************************************************************** + * UPDATE METHODS (MODIFYING EXISTING OBJECTS) + **************************************************************************************************************/ + + /************************************************************************************************************** + * DELETE METHODS (REMOVING OBJECTS) + **************************************************************************************************************/ + + /************************************************************************************************************** + * BUSINESS-LOGIC METHODS (LOGIC & CALCULATIONS) + **************************************************************************************************************/ + + /************************************************************************************************************** + * WRAPPER METHODS (UTILITY & CONVENIENCE) + **************************************************************************************************************/ + + /** + * #### Description + * Retrieves the total number of `PokerRoom` instances currently managed by the Casino. + * + * #### Implements + * `N/A` + * + * #### Overrides + * `N/A` + * + * #### Purpose + * This method provides insight into the number of poker rooms that the Casino manages, supporting + * validation for index-bound operations or general information on Casino state. + * + * #### Events + * `N/A` + * + * #### Parameters + * `N/A` + * + * #### Requirements + * `N/A` + * + * #### Returns + * - Returns the total count of rooms managed by the Casino. + * + * #### Usage + * Use this method to retrieve the total count of active poker rooms, which is helpful when iterating over + * rooms or confirming index-bound conditions. + * + * @returns {number} - The current count of rooms in the Casino. + * + * @example + * ```typescript + * const casino = new Casino(); + * const count = casino.roomCount(); + * console.log(count); // Logs the total number of managed rooms, e.g., 5 + * ``` + */ + tableCount(): number; + + /** + * #### Description + * Validates if a specified index is within the valid bounds of the Casino’s room list. + * + * #### Implements + * `N/A` + * + * #### Overrides + * `N/A` + * + * #### Purpose + * Prevents out-of-bounds errors by confirming that an index is within the acceptable range for the Casino’s + * room list, ensuring that subsequent calls to access rooms by index have a valid target. + * + * #### Events + * `N/A` + * + * #### Parameters + * - `index`: A zero-based integer specifying the position of a room within the Casino's managed room list. + * + * #### Requirements + * - The `index` must be a non-negative integer within the bounds of the `__rooms` array. + * + * #### Returns + * - Returns `true` if the index is within bounds. + * - Throws an `Error` if the index is out of bounds. + * + * #### Usage + * Call this method before performing operations involving indexed access to rooms, ensuring the index + * falls within valid boundaries. + * + * @param {number} index - The zero-based index to validate within the room list. + * @returns {boolean} - Returns `true` if the index is within bounds. + * + * @throws {Error} - Throws an error with a descriptive message if the index is out of bounds. + * + * @example + * ```typescript + * const casino = new Casino(); + * try { + * casino.isValidIndex(2); // Returns true if index 2 exists in the list of rooms + * } catch (error) { + * console.error(error.message); // Logs error if index 2 is invalid + * } + * ``` + */ + isValidIndex(index: number): boolean; +} + +export { PokerRoomConfig, PokerRoomInterface }; diff --git a/src/interfaces/pokerSeat/index.ts b/src/interfaces/pokerSeat/index.ts new file mode 100644 index 0000000..c9ea6c9 --- /dev/null +++ b/src/interfaces/pokerSeat/index.ts @@ -0,0 +1,136 @@ +//@collapse + +import { BaseEventEmitterInterface } from "../_base"; +import { PokerPlayerInterface } from "../pokerPlayer"; + +/** + * @interface `PokerSeatConfig` + * Represents a PokerTable Config. + */ +interface PokerSeatConfig { + /** + * @property {string | undefined} id + * The maximum number of players that can be seated at the PokerTable[2-14]. + */ + id?: string; + + /** + * @property {number} position + * The maximum number of players that can be seated at the PokerTable[2-14]. + */ + position: number; + + /** + * @property {boolean} isDealer + * The maximum number of players that can be seated at the PokerTable[2-14]. + */ + isDealer?: boolean; + + /** + * @property {PokerPlayerInterface | undefined} player + * The maximum number of players that can be seated at the PokerTable[2-14]. + */ + player?: PokerPlayerInterface; +} + +/** + * @interface `PokerSeatInterface` + * Represents a PokerTable within a PokerRoom. + * The PokerTable manages player seats, tracks the dealer, small blind, and big blind positions, + * and handles the start and stop of the PokerGame. + * + * @extends NodeJS.EventEmitter + */ +interface PokerSeatInterface extends BaseEventEmitterInterface { + /************************************************************************************************************** + * CREATE METHODS (SETTERS & OBJECT CREATION) + **************************************************************************************************************/ + + /** + * `setIsDealer` + * @public + * Returns the poker table's `id`. + * @returns {boolean} The poker table's `id`. + * + * @example + * const rank = card.getRank(); + * console.log(rank); // "A" + */ + setDealer(bool: boolean): boolean; + + /************************************************************************************************************** + * READ METHODS (GETTERS & DATA RETRIEVAL) + **************************************************************************************************************/ + + /** + * `getId` + * @public + * Returns the poker table's `id`. + * @returns {string} The poker table's `id`. + * + * @example + * const rank = card.getRank(); + * console.log(rank); // "A" + */ + getId(): string; + + /** + * `getPosition` + * @public + * Returns the poker table's `id`. + * @returns {number} The poker table's `id`. + * + * @example + * const rank = card.getRank(); + * console.log(rank); // "A" + */ + getPosition(): number; + + /** + * `isDealer` + * @public + * Returns the poker table's `id`. + * @returns {boolean} The poker table's `id`. + * + * @example + * const rank = card.getRank(); + * console.log(rank); // "A" + */ + isDealer(): boolean; + + /** + * `getPlayer` + * @public + * Returns the poker table's `id`. + * @returns {PokerPlayerInterface | undefined} The poker table's `id`. + * + * @example + * const rank = card.getRank(); + * console.log(rank); // "A" + */ + getPlayer(): PokerPlayerInterface | undefined; + + /************************************************************************************************************** + * UPDATE METHODS (MODIFYING EXISTING OBJECTS) + **************************************************************************************************************/ + + /************************************************************************************************************** + * DELETE METHODS (REMOVING OBJECTS) + **************************************************************************************************************/ + + /************************************************************************************************************** + * BUSINESS-LOGIC METHODS (LOGIC & CALCULATIONS) + **************************************************************************************************************/ + + isOccupied(): boolean; + + occupy(player: PokerPlayerInterface): void; + + vacate(): void; + + /************************************************************************************************************** + * WRAPPER METHODS (UTILITY & CONVENIENCE) + **************************************************************************************************************/ +} + +export { PokerSeatConfig, PokerSeatInterface }; diff --git a/src/interfaces/pokerTable/index.ts b/src/interfaces/pokerTable/index.ts new file mode 100644 index 0000000..ffc69b0 --- /dev/null +++ b/src/interfaces/pokerTable/index.ts @@ -0,0 +1,350 @@ +//@collapse + +import { BaseEventEmitterInterface } from "../_base"; +import { PokerSeatInterface } from "../pokerSeat"; + +/** + * @interface `PokerTableConfig` + * + * Represents the configuration settings necessary to define a poker table within a `PokerRoom`. This interface + * standardizes essential properties such as unique identifiers, table size, and betting values, ensuring each + * table is set up with consistent and clear parameters. + * + * #### Purpose + * The `PokerTableConfig` interface provides a structured configuration for each table within a poker room. By defining + * specific parameters for table size, small blind, and big blind amounts, this interface supports accurate table setup + * and improves the consistency of poker gameplay within the Casino system. + * + * #### Structure Overview + * - **Identification**: The `id` and `name` properties enable unique identification and labeling of tables. + * - **Betting Structure**: `smallBlind` specify the betting increments for the table. + * - **Seating Capacity**: `size` defines the maximum number of players per table. + * + * #### Usage Context + * `PokerTableConfig` objects are typically used during table creation or setup, offering a clear and consistent way + * to configure and manage individual poker tables within a room. + * + * #### Requirements + * - **Optional**: `id`,`name`, `size` and `smallBlind` are not strictly required. + * - **Mandatory**: No Mandatory. + * + * @example + * ```typescript + * const tableConfig: PokerTableConfig = { + * id: "table1", + * name: "VIP Table", + * size: 8, + * smallBlind: 50 + * }; + * ``` + */ +interface PokerTableConfig { + /************************************************************************************************************** + * PROPERTIES + **************************************************************************************************************/ + + /** + * @property {string | undefined} id + * + * A unique identifier for the poker table, enabling precise reference and management within the Casino system. + * + * #### Purpose + * Used to uniquely identify each `PokerTable` within the Casino, providing a direct reference for table-specific operations. + * + * #### Requirements + * - **Optional**: If provided, `id` must be a unique, non-empty string to avoid conflicts. + * + * @example + * **Example 1**: + * ```typescript + * const tableConfig: PokerTableConfig = { + * id: "table42", + * name: "High Stakes Table", + * size: 6, + * smallBlind: 100 + * }; + * console.log(tableConfig.id); + * // Console Output: "table42" + * ``` + * **Example 2**: + * ```typescript + * const tableConfig: PokerTableConfig = { + * id: undefined, + * name: "Standard Table", + * size: 4, + * smallBlind: 10 + * }; + * console.log(tableConfig.id); + * // Console Output: undefined + * ``` + */ + id?: string; + + /** + * @property {string | undefined} name + * + * A descriptive name for the poker table, often displayed in user interfaces or logs to enhance human readability. + * + * #### Purpose + * Serves as a user-friendly label for the poker table, assisting administrators and players in identifying the table easily. + * + * #### Requirements + * - **Optional**: `name` should be a non-empty string if defined, providing a clear label for the table. + * + * @example + * ```typescript + * const tableConfig: PokerTableConfig = { + * id: "table2", + * name: "VIP Suite", + * size: 8, + * smallBlind: 50 + * }; + * console.log(tableConfig.name); + * // Console Output: "VIP Suite" + * ``` + */ + name?: string; + + /** + * @property {number | undefined} size + * + * Specifies the maximum number of players that can be seated at the poker table, supporting values within + * a typical range of 2 to 14 players. + * + * #### Purpose + * Defines the seating capacity of the poker table, ensuring that no more than the specified number of players + * can join the game at a given time. + * + * #### Requirements + * - Must be a number between 2 and 14 to adhere to typical poker table constraints. + * - **Note**: If the `size` value is set outside the range of 2 to 14, an error or validation warning may be triggered + * during table initialization, as these values fall outside standard poker table configurations. + * + * @example + * ```typescript + * const tableConfig: PokerTableConfig = { + * id: "table3", + * name: "Standard Table", + * size: 6, + * smallBlind: 10 + * }; + * console.log(tableConfig.size); + * // Console Output: 6 + * ``` + */ + size?: number; + + /** + * @property {number | undefined} smallBlind + * + * The value of the small blind for betting at the table, setting the minimum bet increment. + * + * #### Purpose + * Defines the small blind amount, establishing a base for the betting structure in poker games at this table. + * + * #### Requirements + * - Must be a positive number; negative values or zero could result in validation errors. + * + * @example + * ```typescript + * const tableConfig: PokerTableConfig = { + * id: "table4", + * name: "Training Table", + * size: 4, + * smallBlind: 5 + * }; + * console.log(tableConfig.smallBlind); + * // Console Output: 5 + * ``` + */ + smallBlind?: number; +} + +/** + * @interface `PokerTableInterface` + * Represents a PokerTable within a PokerRoom. + * The PokerTable manages player seats, tracks the dealer, small blind, and big blind positions, + * and handles the start and stop of the PokerGame. + * + * @extends NodeJS.EventEmitter + */ +interface PokerTableInterface extends BaseEventEmitterInterface { + /************************************************************************************************************** + * CREATE METHODS (SETTERS & OBJECT CREATION) + **************************************************************************************************************/ + + /** + * #### Description + * Sets the name of the `PokerRoom`, allowing the name to be updated or customized. + * + * #### Implements + * `N/A` - This method is part of the `PokerRoomInterface` and does not implement any external methods. + * + * #### Overrides + * `N/A` - This method does not override any superclass or parent methods. + * + * #### Purpose + * The `setName` method is used to assign a specific name to a `PokerRoom`, which helps distinguish it within the system. + * This is essential for systems where rooms need to be identifiable and manageable through a unique name. + * + * #### Events + * `N/A` - No events are emitted by this method. + * + * #### Parameters + * - `name`: A string representing the new name for the room. It must be a valid, non-empty string to ensure + * the room has a clear, identifiable label. + * + * #### Requirements + * - The `name` parameter should be a non-empty string to provide meaningful identification. + * - Passing an empty or invalid value could result in future misidentification of rooms if validation is implemented. + * + * #### Returns + * - Returns the `name` that was set for the `PokerRoom`. + * + * #### Usage + * Use this method to set or update the name of a room in a system where unique or identifiable room names + * are necessary for reference. + * + * @param {string} name - The new name for the `PokerRoom`. + * @returns {string} - Returns the name of the room that was set. + * + * @example + * ```typescript + * const pokerRoom = new PokerRoom({ name: "Room1", tableSize: 6 }); + * pokerRoom.setName("HighRollers"); // Sets the name of the room to "HighRollers" + * console.log(pokerRoom.getName()); // Logs "HighRollers" + * ``` + */ + setName(name: string): string; + + /************************************************************************************************************** + * READ METHODS (GETTERS & DATA RETRIEVAL) + **************************************************************************************************************/ + + /** + * `getId` + * @public + * Returns the poker table's `id`. + * @returns {string} The poker table's `id`. + * + * @example + * const rank = card.getRank(); + * console.log(rank); // "A" + */ + getId(): string; + + /** + * `getSeats` + * Starts a new PokerGame if there are at least two active players at the PokerTable. + * This method initiates the game flow, including assigning blinds and starting the rounds. + * @returns {number} + */ + getSeats(): PokerSeatInterface[]; + + /************************************************************************************************************** + * UPDATE METHODS (MODIFYING EXISTING OBJECTS) + **************************************************************************************************************/ + + /************************************************************************************************************** + * DELETE METHODS (REMOVING OBJECTS) + **************************************************************************************************************/ + + /************************************************************************************************************** + * BUSINESS-LOGIC METHODS (LOGIC & CALCULATIONS) + **************************************************************************************************************/ + + /************************************************************************************************************** + * WRAPPER METHODS (UTILITY & CONVENIENCE) + **************************************************************************************************************/ + + /** + * #### Description + * Retrieves the total number of `PokerRoom` instances currently managed by the Casino. + * + * #### Implements + * `N/A` + * + * #### Overrides + * `N/A` + * + * #### Purpose + * This method provides insight into the number of poker rooms that the Casino manages, supporting + * validation for index-bound operations or general information on Casino state. + * + * #### Events + * `N/A` + * + * #### Parameters + * `N/A` + * + * #### Requirements + * `N/A` + * + * #### Returns + * - Returns the total count of rooms managed by the Casino. + * + * #### Usage + * Use this method to retrieve the total count of active poker rooms, which is helpful when iterating over + * rooms or confirming index-bound conditions. + * + * @returns {number} - The current count of rooms in the Casino. + * + * @example + * ```typescript + * const casino = new Casino(); + * const count = casino.roomCount(); + * console.log(count); // Logs the total number of managed rooms, e.g., 5 + * ``` + */ + seatCount(): number; + + /** + * #### Description + * Validates if a specified index is within the valid bounds of the Casino’s room list. + * + * #### Implements + * `N/A` + * + * #### Overrides + * `N/A` + * + * #### Purpose + * Prevents out-of-bounds errors by confirming that an index is within the acceptable range for the Casino’s + * room list, ensuring that subsequent calls to access rooms by index have a valid target. + * + * #### Events + * `N/A` + * + * #### Parameters + * - `index`: A zero-based integer specifying the position of a room within the Casino's managed room list. + * + * #### Requirements + * - The `index` must be a non-negative integer within the bounds of the `__rooms` array. + * + * #### Returns + * - Returns `true` if the index is within bounds. + * - Throws an `Error` if the index is out of bounds. + * + * #### Usage + * Call this method before performing operations involving indexed access to rooms, ensuring the index + * falls within valid boundaries. + * + * @param {number} index - The zero-based index to validate within the room list. + * @returns {boolean} - Returns `true` if the index is within bounds. + * + * @throws {Error} - Throws an error with a descriptive message if the index is out of bounds. + * + * @example + * ```typescript + * const casino = new Casino(); + * try { + * casino.isValidIndex(2); // Returns true if index 2 exists in the list of rooms + * } catch (error) { + * console.error(error.message); // Logs error if index 2 is invalid + * } + * ``` + */ + isValidIndex(index: number): boolean; +} + +export { PokerTableConfig, PokerTableInterface }; diff --git a/src/interfaces/rank/index.ts b/src/interfaces/rank/index.ts deleted file mode 100644 index 1d2d01e..0000000 --- a/src/interfaces/rank/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -enum Rank { - Two = "2", - Three = "3", - Four = "4", - Five = "5", - Six = "6", - Seven = "7", - Eight = "8", - Nine = "9", - Ten = "10", - Jack = "J", - Queen = "Q", - King = "K", - Ace = "A", -} - -export { Rank }; diff --git a/src/interfaces/suit/index.ts b/src/interfaces/suit/index.ts deleted file mode 100644 index 6c9d7b1..0000000 --- a/src/interfaces/suit/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -enum Suit { - Hearts = "Hearts", - Diamonds = "Diamonds", - Clubs = "Clubs", - Spades = "Spades", -} - -export { Suit }; diff --git a/src/models/_base/index.ts b/src/models/_base/index.ts new file mode 100644 index 0000000..129b32d --- /dev/null +++ b/src/models/_base/index.ts @@ -0,0 +1,430 @@ +// @collapse + +import { EventEmitter } from "events"; + +// Import Enums +import { LogLevel } from "../../enums"; + +// Import Interfaces +import { BaseEventEmitterInterface, BaseEventInterface } from "../../interfaces"; + +// Import Utils +import { generateUniqueId, logger } from "../../utils"; + +/** + * @class `BaseEventEmitter` + * Represents a base event emitter for handling poker-related events, particularly in managing multiple + * poker rooms (`PokerRooms`). This class is responsible for creating, listing, removing, and searching rooms, + * emitting specific events related to these actions. + * + * #### Purpose + * Acts as a central hub for organizing poker games, enabling the creation and management of poker rooms. Each room + * can accommodate players and maintain its own game state. The `BaseEventEmitter` also supports middleware-based event processing, + * allowing for validation and transformation of events. + * + * #### Extends + * Extends the Node.js `EventEmitter` to emit events when specific actions occur, such as creating or removing a room. + * + * #### Implements + * Implements the `BaseEventEmitterInterface`, ensuring a consistent interface structure and predictable behavior + * for all event emitters within the library. + * + * #### Events Overview + * - **casino:roomCreated**: Emitted when a new room is created, signaling listeners to respond to this action. + * - **casino:roomRemoved**: Emitted when a room is removed, signaling listeners to update or respond accordingly. + * + * #### Usage + * This class can be instantiated to manage rooms, emit events for room-related actions, and handle middleware-based + * processing for emitted events. It’s designed for easy integration into poker or casino game management. + * + * @example + * ```typescript + * const casino = new BaseEventEmitter(); + * casino.on('casino:roomCreated', (room) => console.log(`Room created: ${room.name}`)); + * const room = casino.createRoom({ name: "Room1", tableSize: 6, smallBlind: 10, bigBlind: 20 }); + * console.log(room); // Logs details of "Room1" + * ``` + */ +class BaseEventEmitter + extends EventEmitter + implements BaseEventEmitterInterface +{ + /************************************************************************************************************** + * PROPERTIES + **************************************************************************************************************/ + + /************************************************************************************************************** + * CONSTRUCTOR & INITIALIZERS + **************************************************************************************************************/ + + /** + * The `constructor` initializes the `BaseEventEmitter` class. + * + * @example + * ```typescript + * const casino = new BaseEventEmitter(); + * console.log(casino.getRooms()); // Output: [] + * ``` + */ + constructor() { + super(); + } + + /************************************************************************************************************** + * CREATE METHODS (SETTERS & OBJECT CREATION) + **************************************************************************************************************/ + + /************************************************************************************************************** + * READ METHODS (GETTERS & DATA RETRIEVAL) + **************************************************************************************************************/ + + /************************************************************************************************************** + * UPDATE METHODS (MODIFYING EXISTING OBJECTS) + **************************************************************************************************************/ + + /************************************************************************************************************** + * DELETE METHODS (REMOVING OBJECTS) + **************************************************************************************************************/ + + /************************************************************************************************************** + * BUSINESS-LOGIC METHODS (LOGIC & CALCULATIONS) + **************************************************************************************************************/ + + /** + * #### Description + * The `emitEvent` method is a public method for emitting events, with an optional configuration that allows + * middleware processing. Middleware functions can intercept and transform the event before it reaches the listeners, + * allowing custom validation or data modifications. + * + * #### Purpose + * This method enables flexible event emission with support for middleware, providing a robust event processing + * mechanism in the `BaseEventEmitter`. It’s useful for customizing event behavior based on application-specific needs. + * + * #### Implements + * N/A + * + * #### Overrides + * N/A + * + * #### Events + * This method can emit any event specified by `eventName`, which can then be processed by middleware functions if defined. + * + * #### Parameters + * - `eventName: string` - The name of the event to emit. + * - `options: { event: { data: { [key: string]: any }; [key: string]: any; }, middlewares?: Array<(event: BaseEventInterface, next: () => void) => void | false> }` + * - **event** - The primary event data to emit, containing specific details. + * - **middlewares** - An optional array of middleware functions that process the event before emission. + * + * #### Requirements + * - `eventName` must be a valid string. + * - `options.event` should include relevant data for the event. If `middlewares` are provided, they should be functions with an event and next parameter. + * + * #### Returns + * - `void` - This method does not return a value. + * + * #### Usage + * Use this method to emit events with middleware-based customization, which allows for specific processing + * logic or transformations before the event reaches listeners. + * + * @param {string} eventName - The name of the event to emit. + * @param {object} options - Configuration for the event and optional middleware functions. + * + * @example + * ```typescript + * emitter.emitEvent("game:started", { + * event: { data: { gameId: "001", status: "active" } }, + * middlewares: [ + * (event, next) => { console.log("Processing event:", event); next(); }, + * (event, next) => { event.data.processed = true; next(); } + * ] + * }); + * ``` + */ + public emitEvent( + eventName: string, + options: { + event: { + data: { [key: string]: any }; + [key: string]: any; + }; + middlewares?: Array<(event: BaseEventInterface, next: () => void) => void | false>; + } + ): void { + this.__emitEvent(eventName, options); + } + + /** + * #### Description + * The `emitEvent` method is a public method for emitting events, with an optional configuration that allows + * middleware processing. Middleware functions can intercept and transform the event before it reaches the listeners, + * allowing custom validation or data modifications. + * + * #### Purpose + * This method enables flexible event emission with support for middleware, providing a robust event processing + * mechanism in the `BaseEventEmitter`. It’s useful for customizing event behavior based on application-specific needs. + * + * #### Implements + * N/A + * + * #### Overrides + * N/A + * + * #### Events + * This method can emit any event specified by `eventName`, which can then be processed by middleware functions if defined. + * + * #### Parameters + * - `eventName: string` - The name of the event to emit. + * - `options: { event: { data: { [key: string]: any }; [key: string]: any; }, middlewares?: Array<(event: BaseEventInterface, next: () => void) => void | false> }` + * - **event** - The primary event data to emit, containing specific details. + * - **middlewares** - An optional array of middleware functions that process the event before emission. + * + * #### Requirements + * - `eventName` must be a valid string. + * - `options.event` should include relevant data for the event. If `middlewares` are provided, they should be functions with an event and next parameter. + * + * #### Returns + * - `void` - This method does not return a value. + * + * #### Usage + * Use this method to emit events with middleware-based customization, which allows for specific processing + * logic or transformations before the event reaches listeners. + * + * @param {string} eventName - The name of the event to emit. + * @param {object} options - Configuration for the event and optional middleware functions. + * + * @example + * ```typescript + * emitter.emitEvent("game:started", { + * event: { data: { gameId: "001", status: "active" } }, + * middlewares: [ + * (event, next) => { console.log("Processing event:", event); next(); }, + * (event, next) => { event.data.processed = true; next(); } + * ] + * }); + * ``` + */ + public listenToEvent( + eventName: string, + options: { + handler: (event: BaseEventInterface) => void; + middlewares?: Array<(event: BaseEventInterface, next: () => void) => void | false>; + } + ): void { + this.__listenToEvent(eventName, options); + } + /************************************************************************************************************** + * WRAPPER METHODS (UTILITY & CONVENIENCE) + **************************************************************************************************************/ + + /************************************************************************************************************** + * INTERNAL METHODS (PROTECTED) + **************************************************************************************************************/ + + /************************************************************************************************************** + * INTERNAL METHODS (PRIVATE) + **************************************************************************************************************/ + + /** + * #### Description + * The `__emitEvent` method is an internal method that emits an event with optional middleware processing. + * Middleware functions can process, validate, or modify the event data before the final emission to listeners. + * + * #### Purpose + * This private method centralizes event emission within the `BaseEventEmitter`, supporting middleware-based + * customization for flexible event handling and data transformation. + * + * #### Events + * Emits the specified event after optional middleware processing. + * + * #### Parameters + * - `eventName: string` - The event name to emit. + * - `options: { event: { data: { [key: string]: any } }, middlewares?: Array<(event: BaseEventInterface, next: () => void) => void | false> }` + * - **event** - The primary event data to emit, containing relevant information. + * - **middlewares** - Optional array of middleware functions for processing the event before emission. + * + * #### Requirements + * - `eventName` must be a valid string. + * - If `middlewares` are provided, they should be functions that accept an event and a `next` function. + * + * #### Returns + * - `void` - This method does not return a value. + * + * #### Usage + * Use this method internally within the `emitEvent` method to handle middleware-based processing before the event + * reaches its listeners. + * + * @param {string} eventName - The event name to emit. + * @param {object} options - Configuration object containing the event data and optional middleware functions. + * + * @example + * ```typescript + * emitter.__emitEvent("room:updated", { + * event: { data: { roomId: "room123", players: 6 } }, + * middlewares: [ + * (event, next) => { event.data.updated = true; next(); }, + * (event, next) => { console.log("Middleware processed event:", event); next(); } + * ] + * }); + * ``` + */ + private __emitEvent( + eventName: string, + options: { + event: { + data: { [key: string]: any }; + [key: string]: any; + }; + middlewares?: Array<(event: BaseEventInterface, next: () => void) => void | false>; + } + ): void { + const event: BaseEventInterface = this.__initializeEventObj(eventName, options); + const middlewares = options.middlewares ?? []; + + if (middlewares.length > 0) { + const runMiddlewares = (index: number) => { + if (index < middlewares.length) { + middlewares[index](event, () => runMiddlewares(index + 1)); + } else { + this.emit(eventName, event); + logger.log(LogLevel.INFO, `Event emitted: "${eventName}"`, event); + } + }; + runMiddlewares(0); + } else { + this.emit(eventName, event); + logger.log(LogLevel.INFO, `Event emitted: "${eventName}"`, event); + } + } + + /** + * #### Description + * The `__initializeEventObj` method constructs a structured event object, initializing it with essential metadata + * and additional data specified in the options parameter. + * + * #### Purpose + * This method ensures that all emitted events in `BaseEventEmitter` follow a standardized format, + * with uniform metadata for consistency across the application. + * + * #### Parameters + * - `eventName: string` - The name of the event. + * - `options: { event: { data: { [key: string]: any } } }` - Configuration object for the event. + * + * #### Requirements + * - `eventName` must be a valid event identifier. + * - `options.event.data` should include any relevant data for the event. + * + * #### Returns + * - `BaseEventInterface` - The structured event object ready for processing or emission. + * + * #### Usage + * Use this method to generate a complete `BaseEventInterface` object for any event emission within `BaseEventEmitter`. + * + * @param {string} eventName - The name of the event. + * @param {object} options - Configuration object containing the event data. + * + * @returns {BaseEventInterface} - A structured event object with metadata and data. + * + * @example + * ```typescript + * const event = emitter.__initializeEventObj("player:joined", { event: { data: { playerId: "player123", seat: 5 } } }); + * console.log(event); + * // Output: { id: "generated-id", name: "player:joined", createdAt: [Date], source: "BaseEventEmitter", data: { playerId: "player123", seat: 5 } } + * ``` + */ + private __initializeEventObj( + eventName: string, + options: { + event: { + data: { [key: string]: any }; + }; + } + ): BaseEventInterface { + const baseEvent: BaseEventInterface = { + id: generateUniqueId(), + name: eventName, + createdAt: new Date(), + source: "BaseEventEmitter", + ...options.event, + }; + logger.log(LogLevel.INFO, `Event initialized: "${eventName}"`, baseEvent); + return baseEvent; + } + + + /** + * #### Description + * The `__listenToEvent` method is a private listener method within the `BaseEventListener` class that listens to + * a specified event and allows middleware processing before handling the event data. + * + * #### Purpose + * This method enables event listening within `BaseEventListener`, supporting middleware-based pre-processing + * of events before they reach the main handler. + * + * #### Events + * Subscribes to the specified event and applies middleware before handling. + * + * #### Parameters + * - `eventName: string` - The event name to listen for. + * - `options: { handler: (event: BaseEventInterface) => void, middlewares?: Array<(event: BaseEventInterface, next: () => void) => void | false> }` + * - **handler** - Function that handles the processed event. + * - **middlewares** - Optional array of middleware functions for processing the event before it reaches the handler. + * + * #### Requirements + * - `eventName` must be a valid string. + * - `handler` must be a function that processes the event data. + * - If `middlewares` are provided, they should be functions that accept an event and a `next` function. + * + * #### Returns + * - `void` - This method does not return a value. + * + * #### Usage + * Use this method to listen to events within the `BaseEventListener` and apply middleware before passing them + * to the handler. + * + * @param {string} eventName - The event name to listen for. + * @param {object} options - Configuration object containing the handler and optional middleware functions. + * + * @example + * ```typescript + * listener.__listenToEvent("room:updated", { + * handler: (event) => { console.log("Event received:", event); }, + * middlewares: [ + * (event, next) => { event.data.timestamp = Date.now(); next(); }, + * (event, next) => { if (event.data.isValid) next(); else console.log("Invalid event data"); } + * ] + * }); + * ``` + */ +private __listenToEvent( + eventName: string, + options: { + handler: (event: BaseEventInterface) => void; + middlewares?: Array<(event: BaseEventInterface, next: () => void) => void | false>; + } +): void { + const middlewares = options.middlewares ?? []; + const handler = options.handler; + + // Register the event listener + this.on(eventName, (event: BaseEventInterface) => { + if (middlewares.length > 0) { + // Middleware processing + const processMiddlewares = (index: number) => { + if (index < middlewares.length) { + middlewares[index](event, () => processMiddlewares(index + 1)); + } else { + handler(event); + logger.log(LogLevel.INFO, `Event handled: "${eventName}"`, event); + } + }; + processMiddlewares(0); + } else { + // Directly invoke handler if no middleware + handler(event); + logger.log(LogLevel.INFO, `Event handled: "${eventName}"`, event); + } + }); +} +} + +export { BaseEventEmitter }; diff --git a/src/models/card/index.ts b/src/models/card/index.ts index e25e14b..08d284b 100644 --- a/src/models/card/index.ts +++ b/src/models/card/index.ts @@ -1,56 +1,178 @@ -import { Rank, Suit, ICard } from "../../interfaces"; +//@collapse + +import { Rank, Suit } from "../../enums"; +import { CardConfig, CardInterface } from "../../interfaces"; /** - * @class `Card` : Represents a playing card in a poker game, consisting of a rank and a suit. - * Implements the `ICard` interface. + * @class `Card` + * Represents a playing card in a poker game, consisting of a rank and a suit. + * Implements the `CardInterface`. + * + * The `Card` class encapsulates its properties (`rank` and `suit`) as private + * and provides public getter methods to access these properties. + * It also includes private setter methods for internal control over the state. * * @example * const card = new Card(Rank.Ace, Suit.Spades); * console.log(card.toString()); // "A of Spades" */ -class Card { +class Card implements CardInterface { + /************************************************************************************************************** + * PROPERTIES + **************************************************************************************************************/ + /** - * @property {Rank} rank - * @public + * @property {Rank} _rank + * @private * Holds the rank of the card (e.g., Ace, Two, King). */ - public rank: Rank; + private __rank: Rank = Rank.Ace; /** - * @property {Suit} suit - * @public + * @property {Suit} _suit + * @private * Holds the suit of the card (e.g., Hearts, Spades). */ - public suit: Suit; + private __suit: Suit = Suit.Spades; + + /************************************************************************************************************** + * CONSTRUCTOR & INITIALIZERS + **************************************************************************************************************/ /** - * @method constructor + * constructor * @public * Creates an instance of a `Card` with the given rank and suit. * - * @param {Rank} rank - The rank of the card. - * @param {Suit} suit - The suit of the card. - * + * @param {CardConfig} config - The configuration of the card. * @example * const card = new Card(Rank.Ace, Suit.Spades); */ - constructor(rank: Rank, suit: Suit) { - this.rank = rank; - this.suit = suit; + constructor(config: CardConfig) { + this.__init(config); + } + + /** + * `init` + * @private + * Initializes the deck with 52 unique cards. + * This method is called automatically inside the constructor during deck creation. + * `deck:initialized` : Emits a `deck:initialized` event when the deck is created. + * @returns {void} + */ + private __init(config: CardConfig): void { + this.__rank = config.rank; + this.__suit = config.suit; + } + + /************************************************************************************************************** + * CREATE METHODS (SETTERS & OBJECT CREATION) + **************************************************************************************************************/ + + /************************************************************************************************************** + * READ METHODS (GETTERS & DATA RETRIEVAL) + **************************************************************************************************************/ + + /** + * `getRank` + * @public + * Returns the card's rank. + * @returns {Rank} The card's rank. + * + * @example + * const rank = card.getRank(); + * console.log(rank); // "A" + */ + public getRank(): Rank { + return this.__rank; + } + + /** + * `getSuit` + * @public + * Returns the card's suit. + * @returns {Suit} The card's suit. + * + * @example + * const suit = card.getSuit(); + * console.log(suit); // "Spades" + */ + public getSuit(): Suit { + return this.__suit; } + /************************************************************************************************************** + * UPDATE METHODS (MODIFYING EXISTING OBJECTS) + **************************************************************************************************************/ + + /************************************************************************************************************** + * DELETE METHODS (REMOVING OBJECTS) + **************************************************************************************************************/ + + /************************************************************************************************************** + * BUSINESS-LOGIC METHODS (LOGIC & CALCULATIONS) + **************************************************************************************************************/ + /** - * @method `toString` + * `toString` * @public * Returns a string representation of the card, displaying its rank and suit. * @returns {string} The card's rank and suit as a formatted string. * * @example - * const card = new Card(Rank.Ace, Suit.Spades); - * console.log(card.toString()); // "A of Spades" + * const description = card.toString(); + * console.log(description); // "A of Spades" */ public toString(): string { - return `${this.rank} of ${this.suit}`; + return `${this.__rank} of ${this.__suit}`; + } + + /** + * `toObj` + * @public + * Returns an object representation of the card, containing its rank and suit. + * @returns {object<{ rank: Rank; suit: Suit }>} The card's rank and suit as an object. + * + * @example + * const cardObj = card.toObj(); + * console.log(cardObj); // { rank: "A", suit: "Spades" } + */ + public toObj(): { rank: Rank; suit: Suit } { + return { rank: this.__rank, suit: this.__suit }; + } + + /************************************************************************************************************** + * WRAPPER METHODS (UTILITY & CONVENIENCE) + **************************************************************************************************************/ + + /************************************************************************************************************** + * INTERNAL METHODS (PRIVATE) + **************************************************************************************************************/ + + /** + * `setRank` + * @private + * Sets the card's rank. This method is kept private to control how rank is modified. + * + * @param {Rank} rank - The new rank of the card. + * @returns {Rank} The updated rank of the card. + */ + private __setRank(rank: Rank): Rank { + this.__rank = rank; + return this.__rank; + } + + /** + * `setSuit` + * @private + * Sets the card's suit. This method is kept private to control how suit is modified. + * + * @param {Suit} suit - The new suit of the card. + * @returns {Suit} The updated suit of the card. + */ + private __setSuit(suit: Suit): Suit { + this.__suit = suit; + return this.__suit; } } diff --git a/src/models/casino/index.ts b/src/models/casino/index.ts new file mode 100644 index 0000000..af9b115 --- /dev/null +++ b/src/models/casino/index.ts @@ -0,0 +1,857 @@ +//@collapse + +// Import Enums +import { CasinoEvents, Source } from "../../enums"; + +// Import Interfaces +import { + CasinoInterface, + PokerRoomConfig, + PokerRoomInterface, +} from "../../interfaces"; + +// Import Models +import { BaseEventEmitter } from "../_base"; +import { PokerRoom } from "../pokerRoom"; + +/** + * @class `Casino` + * Represents a Casino environment that manages multiple poker rooms (`PokerRooms`). + * This class handles operations related to room creation, listing, removal, and searching. + * + * #### Purpose + * A Casino serves as a central hub for organizing poker games by managing rooms. + * Each room can accommodate players and maintain its own game state. + * + * #### Extends + * Additionally, it extends the Node.js `BaseEventEmitter` to emit events when specific actions + * occur, such as creating or removing a room. + * + * #### Implements + * This class implements the `CasinoInterface` and inherits from the `BaseEventEmitter` class, + * allowing it to emit events and conform to the defined interface structure for consistency + * and predictability. + * + * #### Events + * The `Casino` class emits custom events to signal room-related actions. For instance, + * when a room is created, an event `casino:roomCreated` is emitted, making it easy + * to handle notifications or updates related to the Casino’s operations. + * + * @example + * ```typescript + * const casino = new Casino(); + * casino.on('casino:roomCreated', (room) => console.log(`Room created: ${room.name}`)); + * const room = casino.createRoom({ name: "Room1", tableSize: 6, smallBlind: 10, bigBlind: 20 }); + * console.log(room); // Logs details of "Room1" + * ``` + */ +class Casino extends BaseEventEmitter implements CasinoInterface { + /************************************************************************************************************** + * PROPERTIES + **************************************************************************************************************/ + + /** + * @property {PokerRoomInterface[]} __rooms + * A private array that holds all the `PokerRoom` instances managed by the Casino. + * + * #### Access Level + * This property is private, meaning it can only be accessed directly within the + * `Casino` class itself. This encapsulation ensures that external modifications + * to the list of rooms are controlled through the class’s public methods. + * + * #### Default Value + * The `__rooms` property is initialized as an empty array `[]`, indicating that + * the Casino starts with no rooms. Rooms are added to this array using the `createRoom` + * or `addRoom` methods. + * + * @example + * ```typescript + * const casino = new Casino(); + * console.log(casino.getRooms()); // Returns an empty array initially + * ``` + */ + private __rooms: PokerRoomInterface[] = []; + + /************************************************************************************************************** + * CONSTRUCTOR & INITIALIZERS + **************************************************************************************************************/ + + /** + * The `constructor` initializes the `Casino` class. + * + * @example + * ```typescript + * const casino = new Casino(); + * console.log(casino.getRooms()); // Output: [] + * ``` + */ + constructor() { + super(); + this.__init(); + } + + /** + * `__init`: Performs any necessary setup logic when the `Casino` is instantiated. + * This is an internal method, meaning it's private and only used within the `Casino` class. + * + * #### Purpose + * This method is designed to be a placeholder for any future setup logic or preparation that the + * Casino might need during initialization. Currently, it's an empty method that gets called within the constructor. + * + * #### Usage + * Developers can add additional logic in this method if there are operations or configurations + * that need to happen every time the Casino is created. + * + * @returns {void} - This method doesn't return any values. + * + * @example + * The `__init` method is automatically invoked when the `Casino` is created: + * ```typescript + * const casino = new Casino(); + * ``` + */ + private __init(): void { + // No current logic, but reserved for future setup or configuration + } + + /************************************************************************************************************** + * CREATE METHODS (SETTERS & OBJECT CREATION) + **************************************************************************************************************/ + + /** + * #### Description + * Sets the list of rooms managed by the Casino. This method is typically used to replace or update + * the entire list of poker rooms in the casino. + * + * #### Implements + * Implements the `setRooms` method of `CasinoInterface`. + * + * #### Overrides + * `N/A` + * + * #### Purpose + * Provides a way to update the current list of rooms managed by the Casino, ensuring a consistent and up-to-date + * list of poker rooms as defined by the casino’s configuration. + * + * #### Events + * - `N/A`: No `event` is emitted by this method. + * + * #### Parameters + * - `rooms`: An array of `PokerRoomInterface` instances, representing individual poker rooms in the Casino. + * + * #### Requirements + * - The `rooms` array must contain at least one room (i.e., `rooms.length >= 1`). + * + * #### Returns + * - Returns `true` when the rooms have been successfully set. + * + * #### Usage + * This method accepts an array of `PokerRoomInterface` objects, representing poker rooms to manage in the casino. + * - Replaces any existing rooms with the new provided list. + * - Calls the internal `_setRooms` method to update the private `__rooms` property securely. + * + * @param {PokerRoomInterface[]} rooms - The new list of poker rooms to be managed by the Casino. + * @returns {boolean} - Returns `true` when the rooms have been successfully set. + * + * @example + * ```typescript + * const casino = new Casino(); + * const rooms: PokerRoomInterface[] = [ + * new PokerRoom({ name: "Room1", tableSize: 6, smallBlind: 10, bigBlind: 20 }) + * ]; + * casino.setRooms(rooms); + * console.log(casino.getRooms()); // Logs an array with the newly set rooms + * ``` + */ + public setRooms(rooms: PokerRoomInterface[]): PokerRoomInterface[] { + return this._setRooms(rooms); + } + + /** + * #### Description + * Creates a new `PokerRoom` within the Casino and adds it to the list of rooms. + * + * #### Implements + * Implements the `createRoom` method of `CasinoInterface`. + * + * #### Overrides + * `N/A` + * + * #### Purpose + * Enables the dynamic creation and addition of a `PokerRoom` to the Casino, expanding the Casino’s managed rooms as required. + * This facilitates flexible game setup and room management in response to user needs. + * + * #### Events + * - `casino:roomCreated`: This custom event is emitted once the room is successfully added. + * Listeners to this event can respond with actions, such as logging or notifying users. + * + * #### Parameters + * - `config`: A configuration object containing details like the room’s name, table size, small blind, and big blind values. + * + * #### Requirements + * - The configuration object must include valid values for `name`, `tableSize`, `smallBlind`, and `bigBlind`. + * + * #### Returns + * - Returns the newly created `PokerRoom` instance, confirming its addition to the Casino. + * + * #### Usage + * This method creates a new room based on the provided configuration, then pushes it into the Casino’s room list. + * After adding the room, it emits a `casino:roomCreated` event for any listeners tracking room creation. + * + * @param {PokerRoomConfig} config - A configuration object with properties like the room name, table size, small blind, and big blind values. + * @returns {PokerRoomInterface} - Returns the newly created `PokerRoom` instance. + * + * @example + * ```typescript + * const casino = new Casino(); + * const room = casino.createRoom({ name: "HighRollers", tableSize: 6, smallBlind: 10, bigBlind: 20 }); + * console.log(casino.getRooms()); // Logs the new room within the array of rooms + * ``` + */ + public createRoom(config: PokerRoomConfig): PokerRoomInterface { + return this._createRoom(config); + } + + /************************************************************************************************************** + * READ METHODS (GETTERS & DATA RETRIEVAL) + **************************************************************************************************************/ + + /** + * #### Description + * Retrieves a specific `PokerRoom` based on its position within the Casino’s list of rooms. + * + * #### Implements + * `N/A` + * + * #### Overrides + * `N/A` + * + * #### Purpose + * This method provides direct access to a single `PokerRoom` by index, allowing for targeted retrieval of rooms, + * which can be useful for room-specific operations or when sequentially processing rooms. + * + * #### Events + * `N/A` + * + * #### Parameters + * - `index`: A zero-based index representing the position of the desired `PokerRoom` in the Casino’s room list. + * + * #### Requirements + * - The index provided must be within the bounds of the `__rooms` array (i.e., `0 <= index < __rooms.length`). + * - Passing an out-of-bounds index will result in an `undefined` return. + * + * #### Returns + * - Returns the `PokerRoomInterface` instance located at the specified index. + * - Returns `undefined` if the provided index is out of bounds. + * + * #### Usage + * Use this method when you need to access a particular room directly by its index in the Casino’s list of rooms. + * This can be useful in looped operations or when accessing rooms based on their position in the list. + * + * @param {number} index - The zero-based index of the desired room in the Casino’s room list. + * @returns {PokerRoomInterface | undefined} - The `PokerRoom` at the specified index or `undefined` if the index is out of bounds. + * + * @example + * ```typescript + * const casino = new Casino(); + * const room = casino.getRoom(0); // Returns the first room or undefined if no rooms exist + * ``` + */ + public getRoom(index: number): PokerRoomInterface { + return this.__rooms[index]; + } + + /** + * #### Description + * Retrieves the full list of rooms currently managed by the Casino. + * + * #### Implements + * Implements the `getRooms` method of `CasinoInterface`. + * + * #### Overrides + * `N/A` + * + * #### Purpose + * Provides access to the Casino's list of rooms, allowing external components or systems to retrieve and display + * information on all currently managed poker rooms. + * + * #### Events + * `N/A` + * + * #### Parameters + * `N/A` + * + * #### Requirements + * `N/A` + * + * #### Returns + * - Returns an array containing all `PokerRoomInterface` instances currently managed by the Casino. + * - Returns an empty array if no rooms have been added to the Casino. + * + * #### Usage + * This method is useful when a complete list of active rooms is needed, such as when displaying the Casino's + * available games or managing room states. + * + * @returns {PokerRoomInterface[]} - An array of all `PokerRoom` objects in the Casino. + * + * @example + * ```typescript + * const casino = new Casino(); + * console.log(casino.getRooms()); // Output: [] + * ``` + */ + public getRooms(): PokerRoomInterface[] { + return this.__rooms; + } + + /************************************************************************************************************** + * UPDATE METHODS (MODIFYING EXISTING OBJECTS) + **************************************************************************************************************/ + + /** + * #### Description + * Adds a new `PokerRoom` instance to the Casino's list of managed rooms, enabling dynamic expansion + * of rooms within the Casino environment. + * + * #### Implements + * `N/A` + * + * #### Overrides + * `N/A` + * + * #### Purpose + * This method provides a flexible mechanism for expanding the Casino's room offerings by allowing new + * rooms to be added as required, thereby supporting various gaming scenarios and player demand. + * + * #### Events + * `N/A` + * + * #### Parameters + * - `room` - A `PokerRoomInterface` instance representing the room to be added to the Casino’s list. + * + * #### Requirements + * - The `room` parameter must be a valid instance implementing `PokerRoomInterface`. + * + * #### Returns + * - Returns `true` to confirm that the room has been successfully added to the Casino. + * + * #### Usage + * Typically used in scenarios where the Casino environment needs to expand by adding more gaming rooms. + * + * @param {PokerRoomInterface} room - The `PokerRoom` instance to add. + * @returns {boolean} - Returns `true` when the room has been added successfully. + * + * @example + * ```typescript + * const casino = new Casino(); + * const room = new PokerRoom({ name: "HighRollers", tableSize: 6, smallBlind: 10, bigBlind: 20 }); + * const success = casino.addRoom(room); + * console.log(success); // true + * ``` + */ + public addRoom(room: PokerRoomInterface): PokerRoomInterface[] { + return this._addRoom(room); + } + + /** + * #### Description + * Adds multiple `PokerRoom` instances to the Casino's list of managed rooms in a single operation, enabling + * efficient and scalable room management. + * + * #### Implements + * `N/A` + * + * #### Overrides + * `N/A` + * + * #### Purpose + * This method provides a convenient way to add several rooms at once, allowing the Casino's environment to + * scale in response to gaming demand or operational changes. + * + * #### Events + * `N/A` + * + * #### Parameters + * - `rooms`: An array of `PokerRoomInterface` instances representing the rooms to be added to the Casino. + * + * #### Requirements + * - Each element in the `rooms` array must be a valid `PokerRoomInterface` instance. + * - The array should contain at least one room. + * + * #### Returns + * - Returns `true` when all rooms have been added successfully. + * + * #### Usage + * Typically used in scenarios where multiple rooms need to be added to the Casino simultaneously, such as + * during batch operations or initial setup. + * + * @param {PokerRoomInterface[]} rooms - Array of `PokerRoomInterface` instances to add. + * @returns {boolean} - Returns `true` when all rooms have been successfully added. + * + * @example + * ```typescript + * const casino = new Casino(); + * const rooms = [ + * new PokerRoom({ name: "Room1", tableSize: 5, smallBlind: 5, bigBlind: 10 }), + * new PokerRoom({ name: "Room2", tableSize: 6, smallBlind: 10, bigBlind: 20 }) + * ]; + * const success = casino.addRooms(rooms); + * console.log(success); // true if both rooms were added successfully + * ``` + */ + public addRooms(rooms: PokerRoomInterface[]): PokerRoomInterface[] { + return this._addRooms(rooms); + } + + /************************************************************************************************************** + * DELETE METHODS (REMOVING OBJECTS) + **************************************************************************************************************/ + + /** + * #### Description + * Removes a `PokerRoom` from the Casino's list of managed rooms based on the room's name, enabling dynamic + * contraction of the Casino environment as required. + * + * #### Implements + * `N/A` + * + * #### Overrides + * `N/A` + * + * #### Purpose + * Allows the Casino environment to remain current by dynamically removing rooms that are no longer active + * or needed. This supports a clean and manageable set of active rooms within the Casino. + * + * #### Events + * - Emits a `casino:roomRemoved` event when a room is successfully removed. This event can be used + * to trigger updates, logging, or notifications. + * + * #### Parameters + * - `roomName`: A string representing the name of the `PokerRoom` to be removed from the Casino. + * + * #### Requirements + * - The `roomName` parameter should match the `name` property of an existing room for successful deletion. + * + * #### Returns + * - Returns `true` if the room was successfully removed, or `false` if no room with the specified name was found. + * + * #### Usage + * Use this method when removing a room that is no longer active or required, ensuring that only + * currently used rooms remain managed by the Casino. + * + * @param {number} index - The name of the `PokerRoom` to be removed. + * @returns {PokerRoomInterface[]} - Returns `true` if the room was removed; `false` if not found. + * + * @example + * ```typescript + * const casino = new Casino(); + * casino.createRoom({ name: "HighRollers", tableSize: 6, smallBlind: 10, bigBlind: 20 }); + * const success = casino.deleteRoom("HighRollers"); + * console.log(success); // true if room was found and removed, false otherwise + * ``` + */ + public deleteRoom(index: number): PokerRoomInterface[] { + return this._deleteRoom(index); + } + + /************************************************************************************************************** + * BUSINESS-LOGIC METHODS (LOGIC & CALCULATIONS) + **************************************************************************************************************/ + + /************************************************************************************************************** + * WRAPPER METHODS (UTILITY & CONVENIENCE) + **************************************************************************************************************/ + + /** + * #### Description + * Retrieves the total count of rooms managed by the Casino, enabling easy access to the room quantity. + * + * #### Implements + * `N/A` - This method is unique to the Casino class and does not implement any other methods. + * + * #### Overrides + * `N/A` - This method does not override any superclass or parent methods. + * + * #### Purpose + * The `size` method provides a shortcut to access the number of poker rooms currently managed by the Casino. + * This method is useful for quickly obtaining the count of active rooms, which can help in managing or displaying + * the Casino's state. + * + * #### Events + * `N/A` + * + * #### Parameters + * `N/A` - This method does not require any input parameters. + * + * #### Requirements + * `N/A` + * + * #### Returns + * - Returns a number representing the current count of poker rooms managed by the Casino. + * + * #### Usage + * Call this method when a quick count of managed rooms is needed, especially for UI updates or managing limits. + * + * @returns {number} - Returns the current count of poker rooms. + * + * @example + * ```typescript + * const casino = new Casino(); + * const count = casino.size(); + * console.log(count); // Console Output: 0 if no rooms have been added + * ``` + */ + public size(): number { + return this.roomCount(); + } + + /** + * #### Description + * Returns the total number of `PokerRoom` instances currently managed by the Casino. + * + * #### Implements + * Part of `CasinoInterface`, ensuring standardization across implementations of the Casino class. + * + * #### Overrides + * `N/A` + * + * #### Purpose + * Provides a reliable way to retrieve the number of active poker rooms managed by the Casino. Useful for + * general management, reporting, and in situations where the Casino’s room capacity or state must be assessed. + * + * #### Events + * `N/A` + * + * #### Parameters + * `N/A` - This method does not accept any parameters. + * + * #### Requirements + * `N/A` + * + * #### Returns + * - Returns the current count of managed rooms. + * + * #### Usage + * Use this method whenever a precise count of rooms is required, such as when iterating through rooms + * or validating bounds. + * + * @returns {number} - Returns the count of rooms in the Casino. + * + * @example + * ```typescript + * const casino = new Casino(); + * const count = casino.roomCount(); + * console.log(count); // Console Output: 0 if no rooms exist, or the total count of rooms otherwise + * ``` + */ + public roomCount(): number { + return this.getRooms().length; + } + + /** + * #### Description + * Checks if a provided index is within the valid range of the Casino’s room list, helping avoid out-of-bounds errors. + * + * #### Implements + * `isValidIndex` method from `CasinoInterface`. + * + * #### Overrides + * `N/A` + * + * #### Purpose + * This method validates an index before it's used to access or modify a room in the Casino’s list, protecting + * against out-of-bound errors. It is useful in any operations that involve room access by index. + * + * #### Events + * `N/A` + * + * #### Parameters + * - `index`: A zero-based integer representing the position of a room in the Casino's managed list. + * + * #### Requirements + * - The `index` should be a non-negative integer within the range `[0, roomCount - 1]`. + * + * #### Returns + * - Returns `true` if the index is valid. + * - Throws an `Error` if the index is out of range, providing a descriptive message. + * + * #### Usage + * Use this method before performing operations that involve accessing a room by index. This helps prevent + * out-of-bound errors in index-based room access. + * + * @param {number} index - The zero-based index to validate. + * @returns {boolean} - Returns `true` if the index is within bounds. + * + * @throws {Error} - Throws an error with a descriptive message if the index is out of bounds. + * + * @example + * ```typescript + * const casino = new Casino(); + * try { + * casino.isValidIndex(2); // Returns true if there are at least 3 rooms + * } catch (error) { + * console.error(error.message); // If index 2 is out of bounds, logs error message + * } + * ``` + */ + public isValidIndex(index: number): boolean { + if (index < 0 || index >= this.roomCount()) { + throw new Error( + `Invalid index: ${index}. It must be between 0 and ${ + this.roomCount() - 1 + }.` + ); + } + return true; + } + + /************************************************************************************************************** + * INTERNAL METHODS (PROTECTED) + **************************************************************************************************************/ + + /** + * #### Description + * Sets the complete list of rooms managed by the Casino with a new array of `PokerRoomInterface` objects. + * + * #### Implements + * `N/A` + * + * #### Overrides + * `N/A` + * + * #### Purpose + * This protected method allows subclasses of `Casino` to modify the entire `__rooms` property, which can be used + * when needing to replace or reset the Casino's room list. + * + * #### Events + * - Emits a `CasinoEvents.ROOMS_SET` event, allowing external listeners to respond to room updates. + * + * #### Parameters + * - `rooms`: An array of `PokerRoomInterface` instances representing the new rooms for the Casino. + * + * #### Requirements + * - The `rooms` array should contain at least one room (`rooms.length >= 1`). + * + * #### Returns + * - Returns the updated list of rooms currently managed by the Casino. + * + * #### Usage + * This method is useful when an update or replacement of all rooms is needed, such as during initialization + * or batch updates. + * + * @param {PokerRoomInterface[]} rooms - Array of new rooms to set in the Casino. + * @returns {PokerRoomInterface[]} - The updated list of rooms managed by the Casino. + * + * @example + * ```typescript + * class ExtendedCasino extends Casino { + * public resetRooms(newRooms: PokerRoomInterface[]): PokerRoomInterface[] { + * return this._setRooms(newRooms); + * } + * } + * const extendedCasino = new ExtendedCasino(); + * const rooms = [new PokerRoom({ name: "VIP", tableSize: 8, smallBlind: 50, bigBlind: 100 })]; + * extendedCasino.resetRooms(rooms); // Resets the Casino's rooms list + * ``` + */ + protected _setRooms(rooms: PokerRoomInterface[]): PokerRoomInterface[] { + this.__rooms = rooms; + this.emit(CasinoEvents.ROOMS_SET, this.getRooms()); + return this.getRooms(); + } + + /** + * #### Description + * Creates a new `PokerRoom` instance based on the provided configuration and adds it to the Casino's rooms list. + * + * #### Implements + * `N/A` + * + * #### Overrides + * `N/A` + * + * #### Purpose + * Allows the Casino to dynamically create new rooms as needed by providing specific room configurations. + * + * #### Events + * - Emits a `CasinoEvents.ROOM_CREATED` event, enabling listeners to respond to the creation of a new room. + * + * #### Parameters + * - `config`: A `PokerRoomConfig` object containing details like `name`, `tableSize`, `smallBlind`, and `bigBlind`. + * + * #### Requirements + * `N/A` + * + * #### Returns + * - Returns the newly created `PokerRoomInterface` instance. + * + * #### Usage + * Primarily used within subclasses or protected methods to dynamically create and add rooms to the Casino. + * + * @param {PokerRoomConfig} config - Configuration settings for creating a new `PokerRoom`. + * @returns {PokerRoomInterface} - The newly created room instance. + * + * @example + * ```typescript + * class SpecialCasino extends Casino { + * public createSpecialRoom(config: PokerRoomConfig): PokerRoomInterface { + * return this._createRoom(config); + * } + * } + * const specialCasino = new SpecialCasino(); + * const newRoom = specialCasino.createSpecialRoom({ name: "Champions Lounge", tableSize: 10, smallBlind: 100, bigBlind: 200 }); + * console.log(newRoom.getName()); // Outputs: "Champions Lounge" + * ``` + */ + protected _createRoom( + config: PokerRoomConfig | undefined + ): PokerRoomInterface { + const room = new PokerRoom(config); + this.__rooms.push(room); + this.emit(CasinoEvents.ROOM_CREATED, room); + return room; + } + + /** + * #### Description + * Adds a single `PokerRoom` instance to the Casino's list of managed rooms. + * + * #### Implements + * `N/A` + * + * #### Overrides + * `N/A` + * + * #### Purpose + * Allows dynamic expansion of rooms within the Casino environment, enabling additional gaming options for players. + * + * #### Events + * - Emits a `CasinoEvents.ROOM_ADDED` event after adding a room. + * + * #### Parameters + * - `room`: The `PokerRoomInterface` instance representing the room to be added. + * + * #### Requirements + * - The `room` parameter must be a valid instance implementing `PokerRoomInterface`. + * + * #### Returns + * - The updated list of rooms currently managed by the Casino. + * + * #### Usage + * Useful when adding a new room to the Casino in response to game demand or configuration changes. + * + * @param {PokerRoomInterface} room - The `PokerRoom` instance to add. + * @returns {PokerRoomInterface[]} - The updated list of rooms managed by the Casino. + * + * @example + * ```typescript + * const casino = new Casino(); + * const room = new PokerRoom({ name: "HighRollers", tableSize: 6, smallBlind: 10, bigBlind: 20 }); + * const rooms = casino.addRoom(room); + * console.log(rooms); // Updated rooms list with the new room + * ``` + */ + protected _addRoom(room: PokerRoomInterface): PokerRoomInterface[] { + this.__rooms.push(room); + this.emit(CasinoEvents.ROOM_ADDED, this.getRooms()); + return this.getRooms(); + } + + /** + * #### Description + * Adds multiple `PokerRoom` instances to the Casino's list of managed rooms. + * + * #### Implements + * `N/A` + * + * #### Overrides + * `N/A` + * + * #### Purpose + * Enables efficient management of batch room additions within the Casino, ensuring all rooms are processed together. + * + * #### Events + * - Emits a `CasinoEvents.ROOMS_SET` event once all rooms are added. + * + * #### Parameters + * - `rooms`: An array of `PokerRoomInterface` instances to add. + * + * #### Requirements + * - Each element in the `rooms` array must be a valid `PokerRoomInterface` instance. + * + * #### Returns + * - The updated list of rooms currently managed by the Casino. + * + * #### Usage + * Useful in scenarios where multiple rooms need to be added to the Casino at once, such as during setup or a bulk update. + * + * @param {PokerRoomInterface[]} rooms - Array of `PokerRoomInterface` instances to add. + * @returns {PokerRoomInterface[]} - The updated list of rooms managed by the Casino. + * + * @example + * ```typescript + * const extendedCasino = new Casino(); + * const rooms = [new PokerRoom({ name: "VIP Room", tableSize: 8, smallBlind: 50, bigBlind: 100 })]; + * extendedCasino.addRooms(rooms); // Adds VIP rooms to the Casino + * ``` + */ + protected _addRooms(rooms: PokerRoomInterface[]): PokerRoomInterface[] { + rooms.forEach((room) => { + this._addRoom(room); + }); + return this.getRooms(); + } + + /** + * #### Description + * Removes a `PokerRoom` from the Casino's list based on the room's index, providing controlled removal of rooms. + * + * #### Implements + * `N/A` + * + * #### Overrides + * `N/A` + * + * #### Purpose + * Allows for the safe removal of a specific room from the Casino’s list. + * + * #### Events + * - Emits a `CasinoEvents.ROOM_DELETED` event once the room is successfully removed. + * + * #### Parameters + * - `index`: The zero-based index of the room to remove. + * + * #### Requirements + * - `index` must be valid within the bounds of the `__rooms` array. + * + * #### Returns + * - The updated list of rooms managed by the Casino. + * + * #### Usage + * Primarily used for controlled removal of a specific room from the Casino's room list. + * + * @param {number} index - The index of the room to be removed. + * @returns {PokerRoomInterface[]} - The updated list of rooms managed by the Casino. + * + * @example + * ```typescript + * const casino = new Casino(); + * const room = casino.createRoom({ name: "HighRollers", tableSize: 6, smallBlind: 10, bigBlind: 20 }); + * const rooms = casino.deleteRoom(room); + * console.log(rooms); // Updated rooms list without the deleted room + * ``` + */ + protected _deleteRoom(index: number): PokerRoomInterface[] { + if (this.isValidIndex(index)) { + this.__rooms.splice(index, 1); + this.emit(CasinoEvents.ROOM_DELETED, this.getRooms()); + } + return this.getRooms(); + } + + /************************************************************************************************************** + * INTERNAL METHODS (PRIVATE) + **************************************************************************************************************/ +} + +export { Casino }; diff --git a/src/models/deck/index.ts b/src/models/deck/index.ts index 01098de..694d4fb 100644 --- a/src/models/deck/index.ts +++ b/src/models/deck/index.ts @@ -1,32 +1,52 @@ -// src/models/deck/index.ts -import { EventEmitter } from "events"; -import { IDeck } from "../../interfaces/deck"; -import { ICard } from "../../interfaces/card"; +//@collapse + +// Import Enums +import { Suit, Rank } from "../../enums"; + +// Import Interfaces +import { CardInterface, DeckInterface } from "../../interfaces"; + +// Import Models +import { BaseEventEmitter } from "../_base"; import { Card } from "../card"; -import { Suit, Rank } from "../../interfaces"; + +// Import Utils +import { logger } from "../../utils"; /** - * @class `Deck` : Represents a deck of 52 playing cards used in poker games. - * This class extends `EventEmitter` and implements the `IDeck` interface. + * @class `Deck` + * Represents a deck of 52 playing cards used in poker games. + * This class extends `BaseEventEmitter` and implements the `DeckInterface` interface. + * + * The `Deck` class provides methods to shuffle the deck, draw cards, and emits + * events for important actions like shuffling and drawing cards. * * @example * const deck = new Deck(); * deck.on('deck:shuffled', () => console.log('Deck has been shuffled.')); * deck.shuffle(); * const card = deck.draw(); - * console.log(card?.toString()); + * console.log(card?.toString()); // "A of Spades" */ -class Deck extends EventEmitter implements IDeck { +class Deck extends BaseEventEmitter implements DeckInterface { + /************************************************************************************************************** + * PROPERTIES + **************************************************************************************************************/ + /** - * @property {ICard[]} cards + * @property {CardInterface[]} cards * @private * Holds the array of 52 playing cards in the deck. * @default [] */ - private cards: ICard[] = []; + private __cards: CardInterface[] = []; + + /************************************************************************************************************** + * CONSTRUCTOR & INITIALIZERS + **************************************************************************************************************/ /** - * @method constructor + * constructor * @public * Creates an instance of a Deck with 52 cards. * Automatically initializes the deck with all combinations of ranks and suits. @@ -36,63 +56,105 @@ class Deck extends EventEmitter implements IDeck { */ constructor() { super(); - this.init(); + this.__init(); } /** - * @method init + * `init` * @private * Initializes the deck with 52 unique cards. * This method is called automatically inside the constructor during deck creation. - * @emits `deck:initialized` : Emits a `deck:initialized` event when the deck is created. + * `deck:initialized` : Emits a `deck:initialized` event when the deck is created. * @returns {void} */ - private init(): void { + private __init(): void { for (const suit of Object.values(Suit)) { for (const rank of Object.values(Rank)) { - this.cards.push(new Card(rank, suit)); + this.__cards.push(new Card({ rank: rank, suit: suit })); } } - this.emit("deck:initialized", this.cards); + this.emit("deck:initialized", this.__cards); } + /************************************************************************************************************** + * CREATE METHODS (SETTERS & OBJECT CREATION) + **************************************************************************************************************/ + + /************************************************************************************************************** + * READ METHODS (GETTERS & DATA RETRIEVAL) + **************************************************************************************************************/ + /** - * @method `shuffle` + * `getCards` * @public - * Shuffles the deck of cards using the Fisher-Yates algorithm. - * @emits `deck:shuffled` Emits a `deck:shuffled` event after the deck is shuffled. - * @returns {void} + * Returns the current state of the deck. + * @returns {CardInterface[]} The array of cards in the deck. * * @example - * const deck = new Deck(); - * deck.shuffle(); + * const cards = deck.getCards(); + * console.log(cards.length); // 52 (before shuffling or drawing) */ - public shuffle(): void { - for (let i = this.cards.length - 1; i > 0; i--) { - const j = Math.floor(Math.random() * (i + 1)); - [this.cards[i], this.cards[j]] = [this.cards[j], this.cards[i]]; - } - this.emit("deck:shuffled", this.cards); + public getCards(): CardInterface[] { + return this.__cards; } + /************************************************************************************************************** + * UPDATE METHODS (MODIFYING EXISTING OBJECTS) + **************************************************************************************************************/ + + /************************************************************************************************************** + * DELETE METHODS (REMOVING OBJECTS) + **************************************************************************************************************/ + + /************************************************************************************************************** + * BUSINESS-LOGIC METHODS (LOGIC & CALCULATIONS) + **************************************************************************************************************/ + /** - * @method `draw` + * `draw` * @public * Draws a card from the top of the deck. * Removes and returns the top card from the deck, or `undefined` if the deck is empty. - * @emits `deck:drawn` : Emits a `deck:drawn` event when a card is drawn. - * @returns {ICard | undefined} Returns the drawn card or `undefined` if no cards remain. + * `deck:drawn` : Emits a `deck:drawn` event when a card is drawn. + * @returns {CardInterface | undefined} Returns the drawn card or `undefined` if no cards remain. * * @example * const deck = new Deck(); * const drawnCard = deck.draw(); - * console.log(drawnCard?.toString()); + * console.log(drawnCard?.toString()); // "A of Spades" */ - public draw(): ICard | undefined { - const drawnCard = this.cards.pop(); + public draw(): CardInterface | undefined { + const drawnCard = this.__cards.pop(); this.emit("deck:drawn", drawnCard); return drawnCard; } + + /** + * `shuffle` + * @public + * Shuffles the deck of cards using the Fisher-Yates algorithm. + * `deck:shuffled` Emits a `deck:shuffled` event after the deck is shuffled. + * @returns {void} + * + * @example + * const deck = new Deck(); + * deck.shuffle(); + */ + public shuffle(): void { + for (let i = this.__cards.length - 1; i > 0; i--) { + const j = Math.floor(Math.random() * (i + 1)); + [this.__cards[i], this.__cards[j]] = [this.__cards[j], this.__cards[i]]; + } + this.emit("deck:shuffled", this.__cards); + } + + /************************************************************************************************************** + * WRAPPER METHODS (UTILITY & CONVENIENCE) + **************************************************************************************************************/ + + /************************************************************************************************************** + * INTERNAL METHODS (PRIVATE) + **************************************************************************************************************/ } export { Deck }; diff --git a/src/models/index.ts b/src/models/index.ts index caae4d1..3363956 100644 --- a/src/models/index.ts +++ b/src/models/index.ts @@ -1,4 +1,32 @@ -import { Card } from "./card"; -import { Deck } from "./deck"; +//@collapse -export { Card, Deck }; +/** + * @module `Models` + * Centralized export for all poker-related models. + * This module gathers and exports models like `Card` and `Deck`. + * + * @example + * // Import models from the centralized module + * import { Card, Deck } from './models'; + */ + +export * as BaseModel from "./_base"; +export * from "./_base"; +export * as CardModel from "./card"; +export * from "./card"; +export * as CasinoModel from "./casino"; +export * from "./casino"; +export * as DeckModel from "./deck"; +export * from "./deck"; +export * as LoggerModel from "./logger"; +export * from "./logger"; +export * as PokerGameModel from "./pokerGame"; +export * from "./pokerGame"; +export * as PokerPlayerModel from "./pokerPlayer"; +export * from "./pokerPlayer"; +export * as PokerRoomModel from "./pokerRoom"; +export * from "./pokerRoom"; +export * as PokerSeatModel from "./pokerSeat"; +export * from "./pokerSeat"; +export * as PokerTableModel from "./pokerTable"; +export * from "./pokerTable"; diff --git a/src/models/logger/index.ts b/src/models/logger/index.ts new file mode 100644 index 0000000..8ace163 --- /dev/null +++ b/src/models/logger/index.ts @@ -0,0 +1,825 @@ +//@collapse + +// Import Vendor Modules +import { promises as fsPromises, existsSync, mkdirSync } from "fs"; +import path from "path"; + +// Import Enums +import { LogLevel } from "../../enums"; + +// Import Interfaces +import { LoggerConfig, LoggerInterface } from "../../interfaces"; + +// Resolve the app's package.json dynamically from the current working directory +const appPackageJson = require(path.resolve(process.cwd(), "package.json")); + +// Resolve the library's package.json dynamically from `node_modules` +const libraryPackageJsonPath = require.resolve("casinojs/package.json"); +const libraryPackageJson = require(libraryPackageJsonPath); + +/** + * @class `Logger` + * + * Provides logging functionality for the library, supporting both file-based and console logging. This class + * allows configurable logging levels and environment-specific log directories for flexible and organized logging. + * + * #### Purpose + * The `Logger` class is designed to capture and store logs with various severity levels. It centralizes + * logging within the library, ensuring that messages are consistently recorded and easily accessible for + * debugging, monitoring, and auditing purposes. + * + * #### Implements + * Implements `LoggerInterface`, adhering to standardized log methods and configuration options. + * + * #### Methods Overview + * The `Logger` class includes the following methods: + * - `log(level: LogLevel, message: string, data?: Record): Promise`: Logs a message with a specified level and optional data context. + * - `initializeLogDirectory()`: Initializes the log directory structure if it does not exist. + * - `setupLogDirPath(basePath: string): string`: Configures the base path for log files, adding environment-specific subdirectories. + * - `__writeLogToFile(level: LogLevel, message: string): Promise`: Writes a formatted log message to a file based on the log level and date. + * + * #### Usage + * Instantiate the `Logger` with a configuration to customize logging behavior, including specifying the log + * directory path and enabling console output. Once instantiated, use the `log` method to record messages + * with various levels, which are stored in both files and optionally displayed in the console. + * + * @example + * ```typescript + * const logger = new Logger({ logDirPath: "./logs", enableConsoleLogging: true }); + * logger.log(LogLevel.INFO, "Application started"); + * ``` + */ +class Logger implements LoggerInterface { + /************************************************************************************************************** + * PROPERTIES (STATIC) + **************************************************************************************************************/ + + /** + * @property {Logger} __instance + * + * Singleton instance of the `Logger` class. Ensures only one instance of the logger is created and used + * throughout the application, maintaining centralized control over logging. + * + * #### Purpose + * Prevents multiple logger instances from being created, ensuring consistency in log handling, configuration, + * and output across the application. + * + * #### Requirements + * - **Singleton Pattern**: Only one instance should be created and accessible across modules. + * + * @example + * ```typescript + * const logger = Logger.getInstance(); + * logger.log(LogLevel.INFO, "Using singleton instance for logging"); + * ``` + */ + private static __instance: Logger; + + /************************************************************************************************************** + * PROPERTIES (INSTANCE) + **************************************************************************************************************/ + + /** + * @property {boolean} __consoleLogging + * + * Determines if logs should also be output to the console. This setting is particularly useful for real-time + * monitoring and debugging during development. + * + * #### Purpose + * Provides a configurable toggle for console logging, enhancing flexibility for developers who need immediate + * feedback during code execution. + * + * #### Requirements + * - **Optional**: Defaults to `true`. + * + * @example + * ```typescript + * const enableConsoleLogging = loggerInstance.__consoleLogging; + * console.log(enableConsoleLogging); // Output: true + * ``` + */ + private __appName: string = appPackageJson.name; + + /** + * @property {boolean} __consoleLogging + * + * Determines if logs should also be output to the console. This setting is particularly useful for real-time + * monitoring and debugging during development. + * + * #### Purpose + * Provides a configurable toggle for console logging, enhancing flexibility for developers who need immediate + * feedback during code execution. + * + * #### Requirements + * - **Optional**: Defaults to `true`. + * + * @example + * ```typescript + * const enableConsoleLogging = loggerInstance.__consoleLogging; + * console.log(enableConsoleLogging); // Output: true + * ``` + */ + private __consoleLogging: boolean = true; + + /** + * @property {string} __env + * + * Specifies the current environment, typically derived from `NODE_ENV`. This setting determines the subdirectory + * within the logging structure to help organize logs by environment (e.g., `development`, `production`). + * + * #### Purpose + * Helps in segregating log data based on the runtime environment, ensuring that logs generated in production are + * separated from development logs. + * + * #### Requirements + * - **Optional**: Defaults to the value of `NODE_ENV`, or `"development"` if `NODE_ENV` is undefined. + * + * @example + * ```typescript + * const env = loggerInstance.__env; + * console.log(env); // Output: "development" or the current NODE_ENV setting + * ``` + */ + private __env: string = process.env.NODE_ENV || `development`; + + /** + * @property {boolean} __consoleLogging + * + * Determines if logs should also be output to the console. This setting is particularly useful for real-time + * monitoring and debugging during development. + * + * #### Purpose + * Provides a configurable toggle for console logging, enhancing flexibility for developers who need immediate + * feedback during code execution. + * + * #### Requirements + * - **Optional**: Defaults to `true`. + * + * @example + * ```typescript + * const enableConsoleLogging = loggerInstance.__consoleLogging; + * console.log(enableConsoleLogging); // Output: true + * ``` + */ + private __libraryName: string = libraryPackageJson.name || `casinojs`; + + /** + * @property {string} __logsDirPath + * + * Defines the directory path where log files are stored, organized by environment for better structure. + * Typically includes a subdirectory for the environment, allowing different logs for `development`, `staging`, and `production`. + * + * #### Purpose + * Provides an organized location for storing log files, structured by the environment to prevent mixing of logs + * from different runtime stages. + * + * #### Requirements + * - **Optional**: Defaults to a `.logs` directory in the root. + * + * @example + * ```typescript + * const logDirPath = loggerInstance.__logsDirPath; + * console.log(logDirPath); // Output: "./logs/development" (example for development environment) + * ``` + */ + private __logsDirPath: string = path.resolve(process.cwd(), `./.logs`); + + /************************************************************************************************************** + * CONSTRUCTOR & INITIALIZERS + **************************************************************************************************************/ + + /** + * #### Description + * Initializes a new instance of the `Logger` class with optional configuration settings. + * + * #### Purpose + * This constructor configures the `Logger` class by initializing settings such as the log directory path, + * console logging preferences, and environment setup. + * + * #### Parameters + * - `config?: LoggerConfig` - Optional. A configuration object for log directory path and console logging settings. + * - `logDirPath: string` - Specifies the base directory for log files. Defaults to `./logs` if not provided. + * - `enableConsoleLogging: boolean` - Determines if logs should also appear in the console. Defaults to `true`. + * + * #### Requirements + * - This method requires no mandatory parameters; configuration is optional. + * + * #### Returns + * - `void` - The constructor does not return a value. + * + * #### Usage + * Instantiates the `Logger` with custom configurations, which dictate logging behavior across the library. + * + * @param {LoggerConfig} [config] - Optional. Configuration for log directory path and console logging settings. + * + * @example + * ```typescript + * const logger = new Logger({ logDirPath: "./logs", enableConsoleLogging: true }); + * // Logs will be saved in "./logs" directory and printed to the console. + * ``` + */ + constructor(config?: LoggerConfig) { + this.__init(config); + } + + /** + * #### Description + * The `__init` method is a private initializer function that applies the provided configuration settings to the `Logger` instance. + * It configures environment variables, log directory path, and console logging preferences, setting defaults where necessary. + * + * #### Purpose + * The initializer method organizes the setup process, making the constructor more concise and maintaining modularity. + * This method ensures all configurations are applied in one place, enhancing readability and flexibility in the initialization phase. + * + * #### Implements + * N/A + * + * #### Overrides + * N/A + * + * #### Parameters + * - `config?: LoggerConfig` - Optional. A configuration object with: + * - `logDirPath: string` - Base directory for log files. Defaults to `"./.logs"`. + * - `enableConsoleLogging: boolean` - Whether to enable console logging. Defaults to `true`. + * + * #### Requirements + * - If `logDirPath` is not specified, a default directory of `"./.logs"` is used. + * - The console logging setting defaults to `true` if not provided. + * + * #### Returns + * - `void` - This method does not return a value. + * + * #### Usage + * This method is automatically called by the constructor to apply initialization settings. + * + * @param {LoggerConfig} config - Optional configuration for initializing the Logger. + * + * @example + * ```typescript + * const logger = new Logger(); + * // Initializes the Logger with default settings. + * ``` + */ + private __init(config?: LoggerConfig): void { + this.__env = process.env.NODE_ENV || "development"; + this.__logsDirPath = path.resolve(process.cwd(), ".logs", this.__env); + this.__setConsoleLogging(config?.enableConsoleLogging ?? true); + this.__initLogsDir(); + } + + /************************************************************************************************************** + * STATIC METHODS + **************************************************************************************************************/ + + /** + * #### Description + * Provides access to the singleton instance of the `Logger` class. This method ensures that only one instance of + * the logger is created and shared across the application, providing a centralized logging management system. + * It initializes the logger with a configuration if not already initialized. + * + * #### Purpose + * The `getInstance` method enforces the Singleton pattern, ensuring that a single instance of the logger is used + * across the entire library or application. This approach helps maintain consistency in logging configuration, + * making sure that all logs are handled by a single, globally accessible instance. + * + * #### Implements + * N/A + * + * #### Overrides + * N/A + * + * #### Events + * N/A + * + * #### Parameters + * - `config?: LoggerConfig` - An optional configuration object for customizing the logger instance: + * - `logDirPath: string` - Optional. Specifies the directory path for storing log files. Defaults to a standard location if omitted. + * - `enableConsoleLogging: boolean` - Optional. Enables or disables logging to the console. Defaults to `true` if omitted. + * + * #### Requirements + * - The logger configuration should be provided only once at initialization; subsequent calls to `getInstance` + * ignore additional configurations. + * + * #### Returns + * - `Logger` - Returns the singleton instance of the `Logger` class, ensuring that the same instance is shared + * throughout the application. + * + * #### Usage + * Use this method to retrieve the `Logger` instance wherever logging is required. This method guarantees that the + * same instance of the `Logger` is used, maintaining a consistent logging configuration. + * + * @param {LoggerConfig} [config] - Configuration options for the logger instance. + * @returns {Logger} - The singleton instance of `Logger`. + * + * @example + * ```typescript + * // Initialize and retrieve the Logger instance with configuration + * const logger = Logger.getInstance({ logDirPath: "./logs", enableConsoleLogging: true }); + * logger.log(LogLevel.INFO, "Application started"); // Logs with the singleton logger instance + * + * // Retrieve the existing Logger instance without reinitializing + * const anotherLoggerReference = Logger.getInstance(); + * anotherLoggerReference.log(LogLevel.ERROR, "Unexpected error occurred"); + * // Both `logger` and `anotherLoggerReference` refer to the same Logger instance + * ``` + */ + public static getInstance(config?: LoggerConfig): Logger { + if (!Logger.__instance) { + Logger.__instance = new Logger(config); + } + return Logger.__instance; + } + + /************************************************************************************************************** + * CREATE METHODS (SETTERS & OBJECT CREATION) + **************************************************************************************************************/ + + /************************************************************************************************************** + * READ METHODS (GETTERS & DATA RETRIEVAL) + **************************************************************************************************************/ + + /** + * #### Description + * Retrieves the current status of console logging, indicating if logs are also output to the console. + * + * #### Purpose + * This getter provides access to the console logging status, useful for checking if real-time log output is enabled. + * + * #### Parameters + * N/A + * + * #### Requirements + * - No parameters or dependencies are needed to access this property. + * + * #### Returns + * - `boolean` - `true` if console logging is enabled, `false` otherwise. + * + * #### Usage + * This method is used to verify whether logs are configured to appear in the console. + * + * @returns {boolean} - The console logging status. + * + * @example + * ```typescript + * const logger = Logger.getInstance(); + * console.log(logger.getConsoleLogging()); + * // Console Output: true (or false based on configuration) + * ``` + */ + public getConsoleLogging(): boolean { + return this.__consoleLogging; + } + + /** + * #### Description + * Retrieves the environment setting currently configured in the Logger instance, such as `"development"` or `"production"`. + * + * #### Purpose + * This getter method allows access to the environment setting, which determines where logs are stored based on runtime context. + * + * #### Parameters + * N/A + * + * #### Requirements + * - No parameters are required to retrieve this property. + * + * #### Returns + * - `string` - The environment setting in use. + * + * #### Usage + * Use this method to check the runtime environment configured for the Logger. + * + * @returns {string} - The current environment setting (e.g., `"development"`). + * + * @example + * ```typescript + * const logger = Logger.getInstance(); + * console.log(logger.getEnv()); + * // Console Output: "development" + * ``` + */ + public getEnv(): string { + return this.__env; + } + + /** + * #### Description + * Retrieves the path of the directory where logs are stored, based on the Logger's configuration and environment setting. + * + * #### Purpose + * This method allows access to the path where logs are written, organized by environment. Useful for managing and verifying log storage locations. + * + * #### Parameters + * N/A + * + * #### Requirements + * - The logs directory should be accessible or creatable by the system. + * + * #### Returns + * - `string` - The full directory path for log storage. + * + * #### Usage + * This method is used to determine where logs are stored on the filesystem, ensuring accessibility and organization. + * + * @returns {string} - The directory path where logs are stored. + * + * @example + * ```typescript + * const logger = Logger.getInstance(); + * console.log(logger.getLogsDirPath()); + * // Console Output: "./logs/development" (example for development environment) + * ``` + */ + public getLogsDirPath(): string { + return this.__logsDirPath; + } + + /************************************************************************************************************** + * UPDATE METHODS (MODIFYING EXISTING OBJECTS) + **************************************************************************************************************/ + + /************************************************************************************************************** + * DELETE METHODS (REMOVING OBJECTS) + **************************************************************************************************************/ + + /************************************************************************************************************** + * BUSINESS-LOGIC METHODS (LOGIC & CALCULATIONS) + **************************************************************************************************************/ + + /** + * #### Description + * The `disableConsoleLogging` method disables console logging for the `Logger` instance. When disabled, log + * entries are only written to log files and are no longer displayed in the console. + * + * #### Purpose + * This method provides a way to turn off console output of log messages, which is useful for reducing console + * clutter in production environments where log messages are typically directed only to log files. + * + * #### Implements + * N/A + * + * #### Overrides + * N/A + * + * #### Parameters + * N/A + * + * #### Requirements + * - This method requires no parameters and should be called when console logging is no longer needed. + * + * #### Returns + * - `boolean` - Returns `false` indicating console logging is now disabled. + * + * #### Usage + * Use this method to disable console logging, especially in production environments where log messages + * should only be stored in log files. + * + * @returns {boolean} - `false` indicating that console logging is disabled. + * + * @example + * ```typescript + * // Disable console logging for production + * logger.disableConsoleLogging(); + * logger.log(LogLevel.INFO, "Console logging disabled"); + * ``` + */ + public disableConsoleLogging(): boolean { + return this.__setConsoleLogging(false); + } + + /** + * #### Description + * The `enableConsoleLogging` method enables console logging for the `Logger` instance. When activated, all log + * entries are displayed in the console in addition to being recorded in log files. + * + * #### Purpose + * This method provides a way to turn on real-time logging output to the console, which is particularly useful + * for development and debugging purposes, allowing for immediate feedback on logged events. + * + * #### Implements + * N/A + * + * #### Overrides + * N/A + * + * #### Parameters + * N/A + * + * #### Requirements + * - This method requires no parameters and should be called when console logging is desired. + * + * #### Returns + * - `boolean` - Returns `true` indicating console logging is now enabled. + * + * #### Usage + * Use this method to enable console logging for quick visibility of log messages during debugging or development. + * + * @returns {boolean} - `true` indicating that console logging is enabled. + * + * @example + * ```typescript + * // Enable console logging for immediate log output + * logger.enableConsoleLogging(); + * logger.log(LogLevel.INFO, "Console logging enabled"); + * ``` + */ + public enableConsoleLogging(): boolean { + return this.__setConsoleLogging(true); + } + + /** + * #### Description + * The `log` method logs a message at a specified severity level with optional data. It supports both console + * output and file-based logging, structuring logs based on environment and log level. + * + * #### Purpose + * This method serves as the core logging function, allowing consistent recording of messages across the library. + * By accepting a log level and optional data, it provides detailed logging for events, errors, or informational messages. + * + * #### Implements + * Implements the logging functionality from the `LoggerInterface`. + * + * #### Overrides + * N/A + * + * #### Events + * - **Console Logging**: If console logging is enabled, the message is output to the console. + * - **File Logging**: Each log entry is stored in a file based on log level and date for organized access and auditing. + * + * #### Parameters + * - `level: LogLevel` - The log's severity level, which determines where it appears. Valid options include: + * - `LogLevel.INFO`: Informational messages indicating standard operations. + * - `LogLevel.WARN`: Warnings that indicate potential issues. + * - `LogLevel.ERROR`: Critical errors requiring attention. + * - `message: string` - The primary log message, ideally concise and descriptive. + * - `data?: Record` - Optional. Additional data to provide context, such as error codes or debug info. + * + * #### Requirements + * - `level` must be a recognized value in `LogLevel`. + * - `message` should clearly describe the log's purpose, providing insight into system operations. + * + * #### Returns + * - `Promise` - Resolves when the log entry is recorded, either in the console or file. + * + * #### Usage + * Use this method to log critical information across the library, choosing the appropriate `LogLevel` to match + * the importance and visibility requirements of the message. + * + * @param {LogLevel} level - The log's severity level. + * @param {string} message - The main log message. + * @param {Record} [data] - Optional additional data for context. + * + * @returns {Promise} - A promise that resolves when logging completes. + * + * @example + * ```typescript + * // Logs a critical error with associated data + * logger.log(LogLevel.ERROR, "Database connection failed", { errorCode: "DB_CONN_ERR", timestamp: Date.now() }); + * + * // Logs an informational message + * logger.log(LogLevel.INFO, "Server started successfully"); + * ``` + */ + public async log( + level: LogLevel, + message: string, + data?: Record + ): Promise { + const timestamp = new Date().toISOString(); + const formattedMessage = `[${this.__appName}-${ + this.__libraryName + }] [${level.toUpperCase()}] [${timestamp}] ${message}`; + const fullLogMessage = data + ? `${formattedMessage} - ${JSON.stringify(data)}` + : formattedMessage; + + if (this.__consoleLogging) { + console.log(this.__colorize(level, fullLogMessage)); + } + + await this.__writeLogToFile(level, fullLogMessage); + } + + /************************************************************************************************************** + * WRAPPER METHODS (UTILITY & CONVENIENCE) + **************************************************************************************************************/ + + /************************************************************************************************************** + * INTERNAL METHODS (PROTECTED) + **************************************************************************************************************/ + + /************************************************************************************************************** + * INTERNAL METHODS (PRIVATE) + **************************************************************************************************************/ + + /** + * #### Description + * The `__setConsoleLogging` method allows the setting of the console logging preference for the logger. + * + * #### Purpose + * This method configures whether log messages should be displayed in the console, which is particularly useful + * for debugging in development environments. Enabling or disabling console logging provides flexibility for various + * deployment scenarios. + * + * #### Implements + * N/A + * + * #### Overrides + * N/A + * + * #### Parameters + * - `bool: boolean` - A boolean indicating whether console logging should be enabled (`true`) or disabled (`false`). + * + * #### Requirements + * - `bool` must be a valid boolean value (`true` or `false`). + * + * #### Returns + * - `boolean` - The current console logging state after assignment. + * + * #### Usage + * This method is used internally to toggle console logging based on configuration settings. + * + * @param {boolean} bool - Determines if console logging is enabled. + * @returns {boolean} - The updated state of console logging. + * + * @example + * ```typescript + * logger.__setConsoleLogging(false); // Disables console logging + * ``` + */ + private __setConsoleLogging(bool: boolean): boolean { + this.__consoleLogging = bool; + return this.__consoleLogging; + } + + /** + * #### Description + * The `__setEnv` method assigns the runtime environment (e.g., `development`, `production`) to the logger instance. + * + * #### Purpose + * This method ensures that the logger instance is aware of the current environment, which can influence the log file + * structure and behavior (e.g., different logging levels or file paths based on environment). + * + * #### Implements + * N/A + * + * #### Overrides + * N/A + * + * #### Parameters + * - `env: string` - The environment setting, typically "development", "production", or a custom environment. + * + * #### Requirements + * - `env` must be a non-empty string. + * + * #### Returns + * - `string` - The assigned environment of the logger. + * + * #### Usage + * Used internally to set the logging environment. This value determines where logs are stored or the format. + * + * @param {string} env - Environment string for the logger. + * @returns {string} - The assigned environment. + * + * @example + * ```typescript + * logger.__setEnv("production"); // Sets the environment to production + * ``` + */ + private __setEnv(env: string): string { + this.__env = + env === process.env.NODE_ENV + ? env + : process.env.NODE_ENV || "development"; + return this.__env; + } + + /** + * #### Description + * The `__setLogsDirPath` method configures the base directory path for log files. + * + * #### Purpose + * This method ensures that the log directory path is valid and ends with `/.logs`, maintaining a standardized + * log file structure. + * + * #### Implements + * N/A + * + * #### Overrides + * N/A + * + * #### Parameters + * - `path: string` - The desired base path for log files. + * + * #### Requirements + * - `path` must be a valid string. It will be appended with `/.logs` if not provided with this suffix. + * + * #### Returns + * - `string` - The updated and standardized log directory path. + * + * #### Usage + * Internally used to configure the base log directory path for storing logs. + * + * @param {string} path - The initial base path for logs. + * @returns {string} - The standardized log directory path. + * + * @example + * ```typescript + * logger.__setLogsDirPath("./custom/logs"); // Sets and formats the log directory path + * ``` + */ + private __setLogsDirPath(path: string): string { + this.__logsDirPath = path.endsWith(`/.logs`) ? path : `${path}/.logs`; + return this.__logsDirPath; + } + + /** + * #### Description + * Initializes the log directory structure if it does not already exist. + * + * #### Purpose + * Ensures that the log directory is available before any file-based logging occurs, creating it if necessary to + * avoid file writing errors. + * + * #### Implements + * N/A + * + * #### Overrides + * N/A + * + * #### Requirements + * - The `logDirPath` must be a valid path and writable by the system. + * + * #### Returns + * - `void` - This method does not return a value. + * + * #### Usage + * Called internally to initialize the log directory before any logs are written. + * + * @returns {void} + * + * @example + * ```typescript + * logger.__initLogsDir(); // Ensures log directory exists + * ``` + */ + private __initLogsDir(): void { + if (!existsSync(this.__logsDirPath)) { + mkdirSync(this.__logsDirPath, { recursive: true }); + } + } + + /** + * #### Description + * Writes a log entry to a file, organizing logs by date and severity level. + * + * #### Purpose + * Stores logs in structured files, organized by severity level and date for easy access and auditing. + * + * #### Parameters + * - `level: LogLevel` - Severity of the log. + * - `message: string` - The log message to be saved. + * + * #### Requirements + * - Log files should be writable. + * + * #### Returns + * - `Promise` - Resolves once logging is complete. + * + * @param {LogLevel} level - Severity level of the log. + * @param {string} message - The log message. + * @returns {Promise} + * + * @example + * ```typescript + * await logger.__writeLogToFile(LogLevel.INFO, "System initialized"); + * ``` + */ + private async __writeLogToFile( + level: LogLevel, + message: string + ): Promise { + const date = new Date().toISOString().split("T")[0]; + const logFilePath = path.join(this.__logsDirPath, `${date}-${level}.log`); + try { + await fsPromises.appendFile(logFilePath, `${message}\n`); + } catch (error) { + console.error(`Failed to write to log file: ${error}`); + } + } + + // Private method to apply color based on log level + private __colorize(level: LogLevel, message: string): string { + const colorCodes = { + [LogLevel.INFO]: "\x1b[32m", // Green + [LogLevel.WARN]: "\x1b[33m", // Yellow + [LogLevel.ERROR]: "\x1b[31m", // Red + }; + + const resetCode = "\x1b[0m"; + const color = colorCodes[level] || resetCode; // Default to reset if level is unknown + return `${color}${message}${resetCode}`; + } +} + +export { Logger }; diff --git a/src/models/pokerGame/index.ts b/src/models/pokerGame/index.ts new file mode 100644 index 0000000..14b811d --- /dev/null +++ b/src/models/pokerGame/index.ts @@ -0,0 +1,257 @@ +//collapse + +// Import Enums +import { PokerPhases } from "../../enums"; + +// Import Interfaces +import { + PokerGameConfig, + DeckInterface, + CardInterface, + PokerGameInterface, + PokerPlayerInterface, + PokerPhaseInterface, +} from "../../interfaces"; + +// Import Models +import { BaseEventEmitter } from "../_base"; +import { Deck } from "../deck"; +import { PokerPhase } from "../pokerPhase"; + +// Import Utils +import { generateUniqueId, logger } from "../../utils"; + +/** + * @class `PokerGame` + * Represents the current PokerGame being played at the PokerTable. + * Manages the deck, community cards, and game phases, such as pre-flop, flop, turn, and river. + * + * @extends BaseEventEmitter + */ +class PokerGame extends BaseEventEmitter implements PokerGameInterface { + /************************************************************************************* + * PROPERTIES + *************************************************************************************/ + + /** + * @property {DeckInterface} __id + * The deck of cards used in the current PokerGame. + */ + private __id: string = ``; + + /** + * @property {string} __deck + * The current phase of the game (e.g., "pre-flop", "flop", "turn", "river"). + */ + private __deck: DeckInterface = new Deck(); + + /** + * @property {number} __smallBlind + * The maximum number of players that can be seated at the PokerTable[2-14]. + */ + private __smallBlind: number = 5; + + /** + * @property {number} __bigBlind + * The maximum number of players that can be seated at the PokerTable[2-14]. + */ + private __bigBlind: number = this.__smallBlind * 2; + + /** + * @property {number} __bigBlind + * The maximum number of players that can be seated at the PokerTable[2-14]. + */ + private __phases: PokerPhaseInterface[] = []; + + /** + * @property {number} __bigBlind + * The maximum number of players that can be seated at the PokerTable[2-14]. + */ + private __currentPhase: PokerPhaseInterface = new PokerPhase(); + + /** + * @property {CardInterface[]} __communityCards + * The community cards that are dealt face-up and shared by all players. + */ + private __communityCards: CardInterface[] = []; + + private __players: PokerPlayerInterface[] = []; + + private __dealerPos: number = 0; + + private __smallBlindPos: number = 1; + + private __bigBlindPos: number = 2; + + private __pot: number = 0; + + /************************************************************************************* + * CONSTRUCTOR & INITIALIZERS + *************************************************************************************/ + + /** + * constructor + * @public + * Creates an instance of a Deck with 52 cards. + * Automatically initializes the deck with all combinations of ranks and suits. + * + * @example + * const deck = new Deck(); + */ + constructor(config?: PokerGameConfig) { + super(); + config ? this.__init(config) : this.__init(); + } + + /** + * `init` + * @private + * Initializes the deck with 52 unique cards. + * This method is called automatically inside the constructor during deck creation. + * `deck:initialized` : Emits a `deck:initialized` event when the deck is created. + * @returns {void} + */ + private __init(config?: PokerGameConfig): void { + if (config) { + this.__id = config.id ? config.id : generateUniqueId(); + this.__deck = new Deck(); + this.__smallBlind = config.smallBlind + ? config.smallBlind + : this.__smallBlind; + this.__bigBlind = config.bigBlind ? config.bigBlind : this.__bigBlind; + this.__communityCards = this.__communityCards; + this.__players = config.players ? config.players : this.__players; + this.__pot = this.__pot; + this.__dealerPos = this.__dealerPos; + this.__smallBlindPos = this.__smallBlindPos; + this.__bigBlindPos = this.__bigBlindPos; + this.__phases = this.__phases; + this.__currentPhase = new PokerPhase({ + name: PokerPhases.PRE_FLOP, + deck: this.__deck, + players: [], + pot: 0, + dealerPos: 0, + smallBlindPos: 0, + bigBlindPos: 0, + }); + this.__validatePlayerList(); + } else { + } + } + + /************************************************************************************************************** + * CREATE METHODS (SETTERS & OBJECT CREATION) + **************************************************************************************************************/ + + /************************************************************************************************************** + * READ METHODS (GETTERS & DATA RETRIEVAL) + **************************************************************************************************************/ + + public getPlayers(): PokerPlayerInterface[] { + return this.__players; + } + + public getDeck(): DeckInterface { + return this.__deck; + } + + public getPot(): number { + return this.__pot; + } + + public getDealerPos(): number { + return this.__dealerPos; + } + + public getSmallBlindPos(): number { + return this.__smallBlindPos; + } + + public getBigBlindPos(): number { + return this.__bigBlindPos; + } + + /************************************************************************************************************** + * UPDATE METHODS (MODIFYING EXISTING OBJECTS) + **************************************************************************************************************/ + private __tagPos(): void { + if ((this.getPlayers().length = 2)) { + this.__setDealerPos(0); + this.__setSmallBlindPos(1); + this.__setBigBlindPos(0); + } else if (this.getPlayers().length >= 3) { + this.__setDealerPos(0); + this.__setSmallBlindPos(1); + this.__setBigBlindPos(2); + } + } + + /************************************************************************************************************** + * DELETE METHODS (REMOVING OBJECTS) + **************************************************************************************************************/ + + /************************************************************************************************************** + * BUSINESS-LOGIC METHODS (LOGIC & CALCULATIONS) + **************************************************************************************************************/ + + /** + * `advancePhase` + * Advances the game to the next phase (pre-flop to flop, flop to turn, etc.). + * @returns {void} + */ + private __advancePhase(): void {} + + /** + * `resolveBets` + * Resolves the current betting round, updating player chip stacks and determining the winner if applicable. + * @returns {void} + */ + private __resolveBets(): void {} + + private __validatePlayerList(): boolean { + if (this.getPlayers().length < 2) { + throw new Error("Players are lesser than two."); + } else { + return true; + } + } + /************************************************************************************************************** + * WRAPPER METHODS (UTILITY & CONVENIENCE) + **************************************************************************************************************/ + + /************************************************************************************************************** + * INTERNAL METHODS (PROTECTED) + **************************************************************************************************************/ + + /************************************************************************************************************** + * INTERNAL METHODS (PRIVATE) + **************************************************************************************************************/ + + private __setPot(pot: number): number { + return (this.__pot = pot); + } + + private __setPlayers( + players: PokerPlayerInterface[] + ): PokerPlayerInterface[] { + return (this.__players = players); + } + + private __setDealerPos(pos: number): boolean { + this.__dealerPos = pos; + return true; + } + + private __setSmallBlindPos(pos: number): boolean { + this.__smallBlindPos = pos; + return true; + } + + private __setBigBlindPos(pos: number): boolean { + this.__bigBlindPos = pos; + return true; + } +} + +export { PokerGame }; diff --git a/src/models/pokerPhase/index.ts b/src/models/pokerPhase/index.ts new file mode 100644 index 0000000..fb99672 --- /dev/null +++ b/src/models/pokerPhase/index.ts @@ -0,0 +1,790 @@ +//@collapse + +// Import Enums +import { PokerPhaseName } from "../../enums"; + +// Import Interfaces +import { + CardInterface, + DeckInterface, + PokerPhaseConfig, + PokerPhaseInterface, + PokerPlayerInterface, +} from "../../interfaces"; + +// Import Models +import { BaseEventEmitter } from "../_base"; +import { Deck } from "../deck"; + +// Import Utils +import { logger } from "../../utils"; + +/** + * @class `PokerPhase` + * + * Manages the various phases of a poker game, such as "Pre-Flop," "Flop," "Turn," and "River." This class encapsulates + * the deck, community cards, and controls to transition between these game phases within a single round of poker. + * + * #### Purpose + * The `PokerPhase` class standardizes and manages the sequence and actions taken during each phase of a poker game. + * It ensures that the game progresses logically from one phase to another, maintaining the integrity of gameplay by + * enforcing rules specific to each phase and managing the deck and community cards. + * + * #### Extends + * - Extends Node.js `BaseEventEmitter`, enabling event-based responses to phase changes and key game events. + * + * #### Implements + * - Implements the `PokerPhaseInterface`, defining essential methods and properties for managing a poker game phase. + * + * #### Methods Overview + * - **Initialization**: `constructor`, `__initPhase` (sets up the deck and initial phase properties). + * - **Phase Control**: Methods to control transitions between phases like `nextPhase`, `resetPhase`. + * - **Deck and Community Cards Management**: Methods for dealing and revealing community cards. + * + * #### Events Overview + * - `phase:change` - Emitted each time the phase changes, enabling updates to game state. + * - `phase:end` - Emitted when the final phase (River) ends, signaling the conclusion of the phase sequence. + * + * #### Usage + * This class is instantiated and utilized during a poker game to control the progression through each game phase. + * It is designed for integration within a `PokerTable` or `PokerRoom`, where it serves as the core game phase manager. + * + * @example + * ```typescript + * const pokerPhase = new PokerPhase(); + * pokerPhase.on('phase:change', (newPhase) => console.log(`Phase changed to ${newPhase}`)); + * pokerPhase.nextPhase(); + * console.log(pokerPhase.getCurrentPhase()); // Outputs the next game phase, e.g., "Flop" + * ``` + */ +class PokerPhase extends BaseEventEmitter implements PokerPhaseInterface { + /************************************************************************************************************** + * PROPERTIES + **************************************************************************************************************/ + + /** + * @property {PokerPhaseName} __name + * + * Tracks the current phase name within the poker game (e.g., "Pre-Flop," "Flop," etc.). + * + * #### Purpose + * This property allows the game to determine which phase-specific actions are permissible, + * ensuring the correct flow and rules are applied throughout the game. + * + * #### Requirements + * - **Required**: Must be a valid `PokerPhaseName` that indicates the correct stage of gameplay. + * + * @example + * ```typescript + * const pokerPhase = new PokerPhase(); + * console.log(pokerPhase.__name); // Expected output: PokerPhaseName.PRE_FLOP + * ``` + */ + private __name: PokerPhaseName = PokerPhaseName.PRE_FLOP; + + /** + * @property {DeckInterface} __deck + * + * Holds the deck of cards utilized throughout the poker game, initialized at the start of each phase. + * + * #### Purpose + * This property ensures that the game uses a controlled and consistent set of cards for each phase, enabling + * accurate dealing to players and revealing community cards. + * + * #### Requirements + * - **Required**: Must be initialized with 52 cards for a standard poker game setup. + * + * @example + * ```typescript + * const pokerPhase = new PokerPhase(); + * console.log(pokerPhase.__deck.countCards()); // Expected output: 52 + * ``` + */ + private __deck: DeckInterface = new Deck(); + + /** + * @property {PokerPlayerInterface[]} __players + * + * Contains all player instances actively participating in the current phase. + * + * #### Purpose + * Tracks each player's actions and decisions during the phase, ensuring the game can access player details + * and update states in real-time. + * + * #### Requirements + * - **Optional**: Populated with player instances at the start of a poker round. + * + * @example + * ```typescript + * const pokerPhase = new PokerPhase(); + * console.log(pokerPhase.__players); // Expected output: Array of PokerPlayer instances + * ``` + */ + private __players: PokerPlayerInterface[] = []; + + /** + * @property {CardInterface[]} __communityCards + * + * Stores the community cards revealed at each phase, allowing all players to view them. + * + * #### Purpose + * Community cards are central to poker gameplay, helping players form their best hands. + * This array is populated during specific phases such as "Flop," "Turn," and "River." + * + * #### Requirements + * - **Optional**: Starts as an empty array and is populated as the game progresses. + * + * @example + * ```typescript + * const pokerPhase = new PokerPhase(); + * pokerPhase.nextPhase(); // Moves to "Flop" + * console.log(pokerPhase.__communityCards.length); // Expected output: 3 + * ``` + */ + private __communityCards: CardInterface[] = []; + + /** + * @property {number} __pot + * + * Represents the total amount of chips or money collected from players' bets in the current phase. + * + * #### Purpose + * The pot serves as the prize for the winning player(s) at the end of the poker round, accumulating all + * bets made during the current phase. + * + * #### Requirements + * - **Default**: Initialized to 0 at the beginning of each phase. + * + * @example + * ```typescript + * const pokerPhase = new PokerPhase(); + * console.log(pokerPhase.__pot); // Expected output: 0 + * ``` + */ + private __pot: number = 0; + + /** + * @property {number} __currentPlayerPos + * + * Tracks the index position of the current active player within the `__players` array. + * + * #### Purpose + * This property allows the game to identify and manage the player currently taking action in the phase. + * + * #### Requirements + * - **Default**: Starts at 1 to indicate the player after the dealer. + * + * @example + * ```typescript + * const pokerPhase = new PokerPhase(); + * console.log(pokerPhase.__currentPlayerPos); // Expected output: 1 + * ``` + */ + private __currentPlayerPos: number = 1; + + /** + * @property {number} __dealerPos + * + * Indicates the dealer's position in the game, impacting player actions and responsibilities. + * + * #### Purpose + * This property is critical for correctly rotating the dealer position after each hand and managing the flow of the game. + * + * #### Requirements + * - **Default**: Begins at 0, positioning the dealer at the start. + * + * @example + * ```typescript + * const pokerPhase = new PokerPhase(); + * console.log(pokerPhase.__dealerPos); // Expected output: 0 + * ``` + */ + private __dealerPos: number = 0; + + /** + * @property {number} __smallBlindPos + * + * Specifies the position of the player who posts the small blind at the start of the phase. + * + * #### Purpose + * The `smallBlindPos` ensures that the correct player posts the small blind in each hand, following standard poker rules. + * + * #### Requirements + * - **Default**: Initialized to position 1 (first position after the dealer). + * + * @example + * ```typescript + * const pokerPhase = new PokerPhase(); + * console.log(pokerPhase.__smallBlindPos); // Expected output: 1 + * ``` + */ + private __smallBlindPos: number = 1; + + /** + * @property {number} __bigBlindPos + * + * Specifies the position of the player who posts the big blind at the start of the phase. + * + * #### Purpose + * The `bigBlindPos` ensures that the correct player posts the big blind in each hand, in accordance with poker rules. + * + * #### Requirements + * - **Default**: Set to position 2 (second position after the dealer). + * + * @example + * ```typescript + * const pokerPhase = new PokerPhase(); + * console.log(pokerPhase.__bigBlindPos); // Expected output: 2 + * ``` + */ + private __bigBlindPos: number = 2; + + /************************************************************************************************************** + * CONSTRUCTOR & INITIALIZERS + **************************************************************************************************************/ + + /** + * constructor + * @public + * Initializes a new instance of `PokerPhase` with configurable settings for the game round, including players, deck, + * community cards, pot, and player positions (dealer, small blind, big blind). + * + * #### Purpose + * The constructor sets up the `PokerPhase` instance, calling the `__init` method to initialize the deck, player settings, + * and positions for the game round. It also emits events for listeners when the phase starts. + * + * #### Parameters + * - `config` (optional): A `PokerPhaseConfig` object to configure properties like phase name, deck, community cards, + * players, pot, and positional markers. + * + * #### Usage + * The constructor is used to initialize a `PokerPhase` instance with specific configurations, including player information + * and positions for the phase. + * + * @param {PokerPhaseConfig} config - Optional configuration object with properties for setting up the poker phase. + * + * @example + * ```typescript + * const pokerPhase = new PokerPhase({ + * name: PokerPhaseName.PRE_FLOP, + * deck: new Deck(), + * communityCards: [], + * players: [...], + * pot: 0, + * dealerPos: 0, + * smallBlindPos: 1, + * bigBlindPos: 2 + * }); + * ``` + */ + constructor(config?: PokerPhaseConfig) { + super(); + this.__init(config); + } + + /** + * __init + * @private + * Handles detailed initialization for `PokerPhase`, setting up phase properties like phase name, deck, community cards, + * players, and positional markers. This method is automatically called within the constructor. + * + * #### Purpose + * The `__init` method ensures that each phase has the correct configuration, including setting up player hands if it is + * the "Pre-Flop" phase, initializing community cards, and other positional configurations based on the provided `config`. + * + * #### Events + * - `deck:initialized`: Emits an event when the deck has been initialized, allowing listeners to confirm phase readiness. + * + * #### Parameters + * - `config` (optional): An object of type `PokerPhaseConfig`, used to define the phase's specific properties such as + * phase name, deck, players, and pot. + * + * #### Requirements + * - The `config` should contain a valid `PokerPhaseName` (e.g., `PRE_FLOP`, `FLOP`) and other properties for setting up + * the phase accurately. + * - If no `config` is provided, defaults are used to initialize each phase property. + * + * #### Returns + * - This method has no return value (`void`), but it initializes several instance properties based on the provided configuration. + * + * #### Usage + * This method is internally called by the constructor and should not be called directly. It ensures all properties are correctly + * initialized based on the phase configuration. + * + * @param {PokerPhaseConfig} config - Configuration object containing properties for phase initialization. + * @returns {void} + * + * @example + * ```typescript + * const config = { + * name: PokerPhaseName.PRE_FLOP, + * players: [...], + * communityCards: [], + * pot: 0 + * }; + * const pokerPhase = new PokerPhase(config); // Automatically calls __init(config) for phase setup + * ``` + */ + private __init(config?: PokerPhaseConfig): void { + if (config) { + this.__name = config.name ?? PokerPhaseName.PRE_FLOP; + this.__deck = config.deck ?? new Deck(); + this.__communityCards = config.communityCards ?? this.__communityCards; + this.__players = config.players ?? this.__players; + this.__pot = config.pot ?? this.__pot; + this.__currentPlayerPos = this.__currentPlayerPos; + this.__dealerPos = config.dealerPos ?? this.__dealerPos; + this.__smallBlindPos = config.smallBlindPos ?? this.__smallBlindPos; + this.__bigBlindPos = config.bigBlindPos ?? this.__bigBlindPos; + } + + if (this.getName() === PokerPhaseName.PRE_FLOP) { + this.deal(); // Deal cards to players if this is the "Pre-Flop" phase + } + } + + /************************************************************************************************************** + * CREATE METHODS (SETTERS & OBJECT CREATION) + **************************************************************************************************************/ + + public bet(amount: number): boolean { + return this._bet(amount); + } + + public fold(): boolean { + return this._fold(); + } + /************************************************************************************************************** + * READ METHODS (GETTERS & DATA RETRIEVAL) + **************************************************************************************************************/ + + /** + * #### Description + * Retrieves the current phase name (e.g., "Pre-Flop," "Flop") of the `PokerPhase`. + * + * #### Implements + * N/A + * + * #### Overrides + * N/A + * + * #### Purpose + * Provides the phase name, helping other parts of the code determine the current stage of the game round. + * + * #### Events + * N/A + * + * #### Parameters + * N/A + * + * #### Returns + * - {PokerPhaseName}: The name of the current game phase. + * + * #### Usage + * Useful for determining the phase of gameplay, allowing specific actions based on the current phase. + * + * @returns {PokerPhaseName} - The name of the current phase in the poker round. + * + * @example + * ```typescript + * const phaseName = pokerPhase.getName(); + * console.log(phaseName); // Outputs: "Pre-Flop" + * ``` + */ + public getName(): PokerPhaseName { + return this.__name; + } + + /** + * #### Description + * Retrieves the list of players currently involved in the `PokerPhase`. + * + * #### Implements + * N/A + * + * #### Overrides + * N/A + * + * #### Purpose + * Accesses the players participating in the current phase, supporting functions that involve player actions or status. + * + * #### Events + * N/A + * + * #### Parameters + * N/A + * + * #### Returns + * - {PokerPlayerInterface[]}: An array of player objects involved in this phase. + * + * #### Usage + * This method is commonly used when the current players need to be accessed, such as for dealing cards or determining + * player turns. + * + * @returns {PokerPlayerInterface[]} - List of players in the phase. + * + * @example + * ```typescript + * const players = pokerPhase.getPlayers(); + * console.log(players); // Outputs an array of player objects + * ``` + */ + public getPlayers(): PokerPlayerInterface[] { + return this.__players; + } + + /** + * #### Description + * Retrieves the position of the player whose turn it currently is within the `PokerPhase`. + * + * #### Implements + * N/A + * + * #### Overrides + * N/A + * + * #### Purpose + * Helps identify the active player during the phase, supporting turn-based actions. + * + * #### Events + * N/A + * + * #### Parameters + * N/A + * + * #### Returns + * - {number}: The zero-based position of the current player. + * + * #### Usage + * Useful in determining which player should act next in the game round. + * + * @returns {number} - Position of the active player. + * + * @example + * ```typescript + * const currentPosition = pokerPhase.getCurrentPlayerPos(); + * console.log(currentPosition); // Outputs: 2 + * ``` + */ + public getCurrentPlayerPos(): number { + return this.__currentPlayerPos; + } + + /** + * #### Description + * Retrieves the deck of cards currently being used in the `PokerPhase`. + * + * #### Implements + * N/A + * + * #### Overrides + * N/A + * + * #### Purpose + * Accesses the deck to support game actions involving the deck, such as dealing or shuffling. + * + * #### Events + * N/A + * + * #### Parameters + * N/A + * + * #### Returns + * - {DeckInterface}: The deck object used for this phase. + * + * #### Usage + * Useful for accessing the deck when cards need to be drawn or reset. + * + * @returns {DeckInterface} - The deck used in the phase. + * + * @example + * ```typescript + * const deck = pokerPhase.getDeck(); + * console.log(deck); // Outputs the deck object + * ``` + */ + public getDeck(): DeckInterface { + return this.__deck; + } + + /** + * #### Description + * Retrieves the current total pot amount for the `PokerPhase`. + * + * #### Implements + * N/A + * + * #### Overrides + * N/A + * + * #### Purpose + * Provides the total value of bets placed in the current phase, aiding in bet-related actions. + * + * #### Events + * N/A + * + * #### Parameters + * N/A + * + * #### Returns + * - {number}: The current value of the pot. + * + * #### Usage + * Useful for calculating winnings or determining the total bet pool. + * + * @returns {number} - The current pot value in the phase. + * + * @example + * ```typescript + * const potAmount = pokerPhase.getPot(); + * console.log(potAmount); // Outputs: 1000 + * ``` + */ + public getPot(): number { + return this.__pot; + } + + /** + * #### Description + * Retrieves the dealer's position for the current phase of poker. + * + * #### Implements + * N/A + * + * #### Overrides + * N/A + * + * #### Purpose + * Indicates which player holds the dealer role, which is essential for turn-based actions. + * + * #### Events + * N/A + * + * #### Parameters + * N/A + * + * #### Returns + * - {number}: The position of the dealer in the game. + * + * #### Usage + * Useful for determining turn order and dealer-related actions. + * + * @returns {number} - Dealer’s position in the phase. + * + * @example + * ```typescript + * const dealerPosition = pokerPhase.getDealerPos(); + * console.log(dealerPosition); // Outputs: 0 + * ``` + */ + public getDealerPos(): number { + return this.__dealerPos; + } + + /** + * #### Description + * Retrieves the position of the player assigned the small blind. + * + * #### Implements + * N/A + * + * #### Overrides + * N/A + * + * #### Purpose + * Helps identify the player with the small blind, aiding in betting actions. + * + * #### Events + * N/A + * + * #### Parameters + * N/A + * + * #### Returns + * - {number}: Position of the small blind player. + * + * #### Usage + * Used to determine the small blind in betting rounds. + * + * @returns {number} - Position of the small blind player. + * + * @example + * ```typescript + * const smallBlindPosition = pokerPhase.getSmallBlindPos(); + * console.log(smallBlindPosition); // Outputs: 1 + * ``` + */ + public getSmallBlindPos(): number { + return this.__smallBlindPos; + } + + /** + * #### Description + * Retrieves the position of the player assigned the big blind. + * + * #### Implements + * N/A + * + * #### Overrides + * N/A + * + * #### Purpose + * Helps identify the player with the big blind, aiding in betting actions. + * + * #### Events + * N/A + * + * #### Parameters + * N/A + * + * #### Returns + * - {number}: Position of the big blind player. + * + * #### Usage + * Used to determine the big blind in betting rounds. + * + * @returns {number} - Position of the big blind player. + * + * @example + * ```typescript + * const bigBlindPosition = pokerPhase.getBigBlindPos(); + * console.log(bigBlindPosition); // Outputs: 2 + * ``` + */ + public getBigBlindPos(): number { + return this.__bigBlindPos; + } + + /************************************************************************************************************** + * UPDATE METHODS (MODIFYING EXISTING OBJECTS) + **************************************************************************************************************/ + + /************************************************************************************************************** + * DELETE METHODS (REMOVING OBJECTS) + **************************************************************************************************************/ + + /************************************************************************************************************** + * BUSINESS-LOGIC METHODS (LOGIC & CALCULATIONS) + **************************************************************************************************************/ + + /** + * `dealHoleCards` + * Deals two hole cards to each player. + * @returns {void} + */ + deal(): boolean { + for (let i = 0; i < 2; i++) {} + return true; + } + + /** + * `dealCommunityCards` + * Deals the community cards to the table during the flop, turn, or river phases. + * @param {number} count - The number of community cards to deal (3 for the flop, 1 for the turn/river). + * @returns {boolean} + */ + dealCommunityCards(count: number): boolean { + for (let index = 0; index < count; index++) { + let card = this.getDeck().draw(); + card ? this.__communityCards.push(card) : {}; + } + return true; + } + + /** + * `advancePhase` + * Advances the game to the next phase (pre-flop to flop, flop to turn, etc.). + * @returns {void} + */ + advancePhase(): void {} + + /** + * `resolveBets` + * Resolves the current betting round, updating player chip stacks and determining the winner if applicable. + * @returns {void} + */ + resolveBets(): void {} + + /** + * name + */ + private nextPlayer(): void { + if (this.getPlayers().length - 1 === this.getCurrentPlayerPos()) { + this.__setCurrentPlayerPos(0); + } else { + this.__setCurrentPlayerPos(this.getCurrentPlayerPos() + 1); + } + } + + /************************************************************************************************************** + * WRAPPER METHODS (UTILITY & CONVENIENCE) + **************************************************************************************************************/ + + /************************************************************************************************************** + * INTERNAL METHODS (PROTECTED) + **************************************************************************************************************/ + + protected _bet(amount: number): boolean { + this.getPlayers()[this.getCurrentPlayerPos()]?.bet(amount); + this.__setPot(this.getPot() + amount); + this.nextPlayer(); + + return true; + } + + protected _fold(): boolean { + this.getPlayers()[this.getCurrentPlayerPos()]?.setIsFolded(true); + this.nextPlayer(); + return true; + } + /************************************************************************************************************** + * INTERNAL METHODS (PRIVATE) + **************************************************************************************************************/ + + private __setPot(pot: number): number { + return (this.__pot = pot); + } + + private __setCurrentPlayerPos(player: number): boolean { + this.__currentPlayerPos = player; + return true; + } + + /** + * `setName` + * @public + * Returns the poker table's `id`. + * @returns {string} The poker table's `id`. + * + * @example + * const rank = card.getRank(); + * console.log(rank); // "A" + */ + private __setName(name: PokerPhaseName): PokerPhaseName { + this.__name = name; + return this.__name; + } + + private __setPlayers( + players: PokerPlayerInterface[] + ): PokerPlayerInterface[] { + return (this.__players = players); + } + + private __setDealerPos(pos: number): boolean { + this.__dealerPos = pos; + return true; + } + + private __setSmallBlindPos(pos: number): boolean { + this.__smallBlindPos = pos; + return true; + } + + private __setBigBlindPos(pos: number): boolean { + this.__bigBlindPos = pos; + return true; + } +} + +export { PokerPhase }; diff --git a/src/models/pokerPlayer/index.ts b/src/models/pokerPlayer/index.ts new file mode 100644 index 0000000..667c053 --- /dev/null +++ b/src/models/pokerPlayer/index.ts @@ -0,0 +1,418 @@ +//@collapse + +// Import Enums +import {} from "../../enums"; + +// Import Interfaces +import { + CardInterface, + PokerPlayerConfig, + PokerPlayerInterface, +} from "../../interfaces"; + +// Import Models +import { BaseEventEmitter } from "../_base"; + +// Import Utils +import { generateUniqueId, logger } from "../../utils"; + +/** + * @class `PokerPlayerInterface` + * Represents a player seated at the PokerTable. + * The player can place bets, fold, and manage their chip stack during the game. + */ +class PokerPlayer extends BaseEventEmitter implements PokerPlayerInterface { + /************************************************************************************************************** + * PROPERTIES + **************************************************************************************************************/ + + /** + * @property {string} _id + * @private + * A unique identifier for the PokerPlayer. + */ + private __id: string = ``; + + /** + * @property {string} _name + * @private + * The player's name or alias. + */ + private __name: string = ``; + + /** + * @property {number} _chips + * @private + * The number of chips the player currently has. + */ + private __chips: number = 100; + + /** + * @property {CardInterface[]} _hand + * @private + * The player's hole cards (the two cards dealt to the player at the start of the game). + */ + private __hand: CardInterface[] = []; + + /** + * @property {boolean} _isFolded + * @private + * Indicates whether the player is still active in the current round or has folded. + */ + private __isFolded: boolean = false; + + /** + * @property {boolean} _isFolded + * @private + * Indicates whether the player is still active in the current round or has folded. + */ + private __isBetMatched: boolean = false; + + /************************************************************************************************************** + * CONSTRUCTOR & INITIALIZERS + **************************************************************************************************************/ + + /** + * constructor + * @public + * Creates an instance of a Deck with 52 cards. + * Automatically initializes the deck with all combinations of ranks and suits. + * + * @example + * const deck = new Deck(); + */ + constructor(config?: PokerPlayerConfig) { + super(); + this.__init(config); + } + + private __init(config?: PokerPlayerConfig) { + if (config) { + this.__id = config.id ? config.id : generateUniqueId(); + this.__name = config.name ? config.name : this.__name; + this.__chips = config.chips ? config.chips : this.__chips; + this.__hand = config.hand ? config.hand : this.__hand; + this.__isFolded = config.isFolded ? config.isFolded : this.__isFolded; + this.__isBetMatched = this.__isBetMatched; + } + } + /************************************************************************************************************** + * CREATE METHODS (SETTERS & OBJECT CREATION) + **************************************************************************************************************/ + + /** + * #### Description + * Sets the name of the `PokerRoom`, allowing the name to be updated or customized. + * + * #### Implements + * `N/A` - This method is part of the `PokerRoomInterface` and does not implement any external methods. + * + * #### Overrides + * `N/A` - This method does not override any superclass or parent methods. + * + * #### Purpose + * The `setName` method is used to assign a specific name to a `PokerRoom`, which helps distinguish it within the system. + * This is essential for systems where rooms need to be identifiable and manageable through a unique name. + * + * #### Events + * `N/A` - No events are emitted by this method. + * + * #### Parameters + * - `name`: A string representing the new name for the room. It must be a valid, non-empty string to ensure + * the room has a clear, identifiable label. + * + * #### Requirements + * - The `name` parameter should be a non-empty string to provide meaningful identification. + * - Passing an empty or invalid value could result in future misidentification of rooms if validation is implemented. + * + * #### Returns + * - Returns the `name` that was set for the `PokerRoom`. + * + * #### Usage + * Use this method to set or update the name of a room in a system where unique or identifiable room names + * are necessary for reference. + * + * @param {string} name - The new name for the `PokerRoom`. + * @returns {string} - Returns the name of the room that was set. + * + * @example + * ```typescript + * const pokerRoom = new PokerRoom({ name: "Room1", tableSize: 6 }); + * pokerRoom.setName("HighRollers"); // Sets the name of the room to "HighRollers" + * console.log(pokerRoom.getName()); // Logs "HighRollers" + * ``` + */ + public setName(name: string): string { + return this._setName(name); + } + + /** + * `setChips` + * @private + * Returns the poker table's `id`. + * @returns {number} The poker table's `id`. + * + * @example + * const rank = card.getRank(); + * console.log(rank); // "A" + */ + public setChips(chips: number): number { + return this._setChips(chips); + } + + /** + * `setHand` + * @private + * Returns the poker table's `id`. + * @returns {number} The poker table's `id`. + * + * @example + * const rank = card.getRank(); + * console.log(rank); // "A" + */ + public setHand(hand: CardInterface[]): CardInterface[] { + return this._setHand(hand); + } + + /** + * `getHand` + * @public + * Returns the poker table's `id`. + * @returns {CardInterface[]} The poker table's `id`. + * + * @example + * const rank = card.getRank(); + * console.log(rank); // "A" + */ + public setisBetMatched(betMatched: boolean): boolean { + return this.__setisBetMatched(betMatched); + } + + /** + * `setIsFolded` + * @private + * Returns the poker table's `id`. + * @returns {boolean} The poker table's `id`. + * + * @example + * const rank = card.getRank(); + * console.log(rank); // "A" + */ + public setIsFolded(bool: boolean): boolean { + return this.__setIsFolded(bool); + } + + /************************************************************************************************************** + * READ METHODS (GETTERS & DATA RETRIEVAL) + **************************************************************************************************************/ + + /** + * `getId` + * @public + * Returns the poker table's `id`. + * @returns {string} The poker table's `id`. + * + * @example + * const rank = card.getRank(); + * console.log(rank); // "A" + */ + public getId(): string { + return this.__id; + } + + /** + * `getName` + * @public + * Returns the poker table's `id`. + * @returns {string} The poker table's `id`. + * + * @example + * const rank = card.getRank(); + * console.log(rank); // "A" + */ + public getName(): string { + return this.__name; + } + + /** + * `getChips` + * @public + * Returns the poker table's `id`. + * @returns {number} The poker table's `id`. + * + * @example + * const rank = card.getRank(); + * console.log(rank); // "A" + */ + public getChips(): number { + return this.__chips; + } + + /** + * `getHand` + * @public + * Returns the poker table's `id`. + * @returns {CardInterface[]} The poker table's `id`. + * + * @example + * const rank = card.getRank(); + * console.log(rank); // "A" + */ + public getHand(): CardInterface[] { + return this.__hand; + } + + /** + * `isFolded` + * @public + * Returns the poker table's `id`. + * @returns {boolean} The poker table's `id`. + * + * @example + * const rank = card.getRank(); + * console.log(rank); // "A" + */ + public isFolded(): boolean { + return this.__isFolded; + } + + /** + * `getHand` + * @public + * Returns the poker table's `id`. + * @returns {CardInterface[]} The poker table's `id`. + * + * @example + * const rank = card.getRank(); + * console.log(rank); // "A" + */ + public isBetMatched(): boolean { + return this.__isBetMatched; + } + + /************************************************************************************************************** + * UPDATE METHODS (MODIFYING EXISTING OBJECTS) + **************************************************************************************************************/ + + public bet(amount: number): boolean { + this.__chips = this.getChips() - amount; + return true; + } + + /** + * `setHand` + * @private + * Returns the poker table's `id`. + * @returns {number} The poker table's `id`. + * + * @example + * const rank = card.getRank(); + * console.log(rank); // "A" + */ + + public addToHand(hand: CardInterface): boolean { + this.getHand().push(hand); + return true; + } + /************************************************************************************************************** + * DELETE METHODS (REMOVING OBJECTS) + **************************************************************************************************************/ + + /************************************************************************************************************** + * BUSINESS-LOGIC METHODS (LOGIC & CALCULATIONS) + **************************************************************************************************************/ + + /************************************************************************************************************** + * WRAPPER METHODS (UTILITY & CONVENIENCE) + **************************************************************************************************************/ + + /************************************************************************************************************** + * INTERNAL METHODS (PROTECTED) + **************************************************************************************************************/ + + protected _setName(name: string): string { + this.__name = name; + return this.__name; + } + + /** + * `setChips` + * @private + * Returns the poker table's `id`. + * @returns {number} The poker table's `id`. + * + * @example + * const rank = card.getRank(); + * console.log(rank); // "A" + */ + protected _setChips(chips: number): number { + this.__chips = chips; + return this.__chips; + } + + /** + * `setHand` + * @private + * Returns the poker table's `id`. + * @returns {number} The poker table's `id`. + * + * @example + * const rank = card.getRank(); + * console.log(rank); // "A" + */ + protected _setHand(hand: CardInterface[]): CardInterface[] { + this.__hand = hand; + return this.__hand; + } + + /************************************************************************************************************** + * INTERNAL METHODS (PRIVATE) + **************************************************************************************************************/ + + /** + * `setId` + * @private + * Returns the poker table's `id`. + * @returns {string} The poker table's `id`. + * + * @example + * const rank = card.getRank(); + * console.log(rank); // "A" + */ + private __setId(id: string): string { + this.__id = id; + return this.__id; + } + + /** + * `setIsFolded` + * @private + * Returns the poker table's `id`. + * @returns {boolean} The poker table's `id`. + * + * @example + * const rank = card.getRank(); + * console.log(rank); // "A" + */ + private __setIsFolded(bool: boolean): boolean { + this.__isFolded = bool; + return this.__isFolded; + } + + /** + * `getHand` + * @public + * Returns the poker table's `id`. + * @returns {CardInterface[]} The poker table's `id`. + * + * @example + * const rank = card.getRank(); + * console.log(rank); // "A" + */ + private __setisBetMatched(betMatched: boolean): boolean { + this.__isBetMatched = betMatched; + return this.__isBetMatched; + } +} + +export { PokerPlayer }; diff --git a/src/models/pokerRoom/index.ts b/src/models/pokerRoom/index.ts new file mode 100644 index 0000000..f75106d --- /dev/null +++ b/src/models/pokerRoom/index.ts @@ -0,0 +1,634 @@ +//@collapse + +// Import Enums +import {} from "../../enums"; + +// Import Interfaces +import { + PokerRoomConfig, + PokerRoomInterface, + PokerTableInterface, + PokerTableConfig, +} from "../../interfaces"; + +// Import Models +import { BaseEventEmitter } from "../_base"; +import { PokerTable } from "../pokerTable"; + +// Import Utils +import { generateUniqueId, logger } from "../../utils"; + +/** + * @class `PokerRoom` + * Represents a PokerRoom within a Casino that holds a single PokerTable. The PokerRoom manages the player queue, automatically assigning players to the PokerTable as seats become available. + * This class extends `BaseEventEmitter` and implements the `PokerRoomInterface` interface. + */ +class PokerRoom extends BaseEventEmitter implements PokerRoomInterface { + /************************************************************************************************************** + * PROPERTIES + **************************************************************************************************************/ + + /** + * @property {PokerRoomInterface[]} __rooms + * A private array that holds all the `PokerRoom` instances managed by the Casino. + * + * #### Access Level + * This property is private, meaning it can only be accessed directly within the + * `Casino` class itself. This encapsulation ensures that external modifications + * to the list of rooms are controlled through the class’s public methods. + * + * #### Default Value + * The `__rooms` property is initialized as an empty array `[]`, indicating that + * the Casino starts with no rooms. Rooms are added to this array using the `createRoom` + * or `addRoom` methods. + * + * @example + * ```typescript + * const casino = new Casino(); + * console.log(casino.getRooms()); // Returns an empty array initially + * ``` + */ + private __id: string = ``; + + /** + * @property {PokerRoomInterface[]} __rooms + * A private array that holds all the `PokerRoom` instances managed by the Casino. + * + * #### Access Level + * This property is private, meaning it can only be accessed directly within the + * `Casino` class itself. This encapsulation ensures that external modifications + * to the list of rooms are controlled through the class’s public methods. + * + * #### Default Value + * The `__rooms` property is initialized as an empty array `[]`, indicating that + * the Casino starts with no rooms. Rooms are added to this array using the `createRoom` + * or `addRoom` methods. + * + * @example + * ```typescript + * const casino = new Casino(); + * console.log(casino.getRooms()); // Returns an empty array initially + * ``` + */ + private __name: string = ``; + + /** + * @property {PokerRoomInterface[]} __rooms + * A private array that holds all the `PokerRoom` instances managed by the Casino. + * + * #### Access Level + * This property is private, meaning it can only be accessed directly within the + * `Casino` class itself. This encapsulation ensures that external modifications + * to the list of rooms are controlled through the class’s public methods. + * + * #### Default Value + * The `__rooms` property is initialized as an empty array `[]`, indicating that + * the Casino starts with no rooms. Rooms are added to this array using the `createRoom` + * or `addRoom` methods. + * + * @example + * ```typescript + * const casino = new Casino(); + * console.log(casino.getRooms()); // Returns an empty array initially + * ``` + */ + private __tables: PokerTableInterface[] = []; + + /************************************************************************************************************** + * CONSTRUCTOR & INITIALIZERS + **************************************************************************************************************/ + + /** + * The `constructor` initializes the `Casino` class. + * + * @example + * ```typescript + * const casino = new Casino(); + * console.log(casino.getRooms()); // Output: [] + * ``` + */ + constructor(config?: PokerRoomConfig) { + super(); + this.__init(config); + } + + /** + * `__init`: Performs any necessary setup logic when the `Casino` is instantiated. + * This is an internal method, meaning it's private and only used within the `Casino` class. + * + * #### Purpose + * This method is designed to be a placeholder for any future setup logic or preparation that the + * Casino might need during initialization. Currently, it's an empty method that gets called within the constructor. + * + * #### Usage + * Developers can add additional logic in this method if there are operations or configurations + * that need to happen every time the Casino is created. + * + * @returns {void} - This method doesn't return any values. + * + * @example + * The `__init` method is automatically invoked when the `Casino` is created: + * ```typescript + * const casino = new Casino(); + * ``` + */ + private __init(config?: PokerRoomConfig): void { + // No current logic, but reserved for future setup or configuration + if (config) { + this.__id = config.id ? config.id : generateUniqueId(); + this.__name = config.name ? config.name : this.__name; + config.tableConfigs?.forEach((tconfig) => { + this._createTable(tconfig); + }); + } + } + + /************************************************************************************************************** + * CREATE METHODS (SETTERS & OBJECT CREATION) + **************************************************************************************************************/ + + /** + * #### Description + * Sets the name of the `PokerRoom`, allowing the name to be updated or customized. + * + * #### Implements + * `N/A` - This method is part of the `PokerRoomInterface` and does not implement any external methods. + * + * #### Overrides + * `N/A` - This method does not override any superclass or parent methods. + * + * #### Purpose + * The `setName` method is used to assign a specific name to a `PokerRoom`, which helps distinguish it within the system. + * This is essential for systems where rooms need to be identifiable and manageable through a unique name. + * + * #### Events + * `N/A` - No events are emitted by this method. + * + * #### Parameters + * - `name`: A string representing the new name for the room. It must be a valid, non-empty string to ensure + * the room has a clear, identifiable label. + * + * #### Requirements + * - The `name` parameter should be a non-empty string to provide meaningful identification. + * - Passing an empty or invalid value could result in future misidentification of rooms if validation is implemented. + * + * #### Returns + * - Returns the `name` that was set for the `PokerRoom`. + * + * #### Usage + * Use this method to set or update the name of a room in a system where unique or identifiable room names + * are necessary for reference. + * + * @param {string} name - The new name for the `PokerRoom`. + * @returns {string} - Returns the name of the room that was set. + * + * @example + * ```typescript + * const pokerRoom = new PokerRoom({ name: "Room1", tableSize: 6 }); + * pokerRoom.setName("HighRollers"); // Sets the name of the room to "HighRollers" + * console.log(pokerRoom.getName()); // Logs "HighRollers" + * ``` + */ + public setName(name: string): string { + return this._setName(name); + } + + /** + * #### Description + * Sets the table configuration within the `PokerRoom`. The table configuration determines essential + * settings for the poker table, such as table size, small blind, and big blind values. + * + * #### Implements + * `N/A` - This method is part of the `PokerRoomInterface` and does not implement any external methods. + * + * #### Overrides + * `N/A` - This method does not override any superclass or parent methods. + * + * #### Purpose + * The `setTables` method allows configuration or reconfiguration of the poker table within a room. + * Properly setting up the table configuration is vital for game mechanics and player experience. + * + * #### Events + * `N/A` - No events are emitted by this method. + * + * #### Parameters + * - `table`: A `PokerTableInterface` instance containing configuration details for the room’s table. + * + * #### Requirements + * - The `table` parameter should be a valid instance of `PokerTableInterface`, configured with necessary game parameters. + * + * #### Returns + * - Returns the `PokerTableInterface` instance after updating it within the room. + * + * #### Usage + * Call this method to configure or update the settings of a poker table in the room. This helps ensure + * all game-related settings, such as seating and blinds, are properly managed. + * + * @param {PokerTableInterface[]} tables - The configuration settings for the poker table. + * @returns {PokerTableInterface[]} - Returns the table configuration set for the room. + * + * @example + * ```typescript + * const pokerRoom = new PokerRoom({ name: "Room3", tableSize: 8 }); + * const tableConfig = new PokerTable({ tableSize: 8, smallBlind: 10, bigBlind: 20 }); + * pokerRoom.setTables(tableConfig); // Configures the table for the room + * console.log(pokerRoom.getTable()); // Logs the table configuration + * ``` + */ + public setTables(tables: PokerTableInterface[]): PokerTableInterface[] { + return this._setTables(tables); + } + + /** + * #### Description + * Creates a new `PokerRoom` instance based on the provided configuration and adds it to the Casino's rooms list. + * + * #### Implements + * `N/A` + * + * #### Overrides + * `N/A` + * + * #### Purpose + * Allows the Casino to dynamically create new rooms as needed by providing specific room configurations. + * + * #### Events + * - Emits a `CasinoEventName.ROOM_CREATED` event, enabling listeners to respond to the creation of a new room. + * + * #### Parameters + * - `config`: A `PokerRoomConfig` object containing details like `name`, `tableSize`, `smallBlind`, and `bigBlind`. + * + * #### Requirements + * `N/A` + * + * #### Returns + * - Returns the newly created `PokerRoomInterface` instance. + * + * #### Usage + * Primarily used within subclasses or protected methods to dynamically create and add rooms to the Casino. + * + * @param {PokerRoomConfig} config - Configuration settings for creating a new `PokerRoom`. + * @returns {PokerRoomInterface} - The newly created room instance. + * + * @example + * ```typescript + * class SpecialCasino extends Casino { + * public createSpecialRoom(config: PokerRoomConfig): PokerRoomInterface { + * return this._createRoom(config); + * } + * } + * const specialCasino = new SpecialCasino(); + * const newRoom = specialCasino.createSpecialRoom({ name: "Champions Lounge", tableSize: 10, smallBlind: 100, bigBlind: 200 }); + * console.log(newRoom.getName()); // Outputs: "Champions Lounge" + * ``` + */ + public createTable(config: PokerTableConfig): PokerTableInterface { + return this._createTable(config); + } + + /************************************************************************************************************** + * READ METHODS (GETTERS & DATA RETRIEVAL) + **************************************************************************************************************/ + + /** + * #### Description + * Creates a new `PokerRoom` instance based on the provided configuration and adds it to the Casino's rooms list. + * + * #### Implements + * `N/A` + * + * #### Overrides + * `N/A` + * + * #### Purpose + * Allows the Casino to dynamically create new rooms as needed by providing specific room configurations. + * + * #### Events + * - Emits a `CasinoEventName.ROOM_CREATED` event, enabling listeners to respond to the creation of a new room. + * + * #### Parameters + * - `config`: A `PokerRoomConfig` object containing details like `name`, `tableSize`, `smallBlind`, and `bigBlind`. + * + * #### Requirements + * `N/A` + * + * #### Returns + * - Returns the newly created `PokerRoomInterface` instance. + * + * #### Usage + * Primarily used within subclasses or protected methods to dynamically create and add rooms to the Casino. + * + * @returns {PokerRoomInterface} - The newly created room instance. + * + * @example + * ```typescript + * class SpecialCasino extends Casino { + * public createSpecialRoom(config: PokerRoomConfig): PokerRoomInterface { + * return this._createRoom(config); + * } + * } + * const specialCasino = new SpecialCasino(); + * const newRoom = specialCasino.createSpecialRoom({ name: "Champions Lounge", tableSize: 10, smallBlind: 100, bigBlind: 200 }); + * console.log(newRoom.getName()); // Outputs: "Champions Lounge" + * ``` + */ + public getId(): string { + return this.__id; + } + + /** + * #### Description + * Retrieves the current name of the `PokerRoom`. + * + * #### Implements + * `N/A` - This method is defined within `PokerRoomInterface` and is implemented by any class adhering to this interface. + * + * #### Overrides + * `N/A` - This method does not override any superclass or parent methods. + * + * #### Purpose + * The `getName` method enables access to the current name of a `PokerRoom`, which can be essential for + * identification, logging, and displaying room information to users. + * + * #### Events + * `N/A` - No events are emitted by this method. + * + * #### Parameters + * `N/A` - This method does not require any parameters. + * + * #### Requirements + * `N/A` - This method simply returns the current name as set by `setName`. + * + * #### Returns + * - Returns the current name of the `PokerRoom` as a string. + * + * #### Usage + * Use this method to fetch the current name of a `PokerRoom`. This can be particularly helpful for displaying + * or verifying the room name during operations. + * + * @returns {string} - The current name of the `PokerRoom`. + * + * @example + * ```typescript + * const pokerRoom = new PokerRoom({ name: "VIP Room", tableSize: 6 }); + * console.log(pokerRoom.getName()); // Logs "VIP Room" + * ``` + */ + public getName(): string { + return this.__name; + } + + /** + * #### Description + * Retrieves the associated `PokerTable` instance within the `PokerRoom`. + * + * #### Implements + * `N/A` - This method does not implement external interfaces. + * + * #### Overrides + * `N/A` - This method does not override any superclass or parent methods. + * + * #### Purpose + * The `getTable` method provides access to the `PokerTable` instance that is actively managed by the `PokerRoom`. + * This can be used to view table configuration, status, and player seating arrangements. + * + * #### Events + * `N/A` - This method does not emit any events. + * + * #### Parameters + * `N/A` - No parameters are required for this method. + * + * #### Requirements + * `N/A` - This method does not modify the table, only retrieves it. + * + * #### Returns + * - Returns the `PokerTableInterface` instance currently set for the room. + * + * #### Usage + * Use this method to access the poker table associated with a specific room. This allows for table-specific + * operations and inquiries. + * + * @returns {PokerTableInterface} - The `PokerTable` instance associated with this room. + * + * @example + * ```typescript + * const pokerRoom = new PokerRoom({ name: "High Stakes", tableSize: 6 }); + * const table = pokerRoom.getTable(); + * console.log(table); // Logs the PokerTable instance associated with "High Stakes" room + * ``` + */ + public getTables(): PokerTableInterface[] { + return this.__tables; + } + + /************************************************************************************************************** + * UPDATE METHODS (MODIFYING EXISTING OBJECTS) + **************************************************************************************************************/ + + /************************************************************************************************************** + * DELETE METHODS (REMOVING OBJECTS) + **************************************************************************************************************/ + + /************************************************************************************************************** + * BUSINESS-LOGIC METHODS (LOGIC & CALCULATIONS) + **************************************************************************************************************/ + + /************************************************************************************************************** + * WRAPPER METHODS (UTILITY & CONVENIENCE) + **************************************************************************************************************/ + + /** + * `size` + * Starts a new PokerGame if there are at least two active players at the PokerTable. + * This method initiates the game flow, including assigning blinds and starting the rounds. + * @returns {number} + */ + public size(): number { + return this.tableCount(); + } + + /** + * #### Description + * Returns the total number of `PokerRoom` instances currently managed by the Casino. + * + * #### Implements + * Implements the `roomCount` method of `CasinoInterface`. + * + * #### Overrides + * `N/A` + * + * #### Purpose + * Provides a simple way to check how many poker rooms the Casino is currently managing. Useful for general + * information about the Casino's state and for validating indices or conditions that depend on room count. + * + * #### Events + * `N/A` + * + * #### Parameters + * `N/A` + * + * #### Requirements + * `N/A` + * + * #### Returns + * - Returns the number of rooms currently managed by the Casino. + * + * #### Usage + * This method is useful for any scenario where the total number of active rooms is needed, such as iterating + * over all rooms or validating index-based operations. + * + * @returns {number} - The current count of rooms in the Casino. + * + * @example + * ```typescript + * const casino = new Casino(); + * const count = casino.roomCount(); + * console.log(count); // Logs the total number of managed rooms, e.g., 5 + * ``` + */ + public tableCount(): number { + return this.getTables().length; + } + + /** + * #### Description + * Checks if a provided index is within the valid range of the Casino’s room list. + * + * #### Implements + * Implements the `isValidIndex` method of `CasinoInterface`. + * + * #### Overrides + * `N/A` + * + * #### Purpose + * This method helps validate that an index is within the valid bounds of the Casino’s room list. It prevents + * out-of-bound errors and ensures that methods calling on rooms by index are provided with a valid reference. + * + * #### Events + * `N/A` + * + * #### Parameters + * - `index`: A zero-based integer representing the position of a room in the Casino's managed list of rooms. + * + * #### Requirements + * - The `index` should be a non-negative integer and within the bounds of the `__rooms` array. + * + * #### Returns + * - Returns `true` if the index is within bounds. + * - Throws an `Error` if the index is out of range. + * + * #### Usage + * Call this method before performing operations that require a valid room index to prevent out-of-bounds errors. + * Can be used in any index-based access patterns for room retrieval or modification. + * + * @param {number} index - The zero-based index to validate. + * @returns {boolean} - Returns `true` if the index is within bounds. + * + * @throws {Error} - Throws an error with a message indicating the invalid index. + * + * @example + * ```typescript + * const casino = new Casino(); + * try { + * casino.isValidIndex(2); // Returns true if there are at least 3 rooms + * } catch (error) { + * console.error(error.message); // If index 2 is out of bounds, logs error message + * } + * ``` + */ + public isValidIndex(index: number): boolean { + if (index >= 0 && index < this.tableCount()) { + throw new Error( + `Invalid index: ${index}. It must be between 0 and ${ + this.tableCount() - 1 + }.` + ); + } else { + return true; + } + } + + /************************************************************************************************************** + * INTERNAL METHODS (PROTECTED) + **************************************************************************************************************/ + + protected _setName(name: string): string { + this.__name = name; + return this.__name; + } + + protected _setTables(table: PokerTableInterface[]): PokerTableInterface[] { + this.__tables = table; + return this.__tables; + } + + /** + * #### Description + * Creates a new `PokerRoom` instance based on the provided configuration and adds it to the Casino's rooms list. + * + * #### Implements + * `N/A` + * + * #### Overrides + * `N/A` + * + * #### Purpose + * Allows the Casino to dynamically create new rooms as needed by providing specific room configurations. + * + * #### Events + * - Emits a `CasinoEventName.ROOM_CREATED` event, enabling listeners to respond to the creation of a new room. + * + * #### Parameters + * - `config`: A `PokerRoomConfig` object containing details like `name`, `tableSize`, `smallBlind`, and `bigBlind`. + * + * #### Requirements + * `N/A` + * + * #### Returns + * - Returns the newly created `PokerRoomInterface` instance. + * + * #### Usage + * Primarily used within subclasses or protected methods to dynamically create and add rooms to the Casino. + * + * @param {PokerRoomConfig} config - Configuration settings for creating a new `PokerRoom`. + * @returns {PokerRoomInterface} - The newly created room instance. + * + * @example + * ```typescript + * class SpecialCasino extends Casino { + * public createSpecialRoom(config: PokerRoomConfig): PokerRoomInterface { + * return this._createRoom(config); + * } + * } + * const specialCasino = new SpecialCasino(); + * const newRoom = specialCasino.createSpecialRoom({ name: "Champions Lounge", tableSize: 10, smallBlind: 100, bigBlind: 200 }); + * console.log(newRoom.getName()); // Outputs: "Champions Lounge" + * ``` + */ + protected _createTable(config?: PokerTableConfig): PokerTableInterface { + const table = new PokerTable(config); + this.__tables.push(table); + return table; + } + + /************************************************************************************************************** + * INTERNAL METHODS (PRIVATE) + **************************************************************************************************************/ + + /** + * `setId` + * @private + * Returns the poker table's `id`. + * @returns {string} The poker table's `id`. + * + * @example + * const rank = card.setRank(); + * console.log(rank); // "A" + */ + private __setId(id: string): string { + this.__id = id; + return this.__id; + } +} + +export { PokerRoom }; diff --git a/src/models/pokerSeat/index.ts b/src/models/pokerSeat/index.ts new file mode 100644 index 0000000..3c55b74 --- /dev/null +++ b/src/models/pokerSeat/index.ts @@ -0,0 +1,894 @@ +//@collapse + +// Import Enums +import { LogLevel, PokerSeatEvents, Source } from "../../enums"; + +// Import Interfaces +import { + PokerPlayerInterface, + PokerSeatConfig, + PokerSeatInterface, + BaseEventInterface, +} from "../../interfaces"; + +// Import Models +import { BaseEventEmitter } from "../_base"; + +// Import Utils +import { generateUniqueId, logger } from "../../utils"; + +/** + * @class `PokerSeat` + * + * Represents a single seat at a poker table, managing player occupancy and seat status events. + * The `PokerSeat` class is central to tracking each player’s seat position, handling seat-related + * events like occupancy, vacancy, and position designation for dealer or blind roles. + * + * #### Purpose + * `PokerSeat` is designed to provide a controlled environment for managing players at individual + * seats on a poker table. It facilitates managing seat occupancy, seat status updates, and emitting + * events that alert the broader poker room to seat changes or player actions. + * + * #### Extends + * This class extends Node.js’s `EventEmitter`, allowing `PokerSeat` to emit events like + * `seatOccupied` or `seatVacated` to notify other components when a seat’s status changes. + * + * #### Implements + * This class implements `PokerSeatInterface`, providing a standard interface for seat operations, + * ensuring consistent seat management across various parts of the application. + * + * #### Methods Overview + * The `PokerSeat` includes the following methods: + * - `occupySeat`: Adds a player to the seat and emits a seat-occupied event. + * - `vacateSeat`: Removes the player from the seat and emits a seat-vacated event. + * - `isSeatOccupied`: Checks if the seat is currently occupied. + * - `assignBlind`: Assigns the small or big blind role to the seat. + * + * #### Events Overview + * The `PokerSeat` class emits events related to player actions at the seat: + * - **PokerSeat:Occupied**: Emitted when a player occupies the seat. + * - **PokerSeat:Vacated**: Emitted when the seat is vacated. + * + * #### Usage + * This class standardizes player management at a single seat, supporting operations like setting + * the dealer or blind role and monitoring seat status. + * + * @example + * ```typescript + * const pokerSeat = new PokerSeat(); + * pokerSeat.on(PokerSeatEvents.SEAT_OCCUPIED, () => console.log("Seat is now occupied")); + * pokerSeat.occupySeat(player); + * console.log(pokerSeat.isSeatOccupied()); // Console Output: true + * ``` + */ +class PokerSeat extends BaseEventEmitter implements PokerSeatInterface { + /************************************************************************************************************** + * PROPERTIES + **************************************************************************************************************/ + + /** + * @property {string} __id + * + * A unique identifier for the `PokerSeat`. + * + * #### Purpose + * The `__id` property uniquely identifies each `PokerSeat` instance, helping to distinguish between different + * seats at a poker table, especially when multiple seats are involved in the game. + * + * #### Requirements + * - This property is auto-generated upon creation, providing a unique string identifier for each seat. + * - Immutable: This property is set once and does not change throughout the seat's lifecycle. + * + * #### Usage + * The `__id` is used internally to track and differentiate seats, especially for operations that require distinct + * seat identification. + * + * @example + * ```typescript + * const pokerSeat = new PokerSeat(); + * console.log(pokerSeat.getId()); // Outputs a unique identifier, e.g., "123e4567-e89b-12d3-a456-426614174000" + * ``` + */ + private __id: string = ``; + + /** + * @property {number} __position + * + * Represents the seat's position at the poker table, usually ranging from 0 to the table’s maximum capacity. + * + * #### Purpose + * The `__position` property assigns each seat a specific position on the table, essential for managing seating + * order, determining player turns, and assigning blinds. + * + * #### Requirements + * - Immutable: This property is set during seat creation and must be within the table’s seating range. + * - Example range: 0 to 13 for a table with 14 seats. + * + * #### Usage + * The `__position` is used internally to keep track of each seat’s order at the table, allowing logical seat + * arrangements and role assignments. + * + * @example + * ```typescript + * const pokerSeat = new PokerSeat({ position: 3 }); + * console.log(pokerSeat.getPosition()); // Console Output: 3 + * ``` + */ + private __position: number = 0; + + /** + * @property {boolean} __isDealer + * + * Indicates if this seat is designated as the dealer’s seat for the current round. + * + * #### Purpose + * The `__isDealer` property helps track whether a player in this seat is assigned the dealer role, which is critical + * for determining game flow, blinds, and the starting point of each round. + * + * #### Requirements + * - Mutable: The `__isDealer` value can change between `true` or `false` depending on the game's dealer rotation. + * - Default: `false` by default, indicating the seat is not a dealer unless explicitly set. + * + * #### Usage + * This property is toggled as the game progresses to assign the dealer role to different seats. + * + * @example + * ```typescript + * const pokerSeat = new PokerSeat(); + * pokerSeat.setDealerStatus(true); + * console.log(pokerSeat.isDealer()); // Console Output: true, if set as dealer + * ``` + */ + private __isDealer: boolean = false; + + /** + * @property {PokerPlayerInterface | undefined} __player + * + * Holds the reference to the player occupying this seat, or `undefined` if no player is seated. + * + * #### Purpose + * The `__player` property keeps track of which player occupies this seat, facilitating player-specific interactions, + * actions, and status updates at the table. + * + * #### Requirements + * - Mutable: The `__player` can be assigned when a player occupies the seat and set to `undefined` when the seat is vacated. + * - Default: `undefined` by default, indicating no player occupies the seat. + * + * #### Usage + * The `__player` property is set when a player occupies the seat and is cleared when the seat is vacated. + * + * @example + * ```typescript + * const pokerSeat = new PokerSeat(); + * pokerSeat.occupySeat(player); // player implements PokerPlayerInterface + * console.log(pokerSeat.getPlayer()); // Console Output: + * ``` + */ + private __player: PokerPlayerInterface | undefined = undefined; + + /************************************************************************************************************** + * CONSTRUCTOR & INITIALIZERS + **************************************************************************************************************/ + + /** + * #### Description + * The public `constructor` method initializes a new instance of `PokerSeat`, setting up its configuration based on the + * provided `PokerSeatConfig` parameter. This configuration includes seat properties such as `id`, `position`, `isDealer`, + * and the `player` occupying the seat. + * + * #### Purpose + * The `constructor` method creates a fully initialized `PokerSeat` instance. It provides a structure for each seat + * at a poker table and uses the `__init` method to ensure all required configurations are applied. + * + * #### Implements + * N/A + * + * #### Overrides + * N/A + * + * #### Parameters + * - `config: PokerSeatConfig` - An optional configuration object that defines initial properties for the seat. + * This includes the `id`, `position`, `isDealer` status, and the `player`. + * + * #### Requirements + * - The `config` object should be structured to align with the `PokerSeatConfig` interface. + * - Default values are set if `config` is missing or incomplete. + * + * #### Returns + * - `N/A` - As a constructor, this does not return a value. + * + * #### Usage + * Use this constructor to create new `PokerSeat` instances for each seat at a poker table, each with a unique + * configuration. This can be particularly useful when setting up multiple seats within a table class. + * + * @param {PokerSeatConfig} config - Configuration object for setting initial seat properties. + * + * @example + * ```typescript + * const seatConfig = { id: "seat1", position: 3, isDealer: false }; + * const pokerSeat = new PokerSeat(seatConfig); + * console.log(pokerSeat.getPosition()); // Console Output: 3 + * ``` + */ + constructor(config: PokerSeatConfig) { + super(); + this.__init(config); + } + + /** + * #### Description + * The `__init` method is a private initializer function that applies the provided configuration to the `PokerSeat` instance. + * It sets the unique `id`, seat `position`, `isDealer` status, and any player occupying the seat. If a property in the + * configuration is missing, a default value or auto-generated value is assigned. + * + * #### Purpose + * This initializer separates configuration logic from the main `constructor`, enhancing readability and modularity. + * It ensures that each seat has consistent properties and auto-generates values where necessary, such as `id` if + * it is not provided. + * + * #### Implements + * N/A + * + * #### Overrides + * N/A + * + * #### Parameters + * - `config?: PokerSeatConfig` - An optional configuration object that provides initial values for the seat. + * - `id: string` - Optional. If provided, sets a unique identifier for the seat. Defaults to an auto-generated ID if missing. + * - `position: number` - Optional. Sets the seat’s position at the table. Throws an error if position is undefined. + * - `isDealer: boolean` - Optional. Determines if the seat is designated as the dealer seat. + * - `player: PokerPlayerInterface | undefined` - Optional. Assigns a player to the seat if occupied. + * + * #### Requirements + * - If `id` is missing, an auto-generated unique identifier is assigned. + * - `position` must be a valid number within the allowed seating range; otherwise, an error is thrown. + * - If `isDealer` is omitted, it defaults to `false`. + * - If `player` is not provided, the seat remains empty (`undefined`). + * + * #### Returns + * - `void` - This method does not return a value. + * + * #### Usage + * The `__init` method is called by the `constructor` to apply initial configuration to the `PokerSeat`. + * It sets default values where needed, ensuring a consistent setup for each seat. Typically, this method is not + * called directly but through the `constructor`. + * + * @param {PokerSeatConfig} config - An optional configuration object for initializing seat properties. + * + * @example + * ```typescript + * const seatConfig = { position: 1, isDealer: true }; + * const pokerSeat = new PokerSeat(seatConfig); + * // The seat is initialized with position 1 and dealer status as true. + * ``` + */ + private __init(config?: PokerSeatConfig): void { + if (config) { + // Set the unique seat ID; generate a new ID if not provided. + config.id && config.id !== `` + ? this.__setId(config.id) + : this.__setId(generateUniqueId()); + + // Set the seat position; if undefined, an error is thrown. + config.position + ? this.__setPosition(config.position) + : new Error(`PokerSeat: Position must be defined for each seat.`); + + // Set the dealer status; default to `false` if not provided. + config.isDealer + ? this.setDealer(config.isDealer) + : this.setDealer(this.__isDealer); + + // Assign a player to the seat if provided; otherwise, seat remains unoccupied. + config.player + ? this.__setPlayer(config.player) + : this.__setPlayer(this.__player); + } + + // Emit `INITIALIZED` event after initialization + this.emitEvent(PokerSeatEvents.INITIALIZED, { + event: { + source: Source.POKER_SEAT, + data: { seatId: this.getId() }, + }, + middlewares: [], + }); + } + + /************************************************************************************************************** + * CREATE METHODS (SETTERS & OBJECT CREATION) + **************************************************************************************************************/ + + /** + * #### Description + * The `setDealer` method is a public setter that designates the `PokerSeat` instance as the dealer seat if `true` + * is passed, or removes the dealer designation if `false` is passed. + * + * #### Implements + * N/A + * + * #### Overrides + * N/A + * + * #### Purpose + * This method allows toggling the dealer status for a seat, which is essential for poker games where the dealer + * role shifts between players. By marking a seat as the dealer, this method helps manage game flow, particularly + * in the context of determining blinds, turn order, and betting phases. + * + * #### Events + * N/A + * + * #### Parameters + * - `bool: boolean` - A boolean value indicating whether this seat should be designated as the dealer. + * - If `true`, the seat is set as the dealer. + * - If `false`, the seat's dealer status is removed. + * + * #### Requirements + * - `bool` must be a boolean value (`true` or `false`). + * - Passing `true` designates the seat as the dealer, while `false` removes the dealer status. + * + * #### Returns + * - `boolean` - The assigned dealer status for the seat. + * - Returns `true` if the seat is designated as the dealer, and `false` if it is not. + * + * #### Usage + * Use this method to assign or remove the dealer status of a seat. Typically, only one seat at a table should + * have the dealer status at any given time. This method is useful in scenarios where the dealer role rotates, + * such as in each new round of a poker game. + * + * @param {boolean} bool - A boolean indicating whether this seat is the dealer. + * + * @returns {boolean} - The updated dealer status of the seat. + * + * @example + * ```typescript + * const pokerSeat = new PokerSeat({ position: 2 }); + * pokerSeat.setDealer(true); // Sets the seat as the dealer + * console.log(pokerSeat.isDealer()); // Console Output: true + * + * pokerSeat.setDealer(false); // Removes dealer designation + * console.log(pokerSeat.isDealer()); // Console Output: false + * ``` + */ + public setDealer(bool: boolean): boolean { + return this.__setDealer(bool); + } + + /************************************************************************************************************** + * READ METHODS (GETTERS & DATA RETRIEVAL) + **************************************************************************************************************/ + + /** + * #### Description + * The `getId` method is a public getter that retrieves the unique identifier (`id`) of the `PokerSeat` instance. + * + * #### Implements + * N/A + * + * #### Overrides + * N/A + * + * #### Purpose + * This method provides access to the unique `id` of each `PokerSeat`, allowing it to be referenced or compared + * with other seats at the table. This identifier is essential for managing individual seats, especially in a table + * with multiple players. + * + * #### Events + * N/A + * + * #### Parameters + * N/A + * + * #### Requirements + * - This method requires no parameters. + * + * #### Returns + * - `string` - Returns the unique identifier (`id`) assigned to the seat. + * + * #### Usage + * Use this method to retrieve the `id` of the seat, which can be useful for logging, comparisons, or when tracking + * which seat a player occupies. + * + * @returns {string} - The unique identifier of the seat. + * + * @example + * ```typescript + * const pokerSeat = new PokerSeat(); + * console.log(pokerSeat.getId()); + * // Console Output: a unique string identifier, e.g., "123e4567-e89b-12d3-a456-426614174000" + * ``` + */ + public getId(): string { + return this.__id; + } + + /** + * #### Description + * The `getPosition` method is a public getter that retrieves the seat’s position at the poker table. + * + * #### Implements + * N/A + * + * #### Overrides + * N/A + * + * #### Purpose + * This method provides access to the seat's specific position on the poker table, which is important for managing + * turn order, dealer rotation, and blind assignments in poker games. + * + * #### Events + * N/A + * + * #### Parameters + * N/A + * + * #### Requirements + * - This method requires no parameters. + * + * #### Returns + * - `number` - Returns the position of the seat at the table. + * + * #### Usage + * Use this method to retrieve the position of the seat, which can be essential for turn-based logic and managing + * seating order at the poker table. + * + * @returns {number} - The position of the seat at the table. + * + * @example + * ```typescript + * const pokerSeat = new PokerSeat({ position: 3 }); + * console.log(pokerSeat.getPosition()); + * // Console Output: 3 + * ``` + */ + public getPosition(): number { + return this.__position; + } + + /** + * #### Description + * The `isDealer` method is a public getter that checks if this seat is currently designated as the dealer seat. + * + * #### Implements + * N/A + * + * #### Overrides + * N/A + * + * #### Purpose + * This method indicates whether the seat has been designated as the dealer, which is critical for determining + * turn order and managing the game's flow, especially in games where the dealer role rotates between players. + * + * #### Events + * N/A + * + * #### Parameters + * N/A + * + * #### Requirements + * - This method requires no parameters. + * + * #### Returns + * - `boolean` - Returns `true` if this seat is designated as the dealer, otherwise `false`. + * + * #### Usage + * Use this method to check if the seat has the dealer role, which is particularly useful for managing dealer-related + * functions like initiating blinds or handling turn order. + * + * @returns {boolean} - The dealer status of the seat. + * + * @example + * ```typescript + * const pokerSeat = new PokerSeat(); + * pokerSeat.setDealer(true); + * console.log(pokerSeat.isDealer()); + * // Console Output: true + * ``` + */ + public isDealer(): boolean { + return this.__isDealer; + } + + /** + * #### Description + * The `getPlayer` method is a public getter that retrieves the player occupying this seat, if any. + * + * #### Implements + * N/A + * + * #### Overrides + * N/A + * + * #### Purpose + * This method provides access to the player currently occupying the seat, allowing the application to retrieve + * player-specific data, manage player actions, or determine seat vacancy. + * + * #### Events + * N/A + * + * #### Parameters + * N/A + * + * #### Requirements + * - This method requires no parameters. + * + * #### Returns + * - `PokerPlayerInterface | undefined` - Returns the player instance occupying this seat, or `undefined` if the seat is vacant. + * + * #### Usage + * Use this method to retrieve the player occupying this seat, which is helpful in managing player actions or + * determining if the seat is available for another player. + * + * @returns {PokerPlayerInterface | undefined} - The player instance if occupied, or `undefined` if vacant. + * + * @example + * ```typescript + * const pokerSeat = new PokerSeat(); + * pokerSeat.occupySeat(player); // player implements PokerPlayerInterface + * console.log(pokerSeat.getPlayer()); + * // Console Output: + * ``` + */ + public getPlayer(): PokerPlayerInterface | undefined { + return this.__player; + } + + /************************************************************************************************************** + * UPDATE METHODS (MODIFYING EXISTING OBJECTS) + **************************************************************************************************************/ + + /************************************************************************************************************** + * DELETE METHODS (REMOVING OBJECTS) + **************************************************************************************************************/ + + /************************************************************************************************************** + * BUSINESS-LOGIC METHODS (LOGIC & CALCULATIONS) + **************************************************************************************************************/ + + /** + * #### Description + * The `isOccupied` method checks if the seat is currently occupied by a player. + * + * #### Purpose + * This method is essential for determining seat occupancy status, enabling other parts of the program to + * verify if a seat is taken before allowing actions such as seating another player. + * + * @returns {boolean} - `true` if the seat has a player, otherwise `false`. + */ + public isOccupied(): boolean { + return this.getPlayer() ? true : false; + } + + /** + * #### Description + * The `occupy` method assigns a player to occupy this seat. + * + * #### Purpose + * This method assigns a player to the seat, indicating the seat is occupied. It is essential for seating + * management, allowing a player to be seated at a specific position at the poker table. + * + * @param {PokerPlayerInterface} player - The player instance to assign to the seat. + * + * @returns {void} + */ + public occupy(player: PokerPlayerInterface): void { + this.emitEvent(PokerSeatEvents.OCCUPIED, { + event: { + source: Source.POKER_SEAT, + data: { seatId: this.getId(), playerId: player.getId() }, + params: { player: player }, + }, + middlewares: [ + (event, next) => { + this.__checkSeatVacancy(event, next); + }, + (event, next) => { + this.__occupy(event, next); + }, + ], + }); + } + + /** + * #### Description + * The `vacate` method removes the player from the seat, marking it as unoccupied. + * + * #### Purpose + * This method allows for freeing up the seat by removing the player, which is essential in poker games + * where players may need to leave their seat or be reassigned to a different seat. + * + * @returns {void} + */ + public vacate(): void { + this.emitEvent(PokerSeatEvents.VACATED, { + event: { + source: Source.POKER_SEAT, + data: { seatId: this.getId(), playerId: this.getPlayer()?.getId() }, + }, + middlewares: [ + (event, next) => { + this.__checkSeatOccupancy(event, next); + }, + (event, next) => { + this.__vacate(event, next); + }, + ], + }); + } + + /************************************************************************************************************** + * WRAPPER METHODS (UTILITY & CONVENIENCE) + **************************************************************************************************************/ + + /************************************************************************************************************** + * INTERNAL METHODS (PROTECTED) + **************************************************************************************************************/ + + /************************************************************************************************************** + * INTERNAL METHODS (PRIVATE) + **************************************************************************************************************/ + + /** + * #### Description + * The `__setId` method assigns a unique identifier (`id`) to this `PokerSeat` instance. + * + * #### Purpose + * This method ensures each `PokerSeat` instance has a unique `id`, enabling it to be individually identified + * within a poker table, which is essential for managing seats in complex games. + * + * #### Implements + * N/A + * + * #### Overrides + * N/A + * + * #### Parameters + * - `id: string` - The unique identifier to be assigned to the `PokerSeat`. + * + * #### Requirements + * - `id` must be a valid, unique string, typically generated when the seat is initialized. + * + * #### Returns + * - `string` - The assigned unique identifier of the seat. + * + * #### Usage + * This method is called internally during seat initialization to set or update the seat's unique `id`. + * + * @param {string} id - A unique identifier for the seat. + * + * @returns {string} - The assigned unique identifier of the seat. + * + * @example + * ```typescript + * const pokerSeat = new PokerSeat(); + * pokerSeat.__setId("unique-seat-id-123"); + * console.log(pokerSeat.getId()); + * // Console Output: "unique-seat-id-123" + * ``` + */ + private __setId(id: string): string { + this.__id = id; + return this.__id; + } + + /** + * #### Description + * The `__setPosition` method assigns a specific position index to this `PokerSeat` instance within the poker table. + * + * #### Purpose + * This method specifies the seat's location on the table, essential for player turn management and role assignments + * like the dealer or blinds. + * + * #### Implements + * N/A + * + * #### Overrides + * N/A + * + * #### Parameters + * - `position: number` - The index position of the seat on the table. + * + * #### Requirements + * - `position` must be a non-negative integer and within the allowed range for the table. + * + * #### Returns + * - `number` - The position of the seat after assignment. + * + * #### Usage + * This method is called internally to set or update the seat’s position at the table during initialization. + * + * @param {number} position - Position index of the seat. + * + * @returns {number} - The position index of the seat. + * + * @example + * ```typescript + * const pokerSeat = new PokerSeat(); + * pokerSeat.__setPosition(2); + * console.log(pokerSeat.getPosition()); + * // Console Output: 2 + * ``` + */ + private __setPosition(position: number): number { + this.__position = position; + return this.__position; + } + + /** + * #### Description + * The `__setDealer` method designates this `PokerSeat` as the dealer’s seat. + * + * #### Purpose + * This method toggles the dealer status for the seat, essential for game flow management, such as assigning blinds + * and determining the first player action. + * + * #### Implements + * N/A + * + * #### Overrides + * N/A + * + * #### Parameters + * - `bool: boolean` - Indicates if the seat is assigned the dealer role. + * + * #### Requirements + * - `bool` should be `true` to assign the dealer status, or `false` to remove it. + * + * #### Returns + * - `boolean` - The updated dealer status of the seat. + * + * #### Usage + * This method is called internally to assign or toggle the dealer status of the seat. + * + * @param {boolean} bool - Specifies if the seat is the dealer. + * + * @returns {boolean} - The assigned dealer status. + * + * @example + * ```typescript + * const pokerSeat = new PokerSeat(); + * pokerSeat.__setDealer(true); + * console.log(pokerSeat.isDealer()); + * // Console Output: true + * ``` + */ + private __setDealer(bool: boolean): boolean { + this.__isDealer = bool; + return this.__isDealer; + } + + /** + * #### Description + * The `__setPlayer` method assigns a player to this `PokerSeat`. + * + * #### Purpose + * This method designates a player to occupy the seat or clears the seat if set to `undefined`, allowing for + * seat availability management. + * + * #### Implements + * N/A + * + * #### Overrides + * N/A + * + * #### Parameters + * - `player: PokerPlayerInterface | undefined` - The player instance to be assigned to the seat, or `undefined` to mark the seat vacant. + * + * #### Requirements + * - `player` must be an instance of `PokerPlayerInterface`, or `undefined` to vacate the seat. + * + * #### Returns + * - `PokerPlayerInterface | undefined` - The player occupying the seat or `undefined` if vacant. + * + * #### Usage + * This method is used internally to assign a player to the seat or clear the seat. + * + * @param {PokerPlayerInterface | undefined} player - The player to occupy the seat, or `undefined` if no player is assigned. + * + * @returns {PokerPlayerInterface | undefined} - The player instance or `undefined` after assignment. + * + * @example + * ```typescript + * const pokerSeat = new PokerSeat(); + * pokerSeat.__setPlayer(playerInstance); + * console.log(pokerSeat.getPlayer()); + * // Console Output: + * ``` + */ + private __setPlayer( + player: PokerPlayerInterface | undefined + ): PokerPlayerInterface | undefined { + this.__player = player; + return this.__player; + } + + /** + * #### Description + * Checks seat availability to determine if it can be occupied by a player. + * + * @param {BaseEventInterface} event - The event object containing event data. + * @param {() => void} next - The next middleware function to call if seat is available. + */ + private __checkSeatVacancy( + event: BaseEventInterface, + next: () => void + ): void { + if (this.isOccupied()) { + logger.log( + LogLevel.WARN, + "Failed to occupy seat: seat is already occupied.", + { + seatId: this.getId(), + } + ); + return; + } + + event.lastModifiedAt = new Date(); + next(); + } + + /** + * #### Description + * Assigns a player to the seat. + * + * @param {BaseEventInterface} event - The event object with player information. + * @param {() => void} next - The next middleware function. + */ + private __occupy(event: BaseEventInterface, next: () => void): void { + this.__setPlayer(event.params.player); + logger.log(LogLevel.INFO, "Seat occupied successfully.", { + seatId: this.getId(), + playerId: event.params.player.getId(), + }); + + event.lastModifiedAt = new Date(); + next(); + } + + /** + * #### Description + * Checks if the seat is occupied to determine if it can be vacated. + * + * @param {BaseEventInterface} event - The event object containing event data. + * @param {() => void} next - The next middleware function if the seat is occupied. + */ + private __checkSeatOccupancy( + event: BaseEventInterface, + next: () => void + ): void { + event.lastModifiedAt = new Date(); + if (!this.isOccupied()) { + logger.log( + LogLevel.WARN, + "Failed to vacate seat: seat is already vacant.", + { + seatId: this.getId(), + } + ); + return; + } + + event.lastModifiedAt = new Date(); + next(); + } + + /** + * #### Description + * Vacates the seat by removing the current player. + * + * @param {BaseEventInterface} event - The event object with seat details. + * @param {() => void} next - The next middleware function. + */ + private __vacate(event: BaseEventInterface, next: () => void): void { + this.__setPlayer(undefined); + logger.log(LogLevel.INFO, "Seat vacated successfully.", { + seatId: this.getId(), + }); + + event.lastModifiedAt = new Date(); + next(); + } +} + +export { PokerSeat }; diff --git a/src/models/pokerTable/index.ts b/src/models/pokerTable/index.ts new file mode 100644 index 0000000..54352e9 --- /dev/null +++ b/src/models/pokerTable/index.ts @@ -0,0 +1,726 @@ +//@collapse + +// Import Enums +import { PokerSeatEvents , LogLevel } from "../../enums"; + +// Import Interfaces +import { + PokerPlayerInterface, + PokerSeatInterface, + PokerTableConfig, + PokerTableInterface, + PokerPlayerConfig, + BaseEventInterface, +} from "../../interfaces"; + +// Import Models +import { BaseEventEmitter } from "../_base"; +import { PokerPlayer } from "../pokerPlayer"; +import { PokerSeat } from "../pokerSeat"; + +// Import Utils +import { generateUniqueId , logger} from "../../utils"; + +/** + * @class `PokerTable` + * + * Represents a poker table within a larger casino or poker room environment. This class manages player seating, + * tracks the positions of the dealer, small blind, and big blind, and coordinates the start and stop of poker games. + * It includes several methods and properties to control game flow and player seating effectively. + * + * #### Purpose + * The `PokerTable` class is central to organizing poker games within a room. It keeps track of players, manages game + * states, and ensures a smooth flow of actions at the table by overseeing betting rounds, blind assignments, and game + * progression. + * + * #### Extends + * This class extends the Node.js `BaseEventEmitter`, enabling it to emit events for key actions such as player seating, + * game start, or game completion. This event-driven approach facilitates integration with other parts of the casino + * system, allowing external components to listen and respond to table actions. + * + * #### Implements + * Implements the `PokerTableInterface`, ensuring a consistent structure and a clear contract for managing poker games, + * player queues, and table configuration. + * + * #### Methods Overview + * The `PokerTable` class includes essential methods for: + * - **Player Management**: `seatPlayer`, `removePlayer`, `getQueue`, `setQueue`. + * - **Game Control**: `startGame`, `endGame`, `setBlinds`. + * - **Table Configuration**: `setTableConfig`, `getTableConfig`, `resetTable`. + * + * #### Events Overview + * The `PokerTable` emits events to signal key actions, including: + * - `table:playerSeated` - Emitted when a new player is seated. + * - `table:gameStarted` - Emitted at the start of a new game. + * - `table:gameEnded` - Emitted upon game completion. + * + * #### Usage + * This class is designed to be used within a larger poker or casino environment, providing a structured system for + * managing player actions, game states, and blind assignments at a poker table. It offers methods to control various + * aspects of the game and seating, making it a foundational part of managing poker tables in an organized way. + * + * @example + * ```typescript + * const pokerTable = new PokerTable(); + * pokerTable.on('table:gameStarted', () => console.log("Game has started")); + * pokerTable.seatPlayer({ name: "Alice", chips: 100 }); + * pokerTable.startGame(); + * console.log(pokerTable.getQueue()); // Logs the current queue of waiting players + * ``` + */ +class PokerTable extends BaseEventEmitter implements PokerTableInterface { + /************************************************************************************************************** + * PROPERTIES + **************************************************************************************************************/ + + /** + * @property {string} __id + * + * A unique identifier for the PokerTable, used to differentiate each table within the Casino system. + * + * #### Purpose + * The `__id` serves as a unique identifier for each PokerTable, allowing for precise management and reference. + * + * #### Requirements + * - **Optional**: Can be auto-generated if not provided. + * + * @example + * ```typescript + * const table = new PokerTable(); + * console.log(table.getId()); // Console Output: A unique table ID + * ``` + */ + private __id: string = ``; + + /** + * @property {string} __name + * + * A name label for the PokerTable, which can be used in the user interface or logs for easy identification. + * + * #### Purpose + * Provides a human-readable label for the table, aiding both administrators and players in table identification. + * + * #### Requirements + * - **Optional**: If not set, it defaults to an empty string. + * + * @example + * ```typescript + * const table = new PokerTable(); + * table.setName("High Stakes Table"); + * console.log(table.getName()); // Console Output: "High Stakes Table" + * ``` + */ + private __name: string = ``; + + /** + * @property {number} __smallBlind + * + * Defines the small blind amount for the table, setting the minimum bet that initiates the betting round. + * + * #### Purpose + * Establishes the basic small blind amount for the game, setting a standard for betting progression at this table. + * + * #### Requirements + * - **Default**: 5 + * - **Non-Negotiable**: Must be a positive number. + * + * @example + * ```typescript + * const table = new PokerTable(); + * console.log(table.getSmallBlind()); // Console Output: 5 + * ``` + */ + private __smallBlind: number = 5; + + /** + * @property {number} __bigBlindAmount + * + * Represents the big blind amount, which is usually double the small blind and a required ante for players. + * + * #### Purpose + * Sets the big blind, which defines the minimum second bet for the table, supporting the betting structure. + * + * #### Requirements + * - **Default**: Twice the small blind amount. + * + * @example + * ```typescript + * const table = new PokerTable(); + * console.log(table.getBigBlind()); // Console Output: 10 + * ``` + */ + private __bigBlindAmount: number = this.__smallBlind * 2; + + /** + * @property {PokerSeatInterface[]} __seats + * + * An array that stores each player’s seating arrangement, tracking available and occupied seats at the table. + * + * #### Purpose + * The `__seats` property enables efficient management of seating arrangements for the players at the table. + * + * #### Requirements + * - **Optional**: Starts as an empty array, populated as players take seats. + * + * @example + * ```typescript + * const table = new PokerTable(); + * console.log(table.getSeats()); + * + * // Console Output: [] (initially empty) + * ``` + */ + private __seats: PokerSeatInterface[] = []; + + /** + * @property {boolean} __gameInProgress + * + * Indicates if a poker game is currently active at the table. + * + * #### Purpose + * Helps track the table’s state, signaling whether a game is in progress or the table is free. + * + * #### Requirements + * - **Default**: `false`, meaning the table is initially open for new games. + * + * @example + * ```typescript + * const table = new PokerTable(); + * console.log(table.isGameInProgress()); + * + * // Console Output: false (initially) + * ``` + */ + private __gameInProgress: boolean = false; + + /************************************************************************************************************** + * CONSTRUCTOR & INITIALIZERS + **************************************************************************************************************/ + + /** + * #### Description + * Creates a new `PokerTable` instance with configuration settings for table ID, small blind, and number of seats. + * If a configuration object is provided, it customizes the table based on this data; otherwise, default values are used. + * + * #### Implements + * - N/A (standard constructor for object instantiation). + * + * #### Overrides + * - N/A + * + * #### Purpose + * This constructor initiates a new instance of `PokerTable`, setting up basic table properties and triggering the initialization process. + * + * #### Parameters + * - `config` _(optional)_: A configuration object that includes table properties such as `id`, `smallBlind`, and `size`. + * + * #### Requirements + * - **Optional**: If no configuration is provided, default values for small blind and seat count are applied. + * + * #### Usage + * This constructor is typically called when a new table is added to a poker room, allowing optional customization for game settings. + * + * @param {PokerTableConfig} [config] - Configuration settings for the poker table. + * + * @example + * ```typescript + * const config = { id: "Table42", smallBlind: 25, size: 6 }; + * const pokerTable = new PokerTable(config); + * console.log(pokerTable.getSeats().length); // Output: 6 + * ``` + */ + constructor(config?: PokerTableConfig) { + super(); + this.__init(config); + } + + /** + * #### Description + * The `__init` method initializes the table based on a provided configuration, setting up the table ID, blinds, and seating arrangement. + * It is automatically called within the constructor during instantiation. + * + * #### Implements + * - N/A (private method). + * + * #### Overrides + * - N/A + * + * #### Purpose + * This method completes the setup of the poker table by establishing its unique ID, small blind amount, and number of seats. + * It also triggers the seating arrangement based on the specified or default seat count. + * + * #### Events + * - Emits `table:initialized` when the table setup is complete, allowing external components to take actions upon initialization. + * + * #### Parameters + * - `config` _(optional)_: A configuration object that can contain `id`, `smallBlind`, and `size` properties. + * + * #### Requirements + * - **Optional**: If no configuration is provided, it will default to a table with a small blind of 5 and a standard seating arrangement. + * + * #### Returns + * - `void`: This method does not return any value. + * + * #### Usage + * Used internally within the constructor to complete table setup, including assigning blinds and initializing seats. + * + * @param {PokerTableConfig} [config] - Configuration settings for initializing the poker table. + * @returns {void} - No return value. + * + * @example + * ```typescript + * const pokerTable = new PokerTable({ id: "MainTable", smallBlind: 20, size: 8 }); + * pokerTable.on("table:initialized", () => console.log("Table setup complete")); + * ``` + */ + private __init(config?: PokerTableConfig): void { + if (config) { + this.__id = config.id ? config.id : generateUniqueId(); + this.__smallBlind = config.smallBlind ? config.smallBlind : 5; + this.__bigBlindAmount = this.__smallBlind * 2; + this.__seats = []; + this.__gameInProgress = false; + + for (let i = 0; this.getSeats().length !== config.size; i++) { + const seat = new PokerSeat({ + position: i, + }); + this.__seats?.push(seat); + + // seat.on(PokerSeatEvents.OCCUPIED,(event)=>{}) + seat.listenToEvent(PokerSeatEvents.OCCUPIED,{ + handler:(event:BaseEventInterface) => { + + }, + middlewares: [ + (event, next) => { + // this.__checkSeatVacancy(event, next); + }, + (event, next) => { + // this.__occupy(event, next); + }, + ], + }) + } + + + + } + } + + /************************************************************************************************************** + * CREATE METHODS (SETTERS & OBJECT CREATION) + **************************************************************************************************************/ + + /** + * #### Description + * Sets the name of the `PokerRoom`, allowing the name to be updated or customized. + * + * #### Implements + * `N/A` - This method is part of the `PokerRoomInterface` and does not implement any external methods. + * + * #### Overrides + * `N/A` - This method does not override any superclass or parent methods. + * + * #### Purpose + * The `setName` method is used to assign a specific name to a `PokerRoom`, which helps distinguish it within the system. + * This is essential for systems where rooms need to be identifiable and manageable through a unique name. + * + * #### Events + * `N/A` - No events are emitted by this method. + * + * #### Parameters + * - `name`: A string representing the new name for the room. It must be a valid, non-empty string to ensure + * the room has a clear, identifiable label. + * + * #### Requirements + * - The `name` parameter should be a non-empty string to provide meaningful identification. + * - Passing an empty or invalid value could result in future misidentification of rooms if validation is implemented. + * + * #### Returns + * - Returns the `name` that was set for the `PokerRoom`. + * + * #### Usage + * Use this method to set or update the name of a room in a system where unique or identifiable room names + * are necessary for reference. + * + * @param {string} name - The new name for the `PokerRoom`. + * @returns {string} - Returns the name of the room that was set. + * + * @example + * ```typescript + * const pokerRoom = new PokerRoom({ name: "Room1", tableSize: 6 }); + * pokerRoom.setName("HighRollers"); // Sets the name of the room to "HighRollers" + * console.log(pokerRoom.getName()); // Logs "HighRollers" + * ``` + */ + public setName(name: string): string { + return this._setName(name); + } + + /** + * #### Description + * Sets the queue of players waiting to enter the `PokerTable` within the `PokerRoom`. This queue helps + * manage player flow and assign seating as tables become available. + * + * #### Implements + * `N/A` - This method is part of the `PokerRoomInterface` and does not implement any external methods. + * + * #### Overrides + * `N/A` - This method does not override any superclass or parent methods. + * + * #### Purpose + * The `setQueue` method provides a structured way to set or update the player queue. This queue is essential + * for room management, helping to keep a record of players awaiting entry and manage seating arrangements. + * + * #### Events + * `N/A` - No events are emitted by this method. + * + * #### Parameters + * - `queue`: An array of `PokerPlayerInterface` objects, each representing a player awaiting entry into the room’s `PokerTable`. + * + * #### Requirements + * - `queue` should be an array of valid `PokerPlayerInterface` instances. + * - If empty, the queue indicates that no players are currently waiting for entry. + * + * #### Returns + * - Returns the `queue` array after updating it within the room. + * + * #### Usage + * Use this method to set or update the player queue in cases where player flow needs control, + * ensuring smooth transitions as players are seated at the table. + * + * @param {number} smallBlind - The new list of players waiting to enter the table. + * @returns {number} - Returns the updated player queue. + * + * @example + * ```typescript + * const pokerRoom = new PokerRoom({ name: "Room2", tableSize: 6 }); + * const queue = [new PokerPlayer("Alice"), new PokerPlayer("Bob")]; + * pokerRoom.setQueue(queue); // Sets the player queue + * console.log(pokerRoom.getQueue()); // Logs the updated player queue + * ``` + */ + public setSmallBlind(smallBlind: number): number { + return this._setSmallBlind(smallBlind); + } + + /************************************************************************************************************** + * READ METHODS (GETTERS & DATA RETRIEVAL) + **************************************************************************************************************/ + + /** + * `getId` + * @public + * Returns the poker table's `id`. + * @returns {string} The poker table's `id`. + * + * @example + * const rank = card.getRank(); + * console.log(rank); // "A" + */ + public getId(): string { + return this.__id; + } + + /** + * `getId` + * @public + * Returns the poker table's `id`. + * @returns {string} The poker table's `id`. + * + * @example + * const rank = card.getRank(); + * console.log(rank); // "A" + */ + public getSmallBlind(): number { + return this.__smallBlind; + } + + /** + * `getId` + * @public + * Returns the poker table's `id`. + * @returns {string} The poker table's `id`. + * + * @example + * const rank = card.getRank(); + * console.log(rank); // "A" + */ + public getBigBlind(): number { + return this.__bigBlindAmount; + } + + /** + * `getSeats` + * Starts a new PokerGame if there are at least two active players at the PokerTable. + * This method initiates the game flow, including assigning blinds and starting the rounds. + * @returns {number} + */ + public getSeats(): PokerSeatInterface[] { + return this.__seats; + } + + + /** + * `getSeats` + * Starts a new PokerGame if there are at least two active players at the PokerTable. + * This method initiates the game flow, including assigning blinds and starting the rounds. + * @returns {number} + */ + public isGameInProgress(): boolean { + return this.__gameInProgress; + } + /************************************************************************************************************** + * UPDATE METHODS (MODIFYING EXISTING OBJECTS) + **************************************************************************************************************/ + + /** + * update + */ + public updateBlinds(smallBlind: number) { + this._setSmallBlind(smallBlind); + this._setBigBlind(this.getSmallBlind() * 2); + return true; + } + + /************************************************************************************************************** + * DELETE METHODS (REMOVING OBJECTS) + **************************************************************************************************************/ + + /************************************************************************************************************** + * BUSINESS-LOGIC METHODS (LOGIC & CALCULATIONS) + **************************************************************************************************************/ + + /************************************************************************************************************** + * WRAPPER METHODS (UTILITY & CONVENIENCE) + **************************************************************************************************************/ + + /** + * `size` + * Starts a new PokerGame if there are at least two active players at the PokerTable. + * This method initiates the game flow, including assigning blinds and starting the rounds. + * @returns {number} + */ + public size(): number { + return this.seatCount(); + } + + /** + * #### Description + * Returns the total number of `PokerRoom` instances currently managed by the Casino. + * + * #### Implements + * Implements the `roomCount` method of `CasinoInterface`. + * + * #### Overrides + * `N/A` + * + * #### Purpose + * Provides a simple way to check how many poker rooms the Casino is currently managing. Useful for general + * information about the Casino's state and for validating indices or conditions that depend on room count. + * + * #### Events + * `N/A` + * + * #### Parameters + * `N/A` + * + * #### Requirements + * `N/A` + * + * #### Returns + * - Returns the number of rooms currently managed by the Casino. + * + * #### Usage + * This method is useful for any scenario where the total number of active rooms is needed, such as iterating + * over all rooms or validating index-based operations. + * + * @returns {number} - The current count of rooms in the Casino. + * + * @example + * ```typescript + * const casino = new Casino(); + * const count = casino.roomCount(); + * console.log(count); // Logs the total number of managed rooms, e.g., 5 + * ``` + */ + public seatCount(): number { + return this.getSeats().length; + } + + /** + * #### Description + * Checks if a provided index is within the valid range of the Casino’s room list. + * + * #### Implements + * Implements the `isValidIndex` method of `CasinoInterface`. + * + * #### Overrides + * `N/A` + * + * #### Purpose + * This method helps validate that an index is within the valid bounds of the Casino’s room list. It prevents + * out-of-bound errors and ensures that methods calling on rooms by index are provided with a valid reference. + * + * #### Events + * `N/A` + * + * #### Parameters + * - `index`: A zero-based integer representing the position of a room in the Casino's managed list of rooms. + * + * #### Requirements + * - The `index` should be a non-negative integer and within the bounds of the `__rooms` array. + * + * #### Returns + * - Returns `true` if the index is within bounds. + * - Throws an `Error` if the index is out of range. + * + * #### Usage + * Call this method before performing operations that require a valid room index to prevent out-of-bounds errors. + * Can be used in any index-based access patterns for room retrieval or modification. + * + * @param {number} index - The zero-based index to validate. + * @returns {boolean} - Returns `true` if the index is within bounds. + * + * @throws {Error} - Throws an error with a message indicating the invalid index. + * + * @example + * ```typescript + * const casino = new Casino(); + * try { + * casino.isValidIndex(2); // Returns true if there are at least 3 rooms + * } catch (error) { + * console.error(error.message); // If index 2 is out of bounds, logs error message + * } + * ``` + */ + public isValidIndex(index: number): boolean { + if (index >= 0 && index < this.seatCount()) { + throw new Error( + `Invalid index: ${index}. It must be between 0 and ${ + this.seatCount() - 1 + }.` + ); + } else { + return true; + } + } + + /************************************************************************************************************** + * INTERNAL METHODS (PROTECTED) + **************************************************************************************************************/ + + /************************************************************************************************************** + * INTERNAL METHODS (PROTECTED) + **************************************************************************************************************/ + + protected _setName(name: string): string { + this.__name = name; + return this.__name; + } + + protected _setSmallBlind(smallBlind: number): number { + if (smallBlind <= 0) { + throw new Error(`Small Blind should always be greator than 0.`); + } else { + return (this.__smallBlind = smallBlind); + } + } + + protected _setBigBlind(bigBlind: number): number { + return (this.__bigBlindAmount = bigBlind); + } + + /************************************************************************************************************** + * INTERNAL METHODS (PRIVATE) + **************************************************************************************************************/ + + /** + * `setId` + * @public + * Returns the poker table's `id`. + * @returns {string} The poker table's `id`. + * + * @example + * const rank = card.getRank(); + * console.log(rank); // "A" + */ + private __setId(id: string): string { + this.__id = id; + return this.__id; + } + + /** + * `setSeats` + * @public + * Returns the poker table's `id`. + * @returns {number} The poker table's `id`. + * + * @example + * const rank = card.getRank(); + * console.log(rank); // "A" + */ + private __setSeats(seats: PokerSeatInterface[]): boolean { + this.__seats = seats; + return true; + } + + + /** + * `getSeats` + * Starts a new PokerGame if there are at least two active players at the PokerTable. + * This method initiates the game flow, including assigning blinds and starting the rounds. + * @returns {number} + */ + private __setGameInProgress(bool:boolean): boolean { + this.__gameInProgress = bool ; + return this.__gameInProgress; + } + + private __occupySeat( + position: number, + player: PokerPlayerInterface + ): boolean { + for (let i = 0; i < this.getSeats().length; i++) { + let seat = this.getSeats()[i]; + let seatPosition = seat.getPosition(); + if (seatPosition === position) { + if (!seat.isOccupied()) { + seat.occupy(player); + console.log("Seat has been assigned"); + return true; + } + } + } + return false; + } + + /** + * #### Description + * Checks seat availability to determine if it can be occupied by a player. + * + * @param {BaseEventInterface} event - The event object containing event data. + * @param {() => void} next - The next middleware function to call if seat is available. + */ + private __checkIsGameInProgress( + event: BaseEventInterface, + next: () => void + ): void|false { + if (this.isGameInProgress()) { + logger.log( + LogLevel.WARN, + "Failed to occupy seat: seat is already occupied.", + { + seatId: this.getId(), + } + ); + return false; + } + + event.lastModifiedAt = new Date(); + next(); + } +} + +export { PokerTable }; diff --git a/src/utils/generateUniqueId/index.ts b/src/utils/generateUniqueId/index.ts new file mode 100644 index 0000000..efc1ef3 --- /dev/null +++ b/src/utils/generateUniqueId/index.ts @@ -0,0 +1,9 @@ +//@collapse + +import crypto from "crypto"; + +function generateUniqueId(): string { + return crypto.randomBytes(16).toString("hex"); +} + +export { generateUniqueId }; diff --git a/src/utils/index.ts b/src/utils/index.ts new file mode 100644 index 0000000..4637e5c --- /dev/null +++ b/src/utils/index.ts @@ -0,0 +1,13 @@ +//@collapse + +/** + * @module `Utils` + * Centralized export for all poker-related models. + * This module gathers and exports models like `Card` and `Deck`. + * + * @example + * // Import models from the centralized module + * import { Card, Deck } from './models'; + */ +export { generateUniqueId } from "./generateUniqueId"; +export { logger } from "./logger"; diff --git a/src/utils/logger/index.ts b/src/utils/logger/index.ts new file mode 100644 index 0000000..acfe963 --- /dev/null +++ b/src/utils/logger/index.ts @@ -0,0 +1,92 @@ +// @collapse + +// Import Interfaces +import { LoggerConfig } from "../../interfaces"; + +// Import Models +import { Logger } from "../../models"; + +/** + * @function `singletonLogger` + * + * Provides a singleton instance of the `Logger` class with the specified configuration. If an instance already exists, + * it returns the existing one; otherwise, it creates a new instance. + * + * #### Purpose + * The `singletonLogger` function ensures that there is only one `Logger` instance across the application, enforcing centralized + * logging configuration and access. + * + * #### Parameters + * - `config?: LoggerConfig` - An optional configuration object for the logger. If provided, it sets properties such as the log + * directory path and console logging behavior. + * + * #### Returns + * - `Logger` - Returns the singleton instance of the `Logger` class. + * + * #### Usage + * This function can be used to initialize or access the single instance of the `Logger` class in any part of the application, + * enabling consistent logging. + * + * @param {LoggerConfig} [config] - Optional configuration for initializing the logger instance. + * @returns {Logger} - The singleton instance of `Logger`. + * + * @example + * ```typescript + * import { singletonLogger } from "./path/to/utils/logger"; + * + * const logger = singletonLogger({ logsDirPath: "./logs", consoleLoggingEnabled: true }); + * ``` + */ +function singletonLogger(config?: LoggerConfig): Logger { + return Logger.getInstance(config); +} + +/** + * @constant {LoggerConfig} config + * + * The default configuration for the `Logger` instance. This configuration object includes settings for log directory path + * and console logging, which can be customized based on the environment. + * + * #### Purpose + * Defines initial configuration settings for the logger, such as the log directory path (`logsDirPath`) and whether to enable + * console logging (`consoleLoggingEnabled`). This configuration can be modified or expanded based on application requirements. + * + * #### Requirements + * - `logsDirPath` should specify a valid directory path for log storage. + * - `consoleLoggingEnabled` should be a boolean indicating whether console logging is enabled. + * + * @example + * ```typescript + * const config = { + * logsDirPath: process.env.LOG_DIR_PATH || "./.logs", + * consoleLoggingEnabled: process.env.ENABLE_CONSOLE_LOGGING !== "false", + * }; + * ``` + */ +const config: LoggerConfig = { + enableConsoleLogging: process.env.ENABLE_CONSOLE_LOGGING !== "false", +}; + +/** + * `logger` + * + * A singleton instance of the `Logger` class. This instance is initialized once with the configuration provided by the `config` + * constant. The instance provides centralized logging across the application. + * + * #### Purpose + * The `logger` singleton offers consistent access to logging functionality, ensuring that all logs follow the specified + * configuration settings, such as the directory for log files and whether to enable console logging. + * + * #### Usage + * Import the `logger` singleton directly wherever logging is required in the application. + * + * @example + * ```typescript + * import { logger } from "./path/to/utils/logger"; + * + * logger.log(LogLevel.INFO, "Application started"); + * ``` + */ +const logger = singletonLogger(config); + +export { logger }; diff --git a/tests/enums/casinoEventName/index.test.ts b/tests/enums/casinoEventName/index.test.ts new file mode 100644 index 0000000..d708a47 --- /dev/null +++ b/tests/enums/casinoEventName/index.test.ts @@ -0,0 +1,83 @@ +//@collapse + +import { CasinoEventName } from "../../../src/enums/casinoEventName"; + +/** + * @file `casinoEventName/index.test.ts` + * @description This file contains unit tests for the `CasinoEventName` enum using Jest. These tests ensure that each event name in the `CasinoEventName` enum is defined correctly and aligns with expected event names for mutable operations within the Casino class. + * + * @jest-environment node + */ + +describe("CasinoEventName Enum", () => { + /** + * @test `should define all event names correctly` + * @description This test checks that all expected event names in the `CasinoEventName` enum exist with the correct string values. The test validates each event’s string value. + * + * @example + * // Verifies that CasinoEventName.ROOM_CREATED is defined as "Casino:PokerRoomCreated" + * expect(CasinoEventName.ROOM_CREATED).toBe("Casino:PokerRoomCreated"); + */ + it("should define all event names correctly", () => { + expect(CasinoEventName.ROOM_CREATED).toBe("Casino:PokerRoomCreated"); + expect(CasinoEventName.ROOM_ADDED).toBe("Casino:PokerRoomAdded"); + expect(CasinoEventName.ROOM_UPDATED).toBe("Casino:PokerRoomUpdated"); + expect(CasinoEventName.ROOM_DELETED).toBe("Casino:PokerRoomDeleted"); + expect(CasinoEventName.ROOMS_SET).toBe("Casino:PokerRoomsSet"); + }); + + /** + * @test `should contain exactly 5 events` + * @description This test ensures that the `CasinoEventName` enum includes exactly 5 events, covering all mutable operations related to casino room management. + * + * @example + * // Confirms the number of keys in the CasinoEventName enum + * expect(Object.keys(CasinoEventName).length).toBe(5); + */ + it("should contain exactly 5 events", () => { + const eventCount = Object.keys(CasinoEventName).length; + expect(eventCount).toBe(5); + }); + + /** + * @test `should not contain any unexpected event names` + * @description This test checks that the `CasinoEventName` enum does not contain any additional, undefined event names outside of the required 5 events for room management. + * + * @example + * // Verifies that CasinoEventName only includes the expected values + * const expectedEvents = ["Casino:PokerRoomCreated", "Casino:PokerRoomAdded", "Casino:PokerRoomUpdated", "Casino:PokerRoomDeleted", "Casino:PokerRoomsSet"]; + * expect(Object.values(CasinoEventName)).toEqual(expectedEvents); + */ + it("should not contain any unexpected event names", () => { + const expectedEvents = [ + "Casino:PokerRoomCreated", + "Casino:PokerRoomAdded", + "Casino:PokerRoomUpdated", + "Casino:PokerRoomDeleted", + "Casino:PokerRoomsSet", + ]; + expect(Object.values(CasinoEventName)).toEqual(expectedEvents); + }); + + /** + * @test `should allow usage of event names in conditional checks` + * @description This test demonstrates the ability to use event names from `CasinoEventName` in conditional logic, ensuring that each event can be utilized programmatically in event-driven code. + * + * @example + * // Example conditional check using CasinoEventName enum + * const event = CasinoEventName.ROOM_CREATED; + * if (event === CasinoEventName.ROOM_CREATED) { + * console.log("Room creation event triggered"); + * } + * expect(event).toBe(CasinoEventName.ROOM_CREATED); + */ + it("should allow usage of event names in conditional checks", () => { + const event = CasinoEventName.ROOM_CREATED; + + if (event === CasinoEventName.ROOM_CREATED) { + expect(event).toBe("Casino:PokerRoomCreated"); + } else { + throw new Error("Incorrect event name used"); + } + }); +}); diff --git a/tests/enums/index.test.ts b/tests/enums/index.test.ts new file mode 100644 index 0000000..5857a58 --- /dev/null +++ b/tests/enums/index.test.ts @@ -0,0 +1,95 @@ +//@collapse + +/** + * @file `index.test.ts` + * This file contains unit tests for the centralized export of all enums related to poker and casino operations. + * It verifies that each enum is correctly exported and accessible, and that the values within the enums + * are as expected. + * + * Enums being tested: + * - `PokerPhaseName`: Represents different phases of a poker game (e.g., pre-flop, flop, turn, river). + * - `Rank`: Represents the ranks of playing cards (e.g., Ace, King, Queen). + * - `Suit`: Represents the suits of playing cards (e.g., Hearts, Spades). + * - `CasinoEventName`: Represents event names triggered by state changes in the casino. + * + * @example + * // This test file ensures that you can import all enums like this: + * import { Rank, Suit, PokerPhaseName, CasinoEventName } from './src/enums'; + * + * @see `./src/enums/index.ts` + */ + +import * as Enums from "../../src/enums"; + +/** + * @testgroup Centralized Enum Exports + * The following tests verify the correct export of enums from the centralized `index.ts` file in the enums directory. + */ + +describe("Enum Centralized Exports", () => { + /** + * @test `PokerPhaseName` export verification + * This test ensures that the `PokerPhaseName` enum is correctly exported from the centralized enums module. + * + * @example + * // The enum should have phases like "PreFlop", "Flop", "Turn", "River", "Showdown" + */ + it("should export PokerPhaseName enum with correct values", () => { + const { PokerPhaseName } = Enums; + + expect(PokerPhaseName.PRE_FLOP).toBe("Pre-Flop"); + expect(PokerPhaseName.FLOP).toBe("Flop"); + expect(PokerPhaseName.TURN).toBe("Turn"); + expect(PokerPhaseName.RIVER).toBe("River"); + expect(PokerPhaseName.SHOWDOWN).toBe("ShowDown"); + }); + + /** + * @test `Rank` export verification + * This test ensures that the `Rank` enum is correctly exported from the centralized enums module. + * + * @example + * // The enum should have ranks like "Ace", "King", "Queen", "Jack" + */ + it("should export Rank enum with correct values", () => { + const { Rank } = Enums; + + expect(Rank.Ace).toBe("A"); + expect(Rank.King).toBe("K"); + expect(Rank.Queen).toBe("Q"); + expect(Rank.Jack).toBe("J"); + }); + + /** + * @test `Suit` export verification + * This test ensures that the `Suit` enum is correctly exported from the centralized enums module. + * + * @example + * // The enum should have suits like "Hearts", "Spades", "Clubs", "Diamonds" + */ + it("should export Suit enum with correct values", () => { + const { Suit } = Enums; + + expect(Suit.Hearts).toBe("Hearts"); + expect(Suit.Spades).toBe("Spades"); + expect(Suit.Clubs).toBe("Clubs"); + expect(Suit.Diamonds).toBe("Diamonds"); + }); + + /** + * @test `CasinoEventName` export verification + * This test ensures that the `CasinoEventName` enum is correctly exported from the centralized enums module. + * + * @example + * // The enum should have events like "Casino:PokerRoomCreated", "Casino:PokerRoomAdded", etc. + */ + it("should export CasinoEventName enum with correct values", () => { + const { CasinoEventName } = Enums; + + expect(CasinoEventName.ROOM_CREATED).toBe("Casino:PokerRoomCreated"); + expect(CasinoEventName.ROOM_ADDED).toBe("Casino:PokerRoomAdded"); + expect(CasinoEventName.ROOM_UPDATED).toBe("Casino:PokerRoomUpdated"); + expect(CasinoEventName.ROOM_DELETED).toBe("Casino:PokerRoomDeleted"); + expect(CasinoEventName.ROOMS_SET).toBe("Casino:PokerRoomsSet"); + }); +}); diff --git a/tests/enums/pokerPhaseName/index.test.ts b/tests/enums/pokerPhaseName/index.test.ts new file mode 100644 index 0000000..704e7b2 --- /dev/null +++ b/tests/enums/pokerPhaseName/index.test.ts @@ -0,0 +1,80 @@ +//@collapse + +import { PokerPhaseName } from "../../../src/enums/pokerPhaseName"; + +/** + * @file `pokerPhaseName/index.test.ts` + * @description This file contains unit tests for the `PokerPhaseName` enum using Jest. It verifies that the enum values for different poker phases are correctly defined. + * + * @jest-environment node + */ + +describe("PokerPhaseName Enum", () => { + /** + * @test `should define all phases correctly` + * @description This test checks whether all expected poker phases exist in the `PokerPhaseName` enum with the correct string values. + * + * @example + * // Verifies that PokerPhaseName enum values are correct + * expect(PokerPhaseName.PRE_FLOP).toBe("Pre-Flop"); + */ + it("should define all phases correctly", () => { + // Expected phases in the poker game + expect(PokerPhaseName.PRE_FLOP).toBe("Pre-Flop"); + expect(PokerPhaseName.FLOP).toBe("Flop"); + expect(PokerPhaseName.TURN).toBe("Turn"); + expect(PokerPhaseName.RIVER).toBe("River"); + expect(PokerPhaseName.SHOWDOWN).toBe("ShowDown"); + }); + + /** + * @test `should have exact number of phases` + * @description This test ensures that the `PokerPhaseName` enum only contains the expected 5 phases. + * + * @example + * // Verifies the number of keys in the PokerPhaseName enum + * expect(Object.keys(PokerPhaseName).length).toBe(5); + */ + it("should have exactly 5 phases", () => { + // Verify that the enum contains exactly 5 phases + const phaseCount = Object.keys(PokerPhaseName).length; + expect(phaseCount).toBe(5); + }); + + /** + * @test `should not contain any unexpected phases` + * @description This test ensures that the `PokerPhaseName` enum does not include any values outside of the predefined poker phases. + * + * @example + * // Check that PokerPhaseName does not include any invalid phases + * expect(PokerPhaseName).not.toContain("InvalidPhase"); + */ + it("should not contain any unexpected phases", () => { + // Get the values of the enum and check that no invalid phase is present + const validPhases = ["Pre-Flop", "Flop", "Turn", "River", "ShowDown"]; + expect(Object.values(PokerPhaseName)).toEqual(validPhases); + }); + + /** + * @test `should allow usage of poker phases in conditional checks` + * @description This test demonstrates how the `PokerPhaseName` enum can be used in conditional logic, ensuring that phases can be matched correctly in code logic. + * + * @example + * // Conditional check using PokerPhaseName enum + * const currentPhase = PokerPhaseName.FLOP; + * if (currentPhase === PokerPhaseName.FLOP) { + * console.log("It's the Flop phase"); + * } + * expect(currentPhase).toBe(PokerPhaseName.FLOP); + */ + it("should allow usage of poker phases in conditional checks", () => { + // Example of using the enum in a conditional check + const currentPhase = PokerPhaseName.FLOP; + + if (currentPhase === PokerPhaseName.FLOP) { + expect(currentPhase).toBe(PokerPhaseName.FLOP); + } else { + throw new Error("Current phase is incorrect"); + } + }); +}); diff --git a/tests/enums/rank/index.test.ts b/tests/enums/rank/index.test.ts new file mode 100644 index 0000000..4ea2076 --- /dev/null +++ b/tests/enums/rank/index.test.ts @@ -0,0 +1,104 @@ +//@collapse + +import { Rank } from "../../../src/enums/rank"; + +/** + * @file `index.test.ts` + * This file contains the unit tests for the `Rank` enum used in a poker game. + * The tests ensure that the `Rank` enum has the correct values for each rank in a standard poker deck. + * + * This tutorial will guide you through writing and understanding Jest tests for the `Rank` enum. + * + * @example + * // To run the tests: + * // Use the following command in your terminal: + * // $ npm run test + * + * // Jest will execute this file and display results. + */ + +describe("Rank Enum", () => { + /** + * @test `should contain all expected rank values` + * This test ensures that the `Rank` enum contains all the correct values for a deck of cards, + * from 2 through Ace, including the face cards Jack, Queen, and King. + * + * @example + * expect(Rank.Ace).toBe("A"); + */ + it("should contain all expected rank values", () => { + // Verify that each rank exists in the enum and has the correct string representation. + expect(Rank.Two).toBe("2"); + expect(Rank.Three).toBe("3"); + expect(Rank.Four).toBe("4"); + expect(Rank.Five).toBe("5"); + expect(Rank.Six).toBe("6"); + expect(Rank.Seven).toBe("7"); + expect(Rank.Eight).toBe("8"); + expect(Rank.Nine).toBe("9"); + expect(Rank.Ten).toBe("10"); + expect(Rank.Jack).toBe("J"); + expect(Rank.Queen).toBe("Q"); + expect(Rank.King).toBe("K"); + expect(Rank.Ace).toBe("A"); + }); + + /** + * @test `should be used in game logic to represent card ranks` + * This test demonstrates how the `Rank` enum can be used to represent the ranks of playing cards + * in poker-related logic. The test simulates creating an array of ranks and verifies their values. + * + * @example + * const handRanks = [Rank.Ace, Rank.King]; + * expect(handRanks[0]).toBe("A"); + * expect(handRanks[1]).toBe("K"); + */ + it("should be used in game logic to represent card ranks", () => { + // Example usage of the `Rank` enum in poker game logic + const handRanks = [Rank.Ace, Rank.King, Rank.Queen]; + + // Ensure that each value in the hand corresponds to the correct rank. + expect(handRanks[0]).toBe("A"); + expect(handRanks[1]).toBe("K"); + expect(handRanks[2]).toBe("Q"); + }); + + /** + * @test `should have correct rank value types` + * This test checks that each value in the `Rank` enum is a string. + * In TypeScript, enums can sometimes have different types, so it's important to ensure consistency. + * + * @example + * expect(typeof Rank.Ace).toBe("string"); + */ + it("should have correct rank value types", () => { + // Loop through each enum value to check its type + const ranks = Object.values(Rank); + + ranks.forEach((rank) => { + expect(typeof rank).toBe("string"); + }); + }); + + /** + * @test `should throw an error for invalid rank` + * While the enum itself only contains valid ranks, this test demonstrates the importance of handling + * invalid values gracefully in other parts of the application. + * Here, we simulate a potential mistake where an invalid rank could be passed into the logic. + * + * @example + * function useRank(rank: Rank) { if (!Object.values(Rank).includes(rank)) throw new Error(); } + */ + it("should throw an error for invalid rank (example)", () => { + // A function to simulate usage of rank in a game + const useRank = (rank: string) => { + if (!Object.values(Rank).includes(rank as Rank)) { + throw new Error("Invalid rank"); + } + }; + + // Correct usage + expect(() => useRank(Rank.Ace)).not.toThrow(); + expect(() => useRank("InvalidRank")).toThrow("Invalid rank"); + }); +}); diff --git a/tests/enums/suit/index.test.ts b/tests/enums/suit/index.test.ts new file mode 100644 index 0000000..26a8721 --- /dev/null +++ b/tests/enums/suit/index.test.ts @@ -0,0 +1,61 @@ +//@collapse + +import { Suit } from "../../../src/enums/suit"; + +/** + * @file `index.test.ts` + * This file contains unit tests for the `Suit` enum. + * The `Suit` enum represents the four suits of a standard deck of playing cards: + * Hearts, Diamonds, Clubs, and Spades. + * + * In this file, we will: + * 1. Test that the `Suit` enum contains the correct keys and values. + * 2. Verify that the enum can be used in real-world scenarios like assignments and functions. + * 3. Ensure that invalid values do not exist within the enum. + */ + +describe("Suit Enum", () => { + /** + * Test: Check that the `Suit` enum contains the correct values for each suit. + * This test ensures that all the expected suits (Hearts, Diamonds, Clubs, Spades) + * are present and correctly mapped to their string values. + */ + it("should have correct values for each suit", () => { + // Verify that the enum contains all the expected suits. + expect(Suit.Hearts).toBe("Hearts"); + expect(Suit.Diamonds).toBe("Diamonds"); + expect(Suit.Clubs).toBe("Clubs"); + expect(Suit.Spades).toBe("Spades"); + }); + + /** + * Test: Use the `Suit` enum in a real-world scenario. + * This test simulates a typical use case where the `Suit` enum is assigned to a variable + * and then used within an application (such as selecting a card suit). + */ + it("should allow using the Suit enum in real-world scenarios", () => { + // Assign the suit "Clubs" from the enum to a variable. + const mySuit = Suit.Clubs; + + // Check that the variable contains the correct enum value. + expect(mySuit).toBe("Clubs"); + + // Example use case: passing the suit to a function and verifying behavior. + function describeSuit(suit: Suit): string { + return `You selected the ${suit} suit.`; + } + + // Call the function with `Suit.Spades` and check the output. + expect(describeSuit(Suit.Spades)).toBe("You selected the Spades suit."); + }); + + /** + * Test: Ensure the enum only includes valid suits. + * This test checks that invalid or undefined suits are not part of the `Suit` enum. + */ + it("should not allow invalid or undefined suits", () => { + // Ensure that the `Suit` enum does not include invalid values. + expect(Suit["InvalidSuit"]).toBeUndefined(); + expect(Suit["Unknown"]).toBeUndefined(); + }); +}); diff --git a/tests/index.test.ts b/tests/index.test.ts new file mode 100644 index 0000000..d634bc9 --- /dev/null +++ b/tests/index.test.ts @@ -0,0 +1 @@ +//@collapse diff --git a/tests/interfaces/card/index.test.ts b/tests/interfaces/card/index.test.ts new file mode 100644 index 0000000..ee26244 --- /dev/null +++ b/tests/interfaces/card/index.test.ts @@ -0,0 +1,149 @@ +//@collapse + +/** + * @file `indext.test.ts` + * This test file verifies the implementation of the `CardInterface`. + * It uses mock implementations to ensure that the contract defined by the interface is followed. + * Jest is used to create unit tests for validating the behavior of the `CardInterface`. + * + * @example + * To run this test: + * $ npx jest ./tests/interfaces/card/index.test.ts + */ + +import { Rank, Suit } from "../../../src/enums"; +import { CardInterface } from "../../../src/interfaces/card"; + +/** + * @class `MockCard` + * A mock implementation of the `CardInterface` used for testing purposes. + * This mock class simulates the behavior of a real card in a poker game. + * + * @implements {CardInterface} + */ +class MockCard implements CardInterface { + private rank: Rank; + private suit: Suit; + + /** + * @constructor + * Initializes a mock card with the given rank and suit. + * + * @param {Rank} rank - The rank of the card (e.g., Ace, King). + * @param {Suit} suit - The suit of the card (e.g., Hearts, Spades). + * + * @example + * const mockCard = new MockCard(Rank.Ace, Suit.Spades); + */ + constructor(rank: Rank, suit: Suit) { + this.rank = rank; + this.suit = suit; + } + + /** + * @method `getRank` + * Returns the rank of the card. + * + * @returns {Rank} - The rank of the card. + * + * @example + * const rank = mockCard.getRank(); + * console.log(rank); // "A" + */ + getRank(): Rank { + return this.rank; + } + + /** + * @method `getSuit` + * Returns the suit of the card. + * + * @returns {Suit} - The suit of the card. + * + * @example + * const suit = mockCard.getSuit(); + * console.log(suit); // "Spades" + */ + getSuit(): Suit { + return this.suit; + } + + /** + * @method `toString` + * Returns a string representation of the card. + * + * @returns {string} - A string in the format of "Rank of Suit". + * + * @example + * const cardStr = mockCard.toString(); + * console.log(cardStr); // "A of Spades" + */ + toString(): string { + return `${this.rank} of ${this.suit}`; + } + + /** + * @method `toObj` + * Returns an object representation of the card. + * + * @returns {object} - An object with the `rank` and `suit` properties. + * + * @example + * const cardObj = mockCard.toObj(); + * console.log(cardObj); // { rank: "A", suit: "Spades" } + */ + toObj(): { rank: Rank; suit: Suit } { + return { rank: this.rank, suit: this.suit }; + } +} + +describe("CardInterface", () => { + let mockCard: MockCard; + + /** + * @beforeEach + * This block runs before each test. It creates a new instance of `MockCard` to be used in the tests. + * + * @example + * Before each test, a new mock card is created: + * const mockCard = new MockCard(Rank.Ace, Suit.Spades); + */ + beforeEach(() => { + mockCard = new MockCard(Rank.Ace, Suit.Spades); + }); + + /** + * @test + * Verifies that the card has the correct rank and suit when initialized. + * + * @example + * expect(mockCard.getRank()).toBe(Rank.Ace); + * expect(mockCard.getSuit()).toBe(Suit.Spades); + */ + it("should create a card with the correct rank and suit", () => { + expect(mockCard.getRank()).toBe(Rank.Ace); + expect(mockCard.getSuit()).toBe(Suit.Spades); + }); + + /** + * @test + * Verifies that the `toString` method returns the correct string representation of the card. + * + * @example + * expect(mockCard.toString()).toBe("A of Spades"); + */ + it("should return the correct string representation", () => { + expect(mockCard.toString()).toBe("A of Spades"); + }); + + /** + * @test + * Verifies that the `toObj` method returns the correct object representation of the card. + * + * @example + * expect(mockCard.toObj()).toEqual({ rank: Rank.Ace, suit: Suit.Spades }); + */ + it("should return the correct object representation", () => { + expect(mockCard.toObj()).toEqual({ rank: Rank.Ace, suit: Suit.Spades }); + }); +}); diff --git a/tests/interfaces/casino/index.test.ts b/tests/interfaces/casino/index.test.ts new file mode 100644 index 0000000..e299252 --- /dev/null +++ b/tests/interfaces/casino/index.test.ts @@ -0,0 +1,214 @@ +//@collapse + +import { EventEmitter } from "events"; +import { + CasinoInterface, + PokerRoomConfig, + PokerRoomInterface, +} from "../../../src/interfaces"; + +/** + * @file `index.test.ts` + * @description This file contains a suite of tests for `CasinoInterface`, validating core functionality, such as adding, retrieving, and managing poker rooms. Each test verifies adherence to the requirements of the `CasinoInterface`, ensuring correct behavior when managing poker rooms within a Casino entity. + * + * @jest-environment node + */ + +// Mock classes to simulate `PokerRoomInterface` and `CasinoInterface` for testing purposes +class MockPokerRoom implements PokerRoomInterface { + constructor(public name: string) {} +} + +class MockCasino extends EventEmitter implements CasinoInterface { + private rooms: PokerRoomInterface[] = []; + + // Method to set a new list of rooms for the casino + setRooms(rooms: PokerRoomInterface[]): PokerRoomInterface[] { + this.rooms = rooms; + return this.rooms; + } + + // Method to create a new room based on configuration and emit an event upon creation + createRoom(config: PokerRoomConfig): PokerRoomInterface { + const newRoom = new MockPokerRoom(config.name || "Unnamed Room"); + this.rooms.push(newRoom); + this.emit("casino:roomCreated", newRoom); + return newRoom; + } + + // Retrieve a room based on its position in the rooms array + getRoom(index: number): PokerRoomInterface | undefined { + return this.rooms[index]; + } + + // Retrieve the complete list of rooms in the casino + getRooms(): PokerRoomInterface[] { + return this.rooms; + } + + // Add a single room to the casino + addRoom(room: PokerRoomInterface): PokerRoomInterface[] { + this.rooms.push(room); + return this.rooms; + } + + // Add multiple rooms to the casino + addRooms(rooms: PokerRoomInterface[]): PokerRoomInterface[] { + this.rooms.push(...rooms); + return this.rooms; + } + + // Remove a room by its index in the array + deleteRoom(index: number): PokerRoomInterface[] { + this.rooms.splice(index, 1); + return this.rooms; + } + + // Return the total number of rooms currently in the casino + roomCount(): number { + return this.rooms.length; + } + + // Validate that an index is within bounds for the rooms array + isValidIndex(index: number): boolean { + if (index < 0 || index >= this.roomCount()) { + throw new Error(`Invalid index: ${index}`); + } + return true; + } +} + +describe("CasinoInterface Implementation", () => { + let casino: CasinoInterface; + + beforeEach(() => { + casino = new MockCasino(); + }); + + /** + * @testgroup Room Creation and Retrieval + * Verifies room creation and retrieval functionality. + */ + describe("Room Creation and Retrieval", () => { + /** + * @test `should create a room and retrieve it by index` + * @description Verifies that a room can be created using the configuration, and the created room is retrievable by its index. + */ + it("should create a room and retrieve it by index", () => { + const roomConfig: PokerRoomConfig = { + name: "Test Room", + tableConfig: {} as any, + }; + const room = casino.createRoom(roomConfig); + expect(casino.getRoom(0)).toBe(room); + expect(room.name).toBe("Test Room"); + }); + + /** + * @test `should set and retrieve the list of rooms` + * @description Confirms that a list of rooms can be set and retrieved accurately from the casino. + */ + it("should set and retrieve the list of rooms", () => { + const rooms: PokerRoomInterface[] = [ + new MockPokerRoom("Room 1"), + new MockPokerRoom("Room 2"), + ]; + casino.setRooms(rooms); + expect(casino.getRooms()).toEqual(rooms); + }); + }); + + /** + * @testgroup Adding and Removing Rooms + * Tests the functionality of adding and removing rooms from the casino. + */ + describe("Adding and Removing Rooms", () => { + /** + * @test `should add a single room to the casino` + * @description Ensures that a single room can be added to the casino, and it appears in the room list. + */ + it("should add a single room to the casino", () => { + const room = new MockPokerRoom("New Room"); + casino.addRoom(room); + expect(casino.getRooms()).toContain(room); + }); + + /** + * @test `should add multiple rooms to the casino` + * @description Verifies that multiple rooms can be added at once, and the room list reflects these additions. + */ + it("should add multiple rooms to the casino", () => { + const rooms = [new MockPokerRoom("Room 1"), new MockPokerRoom("Room 2")]; + casino.addRooms(rooms); + expect(casino.getRooms()).toEqual(rooms); + }); + + /** + * @test `should delete a room by index` + * @description Checks that a room can be deleted by specifying its index and confirms the room list updates accordingly. + */ + it("should delete a room by index", () => { + const rooms = [new MockPokerRoom("Room 1"), new MockPokerRoom("Room 2")]; + casino.setRooms(rooms); + casino.deleteRoom(0); + expect(casino.getRooms()).toHaveLength(1); + expect(casino.getRoom(0)?.name).toBe("Room 2"); + }); + }); + + /** + * @testgroup Room Count and Index Validation + * Verifies the functionality related to counting rooms and validating room indexes. + */ + describe("Room Count and Index Validation", () => { + /** + * @test `should return the correct number of rooms` + * @description Checks that the total number of rooms in the casino is accurately returned by `roomCount()`. + */ + it("should return the correct number of rooms", () => { + const rooms = [ + new MockPokerRoom("Room 1"), + new MockPokerRoom("Room 2"), + new MockPokerRoom("Room 3"), + ]; + casino.setRooms(rooms); + expect(casino.roomCount()).toBe(3); + }); + + /** + * @test `should validate a valid index` + * @description Ensures that a valid index is accepted and returns `true`. + */ + it("should validate a valid index", () => { + casino.setRooms([new MockPokerRoom("Room 1")]); + expect(casino.isValidIndex(0)).toBe(true); + }); + + /** + * @test `should throw an error for an invalid index` + * @description Verifies that an invalid index throws an error, confirming correct validation behavior. + */ + it("should throw an error for an invalid index", () => { + casino.setRooms([new MockPokerRoom("Room 1")]); + expect(() => casino.isValidIndex(2)).toThrow("Invalid index: 2"); + }); + }); + + /** + * @testgroup Event Emission + * Tests the event emission functionality for room-related actions. + */ + describe("Event Emission", () => { + /** + * @test `should emit an event when a room is created` + * @description Confirms that the `casino:roomCreated` event is emitted with the newly created room as a parameter. + */ + it("should emit an event when a room is created", (done) => { + casino.on("casino:roomCreated", (room) => { + expect(room.name).toBe("Event Room"); + done(); + }); + casino.createRoom({ name: "Event Room", tableConfig: {} as any }); + }); + }); +}); diff --git a/tests/interfaces/deck/index.test.ts b/tests/interfaces/deck/index.test.ts new file mode 100644 index 0000000..d634bc9 --- /dev/null +++ b/tests/interfaces/deck/index.test.ts @@ -0,0 +1 @@ +//@collapse diff --git a/tests/interfaces/index.test.ts b/tests/interfaces/index.test.ts new file mode 100644 index 0000000..d634bc9 --- /dev/null +++ b/tests/interfaces/index.test.ts @@ -0,0 +1 @@ +//@collapse diff --git a/tests/interfaces/pokerGame/index.test.ts b/tests/interfaces/pokerGame/index.test.ts new file mode 100644 index 0000000..d634bc9 --- /dev/null +++ b/tests/interfaces/pokerGame/index.test.ts @@ -0,0 +1 @@ +//@collapse diff --git a/tests/interfaces/pokerPhase/index.test.ts b/tests/interfaces/pokerPhase/index.test.ts new file mode 100644 index 0000000..d634bc9 --- /dev/null +++ b/tests/interfaces/pokerPhase/index.test.ts @@ -0,0 +1 @@ +//@collapse diff --git a/tests/interfaces/pokerPlayer/index.test.ts b/tests/interfaces/pokerPlayer/index.test.ts new file mode 100644 index 0000000..d634bc9 --- /dev/null +++ b/tests/interfaces/pokerPlayer/index.test.ts @@ -0,0 +1 @@ +//@collapse diff --git a/tests/interfaces/pokerRoom/index.test.ts b/tests/interfaces/pokerRoom/index.test.ts new file mode 100644 index 0000000..d634bc9 --- /dev/null +++ b/tests/interfaces/pokerRoom/index.test.ts @@ -0,0 +1 @@ +//@collapse diff --git a/tests/interfaces/pokerSeat/index.test.ts b/tests/interfaces/pokerSeat/index.test.ts new file mode 100644 index 0000000..d634bc9 --- /dev/null +++ b/tests/interfaces/pokerSeat/index.test.ts @@ -0,0 +1 @@ +//@collapse diff --git a/tests/interfaces/pokerTable/index.test.ts b/tests/interfaces/pokerTable/index.test.ts new file mode 100644 index 0000000..d634bc9 --- /dev/null +++ b/tests/interfaces/pokerTable/index.test.ts @@ -0,0 +1 @@ +//@collapse diff --git a/tests/mocks/casino/index.ts b/tests/mocks/casino/index.ts new file mode 100644 index 0000000..975ecb2 --- /dev/null +++ b/tests/mocks/casino/index.ts @@ -0,0 +1,67 @@ +//@collapse + +import { EventEmitter } from "events"; +import { + CasinoInterface, + PokerRoomInterface, + PokerRoomConfig, +} from "../../../src/interfaces"; +import { MockPokerRoom } from "../pokerRoom"; + +/** + * @class `MockCasino` + * A mock implementation of `CasinoInterface` used in testing, implementing all required methods for compliance. + * + * @implements {CasinoInterface} + */ +class MockCasino extends EventEmitter implements CasinoInterface { + private rooms: PokerRoomInterface[] = []; + + setRooms(rooms: PokerRoomInterface[]): PokerRoomInterface[] { + this.rooms = rooms; + return this.rooms; + } + + createRoom(config: PokerRoomConfig): PokerRoomInterface { + const newRoom = new MockPokerRoom(config); + this.rooms.push(newRoom); + this.emit("casino:roomCreated", newRoom); + return newRoom; + } + + getRoom(index: number): PokerRoomInterface | undefined { + return this.rooms[index]; + } + + getRooms(): PokerRoomInterface[] { + return this.rooms; + } + + addRoom(room: PokerRoomInterface): PokerRoomInterface[] { + this.rooms.push(room); + return this.rooms; + } + + addRooms(rooms: PokerRoomInterface[]): PokerRoomInterface[] { + this.rooms.push(...rooms); + return this.rooms; + } + + deleteRoom(index: number): PokerRoomInterface[] { + this.rooms.splice(index, 1); + return this.rooms; + } + + roomCount(): number { + return this.rooms.length; + } + + isValidIndex(index: number): boolean { + if (index < 0 || index >= this.roomCount()) { + throw new Error(`Invalid index: ${index}`); + } + return true; + } +} + +export { MockCasino }; diff --git a/tests/mocks/index.ts b/tests/mocks/index.ts new file mode 100644 index 0000000..d634bc9 --- /dev/null +++ b/tests/mocks/index.ts @@ -0,0 +1 @@ +//@collapse diff --git a/tests/mocks/pokerRoom/index.ts b/tests/mocks/pokerRoom/index.ts new file mode 100644 index 0000000..56c56bb --- /dev/null +++ b/tests/mocks/pokerRoom/index.ts @@ -0,0 +1,55 @@ +//@collapse + +import { EventEmitter } from "events"; +import { + PokerPlayerConfig, + PokerPlayerInterface, + PokerRoomInterface, + PokerRoomConfig, + PokerTableConfig, + PokerTableInterface, +} from "../../../src/interfaces"; + +/** + * @class `MockPokerRoom` + * A mock implementation of `PokerRoomInterface` used in testing, implementing all required methods for compliance. + * + * @implements {PokerRoomInterface} + */ +class MockPokerRoom extends EventEmitter implements PokerRoomInterface { + private id: string; + private name: string; + private queue: PokerPlayerInterface[] = []; + private table: PokerTableInterface; + + constructor(config: PokerRoomConfig) { + super(); + this.id = config.id || "default-id"; + this.name = config.name || "default-room"; + this.table = new config.tableConfig() as PokerTableConfig; + } + + getId(): string { + return this.id; + } + + getName(): string { + return this.name; + } + + getQueue(): PokerPlayerInterface[] { + return this.queue; + } + + addToQueue(config: PokerPlayerConfig): boolean { + const player: PokerPlayerInterface = { ...config } as PokerPlayerInterface; + this.queue.push(player); + return true; + } + + getTable(): PokerTableInterface { + return this.table; + } +} + +export { MockPokerRoom }; diff --git a/tests/models/card/index.test.ts b/tests/models/card/index.test.ts new file mode 100644 index 0000000..c23fb51 --- /dev/null +++ b/tests/models/card/index.test.ts @@ -0,0 +1,75 @@ +//@collapse + +import { Card } from "../../../src/models"; +import { Rank, Suit } from "../../../src/enums"; + +/** + * @file `card.test.ts` + * Unit tests for the `Card` class in the `pokerjs` library. + * This file contains test cases to ensure the correct functionality of the `Card` class methods. + * + * The tests verify: + * 1. The creation of a card with a specific rank and suit. + * 2. The string representation of the card. + * 3. The object representation of the card. + * + * @example + * // To run these tests, use the following command: + * npm test + */ + +/** + * @describe `Card` + * Grouping of unit tests for the `Card` class. + */ +describe("Card", () => { + /** + * @var {Card} card + * A variable to store the instance of the `Card` class that will be used in each test. + */ + let card: Card; + + /** + * @beforeEach + * Runs before each individual test case. + * Initializes a new `Card` instance with a rank of `Ace` and a suit of `Spades`. + */ + beforeEach(() => { + card = new Card({ rank: Rank.Ace, suit: Suit.Spades }); + }); + + /** + * @it `should create a card with the correct rank and suit` + * Test case to check if the `Card` instance is created with the correct rank and suit. + * + * @example + * expect(card.getRank()).toBe(Rank.Ace); // Should return `Ace` + * expect(card.getSuit()).toBe(Suit.Spades); // Should return `Spades` + */ + it("should create a card with the correct rank and suit", () => { + expect(card.getRank()).toBe(Rank.Ace); + expect(card.getSuit()).toBe(Suit.Spades); + }); + + /** + * @it `should return the correct string representation` + * Test case to check if the `toString` method returns the correct string representation of the card. + * + * @example + * expect(card.toString()).toBe("A of Spades"); // Should return the string "A of Spades" + */ + it("should return the correct string representation", () => { + expect(card.toString()).toBe("A of Spades"); + }); + + /** + * @it `should return the correct object representation` + * Test case to check if the `toObj` method returns the correct object representation of the card. + * + * @example + * expect(card.toObj()).toEqual({ rank: Rank.Ace, suit: Suit.Spades }); // Should return the object { rank: "A", suit: "Spades" } + */ + it("should return the correct object representation", () => { + expect(card.toObj()).toEqual({ rank: Rank.Ace, suit: Suit.Spades }); + }); +}); diff --git a/tests/models/casino/index.test.ts b/tests/models/casino/index.test.ts new file mode 100644 index 0000000..d634bc9 --- /dev/null +++ b/tests/models/casino/index.test.ts @@ -0,0 +1 @@ +//@collapse diff --git a/tests/models/deck/index.test.ts b/tests/models/deck/index.test.ts new file mode 100644 index 0000000..d634bc9 --- /dev/null +++ b/tests/models/deck/index.test.ts @@ -0,0 +1 @@ +//@collapse diff --git a/tests/models/index.test.ts b/tests/models/index.test.ts new file mode 100644 index 0000000..d634bc9 --- /dev/null +++ b/tests/models/index.test.ts @@ -0,0 +1 @@ +//@collapse diff --git a/tests/models/pokerGame/index.test.ts b/tests/models/pokerGame/index.test.ts new file mode 100644 index 0000000..d634bc9 --- /dev/null +++ b/tests/models/pokerGame/index.test.ts @@ -0,0 +1 @@ +//@collapse diff --git a/tests/models/pokerPhase/index.test.ts b/tests/models/pokerPhase/index.test.ts new file mode 100644 index 0000000..d634bc9 --- /dev/null +++ b/tests/models/pokerPhase/index.test.ts @@ -0,0 +1 @@ +//@collapse diff --git a/tests/models/pokerPlayer/index.test.ts b/tests/models/pokerPlayer/index.test.ts new file mode 100644 index 0000000..d634bc9 --- /dev/null +++ b/tests/models/pokerPlayer/index.test.ts @@ -0,0 +1 @@ +//@collapse diff --git a/tests/models/pokerRoom/index.test.ts b/tests/models/pokerRoom/index.test.ts new file mode 100644 index 0000000..d634bc9 --- /dev/null +++ b/tests/models/pokerRoom/index.test.ts @@ -0,0 +1 @@ +//@collapse diff --git a/tests/models/pokerSeat/index.test.ts b/tests/models/pokerSeat/index.test.ts new file mode 100644 index 0000000..d634bc9 --- /dev/null +++ b/tests/models/pokerSeat/index.test.ts @@ -0,0 +1 @@ +//@collapse diff --git a/tests/models/pokerTable/index.test.ts b/tests/models/pokerTable/index.test.ts new file mode 100644 index 0000000..d634bc9 --- /dev/null +++ b/tests/models/pokerTable/index.test.ts @@ -0,0 +1 @@ +//@collapse diff --git a/tsconfig.cjs.json b/tsconfig.cjs.json new file mode 100644 index 0000000..3fe621e --- /dev/null +++ b/tsconfig.cjs.json @@ -0,0 +1,9 @@ +//@collapse + +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "CommonJS", + "outDir": "./dist/cjs" + } +} diff --git a/tsconfig.esm.json b/tsconfig.esm.json new file mode 100644 index 0000000..b6f33e8 --- /dev/null +++ b/tsconfig.esm.json @@ -0,0 +1,9 @@ +//@collapse + +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "ESNext", + "outDir": "./dist/esm" + } +} diff --git a/tsconfig.json b/tsconfig.json index 42c57ca..77f6e38 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,15 +1,17 @@ +//@collapse + { "compilerOptions": { - "module": "ESNext", - "moduleResolution": "node", - "target": "ES2020", - "declaration": true, - "outDir": "./dist", - "strict": true, - "esModuleInterop": true, - "forceConsistentCasingInFileNames": true, - "skipLibCheck": true, - "sourceMap": true + "module": "ESNext", // Tells TypeScript to use native ESModule syntax (import/export) + "moduleResolution": "node", // Node.js style module resolution + "target": "ES2020", // Specifies the output version of JavaScript + "declaration": true, // Generate .d.ts files for type definitions + "outDir": "./dist", // Output directory for the compiled files + "strict": true, // Enables all strict type-checking options + "esModuleInterop": true, // Enables compatibility between ESModule and CommonJS + "forceConsistentCasingInFileNames": true, // Enforce consistent casing in imports + "skipLibCheck": true, // Skip type checking of library declaration files + "sourceMap": true // Generate source maps for easier debugging }, "include": ["src/**/*"], "exclude": ["node_modules", "dist"]