diff --git a/package.json b/package.json index 6b38fcf..342c9f4 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,8 @@ "prepare": "husky", "ci:lint": "eslint 'src/**/*.ts'", "ci:format": "prettier --check --ignore-unknown .", - "ci:coverage": "nyc check-coverage --lines 90 --branches 80 --statements 90" + "ci:coverage": "nyc check-coverage --lines 90 --branches 80 --statements 90", + "dev": "tsc --watch" }, "engines": { "node": ">=22" @@ -68,8 +69,5 @@ "bugs": { "url": "https://github.com/simonespa/algorithms-and-data-structures/issues" }, - "homepage": "https://github.com/simonespa/algorithms-and-data-structures#readme", - "dependencies": { - "algorithms-and-data-structures": "link:" - } + "homepage": "https://github.com/simonespa/algorithms-and-data-structures#readme" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3a19c33..f9d0396 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -7,10 +7,6 @@ settings: importers: .: - dependencies: - algorithms-and-data-structures: - specifier: 'link:' - version: 'link:' devDependencies: '@eslint/js': specifier: ^9.31.0 @@ -32,7 +28,7 @@ importers: version: 9.31.0 eslint-config-prettier: specifier: ^10.1.5 - version: 10.1.5(eslint@9.31.0) + version: 10.1.8(eslint@9.31.0) globals: specifier: ^16.3.0 version: 16.3.0 @@ -137,158 +133,158 @@ packages: resolution: {integrity: sha512-x0LvFTekgSX+83TI28Y9wYPUfzrnl2aT5+5QLnO6v7mSJYtEEevuDRN0F0uSHRk1G1IWZC43o00Y0xDDrpBGPQ==} engines: {node: '>=6.9.0'} - '@esbuild/aix-ppc64@0.25.6': - resolution: {integrity: sha512-ShbM/3XxwuxjFiuVBHA+d3j5dyac0aEVVq1oluIDf71hUw0aRF59dV/efUsIwFnR6m8JNM2FjZOzmaZ8yG61kw==} + '@esbuild/aix-ppc64@0.25.7': + resolution: {integrity: sha512-uD0kKFHh6ETr8TqEtaAcV+dn/2qnYbH/+8wGEdY70Qf7l1l/jmBUbrmQqwiPKAQE6cOQ7dTj6Xr0HzQDGHyceQ==} engines: {node: '>=18'} cpu: [ppc64] os: [aix] - '@esbuild/android-arm64@0.25.6': - resolution: {integrity: sha512-hd5zdUarsK6strW+3Wxi5qWws+rJhCCbMiC9QZyzoxfk5uHRIE8T287giQxzVpEvCwuJ9Qjg6bEjcRJcgfLqoA==} + '@esbuild/android-arm64@0.25.7': + resolution: {integrity: sha512-p0ohDnwyIbAtztHTNUTzN5EGD/HJLs1bwysrOPgSdlIA6NDnReoVfoCyxG6W1d85jr2X80Uq5KHftyYgaK9LPQ==} engines: {node: '>=18'} cpu: [arm64] os: [android] - '@esbuild/android-arm@0.25.6': - resolution: {integrity: sha512-S8ToEOVfg++AU/bHwdksHNnyLyVM+eMVAOf6yRKFitnwnbwwPNqKr3srzFRe7nzV69RQKb5DgchIX5pt3L53xg==} + '@esbuild/android-arm@0.25.7': + resolution: {integrity: sha512-Jhuet0g1k9rAJHrXGIh7sFknFuT4sfytYZpZpuZl7YKDhnPByVAm5oy2LEBmMbuYf3ejWVYCc2seX81Mk+madA==} engines: {node: '>=18'} cpu: [arm] os: [android] - '@esbuild/android-x64@0.25.6': - resolution: {integrity: sha512-0Z7KpHSr3VBIO9A/1wcT3NTy7EB4oNC4upJ5ye3R7taCc2GUdeynSLArnon5G8scPwaU866d3H4BCrE5xLW25A==} + '@esbuild/android-x64@0.25.7': + resolution: {integrity: sha512-mMxIJFlSgVK23HSsII3ZX9T2xKrBCDGyk0qiZnIW10LLFFtZLkFD6imZHu7gUo2wkNZwS9Yj3mOtZD3ZPcjCcw==} engines: {node: '>=18'} cpu: [x64] os: [android] - '@esbuild/darwin-arm64@0.25.6': - resolution: {integrity: sha512-FFCssz3XBavjxcFxKsGy2DYK5VSvJqa6y5HXljKzhRZ87LvEi13brPrf/wdyl/BbpbMKJNOr1Sd0jtW4Ge1pAA==} + '@esbuild/darwin-arm64@0.25.7': + resolution: {integrity: sha512-jyOFLGP2WwRwxM8F1VpP6gcdIJc8jq2CUrURbbTouJoRO7XCkU8GdnTDFIHdcifVBT45cJlOYsZ1kSlfbKjYUQ==} engines: {node: '>=18'} cpu: [arm64] os: [darwin] - '@esbuild/darwin-x64@0.25.6': - resolution: {integrity: sha512-GfXs5kry/TkGM2vKqK2oyiLFygJRqKVhawu3+DOCk7OxLy/6jYkWXhlHwOoTb0WqGnWGAS7sooxbZowy+pK9Yg==} + '@esbuild/darwin-x64@0.25.7': + resolution: {integrity: sha512-m9bVWqZCwQ1BthruifvG64hG03zzz9gE2r/vYAhztBna1/+qXiHyP9WgnyZqHgGeXoimJPhAmxfbeU+nMng6ZA==} engines: {node: '>=18'} cpu: [x64] os: [darwin] - '@esbuild/freebsd-arm64@0.25.6': - resolution: {integrity: sha512-aoLF2c3OvDn2XDTRvn8hN6DRzVVpDlj2B/F66clWd/FHLiHaG3aVZjxQX2DYphA5y/evbdGvC6Us13tvyt4pWg==} + '@esbuild/freebsd-arm64@0.25.7': + resolution: {integrity: sha512-Bss7P4r6uhr3kDzRjPNEnTm/oIBdTPRNQuwaEFWT/uvt6A1YzK/yn5kcx5ZxZ9swOga7LqeYlu7bDIpDoS01bA==} engines: {node: '>=18'} cpu: [arm64] os: [freebsd] - '@esbuild/freebsd-x64@0.25.6': - resolution: {integrity: sha512-2SkqTjTSo2dYi/jzFbU9Plt1vk0+nNg8YC8rOXXea+iA3hfNJWebKYPs3xnOUf9+ZWhKAaxnQNUf2X9LOpeiMQ==} + '@esbuild/freebsd-x64@0.25.7': + resolution: {integrity: sha512-S3BFyjW81LXG7Vqmr37ddbThrm3A84yE7ey/ERBlK9dIiaWgrjRlre3pbG7txh1Uaxz8N7wGGQXmC9zV+LIpBQ==} engines: {node: '>=18'} cpu: [x64] os: [freebsd] - '@esbuild/linux-arm64@0.25.6': - resolution: {integrity: sha512-b967hU0gqKd9Drsh/UuAm21Khpoh6mPBSgz8mKRq4P5mVK8bpA+hQzmm/ZwGVULSNBzKdZPQBRT3+WuVavcWsQ==} + '@esbuild/linux-arm64@0.25.7': + resolution: {integrity: sha512-HfQZQqrNOfS1Okn7PcsGUqHymL1cWGBslf78dGvtrj8q7cN3FkapFgNA4l/a5lXDwr7BqP2BSO6mz9UremNPbg==} engines: {node: '>=18'} cpu: [arm64] os: [linux] - '@esbuild/linux-arm@0.25.6': - resolution: {integrity: sha512-SZHQlzvqv4Du5PrKE2faN0qlbsaW/3QQfUUc6yO2EjFcA83xnwm91UbEEVx4ApZ9Z5oG8Bxz4qPE+HFwtVcfyw==} + '@esbuild/linux-arm@0.25.7': + resolution: {integrity: sha512-JZMIci/1m5vfQuhKoFXogCKVYVfYQmoZJg8vSIMR4TUXbF+0aNlfXH3DGFEFMElT8hOTUF5hisdZhnrZO/bkDw==} engines: {node: '>=18'} cpu: [arm] os: [linux] - '@esbuild/linux-ia32@0.25.6': - resolution: {integrity: sha512-aHWdQ2AAltRkLPOsKdi3xv0mZ8fUGPdlKEjIEhxCPm5yKEThcUjHpWB1idN74lfXGnZ5SULQSgtr5Qos5B0bPw==} + '@esbuild/linux-ia32@0.25.7': + resolution: {integrity: sha512-9Jex4uVpdeofiDxnwHRgen+j6398JlX4/6SCbbEFEXN7oMO2p0ueLN+e+9DdsdPLUdqns607HmzEFnxwr7+5wQ==} engines: {node: '>=18'} cpu: [ia32] os: [linux] - '@esbuild/linux-loong64@0.25.6': - resolution: {integrity: sha512-VgKCsHdXRSQ7E1+QXGdRPlQ/e08bN6WMQb27/TMfV+vPjjTImuT9PmLXupRlC90S1JeNNW5lzkAEO/McKeJ2yg==} + '@esbuild/linux-loong64@0.25.7': + resolution: {integrity: sha512-TG1KJqjBlN9IHQjKVUYDB0/mUGgokfhhatlay8aZ/MSORMubEvj/J1CL8YGY4EBcln4z7rKFbsH+HeAv0d471w==} engines: {node: '>=18'} cpu: [loong64] os: [linux] - '@esbuild/linux-mips64el@0.25.6': - resolution: {integrity: sha512-WViNlpivRKT9/py3kCmkHnn44GkGXVdXfdc4drNmRl15zVQ2+D2uFwdlGh6IuK5AAnGTo2qPB1Djppj+t78rzw==} + '@esbuild/linux-mips64el@0.25.7': + resolution: {integrity: sha512-Ty9Hj/lx7ikTnhOfaP7ipEm/ICcBv94i/6/WDg0OZ3BPBHhChsUbQancoWYSO0WNkEiSW5Do4febTTy4x1qYQQ==} engines: {node: '>=18'} cpu: [mips64el] os: [linux] - '@esbuild/linux-ppc64@0.25.6': - resolution: {integrity: sha512-wyYKZ9NTdmAMb5730I38lBqVu6cKl4ZfYXIs31Baf8aoOtB4xSGi3THmDYt4BTFHk7/EcVixkOV2uZfwU3Q2Jw==} + '@esbuild/linux-ppc64@0.25.7': + resolution: {integrity: sha512-MrOjirGQWGReJl3BNQ58BLhUBPpWABnKrnq8Q/vZWWwAB1wuLXOIxS2JQ1LT3+5T+3jfPh0tyf5CpbyQHqnWIQ==} engines: {node: '>=18'} cpu: [ppc64] os: [linux] - '@esbuild/linux-riscv64@0.25.6': - resolution: {integrity: sha512-KZh7bAGGcrinEj4qzilJ4hqTY3Dg2U82c8bv+e1xqNqZCrCyc+TL9AUEn5WGKDzm3CfC5RODE/qc96OcbIe33w==} + '@esbuild/linux-riscv64@0.25.7': + resolution: {integrity: sha512-9pr23/pqzyqIZEZmQXnFyqp3vpa+KBk5TotfkzGMqpw089PGm0AIowkUppHB9derQzqniGn3wVXgck19+oqiOw==} engines: {node: '>=18'} cpu: [riscv64] os: [linux] - '@esbuild/linux-s390x@0.25.6': - resolution: {integrity: sha512-9N1LsTwAuE9oj6lHMyyAM+ucxGiVnEqUdp4v7IaMmrwb06ZTEVCIs3oPPplVsnjPfyjmxwHxHMF8b6vzUVAUGw==} + '@esbuild/linux-s390x@0.25.7': + resolution: {integrity: sha512-4dP11UVGh9O6Y47m8YvW8eoA3r8qL2toVZUbBKyGta8j6zdw1cn9F/Rt59/Mhv0OgY68pHIMjGXWOUaykCnx+w==} engines: {node: '>=18'} cpu: [s390x] os: [linux] - '@esbuild/linux-x64@0.25.6': - resolution: {integrity: sha512-A6bJB41b4lKFWRKNrWoP2LHsjVzNiaurf7wyj/XtFNTsnPuxwEBWHLty+ZE0dWBKuSK1fvKgrKaNjBS7qbFKig==} + '@esbuild/linux-x64@0.25.7': + resolution: {integrity: sha512-ghJMAJTdw/0uhz7e7YnpdX1xVn7VqA0GrWrAO2qKMuqbvgHT2VZiBv1BQ//VcHsPir4wsL3P2oPggfKPzTKoCA==} engines: {node: '>=18'} cpu: [x64] os: [linux] - '@esbuild/netbsd-arm64@0.25.6': - resolution: {integrity: sha512-IjA+DcwoVpjEvyxZddDqBY+uJ2Snc6duLpjmkXm/v4xuS3H+3FkLZlDm9ZsAbF9rsfP3zeA0/ArNDORZgrxR/Q==} + '@esbuild/netbsd-arm64@0.25.7': + resolution: {integrity: sha512-bwXGEU4ua45+u5Ci/a55B85KWaDSRS8NPOHtxy2e3etDjbz23wlry37Ffzapz69JAGGc4089TBo+dGzydQmydg==} engines: {node: '>=18'} cpu: [arm64] os: [netbsd] - '@esbuild/netbsd-x64@0.25.6': - resolution: {integrity: sha512-dUXuZr5WenIDlMHdMkvDc1FAu4xdWixTCRgP7RQLBOkkGgwuuzaGSYcOpW4jFxzpzL1ejb8yF620UxAqnBrR9g==} + '@esbuild/netbsd-x64@0.25.7': + resolution: {integrity: sha512-tUZRvLtgLE5OyN46sPSYlgmHoBS5bx2URSrgZdW1L1teWPYVmXh+QN/sKDqkzBo/IHGcKcHLKDhBeVVkO7teEA==} engines: {node: '>=18'} cpu: [x64] os: [netbsd] - '@esbuild/openbsd-arm64@0.25.6': - resolution: {integrity: sha512-l8ZCvXP0tbTJ3iaqdNf3pjaOSd5ex/e6/omLIQCVBLmHTlfXW3zAxQ4fnDmPLOB1x9xrcSi/xtCWFwCZRIaEwg==} + '@esbuild/openbsd-arm64@0.25.7': + resolution: {integrity: sha512-bTJ50aoC+WDlDGBReWYiObpYvQfMjBNlKztqoNUL0iUkYtwLkBQQeEsTq/I1KyjsKA5tyov6VZaPb8UdD6ci6Q==} engines: {node: '>=18'} cpu: [arm64] os: [openbsd] - '@esbuild/openbsd-x64@0.25.6': - resolution: {integrity: sha512-hKrmDa0aOFOr71KQ/19JC7az1P0GWtCN1t2ahYAf4O007DHZt/dW8ym5+CUdJhQ/qkZmI1HAF8KkJbEFtCL7gw==} + '@esbuild/openbsd-x64@0.25.7': + resolution: {integrity: sha512-TA9XfJrgzAipFUU895jd9j2SyDh9bbNkK2I0gHcvqb/o84UeQkBpi/XmYX3cO1q/9hZokdcDqQxIi6uLVrikxg==} engines: {node: '>=18'} cpu: [x64] os: [openbsd] - '@esbuild/openharmony-arm64@0.25.6': - resolution: {integrity: sha512-+SqBcAWoB1fYKmpWoQP4pGtx+pUUC//RNYhFdbcSA16617cchuryuhOCRpPsjCblKukAckWsV+aQ3UKT/RMPcA==} + '@esbuild/openharmony-arm64@0.25.7': + resolution: {integrity: sha512-5VTtExUrWwHHEUZ/N+rPlHDwVFQ5aME7vRJES8+iQ0xC/bMYckfJ0l2n3yGIfRoXcK/wq4oXSItZAz5wslTKGw==} engines: {node: '>=18'} cpu: [arm64] os: [openharmony] - '@esbuild/sunos-x64@0.25.6': - resolution: {integrity: sha512-dyCGxv1/Br7MiSC42qinGL8KkG4kX0pEsdb0+TKhmJZgCUDBGmyo1/ArCjNGiOLiIAgdbWgmWgib4HoCi5t7kA==} + '@esbuild/sunos-x64@0.25.7': + resolution: {integrity: sha512-umkbn7KTxsexhv2vuuJmj9kggd4AEtL32KodkJgfhNOHMPtQ55RexsaSrMb+0+jp9XL4I4o2y91PZauVN4cH3A==} engines: {node: '>=18'} cpu: [x64] os: [sunos] - '@esbuild/win32-arm64@0.25.6': - resolution: {integrity: sha512-42QOgcZeZOvXfsCBJF5Afw73t4veOId//XD3i+/9gSkhSV6Gk3VPlWncctI+JcOyERv85FUo7RxuxGy+z8A43Q==} + '@esbuild/win32-arm64@0.25.7': + resolution: {integrity: sha512-j20JQGP/gz8QDgzl5No5Gr4F6hurAZvtkFxAKhiv2X49yi/ih8ECK4Y35YnjlMogSKJk931iNMcd35BtZ4ghfw==} engines: {node: '>=18'} cpu: [arm64] os: [win32] - '@esbuild/win32-ia32@0.25.6': - resolution: {integrity: sha512-4AWhgXmDuYN7rJI6ORB+uU9DHLq/erBbuMoAuB4VWJTu5KtCgcKYPynF0YI1VkBNuEfjNlLrFr9KZPJzrtLkrQ==} + '@esbuild/win32-ia32@0.25.7': + resolution: {integrity: sha512-4qZ6NUfoiiKZfLAXRsvFkA0hoWVM+1y2bSHXHkpdLAs/+r0LgwqYohmfZCi985c6JWHhiXP30mgZawn/XrqAkQ==} engines: {node: '>=18'} cpu: [ia32] os: [win32] - '@esbuild/win32-x64@0.25.6': - resolution: {integrity: sha512-NgJPHHbEpLQgDH2MjQu90pzW/5vvXIZ7KOnPyNBm92A6WgZ/7b6fJyUBjoumLqeOQQGqY2QjQxRo97ah4Sj0cA==} + '@esbuild/win32-x64@0.25.7': + resolution: {integrity: sha512-FaPsAHTwm+1Gfvn37Eg3E5HIpfR3i6x1AIcla/MkqAIupD4BW3MrSeUqfoTzwwJhk3WE2/KqUn4/eenEJC76VA==} engines: {node: '>=18'} cpu: [x64] os: [win32] @@ -679,8 +675,8 @@ packages: eastasianwidth@0.2.0: resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==} - electron-to-chromium@1.5.185: - resolution: {integrity: sha512-dYOZfUk57hSMPePoIQ1fZWl1Fkj+OshhEVuPacNKWzC1efe56OsHY3l/jCfiAgIICOU3VgOIdoq7ahg7r7n6MQ==} + electron-to-chromium@1.5.187: + resolution: {integrity: sha512-cl5Jc9I0KGUoOoSbxvTywTa40uspGJt/BDBoDLoxJRSBpWh4FFXBsjNRHfQrONsV/OoEjDfHUmZQa2d6Ze4YgA==} emoji-regex@10.4.0: resolution: {integrity: sha512-EC+0oUMY1Rqm4O6LLrgjtYDvcVYTy7chDnM4Q7030tP4Kwj3u/pR6gP9ygnp2CJMK5Gq+9Q2oqmrFJAz01DXjw==} @@ -698,8 +694,8 @@ packages: es6-error@4.1.1: resolution: {integrity: sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg==} - esbuild@0.25.6: - resolution: {integrity: sha512-GVuzuUwtdsghE3ocJ9Bs8PNoF13HNQ5TXbEi2AhvVb8xU1Iwt9Fos9FEamfoee+u/TOsn7GUWc04lz46n2bbTg==} + esbuild@0.25.7: + resolution: {integrity: sha512-daJB0q2dmTzo90L9NjRaohhRWrCzYxWNFTjEi72/h+p5DcY3yn4MacWfDakHmaBaDzDiuLJsCh0+6LK/iX+c+Q==} engines: {node: '>=18'} hasBin: true @@ -711,8 +707,8 @@ packages: resolution: {integrity: sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==} engines: {node: '>=10'} - eslint-config-prettier@10.1.5: - resolution: {integrity: sha512-zc1UmCpNltmVY34vuLRV61r1K27sWuX39E+uyUnY8xS2Bex88VV9cugG+UZbRSRGtGyFboj+D8JODyme1plMpw==} + eslint-config-prettier@10.1.8: + resolution: {integrity: sha512-82GZUjRS0p/jganf6q1rEO25VSoHH0hKPCTrgillPjdI/3bgBhAE1QzHrHTizjpRvy6pGAvKjDJtk2pF9NDq8w==} hasBin: true peerDependencies: eslint: '>=7.0.0' @@ -1640,82 +1636,82 @@ snapshots: '@babel/helper-string-parser': 7.27.1 '@babel/helper-validator-identifier': 7.27.1 - '@esbuild/aix-ppc64@0.25.6': + '@esbuild/aix-ppc64@0.25.7': optional: true - '@esbuild/android-arm64@0.25.6': + '@esbuild/android-arm64@0.25.7': optional: true - '@esbuild/android-arm@0.25.6': + '@esbuild/android-arm@0.25.7': optional: true - '@esbuild/android-x64@0.25.6': + '@esbuild/android-x64@0.25.7': optional: true - '@esbuild/darwin-arm64@0.25.6': + '@esbuild/darwin-arm64@0.25.7': optional: true - '@esbuild/darwin-x64@0.25.6': + '@esbuild/darwin-x64@0.25.7': optional: true - '@esbuild/freebsd-arm64@0.25.6': + '@esbuild/freebsd-arm64@0.25.7': optional: true - '@esbuild/freebsd-x64@0.25.6': + '@esbuild/freebsd-x64@0.25.7': optional: true - '@esbuild/linux-arm64@0.25.6': + '@esbuild/linux-arm64@0.25.7': optional: true - '@esbuild/linux-arm@0.25.6': + '@esbuild/linux-arm@0.25.7': optional: true - '@esbuild/linux-ia32@0.25.6': + '@esbuild/linux-ia32@0.25.7': optional: true - '@esbuild/linux-loong64@0.25.6': + '@esbuild/linux-loong64@0.25.7': optional: true - '@esbuild/linux-mips64el@0.25.6': + '@esbuild/linux-mips64el@0.25.7': optional: true - '@esbuild/linux-ppc64@0.25.6': + '@esbuild/linux-ppc64@0.25.7': optional: true - '@esbuild/linux-riscv64@0.25.6': + '@esbuild/linux-riscv64@0.25.7': optional: true - '@esbuild/linux-s390x@0.25.6': + '@esbuild/linux-s390x@0.25.7': optional: true - '@esbuild/linux-x64@0.25.6': + '@esbuild/linux-x64@0.25.7': optional: true - '@esbuild/netbsd-arm64@0.25.6': + '@esbuild/netbsd-arm64@0.25.7': optional: true - '@esbuild/netbsd-x64@0.25.6': + '@esbuild/netbsd-x64@0.25.7': optional: true - '@esbuild/openbsd-arm64@0.25.6': + '@esbuild/openbsd-arm64@0.25.7': optional: true - '@esbuild/openbsd-x64@0.25.6': + '@esbuild/openbsd-x64@0.25.7': optional: true - '@esbuild/openharmony-arm64@0.25.6': + '@esbuild/openharmony-arm64@0.25.7': optional: true - '@esbuild/sunos-x64@0.25.6': + '@esbuild/sunos-x64@0.25.7': optional: true - '@esbuild/win32-arm64@0.25.6': + '@esbuild/win32-arm64@0.25.7': optional: true - '@esbuild/win32-ia32@0.25.6': + '@esbuild/win32-ia32@0.25.7': optional: true - '@esbuild/win32-x64@0.25.6': + '@esbuild/win32-x64@0.25.7': optional: true '@eslint-community/eslint-utils@4.7.0(eslint@9.31.0)': @@ -2014,7 +2010,7 @@ snapshots: browserslist@4.25.1: dependencies: caniuse-lite: 1.0.30001727 - electron-to-chromium: 1.5.185 + electron-to-chromium: 1.5.187 node-releases: 2.0.19 update-browserslist-db: 1.1.3(browserslist@4.25.1) @@ -2123,7 +2119,7 @@ snapshots: eastasianwidth@0.2.0: {} - electron-to-chromium@1.5.185: {} + electron-to-chromium@1.5.187: {} emoji-regex@10.4.0: {} @@ -2135,40 +2131,40 @@ snapshots: es6-error@4.1.1: {} - esbuild@0.25.6: + esbuild@0.25.7: optionalDependencies: - '@esbuild/aix-ppc64': 0.25.6 - '@esbuild/android-arm': 0.25.6 - '@esbuild/android-arm64': 0.25.6 - '@esbuild/android-x64': 0.25.6 - '@esbuild/darwin-arm64': 0.25.6 - '@esbuild/darwin-x64': 0.25.6 - '@esbuild/freebsd-arm64': 0.25.6 - '@esbuild/freebsd-x64': 0.25.6 - '@esbuild/linux-arm': 0.25.6 - '@esbuild/linux-arm64': 0.25.6 - '@esbuild/linux-ia32': 0.25.6 - '@esbuild/linux-loong64': 0.25.6 - '@esbuild/linux-mips64el': 0.25.6 - '@esbuild/linux-ppc64': 0.25.6 - '@esbuild/linux-riscv64': 0.25.6 - '@esbuild/linux-s390x': 0.25.6 - '@esbuild/linux-x64': 0.25.6 - '@esbuild/netbsd-arm64': 0.25.6 - '@esbuild/netbsd-x64': 0.25.6 - '@esbuild/openbsd-arm64': 0.25.6 - '@esbuild/openbsd-x64': 0.25.6 - '@esbuild/openharmony-arm64': 0.25.6 - '@esbuild/sunos-x64': 0.25.6 - '@esbuild/win32-arm64': 0.25.6 - '@esbuild/win32-ia32': 0.25.6 - '@esbuild/win32-x64': 0.25.6 + '@esbuild/aix-ppc64': 0.25.7 + '@esbuild/android-arm': 0.25.7 + '@esbuild/android-arm64': 0.25.7 + '@esbuild/android-x64': 0.25.7 + '@esbuild/darwin-arm64': 0.25.7 + '@esbuild/darwin-x64': 0.25.7 + '@esbuild/freebsd-arm64': 0.25.7 + '@esbuild/freebsd-x64': 0.25.7 + '@esbuild/linux-arm': 0.25.7 + '@esbuild/linux-arm64': 0.25.7 + '@esbuild/linux-ia32': 0.25.7 + '@esbuild/linux-loong64': 0.25.7 + '@esbuild/linux-mips64el': 0.25.7 + '@esbuild/linux-ppc64': 0.25.7 + '@esbuild/linux-riscv64': 0.25.7 + '@esbuild/linux-s390x': 0.25.7 + '@esbuild/linux-x64': 0.25.7 + '@esbuild/netbsd-arm64': 0.25.7 + '@esbuild/netbsd-x64': 0.25.7 + '@esbuild/openbsd-arm64': 0.25.7 + '@esbuild/openbsd-x64': 0.25.7 + '@esbuild/openharmony-arm64': 0.25.7 + '@esbuild/sunos-x64': 0.25.7 + '@esbuild/win32-arm64': 0.25.7 + '@esbuild/win32-ia32': 0.25.7 + '@esbuild/win32-x64': 0.25.7 escalade@3.2.0: {} escape-string-regexp@4.0.0: {} - eslint-config-prettier@10.1.5(eslint@9.31.0): + eslint-config-prettier@10.1.8(eslint@9.31.0): dependencies: eslint: 9.31.0 @@ -2886,7 +2882,7 @@ snapshots: tsx@4.20.3: dependencies: - esbuild: 0.25.6 + esbuild: 0.25.7 get-tsconfig: 4.10.1 optionalDependencies: fsevents: 2.3.3 diff --git a/src/algorithms/dynamic-programming/fibonacci.ts b/src/algorithms/dynamic-programming/fibonacci.ts index d08fc35..8f23d66 100644 --- a/src/algorithms/dynamic-programming/fibonacci.ts +++ b/src/algorithms/dynamic-programming/fibonacci.ts @@ -16,12 +16,15 @@ * - 2 is the number of time the function is recursively called each time (branching factor) * - "n" is the index of the nth element (height of the tree) * - * @param n the index of the nth element in the Fibonacci sequence. - * @param buffer the object used for memoisation - * @returns the nth element in the Fibonacci sequence. + * @param n the index of the Fibonacci sequence to return + * @param buffer the object used for memoisation (see https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type) + * @returns the nth element of the Fibonacci sequence */ -export default function fibonacci(n: number, buffer: object = {}): number { - if (n in buffer) return buffer[n]; +export default function fibonacci( + n: number, + buffer: Record = {}, +): number { + if (buffer[n] !== undefined) return buffer[n]; if (n <= 0) return 0; if (n <= 2) return 1; diff --git a/src/algorithms/dynamic-programming/grid-traveller.ts b/src/algorithms/dynamic-programming/grid-traveller.ts index 3582c06..5770f9c 100644 --- a/src/algorithms/dynamic-programming/grid-traveller.ts +++ b/src/algorithms/dynamic-programming/grid-traveller.ts @@ -27,7 +27,7 @@ export default function gridTraveller( rows: number, columns: number, - buffer: object = {}, + buffer: Record = {}, ): number { const key = getKey(rows, columns); if (key in buffer) return buffer[key]; diff --git a/src/algorithms/dynamic-programming/sum/can-sum.ts b/src/algorithms/dynamic-programming/sum/can-sum.ts index 95d7022..1acef0d 100644 --- a/src/algorithms/dynamic-programming/sum/can-sum.ts +++ b/src/algorithms/dynamic-programming/sum/can-sum.ts @@ -26,7 +26,7 @@ export default function canSum( targetSum: number, numbers: number[], - buffer: object = {}, + buffer: Record = {}, ): boolean { if (targetSum in buffer) return buffer[targetSum]; if (targetSum === 0) return true; diff --git a/src/algorithms/dynamic-programming/sum/how-sum.ts b/src/algorithms/dynamic-programming/sum/how-sum.ts index a084863..48ed237 100644 --- a/src/algorithms/dynamic-programming/sum/how-sum.ts +++ b/src/algorithms/dynamic-programming/sum/how-sum.ts @@ -26,7 +26,7 @@ export default function howSum( targetSum: number, numbers: number[], - buffer: object = {}, + buffer: Record = {}, ): number[] | null { if (targetSum in buffer) return buffer[targetSum]; if (targetSum === 0) return []; diff --git a/src/algorithms/dynamic-programming/sum/shortest-sum.ts b/src/algorithms/dynamic-programming/sum/shortest-sum.ts index c795b1b..5b1780b 100644 --- a/src/algorithms/dynamic-programming/sum/shortest-sum.ts +++ b/src/algorithms/dynamic-programming/sum/shortest-sum.ts @@ -28,7 +28,7 @@ export default function shortestSum( targetSum: number, numbers: number[], - buffer: object = {}, + buffer: Record = {}, ): number[] | null { if (targetSum in buffer) return buffer[targetSum]; if (targetSum === 0) return []; diff --git a/src/algorithms/sorting/merge-sort.ts b/src/algorithms/sorting/merge-sort.ts index c81ccad..de45fbc 100644 --- a/src/algorithms/sorting/merge-sort.ts +++ b/src/algorithms/sorting/merge-sort.ts @@ -1,4 +1,4 @@ -import SortingOrder from "../../util/SortingOrder"; +import SortingOrder from "@src/util/SortingOrder.ts"; interface Split { left: Array; @@ -81,8 +81,9 @@ export default function mergeSort( const splitInput: Split = split(input); - const sortedLeft = mergeSort(splitInput.left, order); - const sortedRight = mergeSort(splitInput.right, order); + // make sure to handle the case where the split returns null + const sortedLeft = mergeSort(splitInput.left, order) ?? []; + const sortedRight = mergeSort(splitInput.right, order) ?? []; return merge(sortedLeft, sortedRight, order); } diff --git a/src/algorithms/tree-traversal.ts b/src/algorithms/tree-traversal.ts index 07df863..d444e9c 100644 --- a/src/algorithms/tree-traversal.ts +++ b/src/algorithms/tree-traversal.ts @@ -1,4 +1,4 @@ -import BinaryTree from "../data-structures/BinaryTree"; +import BinaryTree from "@src/data-structures/BinaryTree.ts"; /** * Depth-First traversal (DFS) @@ -6,12 +6,14 @@ import BinaryTree from "../data-structures/BinaryTree"; /* Pre-Order Traversal */ -export function recursivePreOrderTraversal(node: BinaryTree): T[] { +export function recursivePreOrderTraversal(node: BinaryTree | null): T[] { if (node === null) return []; - const result = []; + const result: T[] = []; - result.push(node.value); + if (node.value !== null && node.value !== undefined) { + result.push(node.value); + } result.push(...recursivePreOrderTraversal(node.leftChild)); result.push(...recursivePreOrderTraversal(node.rightChild)); @@ -22,16 +24,20 @@ export function recursivePreOrderTraversal(node: BinaryTree): T[] { * Time Complexity: O(N) * Auxiliary Space: O(N), where N is the total number of nodes in the tree. */ -export function iterativePreOrderTraversal(node: BinaryTree): T[] { - const result = []; +export function iterativePreOrderTraversal(node: BinaryTree | null): T[] { + const result: T[] = []; if (node === null) return result; - const stack = [node]; + const stack: BinaryTree[] = [node]; while (stack.length > 0) { const currentNode = stack.pop(); - result.push(currentNode.value); + if (!currentNode) continue; + + if (currentNode.value !== null && currentNode.value !== undefined) { + result.push(currentNode.value); + } // the right child must be pushed first so that the left child is processed first (LIFO order) if (currentNode.rightChild !== null) stack.push(currentNode.rightChild); if (currentNode.leftChild !== null) stack.push(currentNode.leftChild); @@ -48,20 +54,22 @@ export function iterativePreOrderTraversal(node: BinaryTree): T[] { * Auxiliary Space: O(H), where H is the height of the tree. */ export function iterativePreOrderTraversalRightChildOnly( - node: BinaryTree, + node: BinaryTree | null, ): T[] { - const result = []; + const result: T[] = []; if (node === null) return result; - const stack = [node]; - let currentNode = node; + const stack: BinaryTree[] = [node]; + let currentNode: BinaryTree | null = node; while (stack.length > 0) { // if the current node exists, print it and push its right child // to the stack before moving to its left child if (currentNode !== null) { - result.push(currentNode.value); + if (currentNode.value !== null && currentNode.value !== undefined) { + result.push(currentNode.value); + } // push the right child if (currentNode.rightChild !== null) stack.push(currentNode.rightChild); // point to the left child @@ -69,7 +77,7 @@ export function iterativePreOrderTraversalRightChildOnly( } else { // if the current node is null, pop a node from the stack // and set it as the current one - currentNode = stack.pop(); + currentNode = stack.pop() ?? null; } } @@ -78,34 +86,40 @@ export function iterativePreOrderTraversalRightChildOnly( /* In-Order Traversal */ -export function recursiveInOrderTraversal(node: BinaryTree): T[] { +export function recursiveInOrderTraversal(node: BinaryTree | null): T[] { if (node === null) return []; - const result = []; + const result: T[] = []; result.push(...recursiveInOrderTraversal(node.leftChild)); - result.push(node.value); + if (node.value !== null && node.value !== undefined) { + result.push(node.value); + } result.push(...recursiveInOrderTraversal(node.rightChild)); return result; } -export function iterativeInOrderTraversal(node: BinaryTree): T[] { - const result = []; +export function iterativeInOrderTraversal(node: BinaryTree | null): T[] { + const result: T[] = []; if (node === null) return result; - const stack = []; - let currentNode = node; + const stack: BinaryTree[] = []; + let currentNode: BinaryTree | null = node; while (stack.length > 0 || currentNode !== null) { if (currentNode !== null) { stack.push(currentNode); currentNode = currentNode.leftChild; } else { - currentNode = stack.pop(); - result.push(currentNode.value); - currentNode = currentNode.rightChild; + currentNode = stack.pop() ?? null; + if (currentNode) { + if (currentNode.value !== null && currentNode.value !== undefined) { + result.push(currentNode.value); + } + currentNode = currentNode.rightChild; + } } } @@ -113,14 +127,14 @@ export function iterativeInOrderTraversal(node: BinaryTree): T[] { } export function iterativeInOrderTraversalWithDoubleWhile( - node: BinaryTree, + node: BinaryTree | null, ): T[] { - const result = []; + const result: T[] = []; if (node === null) return result; - const stack = []; - let currentNode = node; + const stack: BinaryTree[] = []; + let currentNode: BinaryTree | null = node; while (stack.length > 0 || currentNode !== null) { // Reach the left most Node of the subtree @@ -129,9 +143,13 @@ export function iterativeInOrderTraversalWithDoubleWhile( currentNode = currentNode.leftChild; } - currentNode = stack.pop(); - result.push(currentNode.value); - currentNode = currentNode.rightChild; + currentNode = stack.pop() ?? null; + if (currentNode) { + if (currentNode.value !== null && currentNode.value !== undefined) { + result.push(currentNode.value); + } + currentNode = currentNode.rightChild; + } } return result; @@ -139,14 +157,18 @@ export function iterativeInOrderTraversalWithDoubleWhile( /* Post-order Traversal */ -export function recursivePostOrderTraversal(node: BinaryTree): T[] { +export function recursivePostOrderTraversal( + node: BinaryTree | null, +): T[] { if (node === null) return []; - const result = []; + const result: T[] = []; result.push(...recursivePostOrderTraversal(node.leftChild)); result.push(...recursivePostOrderTraversal(node.rightChild)); - result.push(node.value); + if (node.value !== null && node.value !== undefined) { + result.push(node.value); + } return result; } @@ -155,13 +177,15 @@ export function recursivePostOrderTraversal(node: BinaryTree): T[] { * It starts from the root node every time the left-most and right-most nodes have * been visited. */ -export function iterativePostOrderTraversal(node: BinaryTree): T[] { - const result = []; +export function iterativePostOrderTraversal( + node: BinaryTree | null, +): T[] { + const result: T[] = []; if (node === null) return result; - const visited = new Set(); - let current = node; + const visited = new Set>(); + let current: BinaryTree | null = node; while (current !== null && !visited.has(current)) { if (current.leftChild !== null && !visited.has(current.leftChild)) { @@ -172,7 +196,9 @@ export function iterativePostOrderTraversal(node: BinaryTree): T[] { ) { current = current.rightChild; } else { - result.push(current.value); + if (current.value !== null && current.value !== undefined) { + result.push(current.value); + } visited.add(current); current = node; } @@ -185,16 +211,20 @@ export function iterativePostOrderTraversal(node: BinaryTree): T[] { * Breadth-first traversal (DFS) */ -export function breadthFirstTraversal(node: BinaryTree): T[] { - const result = []; +export function breadthFirstTraversal(node: BinaryTree | null): T[] { + const result: T[] = []; if (node === null) return result; - const queue = [node]; + const queue: BinaryTree[] = [node]; while (queue.length > 0) { const current = queue.shift(); - result.push(current.value); + if (!current) continue; + + if (current.value !== null && current.value !== undefined) { + result.push(current.value); + } if (current.leftChild !== null) { queue.push(current.leftChild); diff --git a/src/data-structures/BinaryTree.ts b/src/data-structures/BinaryTree.ts index de50a62..73ad783 100644 --- a/src/data-structures/BinaryTree.ts +++ b/src/data-structures/BinaryTree.ts @@ -1,7 +1,7 @@ export default class BinaryTree { - value: T = null; - leftChild: BinaryTree = null; - rightChild: BinaryTree = null; + value: T | null = null; + leftChild: BinaryTree | null = null; + rightChild: BinaryTree | null = null; constructor(value: T) { this.value = value; diff --git a/src/data-structures/collections/PriorityQueueArray.ts b/src/data-structures/collections/PriorityQueueArray.ts index 4be03c3..3d5e9eb 100644 --- a/src/data-structures/collections/PriorityQueueArray.ts +++ b/src/data-structures/collections/PriorityQueueArray.ts @@ -11,8 +11,8 @@ export default class PriorityQueueArray extends QueueArray { } else { let added = false; for (let i = 0; i < super.size(); i += 1) { - if (item <= super.queue[i]) { - super.queue.splice(i, 0, item); + if (item <= this.queue[i]) { + this.queue.splice(i, 0, item); added = true; break; } diff --git a/src/data-structures/collections/Queue.ts b/src/data-structures/collections/Queue.ts index f519a35..5e33f18 100644 --- a/src/data-structures/collections/Queue.ts +++ b/src/data-structures/collections/Queue.ts @@ -1,4 +1,4 @@ -import Collection from "./Collection"; +import Collection from "./Collection.ts"; /** * The {@code Queue} interface represents a first-in-first-out diff --git a/src/data-structures/collections/QueueArray.ts b/src/data-structures/collections/QueueArray.ts index 9a13ba3..dcd2e3e 100644 --- a/src/data-structures/collections/QueueArray.ts +++ b/src/data-structures/collections/QueueArray.ts @@ -1,4 +1,4 @@ -import Queue from "./Queue"; +import Queue from "./Queue.ts"; export default class QueueArray implements Queue { protected queue: Array; @@ -11,8 +11,8 @@ export default class QueueArray implements Queue { this.queue.push(item); } - dequeue(): T { - return this.queue.shift(); + dequeue(): T | undefined { + return this.queue.shift() as T; } peek(): T { diff --git a/src/data-structures/collections/Stack.ts b/src/data-structures/collections/Stack.ts index 22b6470..1360ddd 100644 --- a/src/data-structures/collections/Stack.ts +++ b/src/data-structures/collections/Stack.ts @@ -1,4 +1,4 @@ -import Collection from "./Collection"; +import Collection from "./Collection.ts"; /** * The {@code Stack} interface represents a last-in-first-out diff --git a/src/data-structures/collections/StackArray.ts b/src/data-structures/collections/StackArray.ts index 4b524d3..3d267e6 100644 --- a/src/data-structures/collections/StackArray.ts +++ b/src/data-structures/collections/StackArray.ts @@ -1,4 +1,4 @@ -import Stack from "./Stack"; +import Stack from "./Stack.ts"; export default class StackArray implements Stack { private stack: Array; @@ -11,7 +11,7 @@ export default class StackArray implements Stack { this.stack.push(item); } - pop(): T { + pop(): T | undefined { return this.stack.pop(); } diff --git a/src/exercises/majority-elements/index.test.ts b/src/exercises/majority-elements/index.test.ts index c446cfc..f8c08d1 100644 --- a/src/exercises/majority-elements/index.test.ts +++ b/src/exercises/majority-elements/index.test.ts @@ -8,12 +8,12 @@ describe("Majority Elements Exercise", () => { it("majority() with empty array", () => { // eslint-disable-next-line @typescript-eslint/no-unused-expressions - expect(majority([])).to.be.undefined; + expect(majority([])).to.be.null; }); it("majority() with no majority element", () => { // eslint-disable-next-line @typescript-eslint/no-unused-expressions - expect(majority([1, 2, 3, 4])).to.be.undefined; + expect(majority([1, 2, 3, 4])).to.be.null; }); it("majority() with single element", () => { diff --git a/src/exercises/majority-elements/index.ts b/src/exercises/majority-elements/index.ts index 07c1e6d..1939199 100644 --- a/src/exercises/majority-elements/index.ts +++ b/src/exercises/majority-elements/index.ts @@ -1,4 +1,4 @@ -export function majority(nums: number[]): number { +export function majority(nums: number[]): number | null { const n = nums.length; const map = new Map(); @@ -15,4 +15,6 @@ export function majority(nums: number[]): number { map.set(num, counter); } + + return null; } diff --git a/src/exercises/palindrome/index.ts b/src/exercises/palindrome/index.ts index 3709bf2..abc8025 100644 --- a/src/exercises/palindrome/index.ts +++ b/src/exercises/palindrome/index.ts @@ -13,3 +13,5 @@ export function isPalindrome(input: string): boolean { return true; } + +console.log(isPalindrome("racecar")); diff --git a/src/exercises/rotational-cipher/index.ts b/src/exercises/rotational-cipher/index.ts index de6c61f..f3702f0 100644 --- a/src/exercises/rotational-cipher/index.ts +++ b/src/exercises/rotational-cipher/index.ts @@ -1,4 +1,3 @@ -// Add any extra import statements you may need here const letters = [ "a", "b", @@ -27,43 +26,43 @@ const letters = [ "y", "z", ]; -const index = { - a: "0", - b: "1", - c: "2", - d: "3", - e: "4", - f: "5", - g: "6", - h: "7", - i: "8", - j: "9", - k: "10", - l: "11", - m: "12", - n: "13", - o: "14", - p: "15", - q: "16", - r: "17", - s: "18", - t: "19", - u: "20", - v: "21", - w: "22", - x: "23", - y: "24", - z: "25", +const index: { [key: string]: number } = { + a: 0, + b: 1, + c: 2, + d: 3, + e: 4, + f: 5, + g: 6, + h: 7, + i: 8, + j: 9, + k: 10, + l: 11, + m: 12, + n: 13, + o: 14, + p: 15, + q: 16, + r: 17, + s: 18, + t: 19, + u: 20, + v: 21, + w: 22, + x: 23, + y: 24, + z: 25, }; // Add any helper functions you may need here -function encrypt(char, rotationFactor) { +function encrypt(char: string, rotationFactor: number): string { // to make sure all upper and lower case letters are taken into account const lowerCaseChar = char.toLowerCase(); const entry = index[lowerCaseChar]; // it is a letter because an entry has been found in the index - if (typeof entry === "string") { + if (entry !== undefined) { // shift the index module 26 (the size of the alphabet) const shiftedIndex = (Number(entry) + rotationFactor) % 26; const encryptedLetter = letters[shiftedIndex]; @@ -76,7 +75,7 @@ function encrypt(char, rotationFactor) { } // if it is an integer number - if (!isNaN(char)) { + if (!isNaN(Number(char))) { // shift the index module 10 (the size of the numeric list) const shiftedIndex = (Number(char) + rotationFactor) % 10; return `${shiftedIndex}`; @@ -86,7 +85,10 @@ function encrypt(char, rotationFactor) { return char; } -export function rotationalCipher(input, rotationFactor) { +export function rotationalCipher( + input: string, + rotationFactor: number, +): string { /** * We can resize the "rotationFactor" by using the modular arithmetic * The module is the size of the input and rotationFactor % input.length diff --git a/src/exercises/sliding-window-maximum/index.test.ts b/src/exercises/sliding-window-maximum/index.test.ts index c5f384c..9f21213 100644 --- a/src/exercises/sliding-window-maximum/index.test.ts +++ b/src/exercises/sliding-window-maximum/index.test.ts @@ -1,5 +1,5 @@ import { expect } from "chai"; -import { maxSlidingWindow } from "."; +import { maxSlidingWindow } from "./index.ts"; describe("Sliding Window Maximum Exercise", () => { const tests = [ diff --git a/src/exercises/valid-binary-search-tree/index.ts b/src/exercises/valid-binary-search-tree/index.ts index 51a670c..4f2ec9f 100644 --- a/src/exercises/valid-binary-search-tree/index.ts +++ b/src/exercises/valid-binary-search-tree/index.ts @@ -1,20 +1,32 @@ -import BinaryTree from "../../data-structures/BinaryTree"; +import BinaryTree from "@src/data-structures/BinaryTree.ts"; export function isValidBST( - node: BinaryTree, - left: BinaryTree = null, - right: BinaryTree = null, + node: BinaryTree | null, + left: BinaryTree | null = null, + right: BinaryTree | null = null, ): boolean { // Base case: a null subtree is a valid BST if (node === null) return true; // if the left node exists then its value // should be less than the parent's value - if (left !== null && node.value <= left.value) return false; + if ( + left !== null && + node.value !== null && + left.value !== null && + node.value <= left.value + ) + return false; // if right node exist then its value // should be greater than the parent's value - if (right !== null && node.value >= right.value) return false; + if ( + right !== null && + node.value !== null && + right.value !== null && + node.value >= right.value + ) + return false; // check recursively for every node. return (