├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── PULL_REQUEST_TEMPLATE.md ├── dependabot.yml └── workflows │ ├── codeql-analysis.yml │ ├── publish.yml │ └── testsuite.yml ├── .gitignore ├── .mocharc.yml ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── SECURITY.md ├── api.md ├── dist ├── index.cjs.js ├── index.cjs.js.map ├── index.es5.js ├── index.es5.js.map ├── index.iife.js ├── index.iife.js.map ├── index.js └── index.js.map ├── docs ├── SuperTool.html ├── SuperTool.js.html ├── fonts │ ├── OpenSans-Bold-webfont.eot │ ├── OpenSans-Bold-webfont.svg │ ├── OpenSans-Bold-webfont.woff │ ├── OpenSans-BoldItalic-webfont.eot │ ├── OpenSans-BoldItalic-webfont.svg │ ├── OpenSans-BoldItalic-webfont.woff │ ├── OpenSans-Italic-webfont.eot │ ├── OpenSans-Italic-webfont.svg │ ├── OpenSans-Italic-webfont.woff │ ├── OpenSans-Light-webfont.eot │ ├── OpenSans-Light-webfont.svg │ ├── OpenSans-Light-webfont.woff │ ├── OpenSans-LightItalic-webfont.eot │ ├── OpenSans-LightItalic-webfont.svg │ ├── OpenSans-LightItalic-webfont.woff │ ├── OpenSans-Regular-webfont.eot │ ├── OpenSans-Regular-webfont.svg │ └── OpenSans-Regular-webfont.woff ├── global.html ├── index.html ├── scripts │ ├── linenumber.js │ └── prettify │ │ ├── Apache-License-2.0.txt │ │ ├── lang-css.js │ │ └── prettify.js ├── styles │ ├── jsdoc-default.css │ ├── prettify-jsdoc.css │ └── prettify-tomorrow.css └── utils.js.html ├── lib ├── SuperTool.js ├── index.js └── utils.js ├── package-lock.json ├── package.json ├── rollup.dist.config.js └── tests ├── SuperTool.tests.js └── utils.tests.js /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: 4 | - jankapunkt 5 | patreon: # Replace with a single Patreon username 6 | open_collective: # Replace with a single Open Collective username 7 | ko_fi: # Replace with a single Ko-fi username 8 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 9 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 10 | liberapay: # Replace with a single Liberapay username 11 | issuehunt: # Replace with a single IssueHunt username 12 | otechie: # Replace with a single Otechie username 13 | custom: 14 | - https://paypal.me/kuesterjan 15 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 22 | 23 | ## Summary 24 | 27 | 28 | 29 | 30 | ## Linked issue(s) 31 | 34 | 35 | 36 | 37 | ## Involved parts of the project 38 | 41 | 42 | 43 | 44 | ## Added tests? 45 | 48 | 49 | 50 | 51 | ## Webspeech API standard 52 | 57 | 58 | 59 | 60 | ## Reproduction 61 | 65 | 66 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: npm 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | open-pull-requests-limit: 10 8 | 9 | -------------------------------------------------------------------------------- /.github/workflows/codeql-analysis.yml: -------------------------------------------------------------------------------- 1 | # For most projects, this workflow file will not need changing; you simply need 2 | # to commit it to your repository. 3 | # 4 | # You may wish to alter this file to override the set of languages analyzed, 5 | # or to provide custom queries or build logic. 6 | # 7 | # ******** NOTE ******** 8 | # We have attempted to detect the languages in your repository. Please check 9 | # the `language` matrix defined below to confirm you have the correct set of 10 | # supported CodeQL languages. 11 | # 12 | name: "CodeQL Semantic Analysis" 13 | 14 | on: 15 | push: 16 | branches: 17 | - master 18 | pull_request: # all PR 19 | schedule: 20 | - cron: '0 2 * * *' # every night at 2am 21 | 22 | jobs: 23 | analyze: 24 | name: Analyze 25 | runs-on: ubuntu-latest 26 | permissions: 27 | actions: read 28 | contents: read 29 | security-events: write 30 | 31 | strategy: 32 | fail-fast: true 33 | matrix: 34 | language: [ 'javascript' ] 35 | # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] 36 | # Learn more: 37 | # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed 38 | 39 | steps: 40 | - name: Checkout repository 41 | uses: actions/checkout@v3 42 | 43 | # Initializes the CodeQL tools for scanning. 44 | - name: Initialize CodeQL 45 | uses: github/codeql-action/init@v1 46 | with: 47 | languages: ${{ matrix.language }} 48 | # If you wish to specify custom queries, you can do so here or in a config file. 49 | # By default, queries listed here will override any specified in a config file. 50 | # Prefix the list here with "+" to use these queries and those in the config file. 51 | # queries: ./path/to/local/query, your-org/your-repo/queries@main 52 | 53 | # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). 54 | # If this step fails, then you should remove it and run the build manually (see below) 55 | # - name: Autobuild 56 | # uses: github/codeql-action/autobuild@v1 57 | 58 | # ℹ️ Command-line programs to run using the OS shell. 59 | # 📚 https://git.io/JvXDl 60 | 61 | # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines 62 | # and modify them (or add more) to build your code if your project 63 | # uses a compiled language 64 | 65 | #- run: | 66 | # make bootstrap 67 | # make release 68 | 69 | - name: Perform CodeQL Analysis 70 | uses: github/codeql-action/analyze@v1 71 | -------------------------------------------------------------------------------- /.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | name: Publish packages 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | - release-* 8 | pull_request: 9 | branches: 10 | - master 11 | - release-* 12 | 13 | jobs: 14 | docs: 15 | name: Build docs 16 | runs-on: ubuntu-latest 17 | steps: 18 | - name: checkout 19 | uses: actions/checkout@v3 20 | 21 | - name: setup node 22 | uses: actions/setup-node@v3 23 | with: 24 | node-version: 16 25 | 26 | - name: cache dependencies 27 | uses: actions/cache@v3 28 | with: 29 | path: ~/.npm 30 | key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} 31 | restore-keys: | 32 | ${{ runner.os }}-node- 33 | - run: npm ci 34 | - run: npm run docs 35 | 36 | build: 37 | name: Build bundle and publish 38 | runs-on: ubuntu-latest 39 | needs: [docs] 40 | steps: 41 | - name: Checkout ${{ matrix.node }} 42 | uses: actions/checkout@v3 43 | 44 | - name: Setup node ${{ matrix.node }} 45 | uses: actions/setup-node@v3 46 | with: 47 | node-version: 16 48 | 49 | - name: Cache dependencies ${{ matrix.node }} 50 | uses: actions/cache@v3 51 | with: 52 | path: ~/.npm 53 | key: ${{ runner.os }}-node-${{ matrix.node }}-${{ hashFiles('**/package-lock.json') }} 54 | restore-keys: | 55 | ${{ runner.os }}-node-${{ matrix.node }} 56 | - run: | 57 | npm ci 58 | npm run build 59 | npm publish --dry-run 60 | -------------------------------------------------------------------------------- /.github/workflows/testsuite.yml: -------------------------------------------------------------------------------- 1 | name: Test suite 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | - develop 8 | pull_request: 9 | 10 | jobs: 11 | lintjs: 12 | name: Javascript standard lint 13 | runs-on: ubuntu-latest 14 | steps: 15 | - name: checkout 16 | uses: actions/checkout@v3 17 | 18 | - name: setup node 19 | uses: actions/setup-node@v3 20 | with: 21 | node-version: 16 22 | 23 | - name: cache dependencies 24 | uses: actions/cache@v3 25 | with: 26 | path: ~/.npm 27 | key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} 28 | restore-keys: | 29 | ${{ runner.os }}-node- 30 | - run: npm ci 31 | - run: npm run lint 32 | 33 | unittest: 34 | name: unit tests 35 | runs-on: ubuntu-latest 36 | needs: [lintjs] 37 | strategy: 38 | matrix: 39 | node: [16, 18, 20] 40 | steps: 41 | - name: Checkout ${{ matrix.node }} 42 | uses: actions/checkout@v3 43 | 44 | - name: Setup node ${{ matrix.node }} 45 | uses: actions/setup-node@v3 46 | with: 47 | node-version: ${{ matrix.node }} 48 | 49 | - name: Cache dependencies ${{ matrix.node }} 50 | uses: actions/cache@v3 51 | with: 52 | path: ~/.npm 53 | key: ${{ runner.os }}-node-${{ matrix.node }}-${{ hashFiles('**/package-lock.json') }} 54 | restore-keys: | 55 | ${{ runner.os }}-node-${{ matrix.node }} 56 | - run: npm ci 57 | - run: npm run test:coverage 58 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | 9 | # Diagnostic reports (https://nodejs.org/api/report.html) 10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 11 | 12 | # Runtime data 13 | pids 14 | *.pid 15 | *.seed 16 | *.pid.lock 17 | 18 | # Directory for instrumented libs generated by jscoverage/JSCover 19 | lib-cov 20 | 21 | # Coverage directory used by tools like istanbul 22 | coverage 23 | *.lcov 24 | 25 | # nyc test coverage 26 | .nyc_output 27 | 28 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 29 | .grunt 30 | 31 | # Bower dependency directory (https://bower.io/) 32 | bower_components 33 | 34 | # node-waf configuration 35 | .lock-wscript 36 | 37 | # Compiled binary addons (https://nodejs.org/api/addons.html) 38 | build/Release 39 | 40 | # Dependency directories 41 | node_modules/ 42 | jspm_packages/ 43 | 44 | # TypeScript v1 declaration files 45 | typings/ 46 | 47 | # TypeScript cache 48 | *.tsbuildinfo 49 | 50 | # Optional npm cache directory 51 | .npm 52 | 53 | # Optional eslint cache 54 | .eslintcache 55 | 56 | # Microbundle cache 57 | .rpt2_cache/ 58 | .rts2_cache_cjs/ 59 | .rts2_cache_es/ 60 | .rts2_cache_umd/ 61 | 62 | # Optional REPL history 63 | .node_repl_history 64 | 65 | # Output of 'npm pack' 66 | *.tgz 67 | 68 | # Yarn Integrity file 69 | .yarn-integrity 70 | 71 | # dotenv environment variables file 72 | .env 73 | .env.test 74 | 75 | # parcel-bundler cache (https://parceljs.org/) 76 | .cache 77 | 78 | # Next.js build output 79 | .next 80 | 81 | # Nuxt.js build / generate output 82 | .nuxt 83 | 84 | # Gatsby files 85 | .cache/ 86 | # Comment in the public line in if your project uses Gatsby and *not* Next.js 87 | # https://nextjs.org/blog/next-9-1#public-directory-support 88 | # public 89 | 90 | # vuepress build output 91 | .vuepress/dist 92 | 93 | # Serverless directories 94 | .serverless/ 95 | 96 | # FuseBox cache 97 | .fusebox/ 98 | 99 | # DynamoDB Local files 100 | .dynamodb/ 101 | 102 | # TernJS port file 103 | .tern-port 104 | 105 | # IDEs 106 | 107 | .idea 108 | .vscode 109 | .atom -------------------------------------------------------------------------------- /.mocharc.yml: -------------------------------------------------------------------------------- 1 | recursive: true 2 | reporter: "spec" 3 | retries: 0 4 | slow: 20 5 | timeout: 2000 6 | ui: "bdd" 7 | # for more options see here https://github.com/mochajs/mocha/blob/master/example/config/.mocharc.yml 8 | require: '@babel/register' 9 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | **1.0.0** 4 | - published my awesome package 5 | - -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | We as members, contributors, and leaders pledge to make participation in our 6 | community a harassment-free experience for everyone, regardless of age, body 7 | size, visible or invisible disability, ethnicity, sex characteristics, gender 8 | identity and expression, level of experience, education, socio-economic status, 9 | nationality, personal appearance, race, religion, or sexual identity 10 | and orientation. 11 | 12 | We pledge to act and interact in ways that contribute to an open, welcoming, 13 | diverse, inclusive, and healthy community. 14 | 15 | ## Our Standards 16 | 17 | Examples of behavior that contributes to a positive environment for our 18 | community include: 19 | 20 | * Demonstrating empathy and kindness toward other people 21 | * Being respectful of differing opinions, viewpoints, and experiences 22 | * Giving and gracefully accepting constructive feedback 23 | * Accepting responsibility and apologizing to those affected by our mistakes, 24 | and learning from the experience 25 | * Focusing on what is best not just for us as individuals, but for the 26 | overall community 27 | 28 | Examples of unacceptable behavior include: 29 | 30 | * The use of sexualized language or imagery, and sexual attention or 31 | advances of any kind 32 | * Trolling, insulting or derogatory comments, and personal or political attacks 33 | * Public or private harassment 34 | * Publishing others' private information, such as a physical or email 35 | address, without their explicit permission 36 | * Other conduct which could reasonably be considered inappropriate in a 37 | professional setting 38 | 39 | ## Enforcement Responsibilities 40 | 41 | Community leaders are responsible for clarifying and enforcing our standards of 42 | acceptable behavior and will take appropriate and fair corrective action in 43 | response to any behavior that they deem inappropriate, threatening, offensive, 44 | or harmful. 45 | 46 | Community leaders have the right and responsibility to remove, edit, or reject 47 | comments, commits, code, wiki edits, issues, and other contributions that are 48 | not aligned to this Code of Conduct, and will communicate reasons for moderation 49 | decisions when appropriate. 50 | 51 | ## Scope 52 | 53 | This Code of Conduct applies within all community spaces, and also applies when 54 | an individual is officially representing the community in public spaces. 55 | Examples of representing our community include using an official e-mail address, 56 | posting via an official social media account, or acting as an appointed 57 | representative at an online or offline event. 58 | 59 | ## Enforcement 60 | 61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 62 | reported to the community leaders responsible for enforcement at 63 | . 64 | All complaints will be reviewed and investigated promptly and fairly. 65 | 66 | All community leaders are obligated to respect the privacy and security of the 67 | reporter of any incident. 68 | 69 | ## Enforcement Guidelines 70 | 71 | Community leaders will follow these Community Impact Guidelines in determining 72 | the consequences for any action they deem in violation of this Code of Conduct: 73 | 74 | ### 1. Correction 75 | 76 | **Community Impact**: Use of inappropriate language or other behavior deemed 77 | unprofessional or unwelcome in the community. 78 | 79 | **Consequence**: A private, written warning from community leaders, providing 80 | clarity around the nature of the violation and an explanation of why the 81 | behavior was inappropriate. A public apology may be requested. 82 | 83 | ### 2. Warning 84 | 85 | **Community Impact**: A violation through a single incident or series 86 | of actions. 87 | 88 | **Consequence**: A warning with consequences for continued behavior. No 89 | interaction with the people involved, including unsolicited interaction with 90 | those enforcing the Code of Conduct, for a specified period of time. This 91 | includes avoiding interactions in community spaces as well as external channels 92 | like social media. Violating these terms may lead to a temporary or 93 | permanent ban. 94 | 95 | ### 3. Temporary Ban 96 | 97 | **Community Impact**: A serious violation of community standards, including 98 | sustained inappropriate behavior. 99 | 100 | **Consequence**: A temporary ban from any sort of interaction or public 101 | communication with the community for a specified period of time. No public or 102 | private interaction with the people involved, including unsolicited interaction 103 | with those enforcing the Code of Conduct, is allowed during this period. 104 | Violating these terms may lead to a permanent ban. 105 | 106 | ### 4. Permanent Ban 107 | 108 | **Community Impact**: Demonstrating a pattern of violation of community 109 | standards, including sustained inappropriate behavior, harassment of an 110 | individual, or aggression toward or disparagement of classes of individuals. 111 | 112 | **Consequence**: A permanent ban from any sort of public interaction within 113 | the community. 114 | 115 | ## Attribution 116 | 117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 118 | version 2.0, available at 119 | https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. 120 | 121 | Community Impact Guidelines were inspired by [Mozilla's code of conduct 122 | enforcement ladder](https://github.com/mozilla/diversity). 123 | 124 | [homepage]: https://www.contributor-covenant.org 125 | 126 | For answers to common questions about this code of conduct, see the FAQ at 127 | https://www.contributor-covenant.org/faq. Translations are available at 128 | https://www.contributor-covenant.org/translations. 129 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to `my-awesome-package` 2 | 3 | Thank you for your interest in this project and your aims to improving it. 4 | This guide will give you the most important info on how to contribute properly 5 | in order to get your pull requests accepted. 6 | 7 | ## Disclose security vulnerabilities 8 | 9 | First things first: We appreciate every help to improve security! 10 | 11 | **However, please read our [security policy](./SECURITY.md), before taking 12 | actions.** 13 | 14 | ## Guiding principles 15 | 16 | Before contributing to this project, it's' important to understand how this 17 | project and it's collaborators views itself regarding its scope and purpose. 18 | 19 | ## Development 20 | 21 | If you want to fix bugs or add new features, **please read this chapter and it's 22 | sections carefully!** 23 | 24 | ### No PR without issue 25 | 26 | Please make sure your commitment will be appreciated by **first opening an issue** 27 | and discuss, whether this is a useful addition to the project. 28 | 29 | ### Work on a bug or a new feature 30 | 31 | First, clone and install this project from source via 32 | 33 | ```bash 34 | $ git clone git@github.com:me/my-project.git 35 | $ cd my-project 36 | $ npm install 37 | ``` 38 | 39 | From here you can run several scripts for development purposes: 40 | 41 | ```bash 42 | $ npm run lint # runs the linter 43 | $ npm run lint:fix # runs the linter; fixes simple issues 44 | $ npm run test # runs the tests once 45 | $ npm run test:watch # runs the tests; reloads on code-changes 46 | $ npm run test:coverage # runs the tests including coverage 47 | $ npm run docs # generates the API docs 48 | $ npm run build # generates the final distributable files 49 | ``` 50 | 51 | To work on a new feature or a fix please create a new branch: 52 | 53 | ```bash 54 | $ git checkout -b feature-xyz # or fix-xyz 55 | ``` 56 | 57 | ### Coding rules 58 | 59 | - Linter-pass: the linter must pass 60 | - Unit-testing: all features or bug fixes must be tested by specs 61 | - Documentation: all **public** APIs / methods must be documented 62 | 63 | ### Commit message convention 64 | 65 | We use a commit convention, inspired by [angular commit message format](https://github.com/angular/angular/blob/master/CONTRIBUTING.md#-commit-message-format) 66 | with ticket number at the end of summary: 67 | 68 | ``` 69 | (): # 70 | ``` 71 | Summary in present tense. Not capitalized. No period at the end. 72 | The and fields are mandatory, the () and # field is optional. 73 | 74 | ### Run the tests before committing 75 | 76 | Please always make sure your code is passing linter and tests **before 77 | committing**. By doing so you help to make reviews much easier and don't pollute 78 | the history with commits, that are solely targeting lint fixes. 79 | 80 | You can run the tests via 81 | 82 | ```bash 83 | $ npm run test 84 | ``` 85 | 86 | or 87 | 88 | ```bash 89 | $ npm run test:coverage 90 | ``` 91 | 92 | to see your coverage. 93 | 94 | ### Open a pull request (PR) 95 | 96 | Once you have implemented your changes and tested them locally, please open 97 | a [pull request](https://docs.github.com/en/github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request). 98 | 99 | Note: sometimes a pull request (PR) is also referred to as merge request (MR). 100 | 101 | #### Fundamental PR requirements 102 | 103 | There are a few basic requirements for your pull request to become accepted: 104 | 105 | - Make sure to open your pull request to target the `master` branch 106 | - Make sure you are working on a branch, other than `master`; usually you 107 | can name the branch after the feature or fix you want to provide 108 | - Resolve any merge conflicts (usually by keeping your branch updated with 109 | `master`) 110 | - Have a clear description on what the PR does, including any steps necessary 111 | for testing, reviewing, reproduction etc. 112 | - Link to the existing issue 113 | - Added functions or changed functions need to get documented in compliance with 114 | JSDoc 115 | - Make sure all CI Tests are passing 116 | 117 | Also make sure, to comply with the following list: 118 | 119 | - Do not work on `master` directly 120 | - Do not implement multiple features in one pull request (this includes bumping 121 | versions of dependencies that are not related to the PR/issue) 122 | - Do not bump the release version (unless you are a maintainer) 123 | - Do not edit the Changelog as this will be done after your PR is merged 124 | - Do not introduce tight dependencies to a certain package that has not been 125 | approved during the discussion in the issue 126 | 127 | #### Review process 128 | 129 | Finally, your PR needs to pass the review process: 130 | 131 | - A certain amount of maintainers needs to review and accept your PR 132 | - Please **expect change requests**! They will occur and are intended to improve 133 | the overall code quality. 134 | - If your changes have been updated please re-assign the reviewer who asked for 135 | the changes 136 | - Once all reviewers have approved your PR it will be merged by one of the 137 | maintainers :tada: 138 | 139 | #### After merge 140 | 141 | Please delete your branch after merge. 142 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Jan Küster 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 📦 NPM Package Template - Zero Config 📦 2 | 3 | ![Test suite](https://github.com/jankapunkt/npm-package-template/workflows/Test%20suite/badge.svg) 4 | [![Build and publish](https://github.com/jankapunkt/npm-package-template/actions/workflows/publish.yml/badge.svg)](https://github.com/jankapunkt/npm-package-template/actions/workflows/publish.yml) 5 | [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com) 6 | [![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active) 7 | ![GitHub](https://img.shields.io/github/license/jankapunkt/npm-package-template) 8 | 9 | Minimal tested and fully functional NPM package template project for ES6+ Javascript. 10 | 11 | ## About this package 12 | 13 | This template is intended to allow you to **start developing immediatly** with a working set 14 | of tools and scripts that play well together. 15 | 16 | It is little opinionated to the point, that only the most basic tools are integrated. 17 | If you want a different flavour you can fork this project and easily replace the tools or add new ones. 18 | 19 | ## What's included? 20 | 21 | ### Tools / stack 22 | 23 | * 🗪 [Babel](https://babeljs.io/) for transpiling 24 | * 🪄 [Standard](https://standardjs.com/) for linting 25 | * ⚗️ [Mocha](https://mochajs.org/) and [Chai](https://www.chaijs.com) for testing 26 | * 🔍 [c8](https://github.com/bcoe/c8) for code coverage 27 | * 📚 [JSDoc](https://jsdoc.app/) for documentation and [jsdoc-to-markdown](https://www.npmjs.com/package/jsdoc-to-markdown) to create docs as markdown files 28 | * ⚡ [GitHub actions](https://github.com/features/actions) for continuous integration 29 | * 📦 [Rollup](https://rollupjs.org) for bundling 30 | 31 | All tools are defined as **`dev-dependencies`**! 32 | 33 | ### Docs and repository 34 | 35 | This template repository has all relevant GitHub community standards implemented: 36 | 37 | - [x] Description 38 | - [x] [README](./README.md) 39 | - [x] [Code of conduct](./CODE_OF_CONDUCT.md) 40 | - [x] [Contributing](./CONTRIBUTING.md) 41 | - [x] [License](./LICENSE) 42 | - [x] [Security policy](./SECURITY.md) 43 | - [x] [Issue templates](./.github/ISSUE_TEMPLATE) 44 | - [x] [Pull request template](./.github/PULL_REQUEST_TEMPLATE.md) 45 | 46 | ## Getting started 47 | 48 | First, [create a new repository with this repository as template](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-repository-from-a-template) 49 | or fork the repository and clone it to your local machine. 50 | 51 | From here, simply create your Js files in the `./lib` folder and add the tests in the `test` folder. 52 | 53 | ### Use the tools 54 | 55 | We provide a default set of tools via npm scripts. Run a script via 56 | 57 | ```shell 58 | $ npm run 59 | ``` 60 | 61 | where `` is one of the following available commands: 62 | 63 | | command | description | output | 64 | |-----------------|---------------------------------------------------|------------| 65 | | `lint` | runs the linter in read-mode | | 66 | | `lint:fix` | runs the linter; fixes minor issues automatically | | 67 | | `test` | runs the tests once | | 68 | | `test:watch` | runs the tests; re-runs them on code changes | | 69 | | `test:coverage` | runs the tests once and creates a coverage report | `coverage` | 70 | | `docs` | creates API documentation | `docs` | 71 | | `build` | builds the bundles for several target platforms | `dist` | 72 | | `build:full` | runs `build` and `docs` | see above | 73 | 74 | ## Contributing and development 75 | 76 | We provide an [extensive contribution guideline](./CONTRIBUTING.md) and a [code of conduct](./CODE_OF_CONDUCT.md) 77 | to help you in making your contribution a success! 78 | 79 | ## Security 80 | 81 | Please read our [security policy](./SECURITY.md) to get to know which versions are covered. 82 | 83 | ## License 84 | 85 | MIT, see [license file](LICENSE) 86 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | Use this section to tell people about which versions of your project are 6 | currently being supported with security updates. 7 | 8 | | Version | Supported | 9 | | ------- | ------------------ | 10 | | 1.x.x | :white_check_mark: | 11 | 12 | ## Reporting a Vulnerability 13 | 14 | Report security vulnerabilities to me@mydomain.tld 15 | 16 | Please specify exactly how the vulnerability is to be exploited so we can estimate how severe the consequences can be (unless you also can specify them, too). 17 | 18 | Please note that we need to reproduce the vulnerability (as like with bugs) in order to safely fix it. 19 | 20 | A fix will be implemented in private until we can ensure the vulnerability is closed. A new release will immediately be published. 21 | If you want to provide a fix please let us know in the e-mail so we can setup a completely private repository to work on it together. 22 | 23 | Finally, all security fixes will also require to pass all tests and audits. 24 | -------------------------------------------------------------------------------- /api.md: -------------------------------------------------------------------------------- 1 | ## Classes 2 | 3 |
4 |
SuperTool
5 |

