this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix argument validation

Patrik Csak 50d5f908 c0f65b7e

+191 -4
+1
changelog.md
··· 15 15 ### Fixed 16 16 17 17 - Circular imports 18 + - Argument validation in `toDecimal()` 18 19 19 20 ## [4.0.0](https://github.com/patrik-csak/BB26/compare/v3.0.2...v4.0.0) – 2023-05-24 20 21
+179 -1
package-lock.json
··· 9 9 "version": "4.0.0", 10 10 "license": "MIT", 11 11 "dependencies": { 12 + "ow": "^2.0.0", 12 13 "random-int": "^3.0.0" 13 14 }, 14 15 "devDependencies": { ··· 596 597 "integrity": "sha512-831qok9r2t8AlxLko40y2ebgSDhenenCatLVeW/uBtnHPyhHOvG0C7TvfgecV+wHzIm5KUICgzmVpWS+IMEAeg==", 597 598 "dev": true, 598 599 "license": "MIT" 600 + }, 601 + "node_modules/@sindresorhus/is": { 602 + "version": "6.3.1", 603 + "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-6.3.1.tgz", 604 + "integrity": "sha512-FX4MfcifwJyFOI2lPoX7PQxCqx8BG1HCho7WdiXwpEQx1Ycij0JxkfYtGK7yqNScrZGSlt6RE6sw8QYoH7eKnQ==", 605 + "license": "MIT", 606 + "engines": { 607 + "node": ">=16" 608 + }, 609 + "funding": { 610 + "url": "https://github.com/sindresorhus/is?sponsor=1" 611 + } 599 612 }, 600 613 "node_modules/@sindresorhus/merge-streams": { 601 614 "version": "4.0.0", ··· 1834 1847 "version": "4.2.0", 1835 1848 "resolved": "https://registry.npmjs.org/callsites/-/callsites-4.2.0.tgz", 1836 1849 "integrity": "sha512-kfzR4zzQtAE9PC7CzZsjl3aBNbXWuXiSeOCdLcPpBfGW8YuCqQHcRPFDbr/BPVmd3EEPVpuFzLyuT/cUhPr4OQ==", 1837 - "dev": true, 1838 1850 "license": "MIT", 1839 1851 "engines": { 1840 1852 "node": ">=12.20" ··· 2168 2180 "node": "^14.18.0 || >=16.10.0" 2169 2181 } 2170 2182 }, 2183 + "node_modules/convert-hrtime": { 2184 + "version": "5.0.0", 2185 + "resolved": "https://registry.npmjs.org/convert-hrtime/-/convert-hrtime-5.0.0.tgz", 2186 + "integrity": "sha512-lOETlkIeYSJWcbbcvjRKGxVMXJR+8+OQb/mTPbA4ObPMytYIsUbuOE0Jzy60hjARYszq1id0j8KgVhC+WGZVTg==", 2187 + "license": "MIT", 2188 + "engines": { 2189 + "node": ">=12" 2190 + }, 2191 + "funding": { 2192 + "url": "https://github.com/sponsors/sindresorhus" 2193 + } 2194 + }, 2171 2195 "node_modules/convert-source-map": { 2172 2196 "version": "2.0.0", 2173 2197 "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", ··· 2513 2537 "node": ">=0.10.0" 2514 2538 } 2515 2539 }, 2540 + "node_modules/dot-prop": { 2541 + "version": "8.0.2", 2542 + "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-8.0.2.tgz", 2543 + "integrity": "sha512-xaBe6ZT4DHPkg0k4Ytbvn5xoxgpG0jOS1dYxSOwAHPuNLjP3/OzN0gH55SrLqpx8cBfSaVt91lXYkApjb+nYdQ==", 2544 + "license": "MIT", 2545 + "dependencies": { 2546 + "type-fest": "^3.8.0" 2547 + }, 2548 + "engines": { 2549 + "node": ">=16" 2550 + }, 2551 + "funding": { 2552 + "url": "https://github.com/sponsors/sindresorhus" 2553 + } 2554 + }, 2555 + "node_modules/dot-prop/node_modules/type-fest": { 2556 + "version": "3.13.1", 2557 + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-3.13.1.tgz", 2558 + "integrity": "sha512-tLq3bSNx+xSpwvAJnzrK0Ep5CLNWjvFTOp71URMaAEWBfRb9nnJiBoUe0tF8bI4ZFO3omgBR6NvnbzVUT3Ly4g==", 2559 + "license": "(MIT OR CC0-1.0)", 2560 + "engines": { 2561 + "node": ">=14.16" 2562 + }, 2563 + "funding": { 2564 + "url": "https://github.com/sponsors/sindresorhus" 2565 + } 2566 + }, 2516 2567 "node_modules/dunder-proto": { 2517 2568 "version": "1.0.1", 2518 2569 "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", ··· 2610 2661 "license": "MIT", 2611 2662 "engines": { 2612 2663 "node": ">=6" 2664 + } 2665 + }, 2666 + "node_modules/environment": { 2667 + "version": "1.1.0", 2668 + "resolved": "https://registry.npmjs.org/environment/-/environment-1.1.0.tgz", 2669 + "integrity": "sha512-xUtoPkMggbz0MPyPiIWr1Kp4aeWJjDZ6SMvURhimjdZgsRuDplF5/s9hcgGhyXMhs+6vpnuoiZ2kFiu3FMnS8Q==", 2670 + "license": "MIT", 2671 + "engines": { 2672 + "node": ">=18" 2673 + }, 2674 + "funding": { 2675 + "url": "https://github.com/sponsors/sindresorhus" 2613 2676 } 2614 2677 }, 2615 2678 "node_modules/error-ex": { ··· 3719 3782 "dev": true, 3720 3783 "license": "Apache-2.0" 3721 3784 }, 3785 + "node_modules/fast-equals": { 3786 + "version": "5.2.2", 3787 + "resolved": "https://registry.npmjs.org/fast-equals/-/fast-equals-5.2.2.tgz", 3788 + "integrity": "sha512-V7/RktU11J3I36Nwq2JnZEM7tNm17eBJz+u25qdxBZeCKiX6BkVSZQjwWIr+IobgnZy+ag73tTZgZi7tr0LrBw==", 3789 + "license": "MIT", 3790 + "engines": { 3791 + "node": ">=6.0.0" 3792 + } 3793 + }, 3722 3794 "node_modules/fast-glob": { 3723 3795 "version": "3.3.3", 3724 3796 "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.3.tgz", ··· 3962 4034 "license": "MIT", 3963 4035 "funding": { 3964 4036 "url": "https://github.com/sponsors/ljharb" 4037 + } 4038 + }, 4039 + "node_modules/function-timeout": { 4040 + "version": "1.0.2", 4041 + "resolved": "https://registry.npmjs.org/function-timeout/-/function-timeout-1.0.2.tgz", 4042 + "integrity": "sha512-939eZS4gJ3htTHAldmyyuzlrD58P03fHG49v2JfFXbV6OhvZKRC9j2yAtdHw/zrp2zXHuv05zMIy40F0ge7spA==", 4043 + "license": "MIT", 4044 + "engines": { 4045 + "node": ">=18" 4046 + }, 4047 + "funding": { 4048 + "url": "https://github.com/sponsors/sindresorhus" 3965 4049 } 3966 4050 }, 3967 4051 "node_modules/function.prototype.name": { ··· 4424 4508 "node": ">=18.18.0" 4425 4509 } 4426 4510 }, 4511 + "node_modules/identifier-regex": { 4512 + "version": "1.0.0", 4513 + "resolved": "https://registry.npmjs.org/identifier-regex/-/identifier-regex-1.0.0.tgz", 4514 + "integrity": "sha512-Rcy5cjBOM9iTR+Vwy0Llyip9u0cA99T1yiWOhDW/+PDaTQhyski0tMovsipQ/FRNDkudjLWusJ/IMVIlG5WZnQ==", 4515 + "license": "MIT", 4516 + "dependencies": { 4517 + "reserved-identifiers": "^1.0.0" 4518 + }, 4519 + "engines": { 4520 + "node": ">=18" 4521 + }, 4522 + "funding": { 4523 + "url": "https://github.com/sponsors/sindresorhus" 4524 + } 4525 + }, 4427 4526 "node_modules/ignore": { 4428 4527 "version": "5.3.2", 4429 4528 "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", ··· 4789 4888 }, 4790 4889 "engines": { 4791 4890 "node": ">=0.10.0" 4891 + } 4892 + }, 4893 + "node_modules/is-identifier": { 4894 + "version": "1.0.1", 4895 + "resolved": "https://registry.npmjs.org/is-identifier/-/is-identifier-1.0.1.tgz", 4896 + "integrity": "sha512-HQ5v4rEJ7REUV54bCd2l5FaD299SGDEn2UPoVXaTHAyGviLq2menVUD2udi3trQ32uvB6LdAh/0ck2EuizrtpA==", 4897 + "license": "MIT", 4898 + "dependencies": { 4899 + "identifier-regex": "^1.0.0", 4900 + "super-regex": "^1.0.0" 4901 + }, 4902 + "engines": { 4903 + "node": ">=18" 4904 + }, 4905 + "funding": { 4906 + "url": "https://github.com/sponsors/sindresorhus" 4792 4907 } 4793 4908 }, 4794 4909 "node_modules/is-inside-container": { ··· 6003 6118 "node": ">= 0.8.0" 6004 6119 } 6005 6120 }, 6121 + "node_modules/ow": { 6122 + "version": "2.0.0", 6123 + "resolved": "https://registry.npmjs.org/ow/-/ow-2.0.0.tgz", 6124 + "integrity": "sha512-ESUigmGrdhUZ2nQSFNkeKSl6ZRPupXzprMs3yF9DYlNVpJ8XAjM/fI9RUZxA7PI1K9HQDCCvBo1jr/GEIo9joQ==", 6125 + "license": "MIT", 6126 + "dependencies": { 6127 + "@sindresorhus/is": "^6.3.0", 6128 + "callsites": "^4.1.0", 6129 + "dot-prop": "^8.0.2", 6130 + "environment": "^1.0.0", 6131 + "fast-equals": "^5.0.1", 6132 + "is-identifier": "^1.0.0" 6133 + }, 6134 + "engines": { 6135 + "node": ">=18" 6136 + }, 6137 + "funding": { 6138 + "url": "https://github.com/sponsors/sindresorhus" 6139 + } 6140 + }, 6006 6141 "node_modules/own-keys": { 6007 6142 "version": "1.0.1", 6008 6143 "resolved": "https://registry.npmjs.org/own-keys/-/own-keys-1.0.1.tgz", ··· 6489 6624 "license": "MIT", 6490 6625 "engines": { 6491 6626 "node": ">=0.10.0" 6627 + } 6628 + }, 6629 + "node_modules/reserved-identifiers": { 6630 + "version": "1.0.0", 6631 + "resolved": "https://registry.npmjs.org/reserved-identifiers/-/reserved-identifiers-1.0.0.tgz", 6632 + "integrity": "sha512-h0bP2Katmvf3hv4Z3WtDl4+6xt/OglQ2Xa6TnhZ/Rm9/7IH1crXQqMwD4J2ngKBonVv+fB55zfGgNDAmsevLVQ==", 6633 + "license": "MIT", 6634 + "engines": { 6635 + "node": ">=18" 6636 + }, 6637 + "funding": { 6638 + "url": "https://github.com/sponsors/sindresorhus" 6492 6639 } 6493 6640 }, 6494 6641 "node_modules/resolve": { ··· 7202 7349 "url": "https://github.com/sponsors/sindresorhus" 7203 7350 } 7204 7351 }, 7352 + "node_modules/super-regex": { 7353 + "version": "1.0.0", 7354 + "resolved": "https://registry.npmjs.org/super-regex/-/super-regex-1.0.0.tgz", 7355 + "integrity": "sha512-CY8u7DtbvucKuquCmOFEKhr9Besln7n9uN8eFbwcoGYWXOMW07u2o8njWaiXt11ylS3qoGF55pILjRmPlbodyg==", 7356 + "license": "MIT", 7357 + "dependencies": { 7358 + "function-timeout": "^1.0.1", 7359 + "time-span": "^5.1.0" 7360 + }, 7361 + "engines": { 7362 + "node": ">=18" 7363 + }, 7364 + "funding": { 7365 + "url": "https://github.com/sponsors/sindresorhus" 7366 + } 7367 + }, 7205 7368 "node_modules/supertap": { 7206 7369 "version": "3.0.1", 7207 7370 "resolved": "https://registry.npmjs.org/supertap/-/supertap-3.0.1.tgz", ··· 7378 7541 }, 7379 7542 "funding": { 7380 7543 "url": "https://github.com/sponsors/isaacs" 7544 + } 7545 + }, 7546 + "node_modules/time-span": { 7547 + "version": "5.1.0", 7548 + "resolved": "https://registry.npmjs.org/time-span/-/time-span-5.1.0.tgz", 7549 + "integrity": "sha512-75voc/9G4rDIJleOo4jPvN4/YC4GRZrY8yy1uU4lwrB3XEQbWve8zXoO5No4eFrGcTAMYyoY67p8jRQdtA1HbA==", 7550 + "license": "MIT", 7551 + "dependencies": { 7552 + "convert-hrtime": "^5.0.0" 7553 + }, 7554 + "engines": { 7555 + "node": ">=12" 7556 + }, 7557 + "funding": { 7558 + "url": "https://github.com/sponsors/sindresorhus" 7381 7559 } 7382 7560 }, 7383 7561 "node_modules/time-zone": {
+1
package.json
··· 31 31 "test:coverage": "del-cli coverage && eslint && prettier --check . && sort-package-json --check && c8 ava" 32 32 }, 33 33 "dependencies": { 34 + "ow": "^2.0.0", 34 35 "random-int": "^3.0.0" 35 36 }, 36 37 "devDependencies": {
+10 -3
source/to-decimal.ts
··· 1 + import ow from 'ow'; 2 + 1 3 function charToDecimal(letter: string) { 2 4 return letter.codePointAt(0)! - 'A'.codePointAt(0)! + 1; 3 5 } ··· 8 10 * @param string 9 11 */ 10 12 export default function toDecimal(string: string): number { 11 - if (!/[A-Z]/.test(string)) { 12 - throw new Error('String must contain only upper-case characters'); 13 - } 13 + ow( 14 + string, 15 + ow.string 16 + .matches(/^[A-Z]+$/) 17 + .message( 18 + `Expected string to only contain upper-case letters, got \`${string}\``, 19 + ), 20 + ); 14 21 15 22 let number = 0; 16 23