The super tool class. Holds a state and implements the execute command.

6 |
7 |
8 | 9 | ## Constants 10 | 11 |
12 |
existsboolean
13 |

Returns true of a given parameter is not null and not undefined.

14 |
15 |
16 | 17 | 18 | 19 | ## SuperTool 20 | The super tool class. Holds a state and implements the execute command. 21 | 22 | **Kind**: global class 23 | 24 | * [SuperTool](#SuperTool) 25 | * [new SuperTool(state)](#new_SuperTool_new) 26 | * _instance_ 27 | * [.state(value)](#SuperTool+state) ⇒ String 28 | * [.execute()](#SuperTool+execute) ⇒ string 29 | * _static_ 30 | * [.states](#SuperTool.states) ⇒ Object 31 | * [.validateState(value)](#SuperTool.validateState) 32 | 33 | 34 | 35 | ### new SuperTool(state) 36 | Constructor initializes the state. If none is given, it defaults to {'great'}. 37 | 38 | **Throws**: 39 | 40 | - if state is not a valid state 41 | 42 | 43 | | Param | Description | 44 | | --- | --- | 45 | | state | one of the SuperTool.state values | 46 | 47 | 48 | 49 | ### superTool.state(value) ⇒ String 50 | Validates and sets a new state value if given and returns the updated value. If no defined value is given it just returns the 51 | current state value. 52 | 53 | **Kind**: instance method of [SuperTool](#SuperTool) 54 | **Returns**: String - the current state value 55 | 56 | | Param | Type | Description | 57 | | --- | --- | --- | 58 | | value | String \| undefined | optional state to be set. | 59 | 60 | 61 | 62 | ### superTool.execute() ⇒ string 63 | Executes with the current internal state. 64 | 65 | **Kind**: instance method of [SuperTool](#SuperTool) 66 | **Returns**: string - the execution including the current state. 67 | 68 | 69 | ### SuperTool.states ⇒ Object 70 | The possible states of the SuperTool. 71 | 72 | **Kind**: static property of [SuperTool](#SuperTool) 73 | 74 | 75 | ### SuperTool.validateState(value) 76 | Validates a state. To be valid, the value needs to be part of the {SuperTool.states}. 77 | Throws an Error if invalid. Returns void / undefined if passed. 78 | 79 | **Kind**: static method of [SuperTool](#SuperTool) 80 | **Throws**: 81 | 82 | - if state is not a valid state 83 | 84 | 85 | | Param | Description | 86 | | --- | --- | 87 | | value | The state candidate to be validated. | 88 | 89 | 90 | 91 | ## exists ⇒ boolean 92 | Returns true of a given parameter is not null and not undefined. 93 | 94 | **Kind**: global constant 95 | **Returns**: boolean - true if defined, otherwise false 96 | 97 | | Param | Description | 98 | | --- | --- | 99 | | any | any input is feasible | 100 | 101 | -------------------------------------------------------------------------------- /dist/index.cjs.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /** 4 | * Returns true of a given parameter is not null and not undefined. 5 | * @param any any input is feasible 6 | * @return {boolean} true if defined, otherwise false 7 | */ 8 | function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } 9 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 10 | function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } 11 | function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } 12 | function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } 13 | function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } 14 | var exists = function exists(any) { 15 | return any !== null && typeof any !== 'undefined'; 16 | }; 17 | 18 | /** 19 | * The possible states of the supertool. 20 | * @private 21 | */ 22 | var superToolStates = { 23 | great: 'great', 24 | cool: 'cool', 25 | awesome: 'awesome', 26 | swag: 'swag' 27 | }; 28 | 29 | /** 30 | * The super tool class. Holds a state and implements the execute command. 31 | */ 32 | var SuperTool = /*#__PURE__*/function () { 33 | /** 34 | * Constructor initializes the state. If none is given, it defaults to {'great'}. 35 | * @param state one of the SuperTool.state values 36 | * @throws if state is not a valid state 37 | */ 38 | 39 | function SuperTool() { 40 | var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, 41 | _ref$state = _ref.state, 42 | state = _ref$state === void 0 ? SuperTool.states.great : _ref$state; 43 | _classCallCheck(this, SuperTool); 44 | SuperTool.validateState(state); 45 | this._state = state; 46 | } 47 | 48 | /** 49 | * Validates and sets a new state value if given and returns the updated value. If no defined value is given it just returns the 50 | * current state value. 51 | * @param value {String|undefined} optional state to be set. 52 | * @return {String} the current state value 53 | */ 54 | _createClass(SuperTool, [{ 55 | key: "state", 56 | value: function state(value) { 57 | if (exists(value)) { 58 | SuperTool.validateState(value); 59 | this._state = value; 60 | } 61 | return this._state; 62 | } 63 | 64 | /** 65 | * Executes with the current internal state. 66 | * @return {string} the execution including the current state. 67 | */ 68 | }, { 69 | key: "execute", 70 | value: function execute() { 71 | return "I feel ".concat(this._state, "!"); 72 | } 73 | }], [{ 74 | key: "states", 75 | get: 76 | /** 77 | * The possible states of the SuperTool. 78 | * @return {{great: string, cool: string, awesome: string, swag: string}} 79 | */ 80 | 81 | function get() { 82 | return superToolStates; 83 | } 84 | 85 | /** 86 | * Validates a state. To be valid, the value needs to be part of the {SuperTool.states}. 87 | * Throws an Error if invalid. Returns void / undefined if passed. 88 | * @param value The state candidate to be validated. 89 | * @throws if state is not a valid state 90 | */ 91 | }, { 92 | key: "validateState", 93 | value: function validateState(value) { 94 | if (!superToolStates[value]) { 95 | throw new Error("Invalid state: ".concat(value)); 96 | } 97 | } 98 | }]); 99 | return SuperTool; 100 | }(); 101 | exports.SuperTool = SuperTool; 102 | //# sourceMappingURL=index.cjs.js.map 103 | -------------------------------------------------------------------------------- /dist/index.cjs.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.cjs.js","sources":["../lib/utils.js","../lib/SuperTool.js"],"sourcesContent":["/**\n * Returns true of a given parameter is not null and not undefined.\n * @param any any input is feasible\n * @return {boolean} true if defined, otherwise false\n */\nexport const exists = any => any !== null && typeof any !== 'undefined'\n\n/**\n * This should be removed by rollup's tree shaking\n * @private\n */\nexport const ignore = () => {}\n","import { exists } from './utils.js'\n\n/**\n * The possible states of the supertool.\n * @private\n */\nconst superToolStates = {\n great: 'great',\n cool: 'cool',\n awesome: 'awesome',\n swag: 'swag'\n}\n\n/**\n * The super tool class. Holds a state and implements the execute command.\n */\n\nclass SuperTool {\n /**\n * The possible states of the SuperTool.\n * @return {{great: string, cool: string, awesome: string, swag: string}}\n */\n\n static get states () {\n return superToolStates\n }\n\n /**\n * Validates a state. To be valid, the value needs to be part of the {SuperTool.states}.\n * Throws an Error if invalid. Returns void / undefined if passed.\n * @param value The state candidate to be validated.\n * @throws if state is not a valid state\n */\n\n static validateState (value) {\n if (!superToolStates[value]) {\n throw new Error(`Invalid state: ${value}`)\n }\n }\n\n /**\n * Constructor initializes the state. If none is given, it defaults to {'great'}.\n * @param state one of the SuperTool.state values\n * @throws if state is not a valid state\n */\n\n constructor ({ state = SuperTool.states.great } = {}) {\n SuperTool.validateState(state)\n this._state = state\n }\n\n /**\n * Validates and sets a new state value if given and returns the updated value. If no defined value is given it just returns the\n * current state value.\n * @param value {String|undefined} optional state to be set.\n * @return {String} the current state value\n */\n\n state (value) {\n if (exists(value)) {\n SuperTool.validateState(value)\n this._state = value\n }\n return this._state\n }\n\n /**\n * Executes with the current internal state.\n * @return {string} the execution including the current state.\n */\n\n execute () {\n return `I feel ${this._state}!`\n }\n}\n\nexport default SuperTool\n"],"names":["_typeof","obj","Symbol","iterator","constructor","prototype","_classCallCheck","instance","Constructor","TypeError","_defineProperties","target","props","i","length","descriptor","enumerable","configurable","writable","Object","defineProperty","_toPropertyKey","key","_createClass","protoProps","staticProps","arg","_toPrimitive","String","input","hint","prim","toPrimitive","undefined","res","call","Number","exists","any","superToolStates","great","cool","awesome","swag","SuperTool","_ref","arguments","_ref$state","state","states","validateState","_state","value","execute","concat","get","Error"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAJA,SAAAA,QAAAC,GAAA,sCAAAD,OAAA,wBAAAE,MAAA,uBAAAA,MAAA,CAAAC,QAAA,aAAAF,GAAA,kBAAAA,GAAA,gBAAAA,GAAA,WAAAA,GAAA,yBAAAC,MAAA,IAAAD,GAAA,CAAAG,WAAA,KAAAF,MAAA,IAAAD,GAAA,KAAAC,MAAA,CAAAG,SAAA,qBAAAJ,GAAA,KAAAD,OAAA,CAAAC,GAAA;AAAA,SAAAK,gBAAAC,QAAA,EAAAC,WAAA,UAAAD,QAAA,YAAAC,WAAA,eAAAC,SAAA;AAAA,SAAAC,kBAAAC,MAAA,EAAAC,KAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAD,KAAA,CAAAE,MAAA,EAAAD,CAAA,UAAAE,UAAA,GAAAH,KAAA,CAAAC,CAAA,GAAAE,UAAA,CAAAC,UAAA,GAAAD,UAAA,CAAAC,UAAA,WAAAD,UAAA,CAAAE,YAAA,wBAAAF,UAAA,EAAAA,UAAA,CAAAG,QAAA,SAAAC,MAAA,CAAAC,cAAA,CAAAT,MAAA,EAAAU,cAAA,CAAAN,UAAA,CAAAO,GAAA,GAAAP,UAAA;AAAA,SAAAQ,aAAAf,WAAA,EAAAgB,UAAA,EAAAC,WAAA,QAAAD,UAAA,EAAAd,iBAAA,CAAAF,WAAA,CAAAH,SAAA,EAAAmB,UAAA,OAAAC,WAAA,EAAAf,iBAAA,CAAAF,WAAA,EAAAiB,WAAA,GAAAN,MAAA,CAAAC,cAAA,CAAAZ,WAAA,iBAAAU,QAAA,mBAAAV,WAAA;AAAA,SAAAa,eAAAK,GAAA,QAAAJ,GAAA,GAAAK,YAAA,CAAAD,GAAA,oBAAA1B,OAAA,CAAAsB,GAAA,iBAAAA,GAAA,GAAAM,MAAA,CAAAN,GAAA;AAAA,SAAAK,aAAAE,KAAA,EAAAC,IAAA,QAAA9B,OAAA,CAAA6B,KAAA,kBAAAA,KAAA,kBAAAA,KAAA,MAAAE,IAAA,GAAAF,KAAA,CAAA3B,MAAA,CAAA8B,WAAA,OAAAD,IAAA,KAAAE,SAAA,QAAAC,GAAA,GAAAH,IAAA,CAAAI,IAAA,CAAAN,KAAA,EAAAC,IAAA,oBAAA9B,OAAA,CAAAkC,GAAA,uBAAAA,GAAA,YAAAzB,SAAA,4DAAAqB,IAAA,gBAAAF,MAAA,GAAAQ,MAAA,EAAAP,KAAA;AAKO,IAAMQ,MAAM,GAAG,SAATA,MAAMA,CAAGC,GAAG;EAAA,OAAIA,GAAG,KAAK,IAAI,IAAI,OAAOA,GAAG,KAAK,WAAA;AAAA;;ACH5D;AACA;AACA;AACA;AACA,IAAMC,eAAe,GAAG;EACtBC,KAAK,EAAE,OAAO;EACdC,IAAI,EAAE,MAAM;EACZC,OAAO,EAAE,SAAS;EAClBC,IAAI,EAAE;AACR,CAAC;;AAED;AACA;AACA;AAFA,IAIMC,SAAS;EAuBf;AACA;AACA;AACA;AACA;;EAEE,SAAAA,UAAA,EAAsD;IAAA,IAAAC,IAAA,GAAAC,SAAA,CAAAhC,MAAA,QAAAgC,SAAA,QAAAb,SAAA,GAAAa,SAAA,MAAJ,EAAE;MAAAC,UAAA,GAAAF,IAAA,CAArCG,KAAK;MAALA,KAAK,GAAAD,UAAA,cAAGH,SAAS,CAACK,MAAM,CAACT,KAAK,GAAAO,UAAA;IAAAzC,eAAA,OAAAsC,SAAA;IAC3CA,SAAS,CAACM,aAAa,CAACF,KAAK,CAAC;IAC9B,IAAI,CAACG,MAAM,GAAGH,KAAK;EACpB;;EAEH;AACA;AACA;AACA;AACA;AACA;EALAzB,YAAA,CAAAqB,SAAA;IAAAtB,GAAA;IAAA8B,KAAA,EAOE,SAAAJ,MAAOI,KAAK,EAAE;MACZ,IAAIf,MAAM,CAACe,KAAK,CAAC,EAAE;QACjBR,SAAS,CAACM,aAAa,CAACE,KAAK,CAAC;QAC9B,IAAI,CAACD,MAAM,GAAGC,KAAK;MACpB;MACD,OAAO,IAAI,CAACD,MAAM;IACnB;;IAEH;AACA;AACA;AACA;EAHA;IAAA7B,GAAA;IAAA8B,KAAA,EAKE,SAAAC,QAAA,EAAW;MACT,iBAAAC,MAAA,CAAiB,IAAI,CAACH,MAAM;IAC7B;EAAA;IAAA7B,GAAA;IAAAiC,GAAA;IAvDH;AACA;AACA;AACA;;IAEE,SAAAA,IAAA,EAAqB;MACnB,OAAOhB,eAAe;IACvB;;IAEH;AACA;AACA;AACA;AACA;AACA;EALA;IAAAjB,GAAA;IAAA8B,KAAA,EAOE,SAAAF,cAAsBE,KAAK,EAAE;MAC3B,IAAI,CAACb,eAAe,CAACa,KAAK,CAAC,EAAE;QAC3B,MAAM,IAAII,KAAK,mBAAAF,MAAA,CAAmBF,KAAK,CAAE,CAAC;MAC3C;IACF;EAAA;EAAA,OAAAR,SAAA;AAAA;"} -------------------------------------------------------------------------------- /dist/index.es5.js: -------------------------------------------------------------------------------- 1 | function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } 2 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 3 | function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } 4 | function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } 5 | function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } 6 | function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } 7 | /** 8 | * Returns true of a given parameter is not null and not undefined. 9 | * @param any any input is feasible 10 | * @return {boolean} true if defined, otherwise false 11 | */ 12 | var exists = function exists(any) { 13 | return any !== null && typeof any !== 'undefined'; 14 | }; 15 | 16 | /** 17 | * The possible states of the supertool. 18 | * @private 19 | */ 20 | var superToolStates = { 21 | great: 'great', 22 | cool: 'cool', 23 | awesome: 'awesome', 24 | swag: 'swag' 25 | }; 26 | 27 | /** 28 | * The super tool class. Holds a state and implements the execute command. 29 | */ 30 | var SuperTool = /*#__PURE__*/function () { 31 | /** 32 | * Constructor initializes the state. If none is given, it defaults to {'great'}. 33 | * @param state one of the SuperTool.state values 34 | * @throws if state is not a valid state 35 | */ 36 | 37 | function SuperTool() { 38 | var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, 39 | _ref$state = _ref.state, 40 | state = _ref$state === void 0 ? SuperTool.states.great : _ref$state; 41 | _classCallCheck(this, SuperTool); 42 | SuperTool.validateState(state); 43 | this._state = state; 44 | } 45 | 46 | /** 47 | * Validates and sets a new state value if given and returns the updated value. If no defined value is given it just returns the 48 | * current state value. 49 | * @param value {String|undefined} optional state to be set. 50 | * @return {String} the current state value 51 | */ 52 | _createClass(SuperTool, [{ 53 | key: "state", 54 | value: function state(value) { 55 | if (exists(value)) { 56 | SuperTool.validateState(value); 57 | this._state = value; 58 | } 59 | return this._state; 60 | } 61 | 62 | /** 63 | * Executes with the current internal state. 64 | * @return {string} the execution including the current state. 65 | */ 66 | }, { 67 | key: "execute", 68 | value: function execute() { 69 | return "I feel ".concat(this._state, "!"); 70 | } 71 | }], [{ 72 | key: "states", 73 | get: 74 | /** 75 | * The possible states of the SuperTool. 76 | * @return {{great: string, cool: string, awesome: string, swag: string}} 77 | */ 78 | 79 | function get() { 80 | return superToolStates; 81 | } 82 | 83 | /** 84 | * Validates a state. To be valid, the value needs to be part of the {SuperTool.states}. 85 | * Throws an Error if invalid. Returns void / undefined if passed. 86 | * @param value The state candidate to be validated. 87 | * @throws if state is not a valid state 88 | */ 89 | }, { 90 | key: "validateState", 91 | value: function validateState(value) { 92 | if (!superToolStates[value]) { 93 | throw new Error("Invalid state: ".concat(value)); 94 | } 95 | } 96 | }]); 97 | return SuperTool; 98 | }(); 99 | export { SuperTool }; 100 | //# sourceMappingURL=index.es5.js.map 101 | -------------------------------------------------------------------------------- /dist/index.es5.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.es5.js","sources":["../lib/utils.js","../lib/SuperTool.js"],"sourcesContent":["/**\n * Returns true of a given parameter is not null and not undefined.\n * @param any any input is feasible\n * @return {boolean} true if defined, otherwise false\n */\nexport const exists = any => any !== null && typeof any !== 'undefined'\n\n/**\n * This should be removed by rollup's tree shaking\n * @private\n */\nexport const ignore = () => {}\n","import { exists } from './utils.js'\n\n/**\n * The possible states of the supertool.\n * @private\n */\nconst superToolStates = {\n great: 'great',\n cool: 'cool',\n awesome: 'awesome',\n swag: 'swag'\n}\n\n/**\n * The super tool class. Holds a state and implements the execute command.\n */\n\nclass SuperTool {\n /**\n * The possible states of the SuperTool.\n * @return {{great: string, cool: string, awesome: string, swag: string}}\n */\n\n static get states () {\n return superToolStates\n }\n\n /**\n * Validates a state. To be valid, the value needs to be part of the {SuperTool.states}.\n * Throws an Error if invalid. Returns void / undefined if passed.\n * @param value The state candidate to be validated.\n * @throws if state is not a valid state\n */\n\n static validateState (value) {\n if (!superToolStates[value]) {\n throw new Error(`Invalid state: ${value}`)\n }\n }\n\n /**\n * Constructor initializes the state. If none is given, it defaults to {'great'}.\n * @param state one of the SuperTool.state values\n * @throws if state is not a valid state\n */\n\n constructor ({ state = SuperTool.states.great } = {}) {\n SuperTool.validateState(state)\n this._state = state\n }\n\n /**\n * Validates and sets a new state value if given and returns the updated value. If no defined value is given it just returns the\n * current state value.\n * @param value {String|undefined} optional state to be set.\n * @return {String} the current state value\n */\n\n state (value) {\n if (exists(value)) {\n SuperTool.validateState(value)\n this._state = value\n }\n return this._state\n }\n\n /**\n * Executes with the current internal state.\n * @return {string} the execution including the current state.\n */\n\n execute () {\n return `I feel ${this._state}!`\n }\n}\n\nexport default SuperTool\n"],"names":["exists","any","superToolStates","great","cool","awesome","swag","SuperTool","_ref","arguments","length","undefined","_ref$state","state","states","_classCallCheck","validateState","_state","_createClass","key","value","execute","concat","get","Error"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACO,IAAMA,MAAM,GAAG,SAATA,MAAMA,CAAGC,GAAG;EAAA,OAAIA,GAAG,KAAK,IAAI,IAAI,OAAOA,GAAG,KAAK,WAAA;AAAA;;ACH5D;AACA;AACA;AACA;AACA,IAAMC,eAAe,GAAG;EACtBC,KAAK,EAAE,OAAO;EACdC,IAAI,EAAE,MAAM;EACZC,OAAO,EAAE,SAAS;EAClBC,IAAI,EAAE;AACR,CAAC;;AAED;AACA;AACA;AAFA,IAIMC,SAAS;EAuBf;AACA;AACA;AACA;AACA;;EAEE,SAAAA,UAAA,EAAsD;IAAA,IAAAC,IAAA,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAJ,EAAE;MAAAG,UAAA,GAAAJ,IAAA,CAArCK,KAAK;MAALA,KAAK,GAAAD,UAAA,cAAGL,SAAS,CAACO,MAAM,CAACX,KAAK,GAAAS,UAAA;IAAAG,eAAA,OAAAR,SAAA;IAC3CA,SAAS,CAACS,aAAa,CAACH,KAAK,CAAC;IAC9B,IAAI,CAACI,MAAM,GAAGJ,KAAK;EACpB;;EAEH;AACA;AACA;AACA;AACA;AACA;EALAK,YAAA,CAAAX,SAAA;IAAAY,GAAA;IAAAC,KAAA,EAOE,SAAAP,MAAOO,KAAK,EAAE;MACZ,IAAIpB,MAAM,CAACoB,KAAK,CAAC,EAAE;QACjBb,SAAS,CAACS,aAAa,CAACI,KAAK,CAAC;QAC9B,IAAI,CAACH,MAAM,GAAGG,KAAK;MACpB;MACD,OAAO,IAAI,CAACH,MAAM;IACnB;;IAEH;AACA;AACA;AACA;EAHA;IAAAE,GAAA;IAAAC,KAAA,EAKE,SAAAC,QAAA,EAAW;MACT,iBAAAC,MAAA,CAAiB,IAAI,CAACL,MAAM;IAC7B;EAAA;IAAAE,GAAA;IAAAI,GAAA;IAvDH;AACA;AACA;AACA;;IAEE,SAAAA,IAAA,EAAqB;MACnB,OAAOrB,eAAe;IACvB;;IAEH;AACA;AACA;AACA;AACA;AACA;EALA;IAAAiB,GAAA;IAAAC,KAAA,EAOE,SAAAJ,cAAsBI,KAAK,EAAE;MAC3B,IAAI,CAAClB,eAAe,CAACkB,KAAK,CAAC,EAAE;QAC3B,MAAM,IAAII,KAAK,mBAAAF,MAAA,CAAmBF,KAAK,CAAE,CAAC;MAC3C;IACF;EAAA;EAAA,OAAAb,SAAA;AAAA;"} -------------------------------------------------------------------------------- /dist/index.iife.js: -------------------------------------------------------------------------------- 1 | var index = (function (exports) { 2 | 'use strict'; 3 | 4 | function _classCallCheck(instance, Constructor) { 5 | if (!(instance instanceof Constructor)) { 6 | throw new TypeError("Cannot call a class as a function"); 7 | } 8 | } 9 | function _defineProperties(target, props) { 10 | for (var i = 0; i < props.length; i++) { 11 | var descriptor = props[i]; 12 | descriptor.enumerable = descriptor.enumerable || false; 13 | descriptor.configurable = true; 14 | if ("value" in descriptor) descriptor.writable = true; 15 | Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); 16 | } 17 | } 18 | function _createClass(Constructor, protoProps, staticProps) { 19 | if (protoProps) _defineProperties(Constructor.prototype, protoProps); 20 | if (staticProps) _defineProperties(Constructor, staticProps); 21 | Object.defineProperty(Constructor, "prototype", { 22 | writable: false 23 | }); 24 | return Constructor; 25 | } 26 | function _toPrimitive(input, hint) { 27 | if (typeof input !== "object" || input === null) return input; 28 | var prim = input[Symbol.toPrimitive]; 29 | if (prim !== undefined) { 30 | var res = prim.call(input, hint || "default"); 31 | if (typeof res !== "object") return res; 32 | throw new TypeError("@@toPrimitive must return a primitive value."); 33 | } 34 | return (hint === "string" ? String : Number)(input); 35 | } 36 | function _toPropertyKey(arg) { 37 | var key = _toPrimitive(arg, "string"); 38 | return typeof key === "symbol" ? key : String(key); 39 | } 40 | 41 | /** 42 | * Returns true of a given parameter is not null and not undefined. 43 | * @param any any input is feasible 44 | * @return {boolean} true if defined, otherwise false 45 | */ 46 | var exists = function exists(any) { 47 | return any !== null && typeof any !== 'undefined'; 48 | }; 49 | 50 | /** 51 | * The possible states of the supertool. 52 | * @private 53 | */ 54 | var superToolStates = { 55 | great: 'great', 56 | cool: 'cool', 57 | awesome: 'awesome', 58 | swag: 'swag' 59 | }; 60 | 61 | /** 62 | * The super tool class. Holds a state and implements the execute command. 63 | */ 64 | var SuperTool = /*#__PURE__*/function () { 65 | /** 66 | * Constructor initializes the state. If none is given, it defaults to {'great'}. 67 | * @param state one of the SuperTool.state values 68 | * @throws if state is not a valid state 69 | */ 70 | 71 | function SuperTool() { 72 | var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, 73 | _ref$state = _ref.state, 74 | state = _ref$state === void 0 ? SuperTool.states.great : _ref$state; 75 | _classCallCheck(this, SuperTool); 76 | SuperTool.validateState(state); 77 | this._state = state; 78 | } 79 | 80 | /** 81 | * Validates and sets a new state value if given and returns the updated value. If no defined value is given it just returns the 82 | * current state value. 83 | * @param value {String|undefined} optional state to be set. 84 | * @return {String} the current state value 85 | */ 86 | _createClass(SuperTool, [{ 87 | key: "state", 88 | value: function state(value) { 89 | if (exists(value)) { 90 | SuperTool.validateState(value); 91 | this._state = value; 92 | } 93 | return this._state; 94 | } 95 | 96 | /** 97 | * Executes with the current internal state. 98 | * @return {string} the execution including the current state. 99 | */ 100 | }, { 101 | key: "execute", 102 | value: function execute() { 103 | return "I feel ".concat(this._state, "!"); 104 | } 105 | }], [{ 106 | key: "states", 107 | get: 108 | /** 109 | * The possible states of the SuperTool. 110 | * @return {{great: string, cool: string, awesome: string, swag: string}} 111 | */ 112 | 113 | function get() { 114 | return superToolStates; 115 | } 116 | 117 | /** 118 | * Validates a state. To be valid, the value needs to be part of the {SuperTool.states}. 119 | * Throws an Error if invalid. Returns void / undefined if passed. 120 | * @param value The state candidate to be validated. 121 | * @throws if state is not a valid state 122 | */ 123 | }, { 124 | key: "validateState", 125 | value: function validateState(value) { 126 | if (!superToolStates[value]) { 127 | throw new Error("Invalid state: ".concat(value)); 128 | } 129 | } 130 | }]); 131 | return SuperTool; 132 | }(); 133 | 134 | exports.SuperTool = SuperTool; 135 | 136 | return exports; 137 | 138 | })({}); 139 | //# sourceMappingURL=index.iife.js.map 140 | -------------------------------------------------------------------------------- /dist/index.iife.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.iife.js","sources":["../lib/utils.js","../lib/SuperTool.js"],"sourcesContent":["/**\n * Returns true of a given parameter is not null and not undefined.\n * @param any any input is feasible\n * @return {boolean} true if defined, otherwise false\n */\nexport const exists = any => any !== null && typeof any !== 'undefined'\n\n/**\n * This should be removed by rollup's tree shaking\n * @private\n */\nexport const ignore = () => {}\n","import { exists } from './utils.js'\n\n/**\n * The possible states of the supertool.\n * @private\n */\nconst superToolStates = {\n great: 'great',\n cool: 'cool',\n awesome: 'awesome',\n swag: 'swag'\n}\n\n/**\n * The super tool class. Holds a state and implements the execute command.\n */\n\nclass SuperTool {\n /**\n * The possible states of the SuperTool.\n * @return {{great: string, cool: string, awesome: string, swag: string}}\n */\n\n static get states () {\n return superToolStates\n }\n\n /**\n * Validates a state. To be valid, the value needs to be part of the {SuperTool.states}.\n * Throws an Error if invalid. Returns void / undefined if passed.\n * @param value The state candidate to be validated.\n * @throws if state is not a valid state\n */\n\n static validateState (value) {\n if (!superToolStates[value]) {\n throw new Error(`Invalid state: ${value}`)\n }\n }\n\n /**\n * Constructor initializes the state. If none is given, it defaults to {'great'}.\n * @param state one of the SuperTool.state values\n * @throws if state is not a valid state\n */\n\n constructor ({ state = SuperTool.states.great } = {}) {\n SuperTool.validateState(state)\n this._state = state\n }\n\n /**\n * Validates and sets a new state value if given and returns the updated value. If no defined value is given it just returns the\n * current state value.\n * @param value {String|undefined} optional state to be set.\n * @return {String} the current state value\n */\n\n state (value) {\n if (exists(value)) {\n SuperTool.validateState(value)\n this._state = value\n }\n return this._state\n }\n\n /**\n * Executes with the current internal state.\n * @return {string} the execution including the current state.\n */\n\n execute () {\n return `I feel ${this._state}!`\n }\n}\n\nexport default SuperTool\n"],"names":["exists","any","superToolStates","great","cool","awesome","swag","SuperTool","_ref","arguments","length","undefined","_ref$state","state","states","_classCallCheck","validateState","_state","_createClass","key","value","execute","concat","get","Error"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAA;EACA;EACA;EACA;EACA;EACO,IAAMA,MAAM,GAAG,SAATA,MAAMA,CAAGC,GAAG,EAAA;EAAA,EAAA,OAAIA,GAAG,KAAK,IAAI,IAAI,OAAOA,GAAG,KAAK,WAAW,CAAA;EAAA,CAAA;;ECHvE;EACA;EACA;EACA;EACA,IAAMC,eAAe,GAAG;EACtBC,EAAAA,KAAK,EAAE,OAAO;EACdC,EAAAA,IAAI,EAAE,MAAM;EACZC,EAAAA,OAAO,EAAE,SAAS;EAClBC,EAAAA,IAAI,EAAE,MAAA;EACR,CAAC,CAAA;;EAED;EACA;EACA;AAFA,MAIMC,SAAS,gBAAA,YAAA;EAuBb;EACF;EACA;EACA;EACA;;EAEE,EAAA,SAAAA,YAAsD;EAAA,IAAA,IAAAC,IAAA,GAAAC,SAAA,CAAAC,MAAA,GAAA,CAAA,IAAAD,SAAA,CAAA,CAAA,CAAA,KAAAE,SAAA,GAAAF,SAAA,CAAA,CAAA,CAAA,GAAJ,EAAE;QAAAG,UAAA,GAAAJ,IAAA,CAArCK,KAAK;QAALA,KAAK,GAAAD,UAAA,KAAGL,KAAAA,CAAAA,GAAAA,SAAS,CAACO,MAAM,CAACX,KAAK,GAAAS,UAAA,CAAA;EAAAG,IAAAA,eAAA,OAAAR,SAAA,CAAA,CAAA;EAC3CA,IAAAA,SAAS,CAACS,aAAa,CAACH,KAAK,CAAC,CAAA;MAC9B,IAAI,CAACI,MAAM,GAAGJ,KAAK,CAAA;EACrB,GAAA;;EAEA;EACF;EACA;EACA;EACA;EACA;EALEK,EAAAA,YAAA,CAAAX,SAAA,EAAA,CAAA;MAAAY,GAAA,EAAA,OAAA;EAAAC,IAAAA,KAAA,EAOA,SAAAP,KAAOO,CAAAA,KAAK,EAAE;EACZ,MAAA,IAAIpB,MAAM,CAACoB,KAAK,CAAC,EAAE;EACjBb,QAAAA,SAAS,CAACS,aAAa,CAACI,KAAK,CAAC,CAAA;UAC9B,IAAI,CAACH,MAAM,GAAGG,KAAK,CAAA;EACrB,OAAA;QACA,OAAO,IAAI,CAACH,MAAM,CAAA;EACpB,KAAA;;EAEA;EACF;EACA;EACA;EAHE,GAAA,EAAA;MAAAE,GAAA,EAAA,SAAA;MAAAC,KAAA,EAKA,SAAAC,OAAAA,GAAW;EACT,MAAA,OAAA,SAAA,CAAAC,MAAA,CAAiB,IAAI,CAACL,MAAM,EAAA,GAAA,CAAA,CAAA;EAC9B,KAAA;EAAC,GAAA,CAAA,EAAA,CAAA;MAAAE,GAAA,EAAA,QAAA;MAAAI,GAAA;EAvDD;EACF;EACA;EACA;;EAEE,IAAA,SAAAA,MAAqB;EACnB,MAAA,OAAOrB,eAAe,CAAA;EACxB,KAAA;;EAEA;EACF;EACA;EACA;EACA;EACA;EALE,GAAA,EAAA;MAAAiB,GAAA,EAAA,eAAA;EAAAC,IAAAA,KAAA,EAOA,SAAAJ,aAAsBI,CAAAA,KAAK,EAAE;EAC3B,MAAA,IAAI,CAAClB,eAAe,CAACkB,KAAK,CAAC,EAAE;EAC3B,QAAA,MAAM,IAAII,KAAK,CAAA,iBAAA,CAAAF,MAAA,CAAmBF,KAAK,CAAE,CAAC,CAAA;EAC5C,OAAA;EACF,KAAA;EAAC,GAAA,CAAA,CAAA,CAAA;EAAA,EAAA,OAAAb,SAAA,CAAA;EAAA,CAAA;;;;;;;;;;"} -------------------------------------------------------------------------------- /dist/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Returns true of a given parameter is not null and not undefined. 3 | * @param any any input is feasible 4 | * @return {boolean} true if defined, otherwise false 5 | */ 6 | const exists = any => any !== null && typeof any !== 'undefined'; 7 | 8 | /** 9 | * The possible states of the supertool. 10 | * @private 11 | */ 12 | const superToolStates = { 13 | great: 'great', 14 | cool: 'cool', 15 | awesome: 'awesome', 16 | swag: 'swag' 17 | }; 18 | 19 | /** 20 | * The super tool class. Holds a state and implements the execute command. 21 | */ 22 | 23 | class SuperTool { 24 | /** 25 | * The possible states of the SuperTool. 26 | * @return {{great: string, cool: string, awesome: string, swag: string}} 27 | */ 28 | 29 | static get states () { 30 | return superToolStates 31 | } 32 | 33 | /** 34 | * Validates a state. To be valid, the value needs to be part of the {SuperTool.states}. 35 | * Throws an Error if invalid. Returns void / undefined if passed. 36 | * @param value The state candidate to be validated. 37 | * @throws if state is not a valid state 38 | */ 39 | 40 | static validateState (value) { 41 | if (!superToolStates[value]) { 42 | throw new Error(`Invalid state: ${value}`) 43 | } 44 | } 45 | 46 | /** 47 | * Constructor initializes the state. If none is given, it defaults to {'great'}. 48 | * @param state one of the SuperTool.state values 49 | * @throws if state is not a valid state 50 | */ 51 | 52 | constructor ({ state = SuperTool.states.great } = {}) { 53 | SuperTool.validateState(state); 54 | this._state = state; 55 | } 56 | 57 | /** 58 | * Validates and sets a new state value if given and returns the updated value. If no defined value is given it just returns the 59 | * current state value. 60 | * @param value {String|undefined} optional state to be set. 61 | * @return {String} the current state value 62 | */ 63 | 64 | state (value) { 65 | if (exists(value)) { 66 | SuperTool.validateState(value); 67 | this._state = value; 68 | } 69 | return this._state 70 | } 71 | 72 | /** 73 | * Executes with the current internal state. 74 | * @return {string} the execution including the current state. 75 | */ 76 | 77 | execute () { 78 | return `I feel ${this._state}!` 79 | } 80 | } 81 | 82 | export { SuperTool }; 83 | //# sourceMappingURL=index.js.map 84 | -------------------------------------------------------------------------------- /dist/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sources":["../lib/utils.js","../lib/SuperTool.js"],"sourcesContent":["/**\n * Returns true of a given parameter is not null and not undefined.\n * @param any any input is feasible\n * @return {boolean} true if defined, otherwise false\n */\nexport const exists = any => any !== null && typeof any !== 'undefined'\n\n/**\n * This should be removed by rollup's tree shaking\n * @private\n */\nexport const ignore = () => {}\n","import { exists } from './utils.js'\n\n/**\n * The possible states of the supertool.\n * @private\n */\nconst superToolStates = {\n great: 'great',\n cool: 'cool',\n awesome: 'awesome',\n swag: 'swag'\n}\n\n/**\n * The super tool class. Holds a state and implements the execute command.\n */\n\nclass SuperTool {\n /**\n * The possible states of the SuperTool.\n * @return {{great: string, cool: string, awesome: string, swag: string}}\n */\n\n static get states () {\n return superToolStates\n }\n\n /**\n * Validates a state. To be valid, the value needs to be part of the {SuperTool.states}.\n * Throws an Error if invalid. Returns void / undefined if passed.\n * @param value The state candidate to be validated.\n * @throws if state is not a valid state\n */\n\n static validateState (value) {\n if (!superToolStates[value]) {\n throw new Error(`Invalid state: ${value}`)\n }\n }\n\n /**\n * Constructor initializes the state. If none is given, it defaults to {'great'}.\n * @param state one of the SuperTool.state values\n * @throws if state is not a valid state\n */\n\n constructor ({ state = SuperTool.states.great } = {}) {\n SuperTool.validateState(state)\n this._state = state\n }\n\n /**\n * Validates and sets a new state value if given and returns the updated value. If no defined value is given it just returns the\n * current state value.\n * @param value {String|undefined} optional state to be set.\n * @return {String} the current state value\n */\n\n state (value) {\n if (exists(value)) {\n SuperTool.validateState(value)\n this._state = value\n }\n return this._state\n }\n\n /**\n * Executes with the current internal state.\n * @return {string} the execution including the current state.\n */\n\n execute () {\n return `I feel ${this._state}!`\n }\n}\n\nexport default SuperTool\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACO,MAAM,MAAM,GAAG,GAAG,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK;;ACH5D;AACA;AACA;AACA;AACA,MAAM,eAAe,GAAG;AACxB,EAAE,KAAK,EAAE,OAAO;AAChB,EAAE,IAAI,EAAE,MAAM;AACd,EAAE,OAAO,EAAE,SAAS;AACpB,EAAE,IAAI,EAAE,MAAM;AACd,EAAC;AACD;AACA;AACA;AACA;AACA;AACA,MAAM,SAAS,CAAC;AAChB;AACA;AACA;AACA;AACA;AACA,EAAE,WAAW,MAAM,CAAC,GAAG;AACvB,IAAI,OAAO,eAAe;AAC1B,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE,OAAO,aAAa,CAAC,CAAC,KAAK,EAAE;AAC/B,IAAI,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE;AACjC,MAAM,MAAM,IAAI,KAAK,CAAC,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC,CAAC;AAChD,KAAK;AACL,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE,WAAW,CAAC,CAAC,EAAE,KAAK,GAAG,SAAS,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;AACxD,IAAI,SAAS,CAAC,aAAa,CAAC,KAAK,EAAC;AAClC,IAAI,IAAI,CAAC,MAAM,GAAG,MAAK;AACvB,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE,KAAK,CAAC,CAAC,KAAK,EAAE;AAChB,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE;AACvB,MAAM,SAAS,CAAC,aAAa,CAAC,KAAK,EAAC;AACpC,MAAM,IAAI,CAAC,MAAM,GAAG,MAAK;AACzB,KAAK;AACL,IAAI,OAAO,IAAI,CAAC,MAAM;AACtB,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA,EAAE,OAAO,CAAC,GAAG;AACb,IAAI,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;AACnC,GAAG;AACH;;;;"} -------------------------------------------------------------------------------- /docs/SuperTool.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Class: SuperTool 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Class: SuperTool

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 |
30 | 31 |

SuperTool(state)

32 | 33 |
The super tool class. Holds a state and implements the execute command.
34 | 35 | 36 |
37 | 38 |
39 |
40 | 41 | 42 | 43 | 44 |

Constructor

45 | 46 | 47 | 48 |

new SuperTool(state)

49 | 50 | 51 | 52 | 53 | 54 | 55 |
56 | Constructor initializes the state. If none is given, it defaults to {'great'}. 57 |
58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 |
Parameters:
68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 |
NameTypeDescription
state 96 | 97 | one of the SuperTool.state values
109 | 110 | 111 | 112 | 113 | 114 | 115 |
116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 |
Source:
143 |
146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 |
154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 |
Throws:
168 | 169 | 170 | 171 |
172 | 173 | if state is not a valid state 174 | 175 |
176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 |
188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 |

Members

203 | 204 | 205 | 206 |

(static) states

207 | 208 | 209 | 210 | 211 |
212 | The possible states of the SuperTool. 213 |
214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 |
222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 |
Source:
249 |
252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 |
260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 |

Methods

271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 |

(static) validateState(value)

279 | 280 | 281 | 282 | 283 | 284 | 285 |
286 | Validates a state. To be valid, the value needs to be part of the {SuperTool.states}. 287 | Throws an Error if invalid. Returns void / undefined if passed. 288 |
289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 |
Parameters:
299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 |
NameTypeDescription
value 327 | 328 | The state candidate to be validated.
340 | 341 | 342 | 343 | 344 | 345 | 346 |
347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 |
Source:
374 |
377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 |
385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 |
Throws:
399 | 400 | 401 | 402 |
403 | 404 | if state is not a valid state 405 | 406 |
407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 |

execute() → {string}

424 | 425 | 426 | 427 | 428 | 429 | 430 |
431 | Executes with the current internal state. 432 |
433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 |
447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 |
Source:
474 |
477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 |
485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 |
Returns:
501 | 502 | 503 |
504 | the execution including the current state. 505 |
506 | 507 | 508 | 509 |
510 |
511 | Type 512 |
513 |
514 | 515 | string 516 | 517 | 518 |
519 |
520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 |

state(value) → {String}

534 | 535 | 536 | 537 | 538 | 539 | 540 |
541 | Validates and sets a new state value if given and returns the updated value. If no defined value is given it just returns the 542 | current state value. 543 |
544 | 545 | 546 | 547 | 548 | 549 | 550 | 551 | 552 | 553 |
Parameters:
554 | 555 | 556 | 557 | 558 | 559 | 560 | 561 | 562 | 563 | 564 | 565 | 566 | 567 | 568 | 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 578 | 579 | 580 | 581 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | 602 |
NameTypeDescription
value 582 | 583 | 584 | String 585 | | 586 | 587 | undefined 588 | 589 | 590 | 591 | optional state to be set.
603 | 604 | 605 | 606 | 607 | 608 | 609 |
610 | 611 | 612 | 613 | 614 | 615 | 616 | 617 | 618 | 619 | 620 | 621 | 622 | 623 | 624 | 625 | 626 | 627 | 628 | 629 | 630 | 631 | 632 | 633 | 634 | 635 | 636 |
Source:
637 |
640 | 641 | 642 | 643 | 644 | 645 | 646 | 647 |
648 | 649 | 650 | 651 | 652 | 653 | 654 | 655 | 656 | 657 | 658 | 659 | 660 | 661 | 662 | 663 |
Returns:
664 | 665 | 666 |
667 | the current state value 668 |
669 | 670 | 671 | 672 |
673 |
674 | Type 675 |
676 |
677 | 678 | String 679 | 680 | 681 |
682 |
683 | 684 | 685 | 686 | 687 | 688 | 689 | 690 | 691 | 692 | 693 | 694 | 695 | 696 |
697 | 698 |
699 | 700 | 701 | 702 | 703 |
704 | 705 | 708 | 709 |
710 | 711 |
712 | Documentation generated by JSDoc 3.6.11 on Mon Oct 03 2022 18:30:00 GMT+0100 (Central European Standard Time) 713 |
714 | 715 | 716 | 717 | 718 | -------------------------------------------------------------------------------- /docs/SuperTool.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Source: SuperTool.js 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Source: SuperTool.js

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |
29 |
import { exists } from './utils'
 30 | 
 31 | /**
 32 |  * The possible states of the supertool.
 33 |  * @private
 34 |  */
 35 | const superToolStates = {
 36 |   great: 'great',
 37 |   cool: 'cool',
 38 |   awesome: 'awesome',
 39 |   swag: 'swag'
 40 | }
 41 | 
 42 | /**
 43 |  * The super tool class. Holds a state and implements the execute command.
 44 |  */
 45 | 
 46 | class SuperTool {
 47 |   /**
 48 |    * The possible states of the SuperTool.
 49 |    * @return {{great: string, cool: string, awesome: string, swag: string}}
 50 |    */
 51 | 
 52 |   static get states () {
 53 |     return superToolStates
 54 |   }
 55 | 
 56 |   /**
 57 |    * Validates a state. To be valid, the value needs to be part of the {SuperTool.states}.
 58 |    * Throws an Error if invalid. Returns void / undefined if passed.
 59 |    * @param value The state candidate to be validated.
 60 |    * @throws if state is not a valid state
 61 |    */
 62 | 
 63 |   static validateState (value) {
 64 |     if (!superToolStates[value]) {
 65 |       throw new Error(`Invalid state: ${value}`)
 66 |     }
 67 |   }
 68 | 
 69 |   /**
 70 |    * Constructor initializes the state. If none is given, it defaults to {'great'}.
 71 |    * @param state one of the SuperTool.state values
 72 |    * @throws if state is not a valid state
 73 |    */
 74 | 
 75 |   constructor ({ state = SuperTool.states.great } = {}) {
 76 |     SuperTool.validateState(state)
 77 |     this._state = state
 78 |   }
 79 | 
 80 |   /**
 81 |    * Validates and sets a new state value if given and returns the updated value. If no defined value is given it just returns the
 82 |    * current state value.
 83 |    * @param value {String|undefined} optional state to be set.
 84 |    * @return {String} the current state value
 85 |    */
 86 | 
 87 |   state (value) {
 88 |     if (exists(value)) {
 89 |       SuperTool.validateState(value)
 90 |       this._state = value
 91 |     }
 92 |     return this._state
 93 |   }
 94 | 
 95 |   /**
 96 |    * Executes with the current internal state.
 97 |    * @return {string} the execution including the current state.
 98 |    */
 99 | 
100 |   execute () {
101 |     return `I feel ${this._state}!`
102 |   }
103 | }
104 | 
105 | export default SuperTool
106 | 
107 |
108 |
109 | 110 | 111 | 112 | 113 |
114 | 115 | 118 | 119 |
120 | 121 |
122 | Documentation generated by JSDoc 3.6.11 on Mon Oct 03 2022 18:30:00 GMT+0100 (Central European Standard Time) 123 |
124 | 125 | 126 | 127 | 128 | 129 | -------------------------------------------------------------------------------- /docs/fonts/OpenSans-Bold-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jankapunkt/npm-package-template/a354fd40717f89bd493c8b864d75400206668505/docs/fonts/OpenSans-Bold-webfont.eot -------------------------------------------------------------------------------- /docs/fonts/OpenSans-Bold-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jankapunkt/npm-package-template/a354fd40717f89bd493c8b864d75400206668505/docs/fonts/OpenSans-Bold-webfont.woff -------------------------------------------------------------------------------- /docs/fonts/OpenSans-BoldItalic-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jankapunkt/npm-package-template/a354fd40717f89bd493c8b864d75400206668505/docs/fonts/OpenSans-BoldItalic-webfont.eot -------------------------------------------------------------------------------- /docs/fonts/OpenSans-BoldItalic-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jankapunkt/npm-package-template/a354fd40717f89bd493c8b864d75400206668505/docs/fonts/OpenSans-BoldItalic-webfont.woff -------------------------------------------------------------------------------- /docs/fonts/OpenSans-Italic-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jankapunkt/npm-package-template/a354fd40717f89bd493c8b864d75400206668505/docs/fonts/OpenSans-Italic-webfont.eot -------------------------------------------------------------------------------- /docs/fonts/OpenSans-Italic-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jankapunkt/npm-package-template/a354fd40717f89bd493c8b864d75400206668505/docs/fonts/OpenSans-Italic-webfont.woff -------------------------------------------------------------------------------- /docs/fonts/OpenSans-Light-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jankapunkt/npm-package-template/a354fd40717f89bd493c8b864d75400206668505/docs/fonts/OpenSans-Light-webfont.eot -------------------------------------------------------------------------------- /docs/fonts/OpenSans-Light-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jankapunkt/npm-package-template/a354fd40717f89bd493c8b864d75400206668505/docs/fonts/OpenSans-Light-webfont.woff -------------------------------------------------------------------------------- /docs/fonts/OpenSans-LightItalic-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jankapunkt/npm-package-template/a354fd40717f89bd493c8b864d75400206668505/docs/fonts/OpenSans-LightItalic-webfont.eot -------------------------------------------------------------------------------- /docs/fonts/OpenSans-LightItalic-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jankapunkt/npm-package-template/a354fd40717f89bd493c8b864d75400206668505/docs/fonts/OpenSans-LightItalic-webfont.woff -------------------------------------------------------------------------------- /docs/fonts/OpenSans-Regular-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jankapunkt/npm-package-template/a354fd40717f89bd493c8b864d75400206668505/docs/fonts/OpenSans-Regular-webfont.eot -------------------------------------------------------------------------------- /docs/fonts/OpenSans-Regular-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jankapunkt/npm-package-template/a354fd40717f89bd493c8b864d75400206668505/docs/fonts/OpenSans-Regular-webfont.woff -------------------------------------------------------------------------------- /docs/global.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Global 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Global

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 |
30 | 31 |

32 | 33 | 34 |
35 | 36 |
37 |
38 | 39 | 40 | 41 | 42 | 43 | 44 |
45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 |
78 | 79 | 80 | 81 | 82 |
83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 |

Members

98 | 99 | 100 | 101 |

(constant) exists

102 | 103 | 104 | 105 | 106 |
107 | Returns true of a given parameter is not null and not undefined. 108 |
109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 |
117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 |
Source:
144 |
147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 |
155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 |
170 | 171 |
172 | 173 | 174 | 175 | 176 |
177 | 178 | 181 | 182 |
183 | 184 |
185 | Documentation generated by JSDoc 3.6.11 on Mon Oct 03 2022 18:30:00 GMT+0100 (Central European Standard Time) 186 |
187 | 188 | 189 | 190 | 191 | -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Home 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Home

21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 |

30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 |
46 |

:package: NPM Package Template :package:

47 |

Test suite 48 | Build Status 49 | JavaScript Style Guide 50 | Project Status: Active – The project has reached a stable, usable state and is being actively developed. 51 | GitHub

52 |

Minimal tested and fully functional NPM package template project for ES6+ Javascript.

53 |

About this package

54 |

This template is intended to allow you to start developing immediatly with a working set 55 | of tools and scripts that play well together.

56 |

It is little opinionated to the point, that only the most basic tools are integrated. 57 | If you want a different flavour you can fork this project and easily replace the tools or add new ones.

58 |

Which tools are used?

59 |

All tools are only defined as dev-dependencies:

60 | 69 |

Getting started

70 |

Just create your Js files in the ./lib folder and add the tests in the test folder.

71 |

Code Quality

72 |

We use standard as opinionated but zero-config linter. 73 | You can run lint in two modes:

74 |
lint
75 |
$ npm run lint
 76 | 
77 |
lint with auto fixing
78 |
$ npm run lint:fix
 79 | 
80 |

Run the tests

81 |

We use mocha and chai with a mostly (but not strict) behavioural style for testing. 82 | You can run the tests in three different contexts:

83 |
Single run
84 |
$ npm run test
 85 | 
86 |
Watch mode
87 |
$ npm run test:watch
 88 | 
89 |
Coverage
90 |
$ npm run test:coverage
 91 | 
92 |

Documentation

93 |

Documentation is using jsDoc and is available as html or markdown version.

94 |

To build the documentation in development, you need to run

95 |
$ npm run docs
 96 | 
97 |

License

98 |

MIT, see license file

99 |
100 | 101 | 102 | 103 | 104 | 105 | 106 |
107 | 108 | 111 | 112 |
113 | 114 |
115 | Documentation generated by JSDoc 3.6.11 on Mon Oct 03 2022 18:30:00 GMT+0100 (Central European Standard Time) 116 |
117 | 118 | 119 | 120 | 121 | -------------------------------------------------------------------------------- /docs/scripts/linenumber.js: -------------------------------------------------------------------------------- 1 | /*global document */ 2 | (() => { 3 | const source = document.getElementsByClassName('prettyprint source linenums'); 4 | let i = 0; 5 | let lineNumber = 0; 6 | let lineId; 7 | let lines; 8 | let totalLines; 9 | let anchorHash; 10 | 11 | if (source && source[0]) { 12 | anchorHash = document.location.hash.substring(1); 13 | lines = source[0].getElementsByTagName('li'); 14 | totalLines = lines.length; 15 | 16 | for (; i < totalLines; i++) { 17 | lineNumber++; 18 | lineId = `line${lineNumber}`; 19 | lines[i].id = lineId; 20 | if (lineId === anchorHash) { 21 | lines[i].className += ' selected'; 22 | } 23 | } 24 | } 25 | })(); 26 | -------------------------------------------------------------------------------- /docs/scripts/prettify/Apache-License-2.0.txt: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /docs/scripts/prettify/lang-css.js: -------------------------------------------------------------------------------- 1 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\f\r ]+/,null," \t\r\n "]],[["str",/^"(?:[^\n\f\r"\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*"/,null],["str",/^'(?:[^\n\f\r'\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*'/,null],["lang-css-str",/^url\(([^"')]*)\)/i],["kwd",/^(?:url|rgb|!important|@import|@page|@media|@charset|inherit)(?=[^\w-]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*)\s*:/i],["com",/^\/\*[^*]*\*+(?:[^*/][^*]*\*+)*\//],["com", 2 | /^(?:<\!--|--\>)/],["lit",/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],["lit",/^#[\da-f]{3,6}/i],["pln",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i],["pun",/^[^\s\w"']+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[["kwd",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[["str",/^[^"')]+/]]),["css-str"]); 3 | -------------------------------------------------------------------------------- /docs/scripts/prettify/prettify.js: -------------------------------------------------------------------------------- 1 | var q=null;window.PR_SHOULD_USE_CONTINUATION=!0; 2 | (function(){function L(a){function m(a){var f=a.charCodeAt(0);if(f!==92)return f;var b=a.charAt(1);return(f=r[b])?f:"0"<=b&&b<="7"?parseInt(a.substring(1),8):b==="u"||b==="x"?parseInt(a.substring(2),16):a.charCodeAt(1)}function e(a){if(a<32)return(a<16?"\\x0":"\\x")+a.toString(16);a=String.fromCharCode(a);if(a==="\\"||a==="-"||a==="["||a==="]")a="\\"+a;return a}function h(a){for(var f=a.substring(1,a.length-1).match(/\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\[0-3][0-7]{0,2}|\\[0-7]{1,2}|\\[\S\s]|[^\\]/g),a= 3 | [],b=[],o=f[0]==="^",c=o?1:0,i=f.length;c122||(d<65||j>90||b.push([Math.max(65,j)|32,Math.min(d,90)|32]),d<97||j>122||b.push([Math.max(97,j)&-33,Math.min(d,122)&-33]))}}b.sort(function(a,f){return a[0]-f[0]||f[1]-a[1]});f=[];j=[NaN,NaN];for(c=0;ci[0]&&(i[1]+1>i[0]&&b.push("-"),b.push(e(i[1])));b.push("]");return b.join("")}function y(a){for(var f=a.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),b=f.length,d=[],c=0,i=0;c=2&&a==="["?f[c]=h(j):a!=="\\"&&(f[c]=j.replace(/[A-Za-z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return f.join("")}for(var t=0,s=!1,l=!1,p=0,d=a.length;p=5&&"lang-"===b.substring(0,5))&&!(o&&typeof o[1]==="string"))c=!1,b="src";c||(r[f]=b)}i=d;d+=f.length;if(c){c=o[1];var j=f.indexOf(c),k=j+c.length;o[2]&&(k=f.length-o[2].length,j=k-c.length);b=b.substring(5);B(l+i,f.substring(0,j),e,p);B(l+i+j,c,C(b,c),p);B(l+i+k,f.substring(k),e,p)}else p.push(l+i,b)}a.e=p}var h={},y;(function(){for(var e=a.concat(m), 9 | l=[],p={},d=0,g=e.length;d=0;)h[n.charAt(k)]=r;r=r[1];n=""+r;p.hasOwnProperty(n)||(l.push(r),p[n]=q)}l.push(/[\S\s]/);y=L(l)})();var t=m.length;return e}function u(a){var m=[],e=[];a.tripleQuotedStrings?m.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/,q,"'\""]):a.multiLineStrings?m.push(["str",/^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/, 10 | q,"'\"`"]):m.push(["str",/^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,q,"\"'"]);a.verbatimStrings&&e.push(["str",/^@"(?:[^"]|"")*(?:"|$)/,q]);var h=a.hashComments;h&&(a.cStyleComments?(h>1?m.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,q,"#"]):m.push(["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\n\r]*)/,q,"#"]),e.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,q])):m.push(["com",/^#[^\n\r]*/, 11 | q,"#"]));a.cStyleComments&&(e.push(["com",/^\/\/[^\n\r]*/,q]),e.push(["com",/^\/\*[\S\s]*?(?:\*\/|$)/,q]));a.regexLiterals&&e.push(["lang-regex",/^(?:^^\.?|[!+-]|!=|!==|#|%|%=|&|&&|&&=|&=|\(|\*|\*=|\+=|,|-=|->|\/|\/=|:|::|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|[?@[^]|\^=|\^\^|\^\^=|{|\||\|=|\|\||\|\|=|~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\s*(\/(?=[^*/])(?:[^/[\\]|\\[\S\s]|\[(?:[^\\\]]|\\[\S\s])*(?:]|$))+\/)/]);(h=a.types)&&e.push(["typ",h]);a=(""+a.keywords).replace(/^ | $/g, 12 | "");a.length&&e.push(["kwd",RegExp("^(?:"+a.replace(/[\s,]+/g,"|")+")\\b"),q]);m.push(["pln",/^\s+/,q," \r\n\t\xa0"]);e.push(["lit",/^@[$_a-z][\w$@]*/i,q],["typ",/^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,q],["pln",/^[$_a-z][\w$@]*/i,q],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,q,"0123456789"],["pln",/^\\[\S\s]?/,q],["pun",/^.[^\s\w"-$'./@\\`]*/,q]);return x(m,e)}function D(a,m){function e(a){switch(a.nodeType){case 1:if(k.test(a.className))break;if("BR"===a.nodeName)h(a), 13 | a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)e(a);break;case 3:case 4:if(p){var b=a.nodeValue,d=b.match(t);if(d){var c=b.substring(0,d.index);a.nodeValue=c;(b=b.substring(d.index+d[0].length))&&a.parentNode.insertBefore(s.createTextNode(b),a.nextSibling);h(a);c||a.parentNode.removeChild(a)}}}}function h(a){function b(a,d){var e=d?a.cloneNode(!1):a,f=a.parentNode;if(f){var f=b(f,1),g=a.nextSibling;f.appendChild(e);for(var h=g;h;h=g)g=h.nextSibling,f.appendChild(h)}return e} 14 | for(;!a.nextSibling;)if(a=a.parentNode,!a)return;for(var a=b(a.nextSibling,0),e;(e=a.parentNode)&&e.nodeType===1;)a=e;d.push(a)}var k=/(?:^|\s)nocode(?:\s|$)/,t=/\r\n?|\n/,s=a.ownerDocument,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=s.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);for(l=s.createElement("LI");a.firstChild;)l.appendChild(a.firstChild);for(var d=[l],g=0;g=0;){var h=m[e];A.hasOwnProperty(h)?window.console&&console.warn("cannot override language handler %s",h):A[h]=a}}function C(a,m){if(!a||!A.hasOwnProperty(a))a=/^\s*=o&&(h+=2);e>=c&&(a+=2)}}catch(w){"console"in window&&console.log(w&&w.stack?w.stack:w)}}var v=["break,continue,do,else,for,if,return,while"],w=[[v,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"], 18 | "catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],F=[w,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],G=[w,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"], 19 | H=[G,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"],w=[w,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"],I=[v,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"], 20 | J=[v,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],v=[v,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],K=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/,N=/\S/,O=u({keywords:[F,H,w,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END"+ 21 | I,J,v],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),A={};k(O,["default-code"]);k(x([],[["pln",/^[^]*(?:>|$)/],["com",/^<\!--[\S\s]*?(?:--\>|$)/],["lang-",/^<\?([\S\s]+?)(?:\?>|$)/],["lang-",/^<%([\S\s]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\S\s]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\S\s]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\S\s]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]), 22 | ["default-markup","htm","html","mxml","xhtml","xml","xsl"]);k(x([["pln",/^\s+/,q," \t\r\n"],["atv",/^(?:"[^"]*"?|'[^']*'?)/,q,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w-.:]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^\s"'>]*(?:[^\s"'/>]|\/(?=\s)))/],["pun",/^[/<->]+/],["lang-js",/^on\w+\s*=\s*"([^"]+)"/i],["lang-js",/^on\w+\s*=\s*'([^']+)'/i],["lang-js",/^on\w+\s*=\s*([^\s"'>]+)/i],["lang-css",/^style\s*=\s*"([^"]+)"/i],["lang-css",/^style\s*=\s*'([^']+)'/i],["lang-css", 23 | /^style\s*=\s*([^\s"'>]+)/i]]),["in.tag"]);k(x([],[["atv",/^[\S\s]+/]]),["uq.val"]);k(u({keywords:F,hashComments:!0,cStyleComments:!0,types:K}),["c","cc","cpp","cxx","cyc","m"]);k(u({keywords:"null,true,false"}),["json"]);k(u({keywords:H,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:K}),["cs"]);k(u({keywords:G,cStyleComments:!0}),["java"]);k(u({keywords:v,hashComments:!0,multiLineStrings:!0}),["bsh","csh","sh"]);k(u({keywords:I,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}), 24 | ["cv","py"]);k(u({keywords:"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["perl","pl","pm"]);k(u({keywords:J,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb"]);k(u({keywords:w,cStyleComments:!0,regexLiterals:!0}),["js"]);k(u({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes", 25 | hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]);k(x([],[["str",/^[\S\s]+/]]),["regex"]);window.prettyPrintOne=function(a,m,e){var h=document.createElement("PRE");h.innerHTML=a;e&&D(h,e);E({g:m,i:e,h:h});return h.innerHTML};window.prettyPrint=function(a){function m(){for(var e=window.PR_SHOULD_USE_CONTINUATION?l.now()+250:Infinity;p=0){var k=k.match(g),f,b;if(b= 26 | !k){b=n;for(var o=void 0,c=b.firstChild;c;c=c.nextSibling)var i=c.nodeType,o=i===1?o?b:c:i===3?N.test(c.nodeValue)?b:o:o;b=(f=o===b?void 0:o)&&"CODE"===f.tagName}b&&(k=f.className.match(g));k&&(k=k[1]);b=!1;for(o=n.parentNode;o;o=o.parentNode)if((o.tagName==="pre"||o.tagName==="code"||o.tagName==="xmp")&&o.className&&o.className.indexOf("prettyprint")>=0){b=!0;break}b||((b=(b=n.className.match(/\blinenums\b(?::(\d+))?/))?b[1]&&b[1].length?+b[1]:!0:!1)&&D(n,b),d={g:k,h:n,i:b},E(d))}}p th:last-child { border-right: 1px solid #ddd; } 224 | 225 | .ancestors, .attribs { color: #999; } 226 | .ancestors a, .attribs a 227 | { 228 | color: #999 !important; 229 | text-decoration: none; 230 | } 231 | 232 | .clear 233 | { 234 | clear: both; 235 | } 236 | 237 | .important 238 | { 239 | font-weight: bold; 240 | color: #950B02; 241 | } 242 | 243 | .yes-def { 244 | text-indent: -1000px; 245 | } 246 | 247 | .type-signature { 248 | color: #aaa; 249 | } 250 | 251 | .name, .signature { 252 | font-family: Consolas, Monaco, 'Andale Mono', monospace; 253 | } 254 | 255 | .details { margin-top: 14px; border-left: 2px solid #DDD; } 256 | .details dt { width: 120px; float: left; padding-left: 10px; padding-top: 6px; } 257 | .details dd { margin-left: 70px; } 258 | .details ul { margin: 0; } 259 | .details ul { list-style-type: none; } 260 | .details li { margin-left: 30px; padding-top: 6px; } 261 | .details pre.prettyprint { margin: 0 } 262 | .details .object-value { padding-top: 0; } 263 | 264 | .description { 265 | margin-bottom: 1em; 266 | margin-top: 1em; 267 | } 268 | 269 | .code-caption 270 | { 271 | font-style: italic; 272 | font-size: 107%; 273 | margin: 0; 274 | } 275 | 276 | .source 277 | { 278 | border: 1px solid #ddd; 279 | width: 80%; 280 | overflow: auto; 281 | } 282 | 283 | .prettyprint.source { 284 | width: inherit; 285 | } 286 | 287 | .source code 288 | { 289 | font-size: 100%; 290 | line-height: 18px; 291 | display: block; 292 | padding: 4px 12px; 293 | margin: 0; 294 | background-color: #fff; 295 | color: #4D4E53; 296 | } 297 | 298 | .prettyprint code span.line 299 | { 300 | display: inline-block; 301 | } 302 | 303 | .prettyprint.linenums 304 | { 305 | padding-left: 70px; 306 | -webkit-user-select: none; 307 | -moz-user-select: none; 308 | -ms-user-select: none; 309 | user-select: none; 310 | } 311 | 312 | .prettyprint.linenums ol 313 | { 314 | padding-left: 0; 315 | } 316 | 317 | .prettyprint.linenums li 318 | { 319 | border-left: 3px #ddd solid; 320 | } 321 | 322 | .prettyprint.linenums li.selected, 323 | .prettyprint.linenums li.selected * 324 | { 325 | background-color: lightyellow; 326 | } 327 | 328 | .prettyprint.linenums li * 329 | { 330 | -webkit-user-select: text; 331 | -moz-user-select: text; 332 | -ms-user-select: text; 333 | user-select: text; 334 | } 335 | 336 | .params .name, .props .name, .name code { 337 | color: #4D4E53; 338 | font-family: Consolas, Monaco, 'Andale Mono', monospace; 339 | font-size: 100%; 340 | } 341 | 342 | .params td.description > p:first-child, 343 | .props td.description > p:first-child 344 | { 345 | margin-top: 0; 346 | padding-top: 0; 347 | } 348 | 349 | .params td.description > p:last-child, 350 | .props td.description > p:last-child 351 | { 352 | margin-bottom: 0; 353 | padding-bottom: 0; 354 | } 355 | 356 | .disabled { 357 | color: #454545; 358 | } 359 | -------------------------------------------------------------------------------- /docs/styles/prettify-jsdoc.css: -------------------------------------------------------------------------------- 1 | /* JSDoc prettify.js theme */ 2 | 3 | /* plain text */ 4 | .pln { 5 | color: #000000; 6 | font-weight: normal; 7 | font-style: normal; 8 | } 9 | 10 | /* string content */ 11 | .str { 12 | color: #006400; 13 | font-weight: normal; 14 | font-style: normal; 15 | } 16 | 17 | /* a keyword */ 18 | .kwd { 19 | color: #000000; 20 | font-weight: bold; 21 | font-style: normal; 22 | } 23 | 24 | /* a comment */ 25 | .com { 26 | font-weight: normal; 27 | font-style: italic; 28 | } 29 | 30 | /* a type name */ 31 | .typ { 32 | color: #000000; 33 | font-weight: normal; 34 | font-style: normal; 35 | } 36 | 37 | /* a literal value */ 38 | .lit { 39 | color: #006400; 40 | font-weight: normal; 41 | font-style: normal; 42 | } 43 | 44 | /* punctuation */ 45 | .pun { 46 | color: #000000; 47 | font-weight: bold; 48 | font-style: normal; 49 | } 50 | 51 | /* lisp open bracket */ 52 | .opn { 53 | color: #000000; 54 | font-weight: bold; 55 | font-style: normal; 56 | } 57 | 58 | /* lisp close bracket */ 59 | .clo { 60 | color: #000000; 61 | font-weight: bold; 62 | font-style: normal; 63 | } 64 | 65 | /* a markup tag name */ 66 | .tag { 67 | color: #006400; 68 | font-weight: normal; 69 | font-style: normal; 70 | } 71 | 72 | /* a markup attribute name */ 73 | .atn { 74 | color: #006400; 75 | font-weight: normal; 76 | font-style: normal; 77 | } 78 | 79 | /* a markup attribute value */ 80 | .atv { 81 | color: #006400; 82 | font-weight: normal; 83 | font-style: normal; 84 | } 85 | 86 | /* a declaration */ 87 | .dec { 88 | color: #000000; 89 | font-weight: bold; 90 | font-style: normal; 91 | } 92 | 93 | /* a variable name */ 94 | .var { 95 | color: #000000; 96 | font-weight: normal; 97 | font-style: normal; 98 | } 99 | 100 | /* a function name */ 101 | .fun { 102 | color: #000000; 103 | font-weight: bold; 104 | font-style: normal; 105 | } 106 | 107 | /* Specify class=linenums on a pre to get line numbering */ 108 | ol.linenums { 109 | margin-top: 0; 110 | margin-bottom: 0; 111 | } 112 | -------------------------------------------------------------------------------- /docs/styles/prettify-tomorrow.css: -------------------------------------------------------------------------------- 1 | /* Tomorrow Theme */ 2 | /* Original theme - https://github.com/chriskempson/tomorrow-theme */ 3 | /* Pretty printing styles. Used with prettify.js. */ 4 | /* SPAN elements with the classes below are added by prettyprint. */ 5 | /* plain text */ 6 | .pln { 7 | color: #4d4d4c; } 8 | 9 | @media screen { 10 | /* string content */ 11 | .str { 12 | color: #718c00; } 13 | 14 | /* a keyword */ 15 | .kwd { 16 | color: #8959a8; } 17 | 18 | /* a comment */ 19 | .com { 20 | color: #8e908c; } 21 | 22 | /* a type name */ 23 | .typ { 24 | color: #4271ae; } 25 | 26 | /* a literal value */ 27 | .lit { 28 | color: #f5871f; } 29 | 30 | /* punctuation */ 31 | .pun { 32 | color: #4d4d4c; } 33 | 34 | /* lisp open bracket */ 35 | .opn { 36 | color: #4d4d4c; } 37 | 38 | /* lisp close bracket */ 39 | .clo { 40 | color: #4d4d4c; } 41 | 42 | /* a markup tag name */ 43 | .tag { 44 | color: #c82829; } 45 | 46 | /* a markup attribute name */ 47 | .atn { 48 | color: #f5871f; } 49 | 50 | /* a markup attribute value */ 51 | .atv { 52 | color: #3e999f; } 53 | 54 | /* a declaration */ 55 | .dec { 56 | color: #f5871f; } 57 | 58 | /* a variable name */ 59 | .var { 60 | color: #c82829; } 61 | 62 | /* a function name */ 63 | .fun { 64 | color: #4271ae; } } 65 | /* Use higher contrast and text-weight for printable form. */ 66 | @media print, projection { 67 | .str { 68 | color: #060; } 69 | 70 | .kwd { 71 | color: #006; 72 | font-weight: bold; } 73 | 74 | .com { 75 | color: #600; 76 | font-style: italic; } 77 | 78 | .typ { 79 | color: #404; 80 | font-weight: bold; } 81 | 82 | .lit { 83 | color: #044; } 84 | 85 | .pun, .opn, .clo { 86 | color: #440; } 87 | 88 | .tag { 89 | color: #006; 90 | font-weight: bold; } 91 | 92 | .atn { 93 | color: #404; } 94 | 95 | .atv { 96 | color: #060; } } 97 | /* Style */ 98 | /* 99 | pre.prettyprint { 100 | background: white; 101 | font-family: Consolas, Monaco, 'Andale Mono', monospace; 102 | font-size: 12px; 103 | line-height: 1.5; 104 | border: 1px solid #ccc; 105 | padding: 10px; } 106 | */ 107 | 108 | /* Specify class=linenums on a pre to get line numbering */ 109 | ol.linenums { 110 | margin-top: 0; 111 | margin-bottom: 0; } 112 | 113 | /* IE indents via margin-left */ 114 | li.L0, 115 | li.L1, 116 | li.L2, 117 | li.L3, 118 | li.L4, 119 | li.L5, 120 | li.L6, 121 | li.L7, 122 | li.L8, 123 | li.L9 { 124 | /* */ } 125 | 126 | /* Alternate shading for lines */ 127 | li.L1, 128 | li.L3, 129 | li.L5, 130 | li.L7, 131 | li.L9 { 132 | /* */ } 133 | -------------------------------------------------------------------------------- /docs/utils.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Source: utils.js 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Source: utils.js

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |
29 |
/**
30 |  * Returns true of a given parameter is not null and not undefined.
31 |  * @param any any input is feasible
32 |  * @return {boolean} true if defined, otherwise false
33 |  */
34 | export const exists = any => any !== null && typeof any !== 'undefined'
35 | 
36 |
37 |
38 | 39 | 40 | 41 | 42 |
43 | 44 | 47 | 48 |
49 | 50 |
51 | Documentation generated by JSDoc 3.6.11 on Mon Oct 03 2022 18:30:00 GMT+0100 (Central European Standard Time) 52 |
53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /lib/SuperTool.js: -------------------------------------------------------------------------------- 1 | import { exists } from './utils.js' 2 | 3 | /** 4 | * The possible states of the supertool. 5 | * @private 6 | */ 7 | const superToolStates = { 8 | great: 'great', 9 | cool: 'cool', 10 | awesome: 'awesome', 11 | swag: 'swag' 12 | } 13 | 14 | /** 15 | * The super tool class. Holds a state and implements the execute command. 16 | */ 17 | 18 | class SuperTool { 19 | /** 20 | * The possible states of the SuperTool. 21 | * @return {{great: string, cool: string, awesome: string, swag: string}} 22 | */ 23 | 24 | static get states () { 25 | return superToolStates 26 | } 27 | 28 | /** 29 | * Validates a state. To be valid, the value needs to be part of the {SuperTool.states}. 30 | * Throws an Error if invalid. Returns void / undefined if passed. 31 | * @param value The state candidate to be validated. 32 | * @throws if state is not a valid state 33 | */ 34 | 35 | static validateState (value) { 36 | if (!superToolStates[value]) { 37 | throw new Error(`Invalid state: ${value}`) 38 | } 39 | } 40 | 41 | /** 42 | * Constructor initializes the state. If none is given, it defaults to {'great'}. 43 | * @param state one of the SuperTool.state values 44 | * @throws if state is not a valid state 45 | */ 46 | 47 | constructor ({ state = SuperTool.states.great } = {}) { 48 | SuperTool.validateState(state) 49 | this._state = state 50 | } 51 | 52 | /** 53 | * Validates and sets a new state value if given and returns the updated value. If no defined value is given it just returns the 54 | * current state value. 55 | * @param value {String|undefined} optional state to be set. 56 | * @return {String} the current state value 57 | */ 58 | 59 | state (value) { 60 | if (exists(value)) { 61 | SuperTool.validateState(value) 62 | this._state = value 63 | } 64 | return this._state 65 | } 66 | 67 | /** 68 | * Executes with the current internal state. 69 | * @return {string} the execution including the current state. 70 | */ 71 | 72 | execute () { 73 | return `I feel ${this._state}!` 74 | } 75 | } 76 | 77 | export default SuperTool 78 | -------------------------------------------------------------------------------- /lib/index.js: -------------------------------------------------------------------------------- 1 | import SuperTool from './SuperTool.js' 2 | 3 | export { SuperTool } 4 | -------------------------------------------------------------------------------- /lib/utils.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Returns true of a given parameter is not null and not undefined. 3 | * @param any any input is feasible 4 | * @return {boolean} true if defined, otherwise false 5 | */ 6 | export const exists = any => any !== null && typeof any !== 'undefined' 7 | 8 | /** 9 | * This should be removed by rollup's tree shaking 10 | * @private 11 | */ 12 | export const ignore = () => {} 13 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "my-awesome-package", 3 | "version": "1.1.0", 4 | "description": "Look at this great package. Lots of stuff.", 5 | "type": "module", 6 | "main": "dist/index.cjs.js", 7 | "browser": "dist/index.iife.js", 8 | "exports": "./dist/index.js", 9 | "scripts": { 10 | "lint": "standard | snazzy", 11 | "lint:fix": "standard --fix | snazzy", 12 | "lint:test": "npm run lint && npm test", 13 | "test": "mocha \"tests/**/*.tests.js\"", 14 | "test:coverage": "NODE_ENV=test c8 --all --include=lib/* --reporter=html --reporter=text mocha \"tests/**/*.tests.js\"", 15 | "test:watch": "npm test -- --watch", 16 | "docs": "jsdoc --readme README.md ./lib/*.js -d ./docs && jsdoc2md ./lib/*.js > ./api.md", 17 | "build": "rollup --config rollup.dist.config.js", 18 | "build:full": "npm run docs && npm run build" 19 | }, 20 | "babel": { 21 | "presets": [ 22 | "@babel/env" 23 | ], 24 | "env": { 25 | "test": { 26 | "plugins": [ 27 | "istanbul" 28 | ] 29 | } 30 | } 31 | }, 32 | "nyc": { 33 | "sourceMap": false, 34 | "instrument": false 35 | }, 36 | "standard": { 37 | "ignore": [ 38 | "docs/", 39 | "node_modules/", 40 | "dist/" 41 | ] 42 | }, 43 | "targets": "> 0.25%, not dead", 44 | "repository": { 45 | "type": "git", 46 | "url": "git+ssh://git@github.com/jankapunkt/npm-package-template.git" 47 | }, 48 | "keywords": [ 49 | "npm", 50 | "package", 51 | "template", 52 | "javascript" 53 | ], 54 | "author": "Jan Küster ", 55 | "funding": { 56 | "type": "PayPal", 57 | "url": "https://paypal.me/kuesterjan" 58 | }, 59 | "license": "MIT", 60 | "bugs": { 61 | "url": "https://github.com/jankapunkt/npm-package-template/issues" 62 | }, 63 | "engines": { 64 | "node": ">= 14.x" 65 | }, 66 | "files": [ 67 | "dist", 68 | "API.md", 69 | "README.md", 70 | "LICENSE", 71 | "CHANGELOG.md" 72 | ], 73 | "homepage": "https://github.com/jankapunkt/npm-package-template#readme", 74 | "devDependencies": { 75 | "@babel/cli": "^7.23.0", 76 | "@babel/core": "^7.23.2", 77 | "@babel/preset-env": "^7.23.2", 78 | "@babel/register": "^7.22.15", 79 | "@rollup/plugin-babel": "^6.0.4", 80 | "@rollup/plugin-commonjs": "^25.0.5", 81 | "c8": "^8.0.1", 82 | "chai": "^4.3.10", 83 | "cross-env": "7.0.3", 84 | "jsdoc": "^4.0.2", 85 | "jsdoc-to-markdown": "^8.0.0", 86 | "mocha": "^10.2.0", 87 | "rollup": "^4.0.2", 88 | "snazzy": "^9.0.0", 89 | "standard": "^17.1.0" 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /rollup.dist.config.js: -------------------------------------------------------------------------------- 1 | import { babel, getBabelOutputPlugin } from '@rollup/plugin-babel' 2 | import commonjs from '@rollup/plugin-commonjs' 3 | 4 | export default [{ 5 | input: 'lib/index.js', 6 | output: [ 7 | { 8 | file: 'dist/index.js', 9 | format: 'es', 10 | sourcemap: true 11 | }, 12 | { 13 | file: 'dist/index.es5.js', 14 | format: 'es', 15 | plugins: [getBabelOutputPlugin({ presets: ['@babel/preset-env'] })], 16 | sourcemap: true 17 | }, 18 | { 19 | file: 'dist/index.cjs.js', 20 | format: 'cjs', 21 | plugins: [getBabelOutputPlugin({ presets: ['@babel/preset-env'] })], 22 | sourcemap: true 23 | } 24 | ] 25 | }, { 26 | input: 'lib/index.js', 27 | output: { 28 | file: 'dist/index.iife.js', 29 | format: 'iife', 30 | name: 'index', 31 | sourcemap: true 32 | }, 33 | plugins: [ 34 | commonjs(), 35 | babel({ 36 | exclude: 'node_modules/**', 37 | babelHelpers: 'bundled' 38 | }) 39 | ] 40 | }] 41 | -------------------------------------------------------------------------------- /tests/SuperTool.tests.js: -------------------------------------------------------------------------------- 1 | /* global beforeEach afterEach */ 2 | import { describe, it } from 'mocha' 3 | import { expect } from 'chai' 4 | import { SuperTool } from '../lib/index.js' 5 | 6 | describe('SuperTool', function () { 7 | let tool 8 | 9 | beforeEach(function () { 10 | tool = new SuperTool() 11 | }) 12 | 13 | afterEach(function () { 14 | tool = null 15 | }) 16 | 17 | describe('validateState (static)', function () { 18 | it('throws if the value is not a valid state', function () { 19 | const expectThrow = value => { 20 | const fn = () => SuperTool.validateState(value) 21 | expect(fn).to.throw(`${value}`) 22 | } 23 | expectThrow() 24 | expectThrow(null) 25 | expectThrow(undefined) 26 | expectThrow('foo') 27 | expectThrow({}) 28 | expectThrow([]) 29 | expectThrow(1) 30 | expectThrow(true) 31 | }) 32 | 33 | it('returns nothing on a valid state', function () { 34 | const expectValid = value => expect(SuperTool.validateState(value)).to.be.undefined 35 | expectValid(SuperTool.states.great) 36 | expectValid(SuperTool.states.awesome) 37 | expectValid(SuperTool.states.cool) 38 | expectValid(SuperTool.states.swag) 39 | }) 40 | }) 41 | 42 | describe('constructor', function () { 43 | it('is created with default state', function () { 44 | expect(tool.state()).to.equal(SuperTool.states.great) 45 | }) 46 | 47 | it('can be created with an explicit initial state', function () { 48 | const toolExplicit = new SuperTool({ state: SuperTool.states.awesome }) 49 | expect(toolExplicit.state()).to.equal(SuperTool.states.awesome) 50 | }) 51 | }) 52 | 53 | describe('state', function () { 54 | it('returns the current state if no value is given', function () { 55 | // before call 56 | expect(tool._state).to.equal(SuperTool.states.great) 57 | // call 58 | expect(tool.state()).to.equal(SuperTool.states.great) 59 | // after call 60 | expect(tool._state).to.equal(SuperTool.states.great) 61 | }) 62 | 63 | it('sets the current state if the state is a valid state value', function () { 64 | // before call 65 | expect(tool._state).to.equal(SuperTool.states.great) 66 | // call 67 | expect(tool.state(SuperTool.states.awesome)).to.equal(SuperTool.states.awesome) 68 | // after call 69 | expect(tool._state).to.equal(SuperTool.states.awesome) 70 | }) 71 | }) 72 | 73 | describe('execute', function () { 74 | it('executes the current state', function () { 75 | expect(tool.execute()).to.equal(`I feel ${SuperTool.states.great}!`) 76 | tool.state(SuperTool.states.swag) 77 | expect(tool.execute()).to.equal(`I feel ${SuperTool.states.swag}!`) 78 | }) 79 | }) 80 | }) 81 | -------------------------------------------------------------------------------- /tests/utils.tests.js: -------------------------------------------------------------------------------- 1 | import { describe, it } from 'mocha' 2 | import { expect } from 'chai' 3 | import { exists } from '../lib/utils.js' 4 | 5 | describe('exists', function () { 6 | it('returns true if the given parameter is defined', function () { 7 | const expectTrue = value => expect(exists(value)).to.equal(true) 8 | expectTrue('') 9 | expectTrue(0) 10 | expectTrue(false) 11 | expectTrue({}) 12 | expectTrue([]) 13 | expectTrue(new Date(0)) 14 | }) 15 | 16 | it('returns false if the given parameter is undefined or null', function () { 17 | const expectFalse = value => expect(exists(value)).to.equal(false) 18 | expectFalse() 19 | // we disable the next line, because we explicitly want to test against void 20 | expectFalse((void 0)) // eslint-disable-line 21 | expectFalse(undefined) 22 | expectFalse(null) 23 | 24 | let someVar 25 | expectFalse(someVar) 26 | }) 27 | }) 28 | --------------------------------------------------------------------------------