{"_id":"@detachhead/ts-helpers","_rev":"239-fb2793aa1f482c98a783390b4da3761a","name":"@detachhead/ts-helpers","dist-tags":{"latest":"16.2.0","canary":"16.1.0-8075f1b69fcb8e43f9190d228d110fd30d45f9fc"},"versions":{"1.0.0":{"name":"@detachhead/ts-helpers","version":"1.0.0","main":"main.js","types":"dist/main.d.ts","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","build":"rimraf ./dist && tsc"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","dependencies":{"@types/lodash":"^4.14.167","lodash":"^4.17.20","ts-jest":"^26.4.4","typescript":"^4.1.3","utility-types":"^3.10.0"},"devDependencies":{"@types/jest":"^26.0.20","@types/node":"^14.14.20","@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","babel-preset-power-assert":"^3.0.0","eslint":"^7.17.0","eslint-plugin-expect-type":"^0.0.5","espower-typescript":"^9.0.2","jest":"^26.6.3","power-assert":"^1.6.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","typed-nodejs-assert":"^1.1.0"},"gitHead":"db581cfbdc4b8baab7d7dd767fb7efd1db446ec1","_id":"@detachhead/ts-helpers@1.0.0","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-wEq/MM0PSwjdVUac/l5wwBhSbu5vzXGq5luHNrRmagv26vp8gYDJ2gw+82wWdemReUl9XE3Km29evAD1xXn4EQ==","shasum":"79691cafcd7e976357a9bd8e555325a0b3b10f73","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-1.0.0.tgz","fileCount":14,"unpackedSize":15417,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf/cMKCRA9TVsSAnZWagAAFasP/iLKGVdpwzuvU0irou2U\nHP4N7QBGXvSKDfuHwZGBOUUS/MJfKPeClk20FYJ9FpUPAZW6QV6Qy6VV8g1R\nBhZS5i4yPrDukMV/YZ96Cghgs/sQNiHZ3sfSECJEjovl01glVGxsbaSdlXqC\nQa3fqyFrot4WaQ6uRwhm/xODbEth7SBNSbA5uFESJFxwfmNHq5gVhhA3tPiM\nDZZGPShw/hq3VubDIcowC6LZ3hMFOnAHr1x60Z0OdAQ1YRrvc5MxVgbKqZQs\nSbbb+pMgLy6/Ow5LtG1b3AMGfdsyRqWenrizXt2lnRc9ix225qqQ0nHBlW0V\nORcCO/mohJwUTv5ak8dLTOlyKq3Y8vTcIimJiFFlK/LYTBmt8fPFUcJSyjjQ\naq3v5pisCuwDYDUSYeVm6JzzlMliiChCj0ivexm8J/f7uKl4y78js1gNSnfZ\n3qGj8+7WNhDmA204MD0Pj+XXIBH5KrHRSCkAUC2TqQzP0Na4qoMU4h+OYD1x\ne+hUf3Ae54/bQ9NpCxmYrySBHLlf97apx001OAgHpOLMSZYvH8SqWY0RACj3\n7l5JXhZLvUpszbMC6YTgVkKm6NRg/+GsNSVlaDM2/SgIZfmpKQBw6x9AiQ9s\n2O7I2fjEC/kIqX1PKgFmHJs4t1Iw1hqHj4IXCs2gycc2WtuLvTK5LEfMxbZ1\n0mjx\r\n=FL+d\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCID/i+dP+1pZexJjQTumhU8lzhmj+Kt8toe2hv2KGGlXRAiEAiYDXB0XUd1zYU2qxBoPWJifz5q5i5wXz0ke/RvfPsNo="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_1.0.0_1610466058296_0.6525849622044697"},"_hasShrinkwrap":false},"1.0.1":{"name":"@detachhead/ts-helpers","version":"1.0.1","main":"main.js","types":"dist/main.d.ts","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","dependencies":{"@types/lodash":"^4.14.167","lodash":"^4.17.20","ts-jest":"^26.4.4","typescript":"^4.1.3","utility-types":"^3.10.0"},"devDependencies":{"@types/jest":"^26.0.20","@types/node":"^14.14.20","@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","babel-preset-power-assert":"^3.0.0","eslint":"^7.17.0","eslint-plugin-expect-type":"^0.0.5","espower-typescript":"^9.0.2","jest":"^26.6.3","power-assert":"^1.6.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","typed-nodejs-assert":"^1.1.0"},"gitHead":"433428ad237eec65f2ce6ef4675d659636f5f2d0","_id":"@detachhead/ts-helpers@1.0.1","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-v2GB3GY2ZeEJnTi1XyrMhXbLweIV55lxA2Q3QO9y776F9IGWFXm3JmceWwY+FMyfW8gQvGV3xi0R83g3BbmWEQ==","shasum":"290f85fd473409b04b52c039bd836b56be099e03","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-1.0.1.tgz","fileCount":15,"unpackedSize":15505,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf/caCCRA9TVsSAnZWagAAMokP/2bW/rpbzBBP2pdKK6fo\nrYuVMDB2eOMsSiulJTHPY5xEEDrIi+x9B14mfiL1SyQ8tMR7emgtYKeGY8Ud\nOYONbSfR17jfP0AnHf0xmapo+w4omMM0CB09+gd5FB8maWHkxs+YS0trNM45\nsi72hmt39C04ZMrgtVRREXhy9V6pES7QF8QFu9yV73fCcxfBiK0ZtZ3bl6Rf\nrwetuO26W7EgYw1ExMcq+k0qM3xG8fepXTeXNVM4xt4sy4oJNDOEqfL5ixpe\nDZY30XugOWwzJLGcCw5RTYS1RZMtKRCbrOr4olaRlQ/nP/AiiZ6EuLjFNdGe\nz3Km7vpoxSPKgmRQPUi3vfUNU1wvQ8v83k+TO7VxQJT3IkvzAmIcf9qfDPOk\nv6+I+4Ge01whkGUB4w4hdPufRZquBGE0H+SKnozkreSiAUCaKRuMcbbBJRbE\n2O0O2IpcUk6VuXT3skLqJ2VsXKwFzHnxzmRCbcRV9NSsckDTqxmCIYTby2sv\nMq83bKE1+lmO9K+tLm/CjiaxC1X/vHo/5KpbsHjPylJ3HQcH5UeTsTcxhJ8m\nU2vHLa5EzffoKAxsRnHc0m2SUT4zNIs1WKBJVzzNx46/bxbjy5mEshiaITie\nkXA+YvYezpTlFxlETurgUiRBEcBEZ0QrEYVK7xy/W+2bWoisYXDMMJ13XyMm\nzBx3\r\n=3XsA\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICSM3Fm3zrtdk1wZseOGCd4tkz0wTvik5uWmdN5leGTkAiEAne1kQAhl5h+Atoj+vY939FkIdPsN+Qb4YU5ODqtuEs4="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_1.0.1_1610466945557_0.48498845608281815"},"_hasShrinkwrap":false},"1.0.2":{"name":"@detachhead/ts-helpers","version":"1.0.2","main":"dist/main.js","types":"dist/main.d.ts","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","dependencies":{"@types/lodash":"^4.14.167","lodash":"^4.17.20","ts-jest":"^26.4.4","typescript":"^4.1.3","utility-types":"^3.10.0"},"devDependencies":{"@types/jest":"^26.0.20","@types/node":"^14.14.20","@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","babel-preset-power-assert":"^3.0.0","eslint":"^7.17.0","eslint-plugin-expect-type":"^0.0.5","espower-typescript":"^9.0.2","jest":"^26.6.3","power-assert":"^1.6.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","typed-nodejs-assert":"^1.1.0"},"gitHead":"e16d270a2b7f21e4d6b2c4d80ce5a14ab71491e9","_id":"@detachhead/ts-helpers@1.0.2","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-UcSOoUopJeMhsivEbo3mPAa68PFEFPUfsubYGuqxJ4sFjSgZNHNJothp7Bk4hfP8WaQAMF57ExmTjiKA2XzoDw==","shasum":"05c632efc3e808b4cd789bf067f0145615da3c0a","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-1.0.2.tgz","fileCount":33,"unpackedSize":26022,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf/ce3CRA9TVsSAnZWagAAhRYQAJxQF7pESbZKqZLbKLro\nf+LZuZm05IFM8FBrYYKMNHNXLPKRtIyGTqjW+WXgb0TALZGMu511k0+0PGMX\nGFNSXbP+g3QQ6+08naQK2p+DDECwMA+KE3EJaqeNWLaofh2r4BnmcTMLX+Fq\n/+CQllD2LotOKNYg/0AkJe32Qm1kZ46kLhLiWsRHc4U8p9JnjIZT8h492Q8b\nk1jchterabHSigM7x3NhThCSRDnCCJrICkC1ViXdT3dHB2TbWMEyi1jd2kwD\ntd8SzwJh7Y1FGhUp5YqZcTNuUAHBCrGFWD0t+65T1/t90+gYyrD1VYu0jFkj\nRPpMemyv8Ihq+Cy898LU7LHN/8sPFi/TA6XUnI0Gxw2PYEOoFB5NazDkcYoL\noKz71SqjR5WnVq+v3miggqtR5elRMMOJVN/r1E44cGfvnlze/2CxcHomB5sf\nf1DP7NmYTR6WVdqF8baBArnDN4Ww3F9dWoL5xrlmEdvwER30J/koc5cjuTsK\nFmsK8f8ppi14rxkNMyCll0z4WeWHCrtSdL32Ury940WygSQgR3N2//OugvSj\nuHwxTyew/3TRICzpeRPLDJMYw+7aYfxPLHaBH89nTHmbsxB93n4aSEhpDtHz\n2Z/+4Mr9qx4gb3I+eR0F+IRWO2VVJquuoEum05wW42+yLEeAg77EPYet6KYF\nkFrc\r\n=URgb\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFFN9yaJoBM93LpgkVN4B3Lni3Y9sEN/POTFahSXyg8qAiB2D7Lwfith0l9AO4ogy8ZQH+Bk/0dhpMoL5vnD7P2IXw=="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_1.0.2_1610467255084_0.8610648666358913"},"_hasShrinkwrap":false},"1.1.0":{"name":"@detachhead/ts-helpers","version":"1.1.0","main":"dist/main.js","types":"dist/main.d.ts","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","dependencies":{"@types/lodash":"^4.14.167","lodash":"^4.17.20","ts-jest":"^26.4.4","typescript":"^4.1.3","utility-types":"^3.10.0"},"devDependencies":{"@types/jest":"^26.0.20","@types/node":"^14.14.20","@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","babel-preset-power-assert":"^3.0.0","eslint":"^7.17.0","eslint-plugin-expect-type":"^0.0.5","espower-typescript":"^9.0.2","jest":"^26.6.3","power-assert":"^1.6.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","typed-nodejs-assert":"^1.1.0"},"gitHead":"e0a757a155f6afa01fbc38c330ad32e238d67947","_id":"@detachhead/ts-helpers@1.1.0","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-9jlJOHjvNv5rm7v3jmcw4umowY+l05jQiY2EDhRmQLYiChvT7BzYpXJuUC671+RdlAzRhziVjxE0+vFN0GeIXg==","shasum":"e595659040b76065d69bc0bb76bb1d16c9c31729","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-1.1.0.tgz","fileCount":33,"unpackedSize":31552,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf/daOCRA9TVsSAnZWagAAKlAP/1GB9jpQXeWRBIP+oOAL\nFzLzILZ609j1PfoGtVJzzYMLgWwmgmzHhCuXkhQQCZG5uXe6zs3cgdEn63Cm\njnqakQ/EGoeRmAWJhZRJwYmelINEf9gkxr/Y6f0VY8M0WZQi112FvuvLzzpj\nTl5dk/5b0bwZvsdsnENETCSkRkPmebhjJZK8zu+GqRNWDuW3LRfcI9ioWis4\nPINMXzqChxtL0FHK+VTVrN6ruCCs926v70tUBy0LuKfYOZXr+UlzyRrTo+1T\nDXA1MTIvq2pIT78CsrmkdQ0cimk4iPloJ2ZR34jhc4hO9Gd3qWZvXgzyxO4z\nfKeKUAUm5sFlrGRiqM+ao6nU3eajYHlzcvJpMvbxXJsy8UWVy/C8UTZzEGV0\nIClJLDmOzz8l+DhL+n9psWpJb70ezYuyxLGx4+N3QuobatY91ID8jLBdL9hE\n86qhe7h+sxH5t1KsZG4NDSTn6d+K5AbRubirLXZaKKZcoknUtDEZ5LAuCjpm\nNI41fFMSE1hyMazMoXNRBcIezqFE7puNNaD6MAGBeGt6fhELVhimzjp+j/7v\n/eolPa9ow5AXh7z5deqE7G0ZVqlSjK9H5IeoYpH7pxWKg4IJsPD+nlVwv89q\nAJs5wIQbc9QvWrmhUYdxLusiAhyKg+r6J1rJrR3Efxoit2H3R55kiycSqCR8\nJCub\r\n=s1bo\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDGSmGO2D4Zu5hcSDc/mpUbhcAAF8V4pES1x6z0GmDZLAiEAoGFx9gb1PTemsIU7K/xE/YCBFCVHXaiE0tBN4A//z94="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_1.1.0_1610471054311_0.7851931880110374"},"_hasShrinkwrap":false},"2.0.0":{"name":"@detachhead/ts-helpers","version":"2.0.0","main":"dist/main.js","types":"dist/main.d.ts","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check src/**/*","format:fix":"prettier --write src/**/*","build":"rimraf ./dist && tsc -p tsconfig.build.json","postinstall":"cd node_modules/utility-types && npm i && tsc --outDir dist/"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","dependencies":{"@types/lodash":"^4.14.167","lodash":"^4.17.20","ts-jest":"^26.4.4","typescript":"^4.1.3","utility-types":"github:DetachHead/utility-types#ed16c9da0e0b461e592b4c046ff9a6d683a2e000"},"devDependencies":{"@types/jest":"^26.0.20","@types/node":"^14.14.20","@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","babel-preset-power-assert":"^3.0.0","eslint":"^7.17.0","eslint-config-prettier":"^7.1.0","eslint-plugin-expect-type":"^0.0.5","espower-typescript":"^9.0.2","jest":"^26.6.3","power-assert":"^1.6.1","prettier":"2.2.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","typed-nodejs-assert":"^1.1.0"},"gitHead":"9b327d2c068b187c279142e5b4d1371618d5cbe8","_id":"@detachhead/ts-helpers@2.0.0","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-uu/XsqvjspZCnHLOK1XNQJT3APa+d0bEHI47sTC2jxWOO6Qd1LwYN3O6dvUxVumiKRRg5q0QdlR/A74CD8hjxA==","shasum":"c8b9e346236b20eab1ffab5f3762ca1c555fab12","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-2.0.0.tgz","fileCount":40,"unpackedSize":39618,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgDXE6CRA9TVsSAnZWagAA6SkQAIuae+gFx/a+qps9ZmhJ\nJ/vLYzE1TP3G86hzBRdeI1W/hRQLEX1TzCj20IjMsYvOPvPF6QZXBSp8fRHF\nVJg4jwcEt2MFj3N8DxHj5Peqe/0FjP9sj3teRMji60WxBE0T9tjz1zLZNtgN\noSE89nT1QHfEvXCpcZBCGjaag+k/8EmnoSEo+JZv2c/KmX03TnMnV+PbAEGX\nCl4PK7GIumpfcpMWjt6vIoweeT9NlJ7MXAZXM2BvaVMcq+Bl23ZelkOM3QvI\nWxHF7IThd4U6H24WKD0uBhFh2lZ+lR9XWTCoGNiXSROV6joZAtLbz/t2s1Q+\ntDXiKl029e8Thz1SswzGQICQWa1b5TxM7HnLU380/zUXUysbzooFn8znnVHG\nkH3Txrs1WNBacrtjihqRUfa/i1gVjWxLwnuuEO0l+eDmLokxPO6BZ2Lg+PBb\ndh/fYOb5vh3lE2K8gBymTDXvii4zd/9aHQAld0usN5/1I0/BXFaMBVwwSTXl\njKqsY9m01byOjmAMaYMA89AenkOncCcEcD6MFhJWBEzTsI9L8eINiEKGQKy2\nhUQhntWDfboJ7wdm5ns/gSrUnZfE7LArInPgwKKe/bMfCJyIT1197+/1P4Yh\n6kkFnPJFRMEmMaW+J4M3ktHTDIGUi1tDQco5TuaVi/zptjapMvE+zHX87lCM\ny5h3\r\n=PeTE\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC8DjWxO03nLLd1N1XC+M6e8sLD6PpQPmnEmbwlgwZnmQIgX033sjH+qPT4e0CQSXIaukQh6/tSJb3O3vOMwndNdTw="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_2.0.0_1611493690181_0.9005207489323181"},"_hasShrinkwrap":false},"2.1.0":{"name":"@detachhead/ts-helpers","version":"2.1.0","main":"dist/main.js","types":"dist/main.d.ts","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check src/**/*","format:fix":"prettier --write src/**/*","build":"rimraf ./dist && tsc -p tsconfig.build.json","postinstall":"cd node_modules/utility-types && npm i && tsc --outDir dist/"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","dependencies":{"@types/lodash":"^4.14.167","lodash":"^4.17.20","ts-jest":"^26.4.4","typescript":"^4.1.3","utility-types":"github:DetachHead/utility-types#ed16c9da0e0b461e592b4c046ff9a6d683a2e000"},"devDependencies":{"@types/jest":"^26.0.20","@types/node":"^14.14.20","@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","babel-preset-power-assert":"^3.0.0","eslint":"^7.17.0","eslint-config-prettier":"^7.1.0","eslint-plugin-expect-type":"^0.0.5","espower-typescript":"^9.0.2","jest":"^26.6.3","power-assert":"^1.6.1","prettier":"2.2.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","typed-nodejs-assert":"^1.1.0"},"gitHead":"cd18bcbdcb99236e4458e1230ecdc9f45bae4124","_id":"@detachhead/ts-helpers@2.1.0","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-L/+DSRSn3zdEMqG6yg+DTj8QbZehRJjd8UuKnR6e9CQFF+saJ0CHoG2Xt9YiMEiOZ5OdlQFapNuwsnw8YkY4wg==","shasum":"245b76b3a0d6bd41186c237b8e0b83e6101bd684","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-2.1.0.tgz","fileCount":40,"unpackedSize":42781,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgDYRqCRA9TVsSAnZWagAAxVQQAIUze3pYq2b7fJcdbqqK\nLNEau8mA92jZuz29lyOA9qeV1K+uDVzPf3KI7OPTmuCHdDs9RC49roDHx0h7\nO8lL4Kh0mQCRC2dq9CpX0XPYo44QF6AXxYVKysjVhw43HPO3pSLY3WN1vdiS\n9TkmoQaYVai3lijrV8qnVtmDDgO/8rZ4C9zwW4XEomZwixohgTK1mmwbXjRj\ng4YTNPj47HJR8xUzOv2HUbpGrAqAQHZfCNmPPEJO6VnK0vo0XSl9CzOthZ1S\n2Wp4cIz+Bwsn0YOo1D5AWtwxJoLd6hSYOB6SDAOge0No7u4qnDbBOcFwjGvr\nOUVQ3CTHPdQOlQ1K6c14j1waeEv5jB7JcpZ+dD4HJNtNUYcIqIW9Xm0uxD8g\n0dVpFwxkK4ECAP+yHQCvkSZ/evZkXXcwKifE7RlLU300jqch7vmqA2ESP1a4\nXo1rKxtqgGZzyiaHno3osRc97u5Dm86pXkoFszK9Ml5lSOh8/ukYvGXSGIX4\nuux21En68hxSfnDvHsgMptgm5MYJ6syFqyzZdoHV4q9eWADuv5/52J4msW7p\nY/wFq6uCaCu9OvLjHJzIHJhljwXdQQ3beeaKNqgX4nmL2psjaSxvuGcgsEIr\nUrk3b6+7gtQhxExK9VSX9BqqXl8uFggJHZ3npEbBB7YPEbx2j1Kg2Qyvle0w\nYgAT\r\n=ySrc\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIC99FfqPxzZrj1f8t5510/u0eSO0G8EO0KGfOGK0nTFuAiBeRpdu3TzrvHHGLXjURbhG1+Vq3grL4BWS+lkLxUPNeg=="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_2.1.0_1611498601666_0.13094401575229453"},"_hasShrinkwrap":false},"2.2.0":{"name":"@detachhead/ts-helpers","version":"2.2.0","main":"dist/main.js","types":"dist/main.d.ts","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check src/**/*","format:fix":"prettier --write src/**/*","build":"rimraf ./dist && tsc -p tsconfig.build.json","postinstall":"cd node_modules/utility-types && npm i && tsc --outDir dist/"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","dependencies":{"@types/lodash":"^4.14.167","lodash":"^4.17.20","ts-jest":"^26.4.4","typescript":"^4.1.3","utility-types":"github:DetachHead/utility-types#ed16c9da0e0b461e592b4c046ff9a6d683a2e000"},"devDependencies":{"@types/jest":"^26.0.20","@types/node":"^14.14.20","@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","babel-preset-power-assert":"^3.0.0","eslint":"^7.17.0","eslint-config-prettier":"^7.1.0","eslint-plugin-expect-type":"^0.0.5","espower-typescript":"^9.0.2","jest":"^26.6.3","power-assert":"^1.6.1","prettier":"2.2.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","typed-nodejs-assert":"^1.1.0"},"gitHead":"71fce3340227354e19a4cecfa60ac464696b5a60","_id":"@detachhead/ts-helpers@2.2.0","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-3NhC9dJ6sG8w5R2bj7+op7h7WV+cwuLZQYuaVrxumTQtnr4dK16Tz/c2e1eUlnDsIFbjp01H1VQGD7W51uSWVA==","shasum":"17013982e948c3e9c8da05cfc376268216f0ef4e","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-2.2.0.tgz","fileCount":41,"unpackedSize":50837,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgDvE7CRA9TVsSAnZWagAA/EMP/1dZkWOExXI95cylGyYs\ntSK0xq8CS0b2w6jslsDsuPVwK38LSrBlsjsYuB2ydVvlBXOm81hRptKzJJDx\nZXBHpeV5euff0MdwAuQV0X81T8vZWRtn6W3hyKpT1ZntRQqMdoepcUvXHpki\ncmSyczhMorf0dDB0JA+Tkiu+1Q42y0PgpTOWRwIySORynw/AlP5yHv7KFGN0\nNBVB4pPaiZlzzrr+uqw/urFaBi96yccXNToLNVDZUGDgT1owMlySe1Fe/SnI\nogxcLSU99RMyxUPBVOVmuuwVI3AoBItLjsrQFD4Vzpikcxf3ng1tr+Yt0gE3\nQdCaA8SiEilZTp9qv1hyKKjYMEMLVujCMF32872Kjiuu1E1X6e1DpJgGXJ9f\ntKZcoOqoqsKwou2+3l9f8mpRj0vfbYl1MMxpLN/aRveMPaZcfNXVMO3pNCNH\nb6z4UPSnqmiG0uC5MXt2J6mTWbfM+/hr6sK/OJLY4AyxAzFNJ1KIajgPFVQB\nb+e45u+ZrZxSjU0uGnlcSwYH0ildPPxrb0yo1aBaY4ToW8BZJ1pUr0xiqwDt\ntB82q4PecKdbGYfhRjkaNcPKpNLx2KYz9vH7Mu3vd1zbs8qguLZFz3v07kZi\npsaFkD3cJOMFzAziNa1Vai/Da6abnK5Y/xWbN2IqRx1Ww68JAymdshdrOBDP\nCFgA\r\n=77BJ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC7sX+FbzKIpVDbcLkddxkT+46bjYdCSEn6j+bstrcL9gIhAJ5+TdL1inOUVtqn51xwLPagv5SVqc6Smp3JnZ9w6Oob"}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_2.2.0_1611591995228_0.9652367237802191"},"_hasShrinkwrap":false},"3.0.0":{"name":"@detachhead/ts-helpers","version":"3.0.0","main":"dist/main.js","types":"dist/main.d.ts","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check src/**/*","format:fix":"prettier --write src/**/*","build":"rimraf ./dist && tsc -p tsconfig.build.json","postinstall":"cd node_modules/utility-types && npm i && tsc --outDir dist/"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"^4.14.167","lodash":"^4.17.20","ts-jest":"^26.4.4","typescript":"^4.1.3","utility-types":"github:DetachHead/utility-types#ed16c9da0e0b461e592b4c046ff9a6d683a2e000"},"devDependencies":{"@types/jest":"^26.0.20","@types/node":"^14.14.20","@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","babel-preset-power-assert":"^3.0.0","eslint":"^7.17.0","eslint-config-prettier":"^7.1.0","eslint-plugin-expect-type":"^0.0.5","espower-typescript":"^9.0.2","jest":"^26.6.3","power-assert":"^1.6.1","prettier":"2.2.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","typed-nodejs-assert":"^1.1.0"},"gitHead":"dc17dc29a57476e43502aba26e3bfd8ee18fba2a","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@3.0.0","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-S7ec/NNKE5zDZFoFUr5Uj0n9UdrfdfJaZo9nfiKs3deaVgcoaJAcYkcAEpYu9DYpeVXx7cgDP3UlC8cvAQ2fkQ==","shasum":"4ec7a40860f255e6510fe69e5cef01838ad3f46d","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-3.0.0.tgz","fileCount":55,"unpackedSize":137371,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgKAyICRA9TVsSAnZWagAAJEoQAJqgLR20W/U+bNjoLfR/\nAoOG83BNcXI/qzj+4pffnVGalYqUvrt/TgukHWI4FaWYKfoQJ6cfMbdlSBKg\nzZ04tPggaAlNz6xVffH4nIXQFd/o32pvIaqlq9YppPt0HETviW6nq+eXGoqy\nOdd4QtqmBqcOfjqhRYx6lQ/lWc7U6IQ+u8m4L/FJwUAwPLXN+MeRwEJyLa1+\ntn1DYixlR8uiQU6jyV2Gyu/zxFkpABtgLdYbTSqXjPERFis7zoID6JjvM2cN\nJoJauaa/qXJnoWZGcpfszV9EPGDCyeJp6PdyFLZIv7TY7NH9DNnb0/kleA6V\nhbllheRNtVi2i+dhGCoPGl3F+OOwUsDJGfcLFO1rI9a02wHtq5POZp+jNVzq\nxypxS2zzKA/FyjIEQcbKVK6uMPZLppTnoOLaniPtMNUACTQuN5TUp3SCILS2\nW7pofMykSw7GbzJ3CFWzqnWAp8DMxuIq3mdP4M8KdRnYOi/JxGEN5ozl0Icf\nTSJz5h0XF5AQAz5SSDKXQWg9YelsT0IRJV7GLcLvwfqeCfM+Kdh9qdkPs3Oe\njgPOmXNvb1VNbq2sx0gDc/HiGPF5tsolk2FptK0VqYIElpB4Jbtf3Tp2H5eA\nmIWqEv0D9XFJspC6eHeojMj0N5V+qlWVdXxhB5ULXvQTguNMdTZFU99xhTJv\n5ZDB\r\n=lZMR\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDzwTXWkLGpTYvDK5zoivzEgfVXTk+6Do9UpOHWYLm+0AiAJv1IqxlPR8Fwp58OnoYuPERpSynG98CaVYNyiJKUIQA=="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_3.0.0_1613237383549_0.047243009121240576"},"_hasShrinkwrap":false},"3.0.1":{"name":"@detachhead/ts-helpers","version":"3.0.1","main":"dist/main.js","types":"dist/main.d.ts","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check src/**/*","format:fix":"prettier --write src/**/*","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"^4.14.167","lodash":"^4.17.20","ts-jest":"^26.4.4","typescript":"^4.1.3","utility-types":"^3.10.0"},"devDependencies":{"@types/jest":"^26.0.20","@types/node":"^14.14.20","@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","babel-preset-power-assert":"^3.0.0","eslint":"^7.17.0","eslint-config-prettier":"^7.1.0","eslint-plugin-expect-type":"^0.0.5","espower-typescript":"^9.0.2","jest":"^26.6.3","power-assert":"^1.6.1","prettier":"2.2.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","typed-nodejs-assert":"^1.1.0"},"gitHead":"27f783a6bbf63fa4a030278ec4a02776b3c4c575","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@3.0.1","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-bCUVLJgEUIYrR6jzcXjfrcASFQZV4pPdSSG2GyRefo2qKlNq5S5gFNRNg8+qrvDiEBbA/y3385Qy6TgzeNBY9Q==","shasum":"37f0be638f4735e230e9e6ab719f99c6e95250b8","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-3.0.1.tgz","fileCount":55,"unpackedSize":139249,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgKBKzCRA9TVsSAnZWagAAGuIP/AzLHVPA1wNM7QhYEwXn\nvLbpK85KXFl1sGejSIxTu/bP7zGthehFyXLXtciXUj5nUDPCqpkSdRKVzfKH\ngK/gyRFRKjl+mMMFAs+CPVIp27AVqDpzU/THpyAk5O2bwPNeCOaX84mKy79V\nbb53Fwrx0T7qNpXuGVixqQH79WCKwmAVuS2U+IYlY5PXVoSF/IClbGloDdw0\nTNmjkZJZL/yqeqfBuOFh4L8mech01CxQcTuAnsvh351kI4pz5l3HEMhJ+GEO\nge3IqopF2Rb6ANaxzsrVAIrNVQMkt+ln7mEzGrIq6n0PSIYkV9b/A03eyjTo\nwgfDs9BbmplbZDw0dl/oN0CMSczbZPA4n2NX7Vb3EL/CqdxQDXqZ4gj4xJ4C\nVR9SqyYnsO8xZux+34Uzod82TVdeu/ERs+YOXELz6AkM+pL00a8IMjHIuOLO\nmsJeH7xdJ9SVp39dEsWbJrZgsOJd6C7E8x/BZ55Q1KS5raZW6ECnfqoyO9OI\n6o6c1/2BCFoZtWFybxV/lv1wWTyP56zUcA3AvEpIwsZK1le/Ebw7sIxt9wt2\nW1i497C6JWU/IAmSNxc3506KZNCMovE7atvc5XXNVWTghB32KE8upOgjyQRt\niXAwMRNHDLHhzUP1jT47YDQKLNy1UGtSSw3keCHQ/ieuZrGhCiQKxGVK93L3\nE7xq\r\n=jCTy\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCsd6vRJ+Chdn3oX8zoKX6CaL3l6nIXLOjyLyUFftaegwIhAPtef0zgcz2FxezikIdbSUAwa8ZUjUjQaeQMiqEHn+u+"}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_3.0.1_1613238962506_0.29126397862517295"},"_hasShrinkwrap":false},"3.1.0":{"name":"@detachhead/ts-helpers","version":"3.1.0","main":"dist/main.js","types":"dist/main.d.ts","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check src/**/*","format:fix":"prettier --write src/**/*","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"^4.14.167","lodash":"^4.17.20","ts-jest":"^26.4.4","ts-toolbelt":"^9.3.11","typescript":"^4.1.3","utility-types":"^3.10.0"},"devDependencies":{"@types/jest":"^26.0.20","@types/node":"^14.14.20","@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","babel-preset-power-assert":"^3.0.0","eslint":"^7.17.0","eslint-config-prettier":"^7.1.0","eslint-plugin-expect-type":"^0.0.5","espower-typescript":"^9.0.2","jest":"^26.6.3","power-assert":"^1.6.1","prettier":"2.2.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","typed-nodejs-assert":"^1.1.0"},"gitHead":"c406cec3e3934d1f60d80d4ef1a2d54f1cb4eb8a","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@3.1.0","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-uQftD5MRqr84H2kc2L1L2zjdPDQ0KtkeBxBdJcs1IiLIoQ6Wtg9bEsBGZRYBxlg98mJM+Ju7vStMS/BBK/28tg==","shasum":"2975f54278ba8f6869d6bb81c9820068d49ee027","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-3.1.0.tgz","fileCount":55,"unpackedSize":146117,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgK7g/CRA9TVsSAnZWagAAwQUP+wfEUP+UQVnLBPTTqDtV\nsBq6cuk+B7pg65HafNwEbxrPYBLfM6lE/d78xTIRk+X0MGoiBnlZA02tIUt7\nZX4Xy8WJqrtFUfqfUPaZ8TZvOkpLhoWM8h+vFiQdUahOucFDMlFFESBKvvPm\nhtLiqnBLiQywFTHcGJivxzA4sQsISRS8I+Y0VutZnckx3OosCzHSubJpTPa3\nE8blaCuHb3svmr+pvPby6/qmjJuCx96wdixtWtsh3Ylh9/Shd1qtB2oLCAL3\nPElXzEz7ijpd1LRHdNDnBIPrma2mynq0t0GinxXUThScTU4FW4ghp7rsMS5k\n5eTTKN3vqjsO+P45abD8EjVg3+osL/CL9RWpU+rjkjVBH3DqEFkrmpcGQoDj\ncb/Pgt09LHobeu8J/wdcebQ0WiaTVMEpQqzwG13UzhzbKJG7ADeieByZRJrc\nUS2mUZI28GdE2XjTwGbi8BtuUf1bqes0F0vkx5lx69GyN6xnFuK6Clw4jRTQ\ndzkIugT65FUXBeM3GNiCk59qbgwLHDWkJTGmSKFLJislqIPqM+F84q4EQeJH\nTHiC/0/tLrGyCudXN9hcP5ci8G3AqZjj8xZQWvselSl2nOevMPw9qcKSwq9x\nc3KnhL3GmHqDXsNca6DS2x5y7dpr/ON+aZKzaKWk6aqln5Km5a5LooAqT5de\n3edi\r\n=yT0E\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBYXfcwoapV0WfBJmIJnGJ9rk2Iz16l1HSeo1DzbioMJAiEA+EQFAuj04DC0ZzxMTccjVyGzkNtO+EZYcLNOpCTrqUc="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_3.1.0_1613477950902_0.5841105805783571"},"_hasShrinkwrap":false},"3.2.0":{"name":"@detachhead/ts-helpers","version":"3.2.0","main":"dist/main.js","types":"dist/main.d.ts","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check src/**/*","format:fix":"prettier --write src/**/*","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"^4.14.167","lodash":"^4.17.20","ts-jest":"^26.4.4","ts-toolbelt":"^9.3.11","typescript":"^4.1.3","utility-types":"^3.10.0"},"devDependencies":{"@types/jest":"^26.0.20","@types/node":"^14.14.20","@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","babel-preset-power-assert":"^3.0.0","eslint":"^7.17.0","eslint-config-prettier":"^7.1.0","eslint-plugin-expect-type":"^0.0.5","espower-typescript":"^9.0.2","jest":"^26.6.3","power-assert":"^1.6.1","prettier":"2.2.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","typed-nodejs-assert":"^1.1.0"},"gitHead":"4fc289cbdcf253239ea27ef3812c3448b25934c9","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@3.2.0","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-eTvBM4BlGaQfSEEm9ZcWLe8bSVsbuYbX+AKHd8N5Lq/+93PJxQ5DGHGGmEVJYq+JefceRPlSoyZXZfLY0EF47A==","shasum":"5b4b9943daf8200d155d10ae4e29204ee66f56a2","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-3.2.0.tgz","fileCount":55,"unpackedSize":147228,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgN4azCRA9TVsSAnZWagAA6gQQAIUsweaDwHGueokAyAuv\n3wVbH7pFzSpIqdqkTTUEyg7KOh6MB0nhr2oA9pXezOK9HslaDkxdjeXaUmBk\nrMxwrQAjAoZ87ETjsXxKHtv6mwcwe/pb74mamwBUJFdLP+udEwexW50UgyEA\n0juXUcrcknNVS/B8ar/x7I2zsVhy8ouYWcUYO+hMVbD8dthACPJyjLalAQI9\ni7clAgK70sJ3SzknBRERvPVRlegt8mPOVQbwkFI1BPsZyB+m7rcCVMfyss/K\nRgHyEcL3QhCnIy+srj82PSKEu3h/6nzXJqtfX5hrmS4DXHI2bsctP12SxiXz\nqTYkB2IiHAqo7w8b+S1tOVYiibvqYwt7tTbnKPCpal4JP/+JioS/1amGWNYP\nhKTTprmUJuGwcF+TKXRvfaIqP7yjYvIZFV6kt7HT2LClvFLyhr6wyKAyxrXR\n+ZU2Lq2tD/nnVerj7iKTiuTd+dXDuZsfwdp2cy2m2q3MLAbXU44Y10BSl/oI\naDHXMaZ/TxaHUypLQwE2WAn/IcY1+7Tr/XtgvR433n9A4HXowtVVUYANabaL\nURiHsQga8w2mmbkDaQ2jf7wziCcoeDpaBmsM7zcoXm7yDT9Nhd2cyX6Md0gk\nfUYRC8jnRj08uhhy45eSxkv5pyL+W4c33iSVpBny6iP7TwUyPXM6VZhjReql\n9snY\r\n=iOlt\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDPXuxBc7yCpovd05GogW73+dcpT9LX02lHGjRDTykKLAiA5HGjQY9ehHdrYcy3qLZPEahpZnulZB3OKEsYVI4on0w=="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_3.2.0_1614251698923_0.26305087308548036"},"_hasShrinkwrap":false},"3.3.0":{"name":"@detachhead/ts-helpers","version":"3.3.0","main":"dist/main.js","types":"dist/main.d.ts","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check src/**/*","format:fix":"prettier --write src/**/*","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"^4.14.167","lodash":"^4.17.20","ts-jest":"^26.4.4","ts-toolbelt":"^9.3.11","tsdef":"^0.0.14","typescript":"^4.1.3","utility-types":"^3.10.0"},"devDependencies":{"@types/jest":"^26.0.20","@types/node":"^14.14.20","@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","babel-preset-power-assert":"^3.0.0","eslint":"^7.17.0","eslint-config-prettier":"^7.1.0","eslint-plugin-expect-type":"^0.0.5","espower-typescript":"^9.0.2","jest":"^26.6.3","power-assert":"^1.6.1","prettier":"2.2.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","typed-nodejs-assert":"^1.1.0"},"gitHead":"7dbdaa791b9af35dbbb2f6aca1e5c8162f1a7dbb","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@3.3.0","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-o8rlqzSUmwrM39WbfxbOreqjRZQAD/Cw0+o6a97CL89C3E6y2fooO8iS/5Ly5nhT6rQIqZZcZRhBNxqiGpSJKA==","shasum":"9bd8f46f0f6043663b184b5e5b131c2a58132bd3","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-3.3.0.tgz","fileCount":55,"unpackedSize":149191,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgP2bzCRA9TVsSAnZWagAAtusP/34cZR6RFCgROm+LzyJ7\n5m1zzITwH4WGzysAx7lE4IO5ntJn48gVYn5z0+pZpOMSyNaMyR3VJW7oUW5g\nyRueZTAZ1lGrvQE1bqoXJH7FysaYyD0lFl/nYGFaqCgbYwiKoMYimpdmPD2T\nOYaugdsIztmsG6mevDOxVnN32qstlX23fH/tf79w2K2tDgksWXmPXwhdtUrs\naViZ5NIiFy/DEq9ZHwlCo60mbi6uZx9E8w2oQqGrsDkt8K2ooudqtW5bpmqC\nlF2YJyA3Mb0ShnkMnYVsflALTA8hs1yfAiO7IzrgOOaEg+OB45wFn3MX6Bdi\nooSU4VblFI12ryvBT4q1I05O/DT1ljhnIXSEn7ofcyHhoegPXEldDXzkhH7J\nsAWm4QbCArdB4cLOqH7gcsO+SApyKI+yJL7K5Bfl6ovovgf6gLIki03CK+Ma\nXpeqQpbkjlXI/9D/62Pe4hcbquEN8Pd+HPp21+Yoh8Aoo1tioR6jbIjLkPiK\nHPuRzFA1mwCNUBGLhuayOmD9X+Sb/GURkYEPKkAqqgZyV7EFoKgNRMnNMOPh\nCQdh7/dgmzr580OOXKOAJtHzogJ30/MWpQcMrO6YkjMseSq6bC1HryluYZE3\nHWh9j7opyv6XP7NOXMY3jSodBDrafmlccjo5FC7o1dfLd1O/YaWfxY4unL3W\nX04W\r\n=hXNp\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAGimx/xPX0SNHtLAOs8g9MULivc6QPCoXGji/Q1+NxRAiEAo2lzIZwTjtGrvzrjq6s9BMYWDYa+x1VBJ22lc4n3uZo="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_3.3.0_1614767859284_0.037372769439032005"},"_hasShrinkwrap":false},"3.4.0":{"name":"@detachhead/ts-helpers","version":"3.4.0","main":"dist/main.js","types":"dist/main.d.ts","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check src/**/*","format:fix":"prettier --write src/**/*","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"^4.14.167","lodash":"^4.17.20","ts-jest":"^26.4.4","ts-toolbelt":"^9.3.11","tsdef":"^0.0.14","typescript":"^4.1.3","utility-types":"^3.10.0"},"devDependencies":{"@types/jest":"^26.0.20","@types/node":"^14.14.20","@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","babel-preset-power-assert":"^3.0.0","eslint":"^7.17.0","eslint-config-prettier":"^7.1.0","eslint-plugin-expect-type":"^0.0.5","espower-typescript":"^9.0.2","jest":"^26.6.3","power-assert":"^1.6.1","prettier":"2.2.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","typed-nodejs-assert":"^1.1.0"},"gitHead":"5bcdde7a9e0198dd1b9ffe14147f6d1ce8929f6e","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@3.4.0","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-dyupFp7RUOa2Nve0uCMV+sic7IN2CD+g8FE5hD9Uohjx9PU/NofwQh7ZV5v/6cz6EaAtZFKRVbqK3PazFtceZw==","shasum":"fbe12002d66451750fbd4db83e89c747f1036c50","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-3.4.0.tgz","fileCount":55,"unpackedSize":151813,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgQfmKCRA9TVsSAnZWagAA0PMP/1adSK3jXVWQYSvGMu4t\nrYa+HMLhsu2h5KH44ULRTJ6AdPhdfG6q87HEgwyuB+jH8JgvJqFg9ZxP/u2e\nRahVGhbwkbQKLrYa1oNmGh46CGj10YOawEo3H5wlgnO8TsNnpCZgIZp4N7g5\natwPfPuYfRa/KXf5IeBJMA6bFQqtpxBu6hE9lvTIM0QaO7Y7jHK9lP+ILBp6\nwD70HWYVlcNtM2oY3srIyJNdq7C72JB41GDpkpNaSmj/CVpgJodFfEKSvSmw\nZSA8R7LZlK2kfHnzURBYoOQoQU353yG8T07yenJPfhjR0PIQ7K5TNPQcFk/b\nbT+s6oziCo8vso0fNC6Z7a73d32iIQ1ubS2S7RK8otluS3uz8r+zZAXZlctQ\nIO7FLmb6xb3AjvymWLTIkeB9rH3AcG/75Xc3ywEOIZLx/pqU/Ho8XK/w+0/K\ntPf9yl0CBaWMqufEifUbTVQu7NAuElN2Dxell0+dTa6kLCuX2sXbo2uxDWZD\nyRwUDRhBfc3e1CUtpAb3t5r/7DdWjoZ5v6EM0GfsZ5Yg9LHPtHzYDo6cfxnT\noQtiirfgRNBD47LaajN4x7tWDd6ACcz7XtRRs0fSJAPdPFGX2af1NhdtJlSU\nG8Qzh4XSVjVJqQmVtpI1u3YUuzDXnKIZKwyQw4vhAKL5it82uT317PQmkRen\nstaB\r\n=NHrA\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIESixB6CsOF/iHCYEl7Zh5NnDUnpLnZsIY1Gq+3a2LAdAiEAsNdy+Zx8w5AnoiGHDsjBQlMImh/ci9XyIciM1EMqCak="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_3.4.0_1614936457405_0.6614137533578088"},"_hasShrinkwrap":false},"4.0.0":{"name":"@detachhead/ts-helpers","version":"4.0.0","main":"dist/main.js","types":"dist/main.d.ts","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check src/**/*","format:fix":"prettier --write src/**/*","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"^4.14.167","lodash":"^4.17.20","ts-jest":"^26.4.4","ts-toolbelt":"^9.3.11","tsdef":"^0.0.14","typescript":"^4.1.3","utility-types":"^3.10.0"},"devDependencies":{"@types/jest":"^26.0.20","@types/node":"^14.14.20","@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","babel-preset-power-assert":"^3.0.0","eslint":"^7.17.0","eslint-config-prettier":"^7.1.0","eslint-plugin-expect-type":"^0.0.5","espower-typescript":"^9.0.2","jest":"^26.6.3","power-assert":"^1.6.1","prettier":"2.2.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","typed-nodejs-assert":"^1.1.0"},"gitHead":"0e040797b06a1e6476f298fdb2a7906b0c605977","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@4.0.0","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-dJMfwflHWXHmLUb6Ix/Sy6ctcrpzZGzivOg9DXwTpMx3NXBSNmIVoFfLh3GGLL5gu1RDHLGNDK3kBXzlaZZbYw==","shasum":"a865872dd528a75d387cb1c3bbc72c888328f2c4","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-4.0.0.tgz","fileCount":55,"unpackedSize":157121,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgRhS8CRA9TVsSAnZWagAAmJEP/A2gPy1hVzFsgao5GPsu\n5XvG9ssMYPOl8iXEgySkzwDfHgeNnurOYxCP/pDReQiHfuac2ZgxgSF15RZ5\nG9+XzMn69eLCxrV/URkEyVBrBXdJSj5gtf/E+OsKzNiQPCsfgtOSnw++cCtz\n8FuiHEiAIpLgr7wwVew/0MkKSY5SUFUeptroKDPqmZPjQt2Z5GQNSmTZeslm\nq/VB1+lFcJ1Q11VtZKTE6lrRTkEU0dx8XHtsqD55wLETBnwbvM2hDH+L1lwp\n0BkkE3Zh46ZGlchhUJwQXteN7H4A2EvgySn9w8NnaiOZCWv2ifr5wPKar2f8\n8sFNO1hnR4MS3+XagKjzM8rlOupWbHRxAemoVgD8L6EMtmMdLzvRQdm0Xfqs\n7CBQdt3UyqoKAlX8MfybdYJNg8R9WSp+nAw5gYLkdOkFxjjj9cLnD5EHMphZ\nd3/eo3KvwjQlsW1PVoR+ytMlgu7CJyj1DNV+e6nrStS2PKDS3ThG2VFpN6gB\nSYxGzErxsXZtQMiLwZs4xDrdT6VqWd4LLUb8myNGRAPDiObsdlR4TUaM+iS6\n1Oo5LnQxe81GzUEoSKUXn9/71s43ZtbgVWkRLMFqZPPe2iCH1swAfE8GtLln\nhOSmCkpxljJ9aMEIE8Sw+EV28OV0KETyi2T/0XlcfBU1yMuUQ11fLXwGo4gc\n+mL8\r\n=JcKZ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDtCRkJWN5P/MeQmuH+ugKraEu6n5HVpQ0CTsiQkpIeKwIhAOeVXscN5VeTggTq6ZOMlA225qDqriK15bWTRkod9pdH"}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_4.0.0_1615205563682_0.3467636109652068"},"_hasShrinkwrap":false},"5.0.0":{"name":"@detachhead/ts-helpers","version":"5.0.0","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check src/**/*","format:fix":"prettier --write src/**/*","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"^4.14.167","lodash":"^4.17.20","ts-jest":"^26.4.4","ts-toolbelt":"^9.6.0","tsdef":"^0.0.14","typescript":"^4.1.3","utility-types":"^3.10.0"},"devDependencies":{"@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","babel-preset-power-assert":"^3.0.0","eslint":"^7.17.0","eslint-config-prettier":"^7.1.0","eslint-plugin-expect-type":"^0.0.5","espower-typescript":"^9.0.2","jest":"^26.6.3","power-assert":"^1.6.1","prettier":"2.2.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","typed-nodejs-assert":"^1.1.0"},"gitHead":"4c5ef9b41cddd12b7855ccb5b8c59cde67d4258a","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@5.0.0","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-G8qT2zlI7meiVFBCz6jdGkwKHM0Ax9/Nes/ELDrBJhltff+SkpeldeRpQq9ZPtOmOzCDLBME5BYfFXm7oyp+/A==","shasum":"9cd2695e547daffadf12f4f7d56c2511036e9560","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-5.0.0.tgz","fileCount":30,"unpackedSize":567814,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgWe7YCRA9TVsSAnZWagAAxOYQAIdKYxPsOYzPv2c1993v\nxQi+JhkQCihzQ0KHMwsrL7pPlVe0LjFpdaOVr8WPspottv3Q3ZRLykJISfr6\nxCXdp6AiT1OTxzwyKdglSDEEXShgCz4x0vpi1AbzixRc4dCIWlq/LMWlw7Ig\n10GC3rxwpjzJUzyGPtWqDLstpd4LM7IMQ/nUqveq8rBx1JM7cyk/PohSttZu\nH1Fsngpdurg77qN3hgbwDwPNVAZ0QBDhJmQzFAD0ush/qTwtZHhCQGk+KXdy\nQhH8XpxBb8FUz7gum2DENR5TGdLYQ2PXfhHbh4cYSJVNrPLbhZv/OeODrSeL\nl+SVmm/eKniZFc/1hf3Qd1bJrR4mpWByBv0AZogbKiw2KW23YG2eRQy2Ok6i\no8GR9+W5FlIzdFYh+6Bd1Kqmqz3SVFvxZIVUjsY642Jx7M0qMDgHr3HDfNRI\n1vutzZ1WAUMMYK0D1f9DKiXE33dIrg9Bvtu2IFxYTbHmWiT9OenvuoOKuqX8\nc/Xcynw87WBZIvQzy2vWeYN7Gqkfc/RfJNYysS9epSo/ZGxKdZ7zma6Z8ArU\nm/amNgSAfobOD7KsFcG3dpKiLRIX0sgMC9aQYl7aR2aXwCpFEBXUr/EPdxp2\nVCTV9ecihFp0n6WrdQ9DonUO0DLxfmsxOaFPqStoRYTkdp5s7b7xbXyA2P/z\nUMvn\r\n=hILe\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCsZAVtMzMcSxPUb1rlxvsJJszuNjPftUNfuK+S4eceIQIhALkgqfEmbpDJb/AJchpvMfOLTlKRr0m4g4Ym1haTGiCT"}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_5.0.0_1616506583727_0.003984695993184628"},"_hasShrinkwrap":true},"6.0.0":{"name":"@detachhead/ts-helpers","version":"6.0.0","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check src/**/*","format:fix":"prettier --write src/**/*","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"^4.14.167","lodash":"^4.17.20","ts-jest":"^26.4.4","ts-toolbelt":"^9.6.0","tsdef":"^0.0.14","typescript":"^4.1.3","utility-types":"^3.10.0"},"devDependencies":{"@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","babel-preset-power-assert":"^3.0.0","eslint":"^7.17.0","eslint-config-prettier":"^7.1.0","eslint-plugin-expect-type":"^0.0.5","espower-typescript":"^9.0.2","jest":"^26.6.3","power-assert":"^1.6.1","prettier":"2.2.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","typed-nodejs-assert":"^1.1.0"},"gitHead":"061aa92703bae3aa66f8cb8fcaac7d303eedf1b1","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@6.0.0","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-whfI//iN3Aja6scflHmtLyJD3hDXWHfdiWIwDKSSqrKl5BMEq/wPvbf0IrxpOeBbbopuUojXTxxJehFz528Amw==","shasum":"95c84da28c3bcc2c4746f55a69562e7cbd040758","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-6.0.0.tgz","fileCount":30,"unpackedSize":565827,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgYENLCRA9TVsSAnZWagAASFoP/04iEwSDyL5POXZUu+dm\nhJc4Rc/5zcotOq57p2oMdIuul8n33A93JK6bXCy+Keo3gJs43i2/fm4G2b8E\nXHkhPrmwBVvMNyQxQ0twB4f74+wxnFA+QFMSyawkb9mte+YRqtkS5Ca3Tee3\nPYqsHj1kzq2DRkFo2C5ujOmLXMg/2NDAol7GmRmFdhQahsNzO/yu0cAulR6z\neJJiFmHDCkHZAeME/6eVC/0twE1hcNnUBFdUNWURKsWhy0nghBb69nlkWgKR\ni7gsTWOQ1fI1wL2hPThUUqOs179QHrRrMu81+e2aDNWRSeBctLfXjaZdSS9M\nOrIwLP1RfrQOsLCmL7sUKb8HmDTt4hrF83lyf/CGQWTUgosq430vdgrrh3oF\n6SHDGph9UteJ4NeYwjb+R7F6aoWY96qpp2WSfCYtijXIrZJXwZRkEjLyM8hK\nrgsPC+3YP3bsUflk+4NHCUx/ZGkAUDZpmf1el5e1O4o3w41pStwxN/CF4H+D\nZm+d57yslHkavErdjv6ECQ33nfVWveydA5Jp69N4POkVg5mK+pwuL2KiqeVi\nM9VR5MyjBJOBNQHjMd8yH9hnXXM1LzkcNjMhw3331RO2Iy3muKU2jVCaCZav\nucEohw9s0amMDdqIeXChWt7CfCugj3DFhMnAjwWEEfjVKgjUAOm//Mtlxb1Q\nt18b\r\n=yj5l\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCElLVJTleXiYS2sRZMOSLXLXlSPUFl6a/vv1hrv9Wy1wIgJ5WSiX3KR9aQj8y11hzVMAFLivTV0jg5BaMkKNpjvPE="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_6.0.0_1616921418921_0.10508038503080686"},"_hasShrinkwrap":true},"6.1.0":{"name":"@detachhead/ts-helpers","version":"6.1.0","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check src/**/*","format:fix":"prettier --write src/**/*","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"^4.14.167","lodash":"^4.17.20","ts-jest":"^26.4.4","ts-toolbelt":"^9.6.0","tsdef":"^0.0.14","typescript":"^4.1.3","utility-types":"^3.10.0"},"devDependencies":{"@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","babel-preset-power-assert":"^3.0.0","eslint":"^7.17.0","eslint-config-prettier":"^7.1.0","eslint-plugin-expect-type":"^0.0.5","espower-typescript":"^9.0.2","jest":"^26.6.3","power-assert":"^1.6.1","prettier":"2.2.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","typed-nodejs-assert":"^1.1.0"},"gitHead":"c9d5f09349acbc51abb6948ef460ee7c2c379d80","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@6.1.0","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-4+blPvA07W7ENPhPeCGR5kgdyahdbhQ96K0MhTScM0Mrf/EfGqiQi7BMQo5Kc0J8fjgQF+wakCZvzGyS3TZEKg==","shasum":"53c4709ba2bc39554a0e83ec0fa1576284f5fe8e","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-6.1.0.tgz","fileCount":30,"unpackedSize":567452,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgYEgyCRA9TVsSAnZWagAAwxEP/17CvlmT/w6wG3tmiqg7\n1qVDAE+ibTHIbDnXpWP1SHM65Zxnl86WChfBCf7g+encwENeWEUMrAz80uD7\nQlLylsj4WyacJLrGZCanHYOZ0YD2OCNjGpyG7zEgb/RVCkSD/y7KxX9IexKn\n7c0iDasXO0FSPo+182TebGcxZT/nTlMkk4v/bqE4EXEVeXwatH7jI+J4Mae5\nMOAjN9sVC7R8sSHYVz0nIAu4TZnezSv4mso9JhnEOF0NKaiq/b9FrGprpmEZ\nzpFE9Nz2ykV8PmvB9NKDFsdFE0Hgk9y9KivhbM9AXOkUsrOzCloE2FgEgJHZ\nhCRz26vYGf+IahKCcwz7SyyuUIgs1gqJd96gtEhyI0TXINli6PPvC9ofQZgF\nXIw8RkLaVu9etQkH4RLW98xyLKwE9TvhHToVp4JV/8vqP2Cubo1iFpMKOdau\nYU8aFzS7nAZFQRk+zaItYhrxOq/0Vyz++rex9urdGbvuusalJSTfxe7yUagG\nhL7YIpGeyMfJO2PnN/+THSpY6zouKFNsRAMkcjBc0TK6oOqLdBkI4MaSmO4M\nath8GxjYBXtce12hqr7wBiZ5ANrGpEY5zZJpQ5gIIWg9uvWOcNCjWrYhWUbw\nFmcOqxZF4NxDcavQCWmGjJD7BQb4TcyvQi+An30OrQ+r7x0fNjIWMl+qwifU\nTHkc\r\n=jryL\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFEmgNL0oRyhCbBMUuahxYjlHlYJRKSiQQRRBc0k2e0mAiEAq0f7s+GqlhPDICdEOKTit+1gfHff+IljM71jq2lfpS8="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_6.1.0_1616922674343_0.341732662166212"},"_hasShrinkwrap":true},"6.2.0":{"name":"@detachhead/ts-helpers","version":"6.2.0","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check src/**/*","format:fix":"prettier --write src/**/*","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"^4.14.167","lodash":"^4.17.20","ts-jest":"^26.4.4","ts-toolbelt":"^9.6.0","tsdef":"^0.0.14","typescript":"^4.1.3","utility-types":"^3.10.0"},"devDependencies":{"@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","babel-preset-power-assert":"^3.0.0","eslint":"^7.17.0","eslint-config-prettier":"^7.1.0","eslint-plugin-expect-type":"^0.0.5","espower-typescript":"^9.0.2","jest":"^26.6.3","power-assert":"^1.6.1","prettier":"2.2.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","typed-nodejs-assert":"^1.1.0"},"gitHead":"d7cdf35bb13e1f55b404eb54c9dbd4970643d2bf","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@6.2.0","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-gRJ0Lebz54mpU1xtdeqjknAJDT4uDMdmWMIcBsHJHXMAaGzGYBfuIg+JlA6bBOmuRKz4eAIw5DWZdyc+ko4JVQ==","shasum":"b651dddba70760c910d030e03161bdc2672b23e7","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-6.2.0.tgz","fileCount":30,"unpackedSize":568780,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgYSQhCRA9TVsSAnZWagAAiAsP/39k5I10o2CRy1HWmuVb\n+Q9UVCMkKIu2KpxJTHblV1ucELqFGQB6QjJGwXAIKfYm8BWom9AXlyQfU4cU\n2H63Fy10yT1Vs21eBKrP43B/Zoj7AAmNpDkafuBMm2JF2aaS3fpzKka5GJiS\nmH/mchS8XKH/FXgJ1rqCtxYNKdcnlpxUGtRX3vXQnf/TsWBPQ8/sQUZXy/6V\nyxQ9AJm5BNMGUT8vuhILdHexB+RM8dz/UMoVgF1lrxMyqpnwdH+Rg4wWRMdd\nIyOEiVFUXD0JOAnQdYISMlZapZV7YNK30f50VoobvC7dap6vgX+wcN0vIGYV\nEHJrylJ9r5VjMn8jzW1EJwY3GeYmzsb4C8y5+r9kFa+R7KYKtwMVNd1Z7CAj\nZBywkoTsen5IG6PVime6Ku0cugWGdJQ02yxCpDvIlPSzU1p8n6J/9mj5zqI1\nkykcCOPLuWwBZiYB0CbWJeE4+yCTe9B105tQc8G5nfaXdXXnxKYVl1ohy7iR\n89fPTAQtYHbe2thQTI37Db3tDm8yjBEklXbUNY+pHI/vVDH58jlTjdKam6xN\n+inLDEOIeHA2h+N5m3SkjciyVF6NCWmxQq9h0Q7eCMNCtZvullDd+KyK9guC\n6nTIEByidlH0Nm3+meV3pJujqviheo2aOXjOEYje8dnNDq93SStzMr6Ly2yR\nZlqL\r\n=pQEi\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBlde3rbNryvQfU+fkEKrEwMCq8OZc6aE0vSAR8JAPlQAiBZKX42FlerMh4esGkfPu1iZiUi+S36bh9oXbETeLpuzA=="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_6.2.0_1616978977269_0.07069096486051718"},"_hasShrinkwrap":true},"6.3.0":{"name":"@detachhead/ts-helpers","version":"6.3.0","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check src/**/*","format:fix":"prettier --write src/**/*","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"^4.14.167","lodash":"^4.17.20","ts-jest":"^26.4.4","ts-toolbelt":"^9.6.0","tsdef":"^0.0.14","utility-types":"^3.10.0"},"devDependencies":{"@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","babel-preset-power-assert":"^3.0.0","eslint":"^7.17.0","eslint-config-prettier":"^7.1.0","eslint-plugin-expect-type":"^0.0.5","eslint-plugin-prettier":"^3.3.1","espower-typescript":"^9.0.2","jest":"^26.6.3","power-assert":"^1.6.1","prettier":"2.2.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","typed-nodejs-assert":"^1.1.0","typescript":"^4.3.0-dev.20210406"},"gitHead":"bb4108dbf17653d5dbc82c31cc3d6337a1ec5c8f","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@6.3.0","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-pvxkKLe/07VVhvnhjDe0yAy25r/EzBcGTRLzypEsJEktJLhx4NGcmB6Pk2znG5kZ/3LBzWZxoi5ntmaqsjs+RQ==","shasum":"9f72b273d5b9500649489a5d891839e615207b68","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-6.3.0.tgz","fileCount":30,"unpackedSize":571220,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgbE3yCRA9TVsSAnZWagAAllYP/iwLVPPOV6XdwhRlFBTt\n0En7FD5bFbLFU6Qo9I69gN1ROj/sWgA13kb+9H0OaANRU1woD+kvcqOHtjg2\nElFNKIb2c8WKtPg7eu/ibA9QSGi8zNM+6VoLpVR9fSgdAxXjj1THVw+H4QKD\nZVgOjsialWnijbFO2P/cNas1fTT2WYQb05hHa2iegoT1Cj5dXAHYwZhySYOH\nGWdHob7wYArhLNldywoFC+ldnTlLJSuK8RkGWlepd3ks1N0wR5xwVLLrujWP\nKO1bFMy9VMkwxti8mfl4tpgyk8xE+aIB7zdNyhWmewIJAhTbJFibJSt3H+8y\nXKGfbIBCiotaDWhcnibcS/hbMk9N6jaU7EBsB3a3OSdzKI6QGQKT+byxPajq\n40YqdUD5WE2Fzl751UmovyGRZkr2U9najHMkCdZSb8LK6HQmYHyJvt74Pn8L\nSubBYaIJgfIUkSEfeu30+RDGe52/9zYWaEIbG3xH+X3zXrjTo9oywEXDSU3t\nwGtM5CRT3kZi9KUyyLu+AJepo8RX3V5AkaphwLqWdZEXEfkn3/65dR8K+KTB\nuDZ8KaSJKP85XjklpbifOihUjlCCHTGzghFIJJKtZp+Tq6x/r6c6qIqa0vKY\nX08jAB7KJ3kZPiQRt3u8NJbDqH73bNC5kveN7W6Iv2DmP0xTUgwjKZ6ODQzg\n6pYR\r\n=JnfI\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC24f1fTCiSqzbLAzYCUJBC6OIByiap/ch72l/4qLINJwIgfquV2MuzbzHZGWVys+izWgtnPmnXTCXt+soVIRkL88g="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_6.3.0_1617710577466_0.89064711670987"},"_hasShrinkwrap":true},"6.4.0":{"name":"@detachhead/ts-helpers","version":"6.4.0","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check src/**/*","format:fix":"prettier --write src/**/*","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"^4.14.167","date-fns":"^2.21.1","lodash":"^4.17.20","ordinal":"^1.0.3","ts-jest":"^26.4.4","ts-toolbelt":"^9.6.0","tsdef":"^0.0.14","utility-types":"^3.10.0"},"devDependencies":{"@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","babel-preset-power-assert":"^3.0.0","eslint":"^7.17.0","eslint-config-prettier":"^7.1.0","eslint-plugin-expect-type":"^0.0.5","eslint-plugin-prettier":"^3.3.1","espower-typescript":"^9.0.2","jest":"^26.6.3","power-assert":"^1.6.1","prettier":"2.2.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","throw-expression":"^1.0.2","typed-nodejs-assert":"^1.1.0","typescript":"^4.3.0-dev.20210406"},"gitHead":"c9487bf306b6959c5dcdfe8f395314ac4b8b1efb","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@6.4.0","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-7M9yYs93lLr0ZpQ2do3Q+FBGGUpm9juyPcbsb/dMtqg2QTO6j1BtmJddwGBCcaVCr4Nb4sbnuqrFZ7dOYHWP9g==","shasum":"0338929a725c368aab993e5cb18d5b15ed198dce","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-6.4.0.tgz","fileCount":39,"unpackedSize":598324,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgfd0XCRA9TVsSAnZWagAAC5UP/1DKQSYtImoKw3a1rQCF\n+1PTRSFbCpaoX0aEUwgErZQpDhjIgzGLoJo2c3vUu3LpTCtj4LjFGf7Kcf60\nh/vyGaJEagg2Cz4k1JxrZNJ7BgtJs/m4bdTOlVcOHvg2kZUsdHb7meXzg0Cr\nHYpp3vzBGKLvUk4k7MylH73b/qFVKJyw5+E2lIDenVm7uMh+RoJNFBwe2Nx9\nVVdgjjSyxkn+06Fh8W21JP92PrH7sJeeSdJvsSNHKaqkKOkou0JkoRPW4bew\n4a17NqZptJ+Ch3H7YuW5f5gziOnHV7268f94KCLxRchCcrpWPtXZ2PCfsSMw\nJzrEmtZBHa59eIY8SM0MOCgTIPdD/5h4VJDNNQHZeCiNEUFEs9yEO8TL8x2S\narrgEVVJhMezsL+GCSMiWARAa0JHSXc7cD84GsJXoEPYbKoihdp5NoIcADc4\nleegCvLJxYd6FCmvGA6BBqi5ZTb93p70yhbyRndHzTFO2owDWJs0cAxUAQeJ\nUqOsUAg/NSM3MWctu2T1u0IZtU2x9YkJZxY+gg92Y+O8tREvJ+05qop8Jxvp\npTp0jxdBOT17rujIVMh6j+zbtzK3N7/8NX32+9zgwe9jcamRZLQ26Zg9shyJ\nvlcawWtRTiqsepAGRa4ffXXT34pnRwlU+MNiTbk0GVwTN620YaLgJWkBVEN8\nV76j\r\n=Y8Lt\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCBuDfbfcq0zEos8JKEm7NyQPEhTpg/J0YPZCvsF5j55wIhAILGlVgx0TAKRJJZHypTbJfsZMPiM0q8n77Np/Fyxne2"}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_6.4.0_1618861335166_0.19569739592934576"},"_hasShrinkwrap":true},"7.0.0":{"name":"@detachhead/ts-helpers","version":"7.0.0","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"^4.14.167","date-fns":"^2.21.1","lodash":"^4.17.20","ordinal":"^1.0.3","ts-jest":"^26.4.4","ts-toolbelt":"^9.6.0","tsdef":"^0.0.14","utility-types":"^3.10.0"},"devDependencies":{"@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","babel-preset-power-assert":"^3.0.0","eslint":"^7.17.0","eslint-config-prettier":"^7.1.0","eslint-plugin-expect-type":"^0.0.5","eslint-plugin-prettier":"^3.3.1","espower-typescript":"^9.0.2","jest":"^26.6.3","power-assert":"^1.6.1","prettier":"2.2.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","throw-expression":"^1.0.2","typed-nodejs-assert":"^1.1.0","typescript":"^4.3.0-dev.20210406"},"gitHead":"641e8a4b383fb10a4a6b9e8a40837d873d021b66","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@7.0.0","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-z9RFDTar9ZlaWwsfe5GvOrqxF9QmIHdcvIgX6514C3EZAlJl1jgxHk4ITfABOV73mleHoLynZV6IOCSmr54hyA==","shasum":"e7221e4f12535dff7692ff02a2538e9917d583a0","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-7.0.0.tgz","fileCount":39,"unpackedSize":599340,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgg+8kCRA9TVsSAnZWagAAjcIP/jG6rnv7PCmKwCTRF3+x\n2SXFNk3BgrlAZfsQ1ZqFw6lYl8QrTli+KqiISw89wWsRPH3lcdlruf/Xm6zl\n5BWtLL9iI/m9eOavKjFifvydIBnRMjVDEmpnCEHg5djsPcvJAnNrYM2lZzks\nYKGM/63wn4aIVLT0ScyxgomWg2JSlIkb8uPtXnj+jn/80ox/exsMAiix4Eix\nh+uerMjhj385ai5Hw/kt04VBkO5uHUfBx+fxdFvEXiziDsN6JgIvS0B+aBtD\nk/7/ld3lig1KGW3yk6kPP73uiW5/9JECMWMo9H8r6aTimTwAXdtJ8/JDrgpJ\n9OKp1LAlBP5gCwVogcXqB2/hdWXA3Cv1SW364k7wJ/xXz20RH7g92KNPVkTB\nlZ5cEv2nhXh+LahvZAL0wEe93k8Vvfxwt0KN47Oqc0Wd8yq/6xj1cM4PLfam\nGZ85Whg+xyzK9RG+VhQB+Dh2Mrualh6dkmowqzJsXnT0ObhxlnmGj07eNr3b\naQpql2HIiDYO+3NtJ/LrkgIB4OWB/QXfpDGKJtuQia6OSRMZYibxtnHHUnDl\nXFnCKnc70joQaAL9tEa5s7Ho2IlENTlc5lRg83/JTvlDguE0xAT+K2sho4Sy\nM6hUHftLhYoPfKTDbzu41ZSa7Q89MFg0a4jK0FceqRu8rPdvBAwTp7LlpmKV\nz485\r\n=HsSS\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCzqNGoNhRCFmYd5QyWuLwUTeLU+JCB5UMQ4NoLEel8ZgIgGgrdFiAO6uSYXYayJ1gQE72u9AdpoaGFfPZ0t6EzD3g="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_7.0.0_1619259171618_0.747607809751965"},"_hasShrinkwrap":true},"7.0.0-7bf82ae5e8cf9edf82bd05fec5aea7690efe2e50":{"name":"@detachhead/ts-helpers","version":"7.0.0-7bf82ae5e8cf9edf82bd05fec5aea7690efe2e50","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"^4.14.167","date-fns":"^2.21.1","lodash":"^4.17.20","ordinal":"^1.0.3","ts-jest":"^26.4.4","ts-toolbelt":"^9.6.0","tsdef":"^0.0.14","utility-types":"^3.10.0"},"devDependencies":{"@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","babel-preset-power-assert":"^3.0.0","eslint":"^7.17.0","eslint-config-prettier":"^7.1.0","eslint-plugin-expect-type":"^0.0.5","espower-typescript":"^9.0.2","jest":"^26.6.3","power-assert":"^1.6.1","prettier":"2.2.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","throw-expression":"^1.0.2","typed-nodejs-assert":"^1.1.0","typescript":"4.3.0-dev.20210406"},"gitHead":"7bf82ae5e8cf9edf82bd05fec5aea7690efe2e50","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n  const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n  const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@7.0.0-7bf82ae5e8cf9edf82bd05fec5aea7690efe2e50","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-RKH7EN8r+b4bb4D7hPsZm//df9ZqnCWb9Q1Z5Qwxbj6ApUmubc8W0UC4J/dO+93R+P5GzAYHDMSn5TpBc7Us1Q==","shasum":"4af545084e68fe16c70ab72a74ced0a70d5f2856","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-7.0.0-7bf82ae5e8cf9edf82bd05fec5aea7690efe2e50.tgz","fileCount":39,"unpackedSize":633468,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJghDrLCRA9TVsSAnZWagAAqR4QAJ09qQJbkeTb+nuaaMKt\nwUiR1JTIKgFq5i7lcubK8Su1vmQwkW2FKtft1PPT+pgmfx/DM4qM9Rao99iR\nWLzzbjIWZD8hw9uDJJiyXk925+Tk3pvD7QNZA3COGqSgA5VVJ7CcYaJ+3Cxy\nEYoZJzTxChXpwq7UeeA1XgOMZYQjbzalo8tWf/2jwL9tOu+qDewnwrmDSrH9\niRSDb802D+HwRO7UTlrYikvJITKaUZpTWWHh4TKmYg5NOzC58EPNGRxwX9Kv\neu0l+DTLBXFbkq8RTGhGHm5MlZHqHSFnPI5UJJP/9XKUUa8FsRdQZ/UInppi\n8epIujLl4wDK4cKNKI+fFyKhOZb2apg3w+VRSVRy2A+36UP3NBSns99Ksaq/\no7zxOVWxD5pq2qDsu+b/y+PVo0NywG/OfTYTCmCogCfAcilB+cdgT5FiXXu8\n80zHfDHBIf6HRnbWilzAOBPibeam5nK7pwtjNw1N2+VwMbPZRKcnk5a6Mz1P\nVPUHGt9jlKhKCxK+L6UJrPkTuU9GpTfN0bqVQCfzge6tqJr4L9pvvP6Ubxnz\n2EVJKYVOnjS5oNf3ylA8TuXaYh7+YsOyD/cnHo+VWbSjx0w2kpp+/fCnkekU\nfPyjI+kXKcMd/sarhPvhj9ECs+3eu0dB7W0jO6zFOcczBAlZTwhe5k7WyGU6\nh7/V\r\n=OwEP\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCNmjX1uu9xQqhDtfJHEdZqSvOMP9a55gD92MhupXgJsgIhALKJ+RYoUfK/hsjfCNyo4+UXVJt1W2pfJbId0wkgOMJ1"}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_7.0.0-7bf82ae5e8cf9edf82bd05fec5aea7690efe2e50_1619278538285_0.7876808954223857"},"_hasShrinkwrap":true},"7.0.0-e96cffe946bc645a061a0504664607b46063374d":{"name":"@detachhead/ts-helpers","version":"7.0.0-e96cffe946bc645a061a0504664607b46063374d","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"^4.14.167","date-fns":"^2.21.1","lodash":"^4.17.20","ordinal":"^1.0.3","ts-jest":"^26.4.4","ts-toolbelt":"^9.6.0","tsdef":"^0.0.14","utility-types":"^3.10.0"},"devDependencies":{"@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","babel-preset-power-assert":"^3.0.0","eslint":"^7.17.0","eslint-config-prettier":"^7.1.0","eslint-plugin-expect-type":"^0.0.5","espower-typescript":"^9.0.2","jest":"^26.6.3","power-assert":"^1.6.1","prettier":"2.2.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","throw-expression":"^1.0.2","typed-nodejs-assert":"^1.1.0","typescript":"4.3.0-dev.20210406"},"gitHead":"e96cffe946bc645a061a0504664607b46063374d","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n  const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n  const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@7.0.0-e96cffe946bc645a061a0504664607b46063374d","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-5m7dOEdKzcWG4FdVp23JYzl7vtoiHntevLI+99niULjZvyOSarQyTqBq2fBFJKdYtTiW7XNuTGzRYEU9Hjfwag==","shasum":"8ef8fa8b6436cd9e51a166c344530004ce88ccff","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-7.0.0-e96cffe946bc645a061a0504664607b46063374d.tgz","fileCount":38,"unpackedSize":76140,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJghDy2CRA9TVsSAnZWagAA7bQP/10fcGmOZaOHJ3jk3IWY\nBuzb6YjMHA9KU0m7ddj5yXLdPA1TIbTOhWS3orMd9b/3XFdDMKrOYtNTQkRK\nEP65jcINipYe19WNKFkVMK5CwtfkO1qz17T2xIePpHGhxo1Vrzsqj4FQkHAj\nUYyaxwNdkRn0xWCiBEfN6m6qhOjW7PFpDyDFKC97JiQ+9yJEF8hHPf7o44cY\nTlUbIObKI471Ld6oKhUkJQ35ARf7XK3Ori67VKFMdZ8oTV7lwx/hcqL49XAo\n7pudgy9VQkK6ZI0pFpRSvwjuFJWAyV0FxhG0XvNAc6sZDPBVfUx9B9rCoeD4\nLG34H0AkstYuLnaXL+uXB51mn9n7g+3GRFN6v45XMblNNbyMt4rfUtGO2oxH\nAvtYI3jvUxMHkNBo9/NBZD2xpROElvbKUP3ruBdjtAHMr4zlIzj9YkRF+jKs\nez032Hkgn4DK/CpC2q+xvTgW/j11XR3WDX5es+Y4XdmG8k1BXyk1vh/Y1maD\ntDmy7XV4dj3Ov+i9qwYj9eToHupfKnDAGAfQakMCAHlcjBHLfaWcVI1AAool\nN1zd6x2AVy/OzLqbqscufi836kpYF66HoY42lvxeFmpX0xd1eVHG9xYuPwDf\nlPsId6HKCoaycKzNGbyHl4OKqMCkPz7+j7uPjroEfIP3LRQmvd0jpdUJMhEH\nTmjj\r\n=HInr\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDqav01j8FpLhyrZ1KfhC/1mtaELDDdgVrWY71DuH1R4wIgYQrmQPsu4DSz0eWspl0ixp4aVzE7sIXou0uFUizEVvI="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_7.0.0-e96cffe946bc645a061a0504664607b46063374d_1619279029704_0.27704105825023984"},"_hasShrinkwrap":false},"7.0.0-56fddd9273c70b028585f63a2ec0e9f01ff9902b":{"name":"@detachhead/ts-helpers","version":"7.0.0-56fddd9273c70b028585f63a2ec0e9f01ff9902b","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"^4.14.167","date-fns":"^2.21.1","lodash":"^4.17.20","ordinal":"^1.0.3","ts-toolbelt":"^9.6.0","tsdef":"^0.0.14","utility-types":"^3.10.0"},"devDependencies":{"@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","babel-preset-power-assert":"^3.0.0","eslint":"^7.17.0","eslint-config-prettier":"^7.1.0","eslint-plugin-expect-type":"^0.0.5","espower-typescript":"^9.0.2","jest":"^26.6.3","power-assert":"^1.6.1","prettier":"2.2.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","throw-expression":"^1.0.2","ts-jest":"^26.4.4","typed-nodejs-assert":"^1.1.0","typescript":"4.3.0-dev.20210406"},"gitHead":"56fddd9273c70b028585f63a2ec0e9f01ff9902b","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n  const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n  const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@7.0.0-56fddd9273c70b028585f63a2ec0e9f01ff9902b","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-KWg39grITwYttn9L/ur4uhUpr8lvTXdxqpf1sSB88WytGvhU2WuVsGlO0kkIQSRhfhjc/kx3wDMpHoLbWpinUA==","shasum":"29b75a57c98e113a75188fedd6b0bbcd2e8be40c","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-7.0.0-56fddd9273c70b028585f63a2ec0e9f01ff9902b.tgz","fileCount":39,"unpackedSize":634908,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJghD55CRA9TVsSAnZWagAAKPUP/2abQU6uxlBIT1EyUOxH\n9YUGpuKPwwkTVGu/litkl94wDd6VnblIwvzUhwhKhD/9y+eZp9QtCZdYoz9O\nvEDbHG3aVsEnusgOkuibGojr/Rm1KpMpqY6U0HL6biG3/z/Qm92WcD2sWnV8\nRpEVxRI6Gho2YXae2bc4nQrBnFZd2LvJk87B3EPXDRX6vNf+HYI3B3n7Kgsp\nNtxmCFqhf/tSBDfd3dQGSNXCVGSEq+/pZ5RYsZq1qoI/r0dMZC5h6Gm09Pln\n7X942mFcfhZJ6KaJJMxgZ0oJB/6XqMR6vibWvqDCXiixCvj0oVuSA+Ls+JEO\nsziOiJUn+pRovV51QGcFVO48E/ZACm2waZRgeJOHBeqjmvp7wXj23eu/vvVL\nd0CAONqbgzDhQ0q3OSqUB5aCTxL5gvgWcZ93bp2yV4xc8/hc5X58alUYO42e\nSp7cTYTvFJF/vz1brpNgLGdS+3TqJaece8YRYSEBKgfWer7ewnuvrv5vCfXm\n10JgvBWWQ+mNwKJb9WW8+jd082XxalKDrG4chnhlY63X7ZOGD+azlBav2ctl\n8EK3Mhd/D/EHvIOefKo3YJA1abPtF7CTRDEJQ2JnOI0jc65jMK0GcydYhei1\nHUSQ6vxOzT5wzOyFY+O9kYJAbK66Z0D/TxlwIOpjsCbhzEmg8sN9O3YE6Vyo\nvvK1\r\n=emx7\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCnEaS06pnX3IY2JL4FaK6SH/ACL9hFi93lv36Bv2OspwIhAJQGNuDAv4IHLvfgpArmW7abFFFF9HMRdG0Dw6dMbW99"}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_7.0.0-56fddd9273c70b028585f63a2ec0e9f01ff9902b_1619279480658_0.04553362773705083"},"_hasShrinkwrap":true},"7.0.1-d53cd47ab3e47f4d850a4a4d1808372d8cd5c196":{"name":"@detachhead/ts-helpers","version":"7.0.1-d53cd47ab3e47f4d850a4a4d1808372d8cd5c196","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"^4.14.167","date-fns":"^2.21.1","lodash":"^4.17.20","ordinal":"^1.0.3","ts-toolbelt":"^9.6.0","tsdef":"^0.0.14","utility-types":"^3.10.0"},"devDependencies":{"@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","babel-preset-power-assert":"^3.0.0","eslint":"^7.17.0","eslint-config-prettier":"^7.1.0","eslint-plugin-expect-type":"^0.0.5","espower-typescript":"^9.0.2","jest":"^26.6.3","power-assert":"^1.6.1","prettier":"2.2.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","throw-expression":"^1.0.2","ts-jest":"^26.4.4","typed-nodejs-assert":"^1.1.0","typescript":"4.3.0-dev.20210406"},"gitHead":"d53cd47ab3e47f4d850a4a4d1808372d8cd5c196","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n  const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n  const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@7.0.1-d53cd47ab3e47f4d850a4a4d1808372d8cd5c196","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-aDPkd0KwcDCgD4T6yiSJa8EE/I8xEO1Hm1VPp8FzbzyQIa4e1gwpwcAfJw3bi1vXaYnZ8f1MlIcvD4TbiGMfuQ==","shasum":"f72b06078b0c362061518596827939b712154bdd","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-7.0.1-d53cd47ab3e47f4d850a4a4d1808372d8cd5c196.tgz","fileCount":38,"unpackedSize":76140,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJghEZyCRA9TVsSAnZWagAAo6UQAIca5s4708MC8QfKnRv3\nLl5SwNvhXEF4Spez5kC1WzW/lvRIUUBt2LPyCCekN3QpBsftF/xeDYYb2Ha5\nvZLk1trByBtCwOA4ICqi74a4h7IYzty3VTcI+hUCfJKM6K8yjSEHo1+EFYZR\nj4gp99fGJb+Xtk0iW1W1CEdXWsIyVdxvKae6gpoQ3He0+F4QKOujPZTAe9Gd\nBJzjirEwCCEwBuqwncXFuKYBzLRZUeFPc+7wMPJkSQ0pJW8SExTuNxXkbTPZ\ngbJtZk0XkBRi+SbnguM594XXaoan35ZlO0nYyqIFL6NVoo8t8qLoYqmB6jGT\nDCE/JO3i9R28m3wsfnkFmbCpFJRXiUV42NbNEXqlkaYvYEt37km0iGq54qqC\nN/I6K+L2y4g4qQAWWhBVR2QbDc2Rks4JooK/L3gf1KKRp41Bac7Upg1/sVyO\n8tGhWx8JoPJ2NgWnG85897yy1DyLIR5oZwe/HNhpH+cpKjx3fyxUfAeslLUM\ncRdYdB5nruA+dH474OduDe+RP8cp7KKMgVP559+yVp/0cg0/mQJlGOg9PP3V\nG4YI1EcMPylBmriRKtrh/2ZxzaPR5WxWyq12tDf+ZtVRM/Wk/iFRQOtF+xBd\n6m/b/bI+pKebLcj9RIx7HTByavjAzanN4/69Mwa/Q7GZJOozK81T45J0ong4\nXwta\r\n=CgRg\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCdQ5pHnxuHjeHl5w7LvLMJ4nhGuNILzJtq8HuvIV+DhAIgNECixf2EZ8jhgJPhZoTI9IytUVqGCrqOjWKFe2HBuk4="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_7.0.1-d53cd47ab3e47f4d850a4a4d1808372d8cd5c196_1619281521831_0.4870646044750264"},"_hasShrinkwrap":false},"7.0.1-5ad39f676f8d28536316255a3b248b6aff931450":{"name":"@detachhead/ts-helpers","version":"7.0.1-5ad39f676f8d28536316255a3b248b6aff931450","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"yarn run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","regenerateSDKs":"yarn pnpify --sdk"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"^4.14.167","date-fns":"^2.21.1","lodash":"^4.17.20","ordinal":"^1.0.3","ts-toolbelt":"^9.6.0","tsdef":"^0.0.14","utility-types":"^3.10.0"},"devDependencies":{"@babel/core":"^7.13.16","@babel/helper-plugin-utils":"^7.13.0","@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","@yarnpkg/pnpify":"^3.0.0-rc.3","babel-jest":"^26.6.3","babel-preset-power-assert":"^3.0.0","eslint":"^7.17.0","eslint-config-prettier":"^7.1.0","eslint-plugin-expect-type":"^0.0.5","espower-typescript":"^9.0.2","jest":"^26.6.3","power-assert":"^1.6.1","prettier":"2.2.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","throw-expression":"^1.0.2","ts-jest":"^26.4.4","typed-nodejs-assert":"^1.1.0","typescript":"4.3.0-dev.20210406"},"gitHead":"5ad39f676f8d28536316255a3b248b6aff931450","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n  const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n  const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@7.0.1-5ad39f676f8d28536316255a3b248b6aff931450","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-atlSw5UcHty5cZFGQYfYMMARsjsTCJphN8tZXpI0ntkcHPXKJKOn72wdnJNwvLAV4lV6bEYY52T3F/Q1c4HqnQ==","shasum":"3248831141a81a656ec881df931e7bba68a7f3cc","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-7.0.1-5ad39f676f8d28536316255a3b248b6aff931450.tgz","fileCount":38,"unpackedSize":76327,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJghV/uCRA9TVsSAnZWagAAcJsQAJK8rF23cM2hGt49ahuD\nsDKeK46J/4BjyALB8fm7bfSu4BJwWPI0loLjnzzn6PE91jCxvZ0B2e0g3AOg\nUYv11OflRZBfc1Axp9kBoZn9zHCw8G4tTpbHNnR/5L93s6uQ+5C+GqnBums4\nW6axG9N3HJrF1n49+PqMhe54c2b61EZAFnrbPrlx7odcwkjc6ldRhPfG8zEQ\nqDXc3WG0DHbdFTLXJOi+asiVQV0dJqtmwPVU44Ii/j6i7nlpz2kT/MaXWjjV\nOGVwfMKmQqxy4k0pyO0aCGkhX/CqETPjlPpFnz/kBwsIK9QiaEtuqkUZu5Qx\nAxvwJB85uj7dHCZXw7NHklVtfIne+PxSeAt0+lZ8qYQQzt9mt5KwK/p55p3/\nYW+/F7hCotQfYNMR7bOzrFgC7AZCjVAalgGAn3hbG88atell8wNQtaC9xrlw\nfB3Y5rlZrH7UCy05lv7iN8qjUyjurb2WUsewvwqwTXmXn4FdKw/6+VO29Y3l\nD/5gqZan+dRbfz3e2UP+F+AYGETQ4wc9KWQT5PodawbTaWegcvLbDRYqdSE4\npDpeyxg3IaaQ6Eg5+Hi83Jis1vfFRAwJDuA6r7dEVQarU601oEcQe3Lwtna/\nLSz09rLU88NG99tSc/yje2anU+r8nOfPwhclex9UHZl2GmCRMO/KkVVaAf4D\nwbbL\r\n=nuAk\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICYovz/T3d5ak/ONLHs4Y1LolgN+pat/ri5pO2Y/JwDnAiEA7AvWbYwXqGBWd1/tRHprUpQ23oIOdNdWBjhgkKO50Gw="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_7.0.1-5ad39f676f8d28536316255a3b248b6aff931450_1619353582202_0.05764930081397068"},"_hasShrinkwrap":false},"7.0.1-1d3a8f7c897d4d9a22e1e7bf61116504809d8ca1":{"name":"@detachhead/ts-helpers","version":"7.0.1-1d3a8f7c897d4d9a22e1e7bf61116504809d8ca1","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"yarn run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","regenerateSDKs":"yarn pnpify --sdk"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"^4.14.167","date-fns":"^2.21.1","lodash":"^4.17.20","ordinal":"^1.0.3","ts-toolbelt":"^9.6.0","tsdef":"^0.0.14","utility-types":"^3.10.0"},"devDependencies":{"@babel/core":"^7.13.16","@babel/helper-plugin-utils":"^7.13.0","@types/jest":"26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","@yarnpkg/pnpify":"^3.0.0-rc.3","babel-jest":"^26.6.3","babel-preset-power-assert":"^3.0.0","eslint":"^7.17.0","eslint-config-prettier":"^7.1.0","eslint-plugin-expect-type":"^0.0.5","espower-typescript":"^9.0.2","jest":"^26.6.3","power-assert":"^1.6.1","prettier":"2.2.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","throw-expression":"^1.0.2","ts-jest":"^26.4.4","typed-nodejs-assert":"^1.1.0","typescript":"4.3.0-dev.20210406"},"gitHead":"1d3a8f7c897d4d9a22e1e7bf61116504809d8ca1","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n  const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n  const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@7.0.1-1d3a8f7c897d4d9a22e1e7bf61116504809d8ca1","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-pYutObdA6dEBS3hNEgJI5EbB3PJVIP6v8J8wZcliv0ZZq9Ybl8ZTELgiMBwY9u9Q99THk4RSDprNmhMPEAzCqw==","shasum":"f45d47c65d17ce6414c886e0c1b22a4934cb08b3","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-7.0.1-1d3a8f7c897d4d9a22e1e7bf61116504809d8ca1.tgz","fileCount":38,"unpackedSize":76326,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJghWJfCRA9TVsSAnZWagAASAYP/j3FfkbfJO6I+T3JlWTa\nQuqTbNtTroIkgwxmqY7FrBRO7yGSU+pSolUv93FQz228xFBlGjruMsaEF5aR\nJbu/pk+r4KjdNJcw6ENwGgiEjkexU1rODFNUX9uk1+F8WLIznrggLD6s5pSy\nvWbcDv+1EzJQT7Br6tU3DsPgRlycgwDqg7t7PEaiAf6rIftnBFLLIZPN6Bck\nAAzN0x6bDDzXniFF+l1X/1a00eaLwIggMNp8rDRfuBYw1m5SvpWE7Vuh263Q\nR9J5EET+FR/qcC72jn/DzSNogFMM+A0YmtBoeAAyg0bXlO2+jzzZRbfDpQh4\nF3oog+pG7BD8zz3hLVvjDgRMkhLmQ9Y20dSn1YO+Cwj3japFly1h6eByt34m\nAucTyuNjwJ7I96wXbCPdGwZLVKBx/ai1fb89qfROe/RHvG4hxuYuCgLxgbOG\nX1VqnTE44u1DibKNUP2IxI+FgfGjblH5MrnmaS+sMdXyX1+3ttQyRxNw9HcE\nlW6Gwl2/aOpx3RaXXxPStMn1KEd1hZao/eNY26fxU8qA2vLxa3ktmHU3n6bB\nNpze8TUrroQGkgdlODnpv8IwP1hjEdzoJyRz/f2V2G7iKJKzpZfqfITOFagD\n3x77SOqdB4WCMCCUBv6/8XKJjOAXPN0Rq5WOt8xv+BKL1i0uvjxnVtNKEeeX\nmxrI\r\n=QJF+\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAXxIUCCShNRZZsiUzp4m2UF0KM8QVreNNkStVgrKV6NAiBTGzTZ3zpRqygvq8AHnqZzeLB97FucIbB9bhCbpXNiSQ=="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_7.0.1-1d3a8f7c897d4d9a22e1e7bf61116504809d8ca1_1619354206545_0.9355971897466369"},"_hasShrinkwrap":false},"7.0.1-10cff7ecce9c20dbd7398dd426ad2c39ce4bc866":{"name":"@detachhead/ts-helpers","version":"7.0.1-10cff7ecce9c20dbd7398dd426ad2c39ce4bc866","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"yarn run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","regenerateSDKs":"yarn pnpify --sdk"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"^2.21.1","lodash":"^4.17.20","ordinal":"^1.0.3","ts-toolbelt":"^9.6.0","tsdef":"^0.0.14","utility-types":"^3.10.0"},"devDependencies":{"@babel/core":"^7.13.16","@babel/helper-plugin-utils":"^7.13.0","@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","@yarnpkg/pnpify":"^3.0.0-rc.3","babel-jest":"^26.6.3","babel-preset-power-assert":"^3.0.0","eslint":"^7.17.0","eslint-config-prettier":"^7.1.0","eslint-plugin-expect-type":"^0.0.5","espower-typescript":"^9.0.2","jest":"^26.6.3","power-assert":"^1.6.1","prettier":"2.2.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","throw-expression":"^1.0.2","ts-jest":"^26.4.4","typed-nodejs-assert":"^1.1.0","typescript":"4.3.0-dev.20210406"},"gitHead":"10cff7ecce9c20dbd7398dd426ad2c39ce4bc866","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n  const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n  const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@7.0.1-10cff7ecce9c20dbd7398dd426ad2c39ce4bc866","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-+pD/v0jeydadpuL0LG3oWC48biCSO0Jz1zG5c4tfM3IfLzouSMkjxFOX2vPJz9knD6tne3WvNv3b+SBR2AY6oQ==","shasum":"3db43845835f80822354e724f5bbad90c57faeac","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-7.0.1-10cff7ecce9c20dbd7398dd426ad2c39ce4bc866.tgz","fileCount":38,"unpackedSize":76326,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJghWNYCRA9TVsSAnZWagAAno8P/jP+trqyD7hgpMS2Eqph\nH1a18aA0dJIimk+Z/VNniI2HUbAa+CiUKT7xY2p/O9GII3aywbK0kMnylMhR\nGlQFrKqX1GOyqFn22uVGsL3ZFv/G3Xh3JvHqZUwqGFry74/fbzoGqM4l75OT\n9jb6UVWn8Ilhn5LRv4GFM2E2KnvTR79rJox329IaYThSAvCSoCGeZFPHbNQF\nNkWrIb8s3UhldYthIilaigkcYgiROi6QplerH1uu2FwEn4YVQV+wcEKbS2co\nhi18XWss6mq3hl62nRn7WpOn4F1PbCh+0izcBIK9KOyrEUABGXEx92FH3jH4\nakliu1tiIKnqZHaK1OhveWOeS4fx0Y6dE0i10/+OXNVJ525afbGB0+NU4o63\nzH/z81zs5uOcXp5jJwf5APWVS0BqPZ5hpkPPXaz5Ff5uFe2g5cOqbI7sMD+J\ncf72ZMhjvRnnIFMHRX39vMN52jLYfFt92J6Rzqy1ll3M8/XXRtweeM3KmX3V\nwbVwVuoNPjbc9YwIor8Yo3cm1fbFakqMzZIUmWdpfi6B99cPP/nuRSeEuRP8\nB7/JW26oW+ISVf0m86bozDCRSYxXVxLRZ2aZwgqi6bL35PLr2DaULADnkRqz\nrHa8Qqbk/FO6/PQpPSlb5L0R8ayA/bxnAJq9uPCwrrW513LjskidTsUjgCDd\nU8DP\r\n=XTkZ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBb7ZU2C55RJNjZw4Ye4Qsn6dcSaJJz9HpY844H34jrDAiEArrJ1ivbd/RquNiaDqxhqbjNNbfZxkmtBYDVNs2osE28="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_7.0.1-10cff7ecce9c20dbd7398dd426ad2c39ce4bc866_1619354456322_0.5200783680095065"},"_hasShrinkwrap":false},"7.0.1-57f39b191556f9992d5909b36025526588252c61":{"name":"@detachhead/ts-helpers","version":"7.0.1-57f39b191556f9992d5909b36025526588252c61","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"yarn run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","regenerateSDKs":"yarn pnpify --sdk"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"^4.14.167","date-fns":"^2.21.1","lodash":"^4.17.20","ordinal":"^1.0.3","ts-toolbelt":"^9.6.0","tsdef":"^0.0.14","utility-types":"^3.10.0"},"devDependencies":{"@babel/core":"^7.13.16","@babel/helper-plugin-utils":"^7.13.0","@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","@yarnpkg/pnpify":"^3.0.0-rc.3","babel-jest":"^26.6.3","babel-preset-power-assert":"^3.0.0","eslint":"^7.17.0","eslint-config-prettier":"^7.1.0","eslint-plugin-expect-type":"^0.0.5","espower-typescript":"^9.0.2","jest":"^26.6.3","power-assert":"^1.6.1","prettier":"2.2.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","throw-expression":"^1.0.2","ts-jest":"^26.4.4","typed-nodejs-assert":"^1.1.0","typescript":"4.3.0-dev.20210406"},"gitHead":"57f39b191556f9992d5909b36025526588252c61","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n  const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n  const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@7.0.1-57f39b191556f9992d5909b36025526588252c61","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-fuCAuM/+OXB0j+0ozF/02s5V6q7yuDZZfUWykXd3J9cinNMc75NQ5hZPnWRL1m2yYxbmA4hPMq+6qz27RSzHxA==","shasum":"81bd27fbdc2ed54b3719a25b07e9754a2c025a73","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-7.0.1-57f39b191556f9992d5909b36025526588252c61.tgz","fileCount":38,"unpackedSize":76327,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJghWbZCRA9TVsSAnZWagAARmoP/Rw1Ul3owlAHIMx7hnvA\n0vgt1UMBDBnMLmZg8VvjdpIcoFuE5qAflZvgkGHPZbZuMmA6eD5bv+avxUyc\nVs1eqjsRxhfPJDrOVDBDgwRChmd5zC/4j7ImuPZQlvCiwZccPQTcka4+24ng\nQ+bFMNhQBP7aBrk35U7JCsRxdPtYQfiA0WxPa27/lQgrPBSPsiZd15nC/UFQ\npkNK3rNn2Yrlt2pl86qBgAqZbSIxt6VBnCytOZxmPA6T7w+tWvR+pBVG0sEE\n8bLRhyg65j5L5rUtqE9TaGQYocsitqw+apL5tSsTm23PlluxzMG5KihJZ8t7\nFpiCGvr0Ygrsny8E/nblBxAXcdggSKPVxqHavDaIdaYZHGNcduqwU0PiUhuC\neu0UbH0HaujpLuv0OIFFB+MmlkaiFYzxzswFGyzcPBlxt2s9sbwwc6JPKFAG\ndQqPmTb8KNRplQ2iu8+ZOBlXunrqElPGB/f9WLcmQjuPNfxV9dpLe14++h1A\n8w/Eka2fpo2f0VCWJOkObCU4DzcG/J6hhWtvbMhFGZ+8LTfqQWDCXxglOLfa\nuwDyzezcnlmvwpajXZylVRcxnwmEEFfOR0CEi1x4oBc1S5VLXVymfzxEQE3E\nxdSiQHG+FygsxWV2FdOL8X4S5SfHeSHrtI95qKVTPj9uaUD09rTk2csZe56h\nWAxA\r\n=2mPJ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHS+GEm126CgZWKqAbgoIpbgKanRRzsGXl/McFWbk+f5AiEAnYayN31D48/0OeGhePas0f1VKNs+JaNA5GmVzXoZN2U="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_7.0.1-57f39b191556f9992d5909b36025526588252c61_1619355352575_0.38788926944519786"},"_hasShrinkwrap":false},"7.0.0-38be65f531b05ac601780ce711717449e038c856":{"name":"@detachhead/ts-helpers","version":"7.0.0-38be65f531b05ac601780ce711717449e038c856","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"^4.14.167","date-fns":"^2.21.1","lodash":"^4.17.20","ordinal":"^1.0.3","ts-jest":"^26.4.4","ts-toolbelt":"^9.6.0","tsdef":"^0.0.14","utility-types":"^3.10.0"},"devDependencies":{"@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","babel-preset-power-assert":"^3.0.0","eslint":"^7.17.0","eslint-config-prettier":"^7.1.0","eslint-plugin-expect-type":"^0.0.5","espower-typescript":"^9.0.2","jest":"^26.6.3","power-assert":"^1.6.1","prettier":"2.2.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","throw-expression":"^1.0.2","typed-nodejs-assert":"^1.1.0","typescript":"^4.3.0-dev.20210406"},"gitHead":"38be65f531b05ac601780ce711717449e038c856","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n  const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n  const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@7.0.0-38be65f531b05ac601780ce711717449e038c856","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-oVoZq3WRVBIo18nUandZ+LGSnuBUJ73q/T650xdibBoSokNvDWC2KidmmCSL6QOizPcAEqHULHNtRkCsR2x7SQ==","shasum":"04bbaf55104861e815d2c2d354ea2572602fc9fd","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-7.0.0-38be65f531b05ac601780ce711717449e038c856.tgz","fileCount":39,"unpackedSize":596817,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgiUmQCRA9TVsSAnZWagAAsQ8P/2ox6iHcIbVAWNZCGG6q\nOEEdDA8Mr/4vUQHwbfgtoyKkie4DF1AC0H/DEVB6687gv6B3P2y3ZLfkYZ4M\n5Xp2CpviRA4SFX4QbStN5Kti252Y2qNEFYeMc+xThhmeBVVfMlyHuAVI0EZT\nMkElBVb3X2lW37pPF/+5yFMOFGmkrrW5lbqg6UTNMF01t6gFOykMVQlvnGH/\n2wfWhAaCSY9P1MlaQOc2NpC8Maw21L3PDRV1wBPvv+Gz842YOzTFnAZtrAOC\nwxF5cSlyPmFjhONgjZUUxuMAqb/apw2ADhkwIGx7ExNJlp3P3IHI8EKjd22m\n2xmM/opcEnE/pjAhCZSxtP4LZs1eim6/bzFp61nEWoxZ328BZdfJhYa9aIhk\ng0OGLhSph5pqht0SRrPCZXbETtqhfcPewdUKNpTQo++d+rMJNpIjYIl8MH7+\nhs7l3wz0ztXBdFwQTdff4IIoIP0nmuNOggTSM6TkBfCZJ6U5nZ2OzHLLm4sg\nA2Qf7qdAnXXHoKy0kyui9Pte35aj40xiIb6vd8jXOeVqEibc94PbIrJv1UQn\ngKQ5sjpYmPJVSENcsRghWopOyL54I/E54a0QQmNEN1iZ8GsuR0m+Xj0nUKP4\n/Zf0hL0LoV/W60TrPi7t1pbN5bb19lmYW4yF5/TTBMTgZLOXLOZaqHSH+Dcy\nUCvp\r\n=HqTp\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDZbtKMXmQwNfAVeDOFq5NQK3PJF89Tz5VS48TFxYU35wIhAL6+esHNoVgt6r31P0yXS0de6OEAcgk5hTwo+QUnPpUv"}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_7.0.0-38be65f531b05ac601780ce711717449e038c856_1619609999716_0.6569783971147851"},"_hasShrinkwrap":true},"7.0.0-b3dc70bcb221c7a3a831492da2c7763deeae95bf":{"name":"@detachhead/ts-helpers","version":"7.0.0-b3dc70bcb221c7a3a831492da2c7763deeae95bf","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"^4.14.167","date-fns":"^2.21.1","lodash":"^4.17.20","ordinal":"^1.0.3","ts-is-present":"^1.2.1","ts-jest":"^26.4.4","ts-toolbelt":"^9.6.0","tsdef":"^0.0.14","utility-types":"^3.10.0"},"devDependencies":{"@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","babel-preset-power-assert":"^3.0.0","eslint":"^7.17.0","eslint-config-prettier":"^7.1.0","eslint-plugin-expect-type":"^0.0.5","espower-typescript":"^9.0.2","jest":"^26.6.3","power-assert":"^1.6.1","prettier":"2.2.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","throw-expression":"^1.0.2","typed-nodejs-assert":"^1.1.0","typescript":"^4.3.0-dev.20210406"},"gitHead":"b3dc70bcb221c7a3a831492da2c7763deeae95bf","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n  const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n  const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@7.0.0-b3dc70bcb221c7a3a831492da2c7763deeae95bf","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-XD8hPFvgnSww+qWEJO/AmfjjqXfEhpA4zXwbHAeHVP0CTz9wzHnDKhOVvB1mUfr2fP7+m3ut0JC66063DPWUgA==","shasum":"7411ca3d92aa655d033f09dd7cb1a764a1934f4c","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-7.0.0-b3dc70bcb221c7a3a831492da2c7763deeae95bf.tgz","fileCount":39,"unpackedSize":599245,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgtMQNCRA9TVsSAnZWagAAHQUP/RbUg3fG284U6wL1WDYU\nICeUOPq5BwzzhqkjgeyiNGzzavarV8neCoQcKItwAQ4+h9F4qCy8hlXOpc/T\n4MefMCfNgr3B1cs/AsO3R31z9w8cPzYPjiky2Pc9fQQBkQa7cZFEiDIRhAne\nOFSMPR8h8iaBjp/yig1C0rP/yi4g2ylareM0C3d1h+mmuGMdlSRTyArvfq+L\nn0PWJP7ehmTlL6gIwyDlAPVaVhPgdY6J0YHOH9ATMIL9KmUgkczdjy1bBwKM\nQs+Fe3kq7++UMS6McSisdYaind8jXjgkW4VXZiz+ICtXtU6G+tMmt+KaUbeB\nm8DZOpliS5Q03Zuk6tdO9ULsPEpAtZNQMvy0uyESisJUzz9USTXRksH3LFNE\nE+nnR1q9Op0iG2RanwNZuU1hMRvMW1gLjOKWhUWkT/wpVUr6dzyV65BvS22K\n/jLsW4M5Rm6QR58LUxCRfa2sSCWX7s2VgAgO5FY1NJ0uD0/wtogzUV2o00Zo\nKhWuMR2j/ssapfwzqgrdaQrKDaRv0g3TzDVg5sAJ2SufkmnSg3giBLot3zGy\n+qeD1EALnY/tJGHDrw1ssEQexbK8tO7Bl/r4xTgmHdMchpr6LlQs0JS1fUTT\nrEqyKaY+bql0MDWepU4jfiGSn/HusOh249aOryVFdG1WHrki66TZrNNRlwpJ\ncSIP\r\n=tJ/I\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCahxaTnH2jMCuNkOOWiUtR0nZIpx0BdkDS+X6lJkbgLAIgUKrKRhEf/D7cEUjr7hd0JzMwCk1RGRqAd0s5+huQmR8="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_7.0.0-b3dc70bcb221c7a3a831492da2c7763deeae95bf_1622459404419_0.5438915004567788"},"_hasShrinkwrap":true},"7.0.0-e528e8c7edfc4b16e7aaf3f7f00ec2efa03991b6":{"name":"@detachhead/ts-helpers","version":"7.0.0-e528e8c7edfc4b16e7aaf3f7f00ec2efa03991b6","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"^4.14.167","date-fns":"^2.21.1","lodash":"^4.17.20","ordinal":"^1.0.3","ts-is-present":"^1.2.1","ts-jest":"^26.4.4","ts-toolbelt":"^9.6.0","tsdef":"^0.0.14","utility-types":"^3.10.0"},"devDependencies":{"@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","babel-preset-power-assert":"^3.0.0","eslint":"^7.17.0","eslint-config-prettier":"^7.1.0","eslint-plugin-expect-type":"^0.0.5","espower-typescript":"^9.0.2","jest":"^26.6.3","power-assert":"^1.6.1","prettier":"2.2.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","throw-expression":"^1.0.2","typed-nodejs-assert":"^1.1.0","typescript":"^4.3.0-dev.20210406"},"gitHead":"e528e8c7edfc4b16e7aaf3f7f00ec2efa03991b6","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n  const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n  const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@7.0.0-e528e8c7edfc4b16e7aaf3f7f00ec2efa03991b6","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-PDJlkEeiEk6V/yJC81pI5EnAXOIjk7d8Xln5Q0kfN4LmJfF1Ob3bHCBgxEHgM5yjvBZ0Z/+zAuRtIG4k0syujA==","shasum":"965c9269f90fa4f29bf517160f505a4810f3ef02","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-7.0.0-e528e8c7edfc4b16e7aaf3f7f00ec2efa03991b6.tgz","fileCount":39,"unpackedSize":604807,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgyee/CRA9TVsSAnZWagAASSwP/1gVsuRdpDWOZK9f6sw5\nPc/1533N/kdrCrgT+nSpWg4+rfCYwlMBoO7XLworervofrbOIfP8B7b1LZDz\nU2mVrhPynII6F2ps7mtj3GL1jAD0c9oJaNc20wqZIuwL1VB+Oe4Q9JFa8yFl\ncRanXEtu/knSruhhjS5/nlO2sRLd4G3ubPX1ZhO8s9nKl37thSn4qQ3+b2Ja\n2wqIzv3USYGv1O6rfa6hmsxeL8YcfFTuAsToYBX+nkpxhAx4iAZsUrTXzRWD\ntapXLS2YdVRflexO17Z2TaW3eY0Nr70pAR0ErEGyh083bmgoH+0PzPdnwAQg\n6thZwXmdJ6uhhSphKUzcZnn0T1c8RnupKH6Ve2WXvVlBYKAV+PDi73il5nSU\nSOqAbr1AETkPdfjm0AtYgg5sEeAt3tylJRiMvQupQp/Vk0VjHQJRN9HrznBj\nmcR8CUXtj4EXLHo6NoelEbCmEDPZB2ywg3KFITPWu0irXqiI5xpR+d0OPewX\n45xOEuSs6kR1tbj8wHbQN8ReMVgumWqeqAICA4sJRTrx4msPxyiFEXLVGjsg\n1TejRLgxz7MpqYwgOQpPdbHew0Iz68t8XYsgEsE7ZNGf+2jLYlzrOpXGOBoe\nMr6tO0RvHv9EpH0B1vvVgGSctToN1DAEcJV7Fg9NWmmhunabCiSqYbyVkBzw\nWkdD\r\n=wEVJ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDoLq31Snc+ZsYukcjTG/Oebzexqmuhiw7Yf0v+82qGRgIhANwcOZv81n9bC/B2011F+qJTujF2OiKeWseTX5DSUUIw"}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_7.0.0-e528e8c7edfc4b16e7aaf3f7f00ec2efa03991b6_1623844799228_0.22527628515991882"},"_hasShrinkwrap":true},"7.0.0-7340d9ddedf3534eabaee09621780c6d3a71eeff":{"name":"@detachhead/ts-helpers","version":"7.0.0-7340d9ddedf3534eabaee09621780c6d3a71eeff","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"^4.14.167","date-fns":"^2.21.1","is-ci":"^2.0.0","lodash":"^4.17.20","ordinal":"^1.0.3","ts-is-present":"^1.2.1","ts-jest":"^26.4.4","ts-toolbelt":"^9.6.0","tsdef":"^0.0.14","utility-types":"^3.10.0"},"devDependencies":{"@types/is-ci":"^3.0.0","@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","babel-preset-power-assert":"^3.0.0","eslint":"^7.17.0","eslint-config-prettier":"^7.1.0","eslint-plugin-expect-type":"^0.0.5","espower-typescript":"^9.0.2","jest":"^26.6.3","power-assert":"^1.6.1","prettier":"2.2.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","throw-expression":"^1.0.2","typed-nodejs-assert":"^1.1.0","typescript":"^4.3.0-dev.20210406"},"gitHead":"7340d9ddedf3534eabaee09621780c6d3a71eeff","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n  const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n  const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@7.0.0-7340d9ddedf3534eabaee09621780c6d3a71eeff","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-+nGzTOoyWFoBRefOx5PInnh6fVBzRF3s1a5SOVihJSpBoo6XbPNd4kIlSAf/zo5vDoknkeG8U0Dgvu9xIFv00A==","shasum":"909d575e01000ad88ac2687099543fdec0727091","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-7.0.0-7340d9ddedf3534eabaee09621780c6d3a71eeff.tgz","fileCount":39,"unpackedSize":606925,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg4CQiCRA9TVsSAnZWagAAcZ0QAJ5zIGMQdNCxCRRXqolT\nMxnIeICoDOenbK9VhUT0idmcylhG8iLpVpWdtF8NFQJKXrBZ2sH65EkvmXhi\n6tHsWk3fI0M6N4iAZ1rMVW1Z7DtemFPZWvTZ+dNozS0rX3fAz7WGkKIsl7BK\nqetwRvvCqD5w4iDX5Yx5xRBnK9TfwhFd6VGvvB2QR9RvNQ1JMcdjXTxLUyub\n01Koriyb7rtpHHj3RMgx6gNEsJ1Nj+Qvq8qizZZM/Lsuk/IjZxKITDLfPAYc\ng/38lyK7ZP7LhjGK3v+Tmqpii83AluBsGBhRmAVqhN3ffHl+cbOYKm48QiJ4\nzHGB7Uo45Y2kfrGoSA6nkDm+VtLNmyBhSd4GwmaCekglOz52uFnS+gdh5YyC\nyBJBQkyUJ3fQHx3X68ipz+45YTvBTkTDPUf9BUSGgFNSv5PKlUEIzzt9bA8X\nkQxZN+x/oJMgiQ/d97DIQTuFZgE8I7kQBvga7y0x/kYAlQ/9kauLMSJhsyZh\njTMibZeM5cY+G9DuYVm2nyoAZa/nHRm83a6mDcZqV43m2tbgchYLCy/A4v9p\nrFvR5OObi6MZjNoZNjivTtilqVsQ0c85Z83jW4jXrcTsQVKPB1Mx5jFELUEf\nNIKHIXXalvV2Ldq4jMcxkSaLQkfoT2Leh4sc306sIu4YnmcjhJflSrE577Xz\nXshx\r\n=osUv\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCaQB1zh+ljGA4sveTYP+cavgWckKl9AbCpanOaEX7UsAIhALVNAC1V8APf8tjPY1QtGEyK/m7qPpB6alAUSaLdwhcJ"}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_7.0.0-7340d9ddedf3534eabaee09621780c6d3a71eeff_1625302049491_0.0645543510181783"},"_hasShrinkwrap":true},"7.0.0-2a850824a7432eced04a89875f0dd0c5eee8fa0d":{"name":"@detachhead/ts-helpers","version":"7.0.0-2a850824a7432eced04a89875f0dd0c5eee8fa0d","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"^4.14.167","date-fns":"^2.21.1","is-ci":"^2.0.0","lodash":"^4.17.20","ordinal":"^1.0.3","ts-is-present":"^1.2.1","ts-jest":"^26.4.4","ts-toolbelt":"^9.6.0","tsdef":"^0.0.14","utility-types":"^3.10.0"},"devDependencies":{"@types/is-ci":"^3.0.0","@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","babel-preset-power-assert":"^3.0.0","eslint":"^7.17.0","eslint-config-prettier":"^7.1.0","eslint-plugin-expect-type":"^0.0.5","espower-typescript":"^9.0.2","jest":"^26.6.3","power-assert":"^1.6.1","prettier":"2.2.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","throw-expression":"^1.0.2","typed-nodejs-assert":"^1.1.0","typescript":"^4.3.0-dev.20210406"},"gitHead":"2a850824a7432eced04a89875f0dd0c5eee8fa0d","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n  const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n  const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@7.0.0-2a850824a7432eced04a89875f0dd0c5eee8fa0d","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-ArtQjh9f39cngUBVv95pSNSsIEZgqlXqz/ufKGLvk4Y5iDrzyc2QJUeVQKi3s+zaxfM5kmXXLo9GMdZa9ieCaQ==","shasum":"ad42b8c3cb7c49de54cb7fbbccd3f32c2db9f3a9","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-7.0.0-2a850824a7432eced04a89875f0dd0c5eee8fa0d.tgz","fileCount":39,"unpackedSize":606925,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg4CVZCRA9TVsSAnZWagAA/OUP/RsryMsJuPsT9VodVgnD\n7OXxdUkd7H1bSMvtOusGq/ZPvklS1xiz5L5ZMV286hlF05q1oK48qSggIzjH\nEmCv8JYocmabmOtyh8Ua4/ugrphQpBBr7PRojisGegGd7hCjuvygLFj7R9ms\nTgs04JqwXX3RpO9UWRgSUw3ztZmNxcjW/pPJxDTd9qM35KWgthKYqLRcVkNr\nqDPluy/TQ3s7uS2kgBhYaZZF66CcBqOEXJn2nZZloloqzhj1Cvsejd8ox7nW\n33cz9PxKKHx/uocfHCT3IEwiFv2ayeUShrxVXie8LzNg00xvWjeJ0M7PyPih\ncYgtlZM0raeApZqcCjNStrho+lRNpIilOFpvo6tfYN5hOPbxSdiBHrKXZIoe\nTauWpux23vx/BhiLYzgXtlrLHGUcSja9VggFJ8bLgdnk46v5lG4nTNZne5Bn\n9R3cSkEZFGgXQKQwhoegvwltIHUUtg5PyA7kOD6e424DJEa0iC8In7RoCOZe\nwKFzjCwkBQ4P+xNoHtuPXpk3VGlatgMkh+guWXAGb+oTNIVFotF/tgTpeTYk\nJ/MC2eLmONoHqP27DZJ/CogWvuAlGpKMCwerTHd6qRf8hQ6bAx6qZTq2M5ey\n7xugBNrDur+8j8vaj3GJxYFpnQao9obTGjjiNpRlgHDxsWYBd369YK8Uyc5a\nCZAg\r\n=5oqr\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD6RiX6nR2YE/SpN61Kk+JSJYQvkXJZS88jN4wWErZHiwIgKEsC42qOYm3tnbIKEBAe1qjFuURiXpY2BKSqivoaW8w="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_7.0.0-2a850824a7432eced04a89875f0dd0c5eee8fa0d_1625302361042_0.4652954197679764"},"_hasShrinkwrap":true},"7.0.0-d21e889d602ab3ed8bd643999cafeaf1c8d04fd1":{"name":"@detachhead/ts-helpers","version":"7.0.0-d21e889d602ab3ed8bd643999cafeaf1c8d04fd1","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"^4.14.167","date-fns":"^2.21.1","is-ci":"^2.0.0","lodash":"^4.17.20","ordinal":"^1.0.3","ts-is-present":"^1.2.1","ts-jest":"^26.4.4","ts-toolbelt":"^9.6.0","tsdef":"^0.0.14","utility-types":"^3.10.0"},"devDependencies":{"@types/is-ci":"^3.0.0","@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","babel-preset-power-assert":"^3.0.0","eslint":"^7.17.0","eslint-config-prettier":"^7.1.0","eslint-plugin-expect-type":"^0.0.5","espower-typescript":"^9.0.2","jest":"^26.6.3","power-assert":"^1.6.1","prettier":"2.2.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","throw-expression":"^1.0.2","typed-nodejs-assert":"^1.1.0","typescript":"^4.3.0-dev.20210406"},"gitHead":"d21e889d602ab3ed8bd643999cafeaf1c8d04fd1","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n  const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n  const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@7.0.0-d21e889d602ab3ed8bd643999cafeaf1c8d04fd1","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-kEuMi286Ac4pf9GyZReQdCo1H04yM8Cfr5bz2pdfb0B4ZdNDA+hJqpmEZKnvTS2XqQLbgsEojCPB2BZJ3uXfJg==","shasum":"6a4b822eb93e72e83c18f4d805d10d3b4dedbfc9","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-7.0.0-d21e889d602ab3ed8bd643999cafeaf1c8d04fd1.tgz","fileCount":39,"unpackedSize":606925,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg4CWqCRA9TVsSAnZWagAAUGUP/j3Sss9DTzoVoa2xYRdB\n/jzX6buieOiAU/leEEF/ZjHpBhp53Bp/tSRU7qhaNRfgIDVTCg7A0WErNpOV\nLvz+RDRJBY5W/9Ck4AQ3wvUMMsRaUI4GAA2slhxJjlRmgvl9q6ad/nDJmXzE\nsQNGX/WLNhNJu4Xi4WQf8EAejezyP19/6YxiKYf59AsmncMbqZKtUkxEGUNO\nr80j1AYGD+Ns9/KGIsMO8gZxjKqrJHwV/66Ssfu+QxiDfOSW9JPtv1fEXFWP\nPqFpFcxgGm1FHCxSjJHCUUWy1nljCPc7rrCbfbQ0cEWho/Wyx/5F2/pJM49z\nkAkQRmecyAlwFE2ooFfWog+RAg/hVRo79sabvzm9A1M6DlB2OPlRT8tCfy2r\n92LBIGgc60YAXQwJAoxgCNveCbby3bA7CXULoJ1DKv60SWnbu5qDbWXZUZCd\n8f8YzvkgrgrWPdYndLYbuelUZ2qI8n5Zr1O8e1/JNGlfsVr4DOoAVUDyf5L4\nHJRg/K7ZbJrtu7QCxPeOalkzqEoETFutypE58farJUfYuzI2wRm1LSArHuYN\n46z7O9Kk1YK2BLBZOmAQ681kBH5sFxI0vSOyrdvOG9/twMI/qMBBHozLyhrc\nYLlIGKjW2a0vHnzzLMqN1ES8bKc8ekdxrIOO0IEKI6qWK2JnSzzASDF6ky8Q\nV8Mw\r\n=b+MH\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCg19ue0aPNQBXu0AIVn8qIYhcv4iyWQKU1JQnX18YkWgIhALi1PLPS96Tf17laEnEG2nO3W+YS7oMqSuxi5Cmvhv7X"}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_7.0.0-d21e889d602ab3ed8bd643999cafeaf1c8d04fd1_1625302441571_0.9958151936008595"},"_hasShrinkwrap":true},"7.0.0-f45cfb04909f3065f245703b2f6be57a0a03e802":{"name":"@detachhead/ts-helpers","version":"7.0.0-f45cfb04909f3065f245703b2f6be57a0a03e802","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"^4.14.167","date-fns":"^2.21.1","is-ci":"^2.0.0","lodash":"^4.17.20","ordinal":"^1.0.3","ts-is-present":"^1.2.1","ts-jest":"^26.4.4","ts-toolbelt":"^9.6.0","tsdef":"^0.0.14","utility-types":"^3.10.0"},"devDependencies":{"@types/is-ci":"^3.0.0","@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","babel-preset-power-assert":"^3.0.0","eslint":"^7.17.0","eslint-config-prettier":"^7.1.0","eslint-plugin-expect-type":"^0.0.5","espower-typescript":"^9.0.2","jest":"^26.6.3","power-assert":"^1.6.1","prettier":"2.2.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","throw-expression":"^1.0.2","typed-nodejs-assert":"^1.1.0","typescript":"^4.3.0-dev.20210406"},"gitHead":"f45cfb04909f3065f245703b2f6be57a0a03e802","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n  const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n  const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@7.0.0-f45cfb04909f3065f245703b2f6be57a0a03e802","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-x9iGZDWjrb8AO0knEpTFJpJFGjO3WgNkWwaRUpzgMxUEXiLjvJdXRmFLNb29/63jfb8nj8HwC1qkfViLyO3ZSQ==","shasum":"b877890aebee497f24e62b37f4ff77401206bbbd","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-7.0.0-f45cfb04909f3065f245703b2f6be57a0a03e802.tgz","fileCount":72,"unpackedSize":731289,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg4HJKCRA9TVsSAnZWagAAsE8P/2lclE6uhm1bLwq7olsb\n7ttQ6MC0yIOz6T/kgIu/aBDZ3paz1s9KJSkFxP7RHQ11ElE82AwvHXk4feVa\nmr6CVDxI3lf6HczkApXj3NEtlS8OWAE4bN9SKmqRE6bz6EnprGpTNxM85NQz\ndKaB3eVz+rC4c24eDr72qmYBHB9/tx0JEbxZieY0Kp/rvGXL3C+vLtt9zDPU\n5DOXpeuiGGqCbgNSEbP0Y65YExbH5ZNDMiCkjPbvqdRM1wd4icWLjL9ckYbI\nrG/s20kLLfJdVza2HeRMKzqOsDKTMkPYOTdOwmrB73KWTpJwsCDLoVGsTHty\nWYjaf3lZKJtuq9oZmvDQk3NcZ3x5gY2X9A2qkacbKeOsSRtvbQysb5HHBXUg\nzwgSPTrS90VgzqJd5I5reSQZuer6OPypKUKfdNmY8BIJz+xDxsbXCfsd68Js\n9oTjSXEVqeds7o40hee/5Mi5yrdvy4Xxe66zGauGskSG8OSBM65lJ9vSR+yi\nCdosFGP++M2fRaK8BThAfcVIdGlFSp+VFl4PSBPgdFBdfCoOzrpczAz6hkGb\nKu/HCGxgQzWb1EcZadnz0qQUVOkWmRk5i+IDygAXTBsvWQvBgfASu+nm1weW\ntH8ttZz+w2nr6Gc2dxYiUfoenxmPL3urCdrU4UIwFvapZwZ9NEWE/R8L6FYx\nJyI1\r\n=bf8/\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDAGJkK4Jvrckt+4g9FiaCC/TWmdgftO3YuCPn/NuHHbgIgCawd+2H1QI/Ge28e8J9aRyLg7pdi1y3L/dvyhLTOWkY="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_7.0.0-f45cfb04909f3065f245703b2f6be57a0a03e802_1625322058094_0.7344884807118937"},"_hasShrinkwrap":true},"8.0.0-5c375b6c6397c32ed6134bed531ff51d7e9761f8":{"name":"@detachhead/ts-helpers","version":"8.0.0-5c375b6c6397c32ed6134bed531ff51d7e9761f8","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"^4.14.167","date-fns":"^2.21.1","is-ci":"^2.0.0","lodash":"^4.17.20","ordinal":"^1.0.3","ts-toolbelt":"^9.6.0","tsdef":"^0.0.14","utility-types":"^3.10.0"},"devDependencies":{"@types/is-ci":"^3.0.0","@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","babel-preset-power-assert":"^3.0.0","eslint":"^7.17.0","eslint-config-prettier":"^7.1.0","eslint-plugin-eslint-comments":"^3.2.0","eslint-plugin-expect-type":"^0.0.5","eslint-plugin-prefer-arrow":"^1.2.3","espower-typescript":"^9.0.2","jest":"^26.6.3","power-assert":"^1.6.1","prettier":"2.2.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","throw-expression":"^1.0.2","ts-is-present":"^1.2.1","ts-jest":"^26.4.4","typed-nodejs-assert":"^1.1.0","typescript":"^4.4.0-dev.20210727"},"gitHead":"5c375b6c6397c32ed6134bed531ff51d7e9761f8","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@8.0.0-5c375b6c6397c32ed6134bed531ff51d7e9761f8","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-L42qJugqK9gjp7ycm56WpPQHFL8YYnO5ltPNRyKp6ari3AMDpZLsqHDrJTrUWTiye+KdRO+YAuSYXROIX52XTA==","shasum":"b39e3409e75c4931a5530b67b2980c873c9566eb","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-8.0.0-5c375b6c6397c32ed6134bed531ff51d7e9761f8.tgz","fileCount":72,"unpackedSize":964723,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhAEYsCRA9TVsSAnZWagAA3owQAIbWXxR932zivwiKdsmC\ng93KmrA4jgrjZo0GNqm7HVeoFWy3FMgaweBVbqSo4UArWIYzG8Y3HFvWNdkz\nPklqsdvPQxhaLDAlSLubAXzUaNh01jyGPrBqW7J3IH9kxOXal3Y/FIrH3l9Q\nzDyXH/xecdsUmFTA/lG/1YexZE5oaEXCknHxIltxMFRhsYRu+BNxAniyy/eJ\nW8Zw+tC1HRxw6q8u//NODiaPgMybNHVn0PYkU/v+M5+npsokwVKj8m+2kPWv\nZFFXtmpwc9yfhD8wPeGKSz0GqHTujpL6J7d0BGGTBjLYEABzBCrPxRofj7tm\njPZE+Fb/SqAGYr6SwFHOArIaSXiH+ycbNn4Fm4gjczEmrdCkwvrGjw6g9YDc\nCU/DvpcN82o1ObSi81d2jxid9T5hfppDN5iJYqpThsMQNqoyvHvdYZKHSUea\nkXjRkLe5UQOGZ+mX90M0YQU/bIuhSo8c6SdpD54oRdQ3UgG97oBWhdHGw+Bz\neRVUrj7Nmmo9EN8AaTkM6GVJXNOkBef72MbZMCz9wxjDmMR3h7GmKo5/SArB\nM6q/kisvpQNvboIpibnsNaZgKARr8dT979hh1CH/NmH81tCVN9pb6OwIduWy\nxDI3Co3BKrG5fx6Q+fogqy1SzYmPtGw1FD7VG7af/2ivPcT9XE9XnGiPO87b\nqs9C\r\n=2Nz0\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIA1CWh8FRbdqZtA9mULkP+liMSS8j0F7805EkVLzEXnxAiAm/+jr9V1HTtoD3s7iI1fvFZ5uJi9c1LGvrC1ZDKk8yw=="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_8.0.0-5c375b6c6397c32ed6134bed531ff51d7e9761f8_1627407916438_0.819719756039901"},"_hasShrinkwrap":true},"8.0.0-76d17fd608922ef08d5fb5f8799d0cf7d227143d":{"name":"@detachhead/ts-helpers","version":"8.0.0-76d17fd608922ef08d5fb5f8799d0cf7d227143d","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"^4.14.167","date-fns":"^2.21.1","is-ci":"^2.0.0","lodash":"^4.17.20","ordinal":"^1.0.3","ts-toolbelt":"^9.6.0","tsdef":"^0.0.14","utility-types":"^3.10.0"},"devDependencies":{"@types/is-ci":"^3.0.0","@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","babel-preset-power-assert":"^3.0.0","eslint":"^7.17.0","eslint-config-prettier":"^7.1.0","eslint-plugin-eslint-comments":"^3.2.0","eslint-plugin-expect-type":"^0.0.5","eslint-plugin-prefer-arrow":"^1.2.3","espower-typescript":"^9.0.2","jest":"^26.6.3","power-assert":"^1.6.1","prettier":"2.2.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","throw-expression":"^1.0.2","ts-is-present":"^1.2.1","ts-jest":"^26.4.4","typed-nodejs-assert":"^1.1.0","typescript":"^4.4.0-dev.20210727"},"gitHead":"76d17fd608922ef08d5fb5f8799d0cf7d227143d","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@8.0.0-76d17fd608922ef08d5fb5f8799d0cf7d227143d","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-bG9hQbEVgtvwNoXYcZc4HhOPWynzHOtuBl2/SRrYTpByODlieC/AhBWiE7fDgco3rRa0/qzm63zwFcKAEKju8Q==","shasum":"81b0d77bda24426616e8320eeed408ca3d454f38","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-8.0.0-76d17fd608922ef08d5fb5f8799d0cf7d227143d.tgz","fileCount":72,"unpackedSize":964938,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhAEk1CRA9TVsSAnZWagAAO8MQAIUK1Ffp7dFrlRIGgy5w\nfg89lIJZJmrlkxggT5ytHgq1+YJ97r2xF12N+QGm7vyg/2AfnEoiQQF5g/2V\n05hXn/QR7EGVjlIIhVpKM2Wohr7sXq6BjaVf9/JwtOJytOcLktBsAK1c1JVY\nAAyLUGpuvKkFAgc98xbDQaEC+OzCf6O70CSOEQ3TaKDlhnmTXB8J8pngfnEs\nP92BwEr4D6jsYnyqJl4bPM8GvXeEXSeHiKDgsQPyGU+hvSrTn10sNJCBGsuy\nZjhOgT5LaQDunxP43KrwCLwXGV7GIRSaSOgEZairrCBHHlcO7WynG8UgiTxR\nWlrYcbH4r5KzKf4NUDyHFedb51O/EWUdTq/MTdajDRyN1MbFQpRAbjZ8Ih7u\n9LiRHF73nhkIkWCfvRKOPNzyz/9aDCfcbPxQILZpCVK5CYFhYK9c5XUUoAVe\nPST24KRXoORwQaA4/3p4Ylg7RcqJhFGRG2WLkttZzMMsp7DLhRPWyV5uFhWp\nEaEEXyBOKl+y8N7Wf+OdjoVRoQZWQ9LbacNoWgzd4CKCNz6ZgbcFILv7oERi\nwNumS2W951jhhlCfgHe7h/KKPBd+2Ifeakt/FClydYCiWyE/a4h1ifk6HeH1\nadBKqoJrgJ0BabY4tfUNT8X/u2S1xcvO6yFfGuorO/QVp16NmWpQ40I4tgGU\nJALl\r\n=TlNV\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICV+78VtDJSVpeYI7ctyLwBpGftCABN2A1RNpBiMOKURAiB7n3B7wio+AyvMVKuLcXRZqSX5EzxKksRjyI+Fnu3T4A=="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_8.0.0-76d17fd608922ef08d5fb5f8799d0cf7d227143d_1627408693366_0.6934159768377663"},"_hasShrinkwrap":true},"8.0.0":{"name":"@detachhead/ts-helpers","version":"8.0.0","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"^4.14.167","date-fns":"^2.21.1","is-ci":"^2.0.0","lodash":"^4.17.20","ordinal":"^1.0.3","ts-toolbelt":"^9.6.0","tsdef":"^0.0.14","utility-types":"^3.10.0"},"devDependencies":{"@types/is-ci":"^3.0.0","@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","babel-preset-power-assert":"^3.0.0","eslint":"^7.17.0","eslint-config-prettier":"^7.1.0","eslint-plugin-eslint-comments":"^3.2.0","eslint-plugin-expect-type":"^0.0.5","eslint-plugin-prefer-arrow":"^1.2.3","espower-typescript":"^9.0.2","jest":"^26.6.3","power-assert":"^1.6.1","prettier":"2.2.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","throw-expression":"^1.0.2","ts-is-present":"^1.2.1","ts-jest":"^26.4.4","typed-nodejs-assert":"^1.1.0","typescript":"^4.4.0-dev.20210727"},"gitHead":"91ad259840e5c13a73395a9c76697615882add8c","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@8.0.0","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-ldvzARQUuqtcey3XfVZ+JU9MUU5K4lR/W2j/wvPkyoO9Tz1VFQAfEzfcGp2qAJvhmH1gPYOID4VVN978gsxn1Q==","shasum":"bdb5323450d1d038f78ca7ae29eaa0f15c34ed29","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-8.0.0.tgz","fileCount":72,"unpackedSize":964815,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhBelaCRA9TVsSAnZWagAATxgP/2H6st837cTHW9YSuZY0\nqYDyX5V0kn0IT4x5crzx1QHKEsnOhqimk41Ryxl/snM4K/s3dVNOLsGrWqaw\nkH1OKZXtZRpMeutPFO4OEDSZXoYQsj/UasdMMyehhm/X9NnWSWkWIzN4KfNP\nqKi3NWCItS18QIWK9S3u6DtqUUfAHXXIuk+QqrqXISWz9mFWENvbOEEnfzjF\nbJd7yxE1CemYq3uteuF5w2xHutI1zEoANywcBS9XIK4WCDmQHfyJxBbbZNim\nPE/jZShXSBH/r/zanA8cqpNpMBls2PgSglKJT+iov2KsBAuzwkqGcAK14xgM\nux0nJnpXkWVk9F5i+sqV4zuDR1gWC1ox9dYSIAtvqMcvXKi+ds0Px9rnTFdY\nBy6Jj3VpgjXe8iRcy/M+zLhUNO8g8Gc320bbWtVdUJR9/Ujbs8CdGRDvdyji\ndjo3vhOygBqW+ZUdngqoojnoug8ceNFnDkkWn+RK52NzleV8SqPaurzOZ9eU\ndsYxgwCnQ76eb4k8U02Ndj+FlKXaARKdtM6x92JAWasqjr4nZepQnSEn099f\nzE5cyJ0WEZc4ergIp4MEc089HUl1stC0iE9nuy/Knf+78VKvNDZ7645WsFn5\nNCYg+hAsJMhTq8dpmEq3v3l1lgnQpWfgzB3j1LvvxPxSF6PPlEhqJCnU7+NF\n11bM\r\n=ju0y\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIETxgYG7OUsa2+zdKvIMg71GlnTKOKjFooleHosg9mBCAiBMgfCTEv2ZWYf5Qda+R0RChZkD/jtXmK3rA/hwc0tbTw=="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_8.0.0_1627777370362_0.9554542775098254"},"_hasShrinkwrap":true},"8.0.0-eaf2f20205261f4441d091c2a48987ee10ad8739":{"name":"@detachhead/ts-helpers","version":"8.0.0-eaf2f20205261f4441d091c2a48987ee10ad8739","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"^4.14.167","date-fns":"^2.21.1","is-ci":"^2.0.0","lodash":"^4.17.20","ordinal":"^1.0.3","ts-toolbelt":"^9.6.0","tsdef":"^0.0.14","utility-types":"^3.10.0"},"devDependencies":{"@types/is-ci":"^3.0.0","@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","babel-preset-power-assert":"^3.0.0","eslint":"^7.17.0","eslint-config-prettier":"^7.1.0","eslint-plugin-eslint-comments":"^3.2.0","eslint-plugin-expect-type":"^0.0.5","eslint-plugin-prefer-arrow":"^1.2.3","espower-typescript":"^9.0.2","jest":"^26.6.3","power-assert":"^1.6.1","prettier":"2.2.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","throw-expression":"^1.0.2","ts-is-present":"^1.2.1","ts-jest":"^26.4.4","typed-nodejs-assert":"^1.1.0","typescript":"^4.4.0-dev.20210727"},"gitHead":"eaf2f20205261f4441d091c2a48987ee10ad8739","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\n// values\nlet a: 1 | 2 = 1\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknwon, never> // false\n```\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@8.0.0-eaf2f20205261f4441d091c2a48987ee10ad8739","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-hLYtXaVnRtdTuERigMUVW46OkoneYqWqh7ENTKMh4ZZiFffFqHhXDWt67JiK0s68GA022bJVzZHb+8qUSB+Tpg==","shasum":"8fbe63af97c30eef1245893cdf10f6095879003c","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-8.0.0-eaf2f20205261f4441d091c2a48987ee10ad8739.tgz","fileCount":72,"unpackedSize":973401,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhB8uKCRA9TVsSAnZWagAA5r4P/jGsbWpace476ChPnRIY\n9x3qKZnd5k+GXL5lnko+fk2zMO9xDSeFYWrGK/V2oGFloqmjG7mHFlnBWcl/\nmAavVwjv9S/K1vydkBgeks4uuXDj8i/6yKJ6DhzZjpkA8x8FH/8oyDM3cHuy\nOREh7/YKXTKK5jSH5FZbWpnynK9CUtoFM4rB4d+Lwt66zUZVwL1rS81VTkkz\nRPelnqeXCghpWqx5Gs243dxRdwNM39olSxo18KQaZ/i08BCo/E0LhNlYVPIC\npC5CWyeUx9p/FDakVBeSRqKJj9hShMp8eOn7R7pD6ZnFYUlV693KwN0kvChH\ngc+ARU7Gf7amfYJI1byBVyJMr0c33jCz8mx+w55/HyUzPy4SUzGI3zxxwS7X\nXv2KF15JDjDlxB4o+kgLN2sjiFLvS67C31m5/2y1pBrKtCZNhLnW9y8R6krm\n5CGTSvZBVrcr7qQ5mviGYnG6tpj/h75nUJcVz/gN3oiEOF+lMJTqY964vk05\nIOn5df9vBwn1Se/BlV9u6Lh9wEvMcCFrq3hA3wZsCyBOiFcntws6HoXq4x2v\nlGBN7sZQLxfqnk2Ar8TRCu6wH6sL15RFH4nETRYqsDA794pRXp3lVLICyYq1\nmvfXoVDmXOKK/MFTlRrHCb7gJ0VbDs+kFDnGRf/+8wBj2zyGfA69195t87kM\n90qp\r\n=NlIh\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCcYgtPNT+5FUkqT3+IBHckD3tyrFw+wwOex7PC5Qx8IQIgGEWjUEaaAAIiO47qAJXpXaGICEDF7uc0WHPmAZsR2bY="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_8.0.0-eaf2f20205261f4441d091c2a48987ee10ad8739_1627900810752_0.5638936626169453"},"_hasShrinkwrap":true},"8.0.0-3c779a35b80fa320acf35da8d051e77e30d80599":{"name":"@detachhead/ts-helpers","version":"8.0.0-3c779a35b80fa320acf35da8d051e77e30d80599","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"^4.14.167","date-fns":"^2.21.1","is-ci":"^2.0.0","lodash":"^4.17.20","ordinal":"^1.0.3","ts-toolbelt":"^9.6.0","tsdef":"^0.0.14","utility-types":"^3.10.0"},"devDependencies":{"@types/is-ci":"^3.0.0","@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","babel-preset-power-assert":"^3.0.0","eslint":"^7.17.0","eslint-config-prettier":"^7.1.0","eslint-plugin-eslint-comments":"^3.2.0","eslint-plugin-expect-type":"^0.0.5","eslint-plugin-prefer-arrow":"^1.2.3","espower-typescript":"^9.0.2","jest":"^26.6.3","power-assert":"^1.6.1","prettier":"2.2.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","throw-expression":"^1.0.2","ts-is-present":"^1.2.1","ts-jest":"^26.4.4","typed-nodejs-assert":"^1.1.0","typescript":"^4.4.0-dev.20210727"},"gitHead":"3c779a35b80fa320acf35da8d051e77e30d80599","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\n// values\nlet a: 1 | 2 = 1\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@8.0.0-3c779a35b80fa320acf35da8d051e77e30d80599","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-hlJwsvGTN4PPA8GRb4TpRs/BReyHvbJm41PHOVzxRoEJE2rOQgbk8xTbozqiwLbCs0ns3giDXONxBaB5+NnXoA==","shasum":"e748d42e90899c20839cfa3bac2c3054d46e7b75","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-8.0.0-3c779a35b80fa320acf35da8d051e77e30d80599.tgz","fileCount":72,"unpackedSize":974283,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhB9SzCRA9TVsSAnZWagAADTMP/01QNdlnRHR4CFLm7AyN\neQMp9pBh+h/dHRXBfN8H+3OEpdeAG962UB3GFijVUSbJoLnm/x0/bkoV1+FI\nAR0boQR74lzUEv5U2WAEmfQxgWjSIy4T5f4R+lciGP3q4AHDHcFPLI1+AL3S\nCz3JM7cEy6D0gJtGU6J/t2en7jGsaX6wS59hpElvqLtgDk/MY4b9SkREyfED\nRq/oMWUv+/fLw7CFlM9RTW+/KzmnUJvRBju6kVGLUBq6OVeivx5K6KX+yMoc\nEy+YwCmleqJa0kdh7UmS0Z2NgsqztvrobTHYVrV7iYm0xGWzK/dprzCZdOwf\nAXY8peEH4fVcrh2WixSdgvh6Pwh4XbKXeegx0dL8mo/Nex+hL2foRSR72BDb\nbxUQGSiCNKAHeN+rGxU8eH0+BYo23FVx7o/cu/WTnUtyC6CIV9td4zF7coE1\nAaa/qZ2lK9cdP/OFQo2leDg1hKUWXgYJPxRgDaHfF+/ttZIa1XQLiczaQIhm\nRqEQjaZsiJcxvQAiq9WT+TmqtIcz4Fx78cfuqy9kRIDTOaVfSJxkyOAFCF/E\njv263jV4B1JgyRZWTx9zBTx/oprQrZGZt7CVw2fG/E05zJp9yfPkEkrX1/zO\nRI7BH0lR8GQAwb3EC2zSIiPPIjP9CdOBRwgyWZDXP7a5oa/FFsmsWOEcVq4H\nlW/e\r\n=bX9D\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGS7Y2Mi4FiixlIMLCHnhnqH/APdPJ2bbDUL1b747PixAiEArkRaCSjcWvnBk34drenV5v9lxT8PRW6yI0PXzxblH6k="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_8.0.0-3c779a35b80fa320acf35da8d051e77e30d80599_1627903154908_0.3835517819554213"},"_hasShrinkwrap":true},"8.0.0-fc6c8b8b5bd674e70d1cb6dec7c0ad6bfa50a820":{"name":"@detachhead/ts-helpers","version":"8.0.0-fc6c8b8b5bd674e70d1cb6dec7c0ad6bfa50a820","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"^4.14.167","date-fns":"^2.21.1","is-ci":"^2.0.0","lodash":"^4.17.20","ordinal":"^1.0.3","ts-toolbelt":"^9.6.0","tsdef":"^0.0.14","utility-types":"^3.10.0"},"devDependencies":{"@types/is-ci":"^3.0.0","@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","babel-preset-power-assert":"^3.0.0","eslint":"^7.17.0","eslint-config-prettier":"^7.1.0","eslint-plugin-eslint-comments":"^3.2.0","eslint-plugin-expect-type":"^0.0.5","eslint-plugin-prefer-arrow":"^1.2.3","espower-typescript":"^9.0.2","jest":"^26.6.3","power-assert":"^1.6.1","prettier":"2.2.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","throw-expression":"^1.0.2","ts-is-present":"^1.2.1","ts-jest":"^26.4.4","typed-nodejs-assert":"^1.1.0","typescript":"^4.4.0-dev.20210727"},"gitHead":"fc6c8b8b5bd674e70d1cb6dec7c0ad6bfa50a820","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\n// values\nlet a: 1 | 2 = 1\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@8.0.0-fc6c8b8b5bd674e70d1cb6dec7c0ad6bfa50a820","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-+5aY9LSrpnT4dXgYAAJ5FG/K0GXShQfn8gmg3fGvCPktPj+mxWkBtmPDDW97jglRcbBu8ux52eYL3TQfd6abVg==","shasum":"7b8ecd52469e2a716ebbb879e52de598939ea45d","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-8.0.0-fc6c8b8b5bd674e70d1cb6dec7c0ad6bfa50a820.tgz","fileCount":72,"unpackedSize":974422,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhB9XDCRA9TVsSAnZWagAAj8sP/260nA+yd77xkyq/z7H3\nojUMxdrVywSWICQrx4FSvZcBt0T+olPycohGLxx01AZOsQN1g1BftlvPak0m\nDXCI/MrRXhsYDlonQpnRiqZXK5KpeBBazkjwatZoeO+uq5VIubi/eipU8ZVp\nvm7x9/8hbD+zMNyexrbu101pqnm0uLbPvtbLA/uAUFVjCwgh8krYPOQtOcj0\npwRnr2LoWiQgW9Pbyu0zntR2Ni5RSlKCVHU5rIC3mpvXW+uR695/DX1aZLWe\n+x5w8V2Kxy1axlfpLE8dN/pmHNwm6CPfzAONrhOoKCoG91dizxn00VxKCi1C\nMOEAXMXnLTUiooEHAUgb2c7sIf0b6XBUDQ+mLnG2LNcR5BxJf6P/TLExAPSx\nted+Y/Plhdnyn+6kU8orZRmk14itJH9P4lh5K+gD8WJM+iICdfZEVJR2KDgE\nUrl0eAcsYvYe0cgwIdUWDS3fJYDANpC/HdQap2V6r3iF7CWG+cvD1SMq6jSp\nu6eLdUAkccLUjHgfZ4FDqXzmT3VJvdk5WhV3SJSGms/2Aa0y3JEMx5SiM0zK\nZZ3N0eyE8ybfHzG3u+CADL3uoAueh7pw/P4u4ilna+inhraPq1vzlL37Q7SK\nW3ksdR1pxYdbp/iDP5RNWSDLKLFdS+Ltzh5Xsgz7n2rW2rN4FbqzK2wUZssH\niiz5\r\n=eZ7o\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCID87PJZHdHSGTsQ/3qOTbW6zB4jot000Wok54CDqZOpyAiEA+3kDnKFzfmyn2cXpyOrYJLvEruGgmykMxtj2uKNiSXA="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_8.0.0-fc6c8b8b5bd674e70d1cb6dec7c0ad6bfa50a820_1627903427305_0.6867261082300529"},"_hasShrinkwrap":true},"8.0.0-3c0f47a679dbdd208a68d26246f7726807d687f8":{"name":"@detachhead/ts-helpers","version":"8.0.0-3c0f47a679dbdd208a68d26246f7726807d687f8","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"^4.14.167","date-fns":"^2.21.1","is-ci":"^2.0.0","lodash":"^4.17.20","ordinal":"^1.0.3","ts-toolbelt":"^9.6.0","tsdef":"^0.0.14","utility-types":"^3.10.0"},"devDependencies":{"@types/is-ci":"^3.0.0","@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","babel-preset-power-assert":"^3.0.0","eslint":"^7.17.0","eslint-config-prettier":"^7.1.0","eslint-plugin-eslint-comments":"^3.2.0","eslint-plugin-expect-type":"^0.0.5","eslint-plugin-prefer-arrow":"^1.2.3","espower-typescript":"^9.0.2","jest":"^26.6.3","power-assert":"^1.6.1","prettier":"2.2.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","throw-expression":"^1.0.2","ts-is-present":"^1.2.1","ts-jest":"^26.4.4","typed-nodejs-assert":"^1.1.0","typescript":"4.4.0-dev.20210727"},"gitHead":"3c0f47a679dbdd208a68d26246f7726807d687f8","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@8.0.0-3c0f47a679dbdd208a68d26246f7726807d687f8","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-In4It0fSf2o9/JhqJjk95Esp0T9dcabA2MhhiZLxHuL5Nc/gavvJ64Ll/UXeEsANTADn6rt0tq9X/ZGO/kOmTg==","shasum":"2854f021e4e5165d2ee3078bbf40ab844615a947","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-8.0.0-3c0f47a679dbdd208a68d26246f7726807d687f8.tgz","fileCount":77,"unpackedSize":999696,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhCCf6CRA9TVsSAnZWagAAX+4P/ijTkjLuGRblor/A93N4\neeB5aSD2d2FsKc4dbPaooRJQlvtMqtjyRBmxbyEZcUQlJZvtbJ/Z7hjdURi5\nKjt1623xFN+78Tj+OAO+HhxVvmOgG61RSoL2d+TF3LZGHEGykgYO3Gvv7cUm\nGvAGqboa+XtU0/KNlH5KjWpD7lPQ4/m/VfqNV8Qr1RawPD2fvNudyI4s3Bs2\nCjDteTVY1VDne2TvXEG4lTabiWcG/TGxY1ZTGQKfsy2GqNE4Lbs0FygQDncS\nOQBgDMxAyBURrhoZ0CChcuqfoYVjVcd9Sj7VRI1GsVfyqqmuJ0EDRelJPsXT\niiC8Ko5IOC82okw+lIAuZ/NWYYrwp7fbu+Sc9pCxi/lQcnaYdw0BnvmflWAM\n9wysF9Jir/YDxyRmxDHv79WQqZ8ECrxSGBHYlro1aNkGs0oS274uEx76g3wz\nAvnZFj5H4Yv+RwuCePd95Uov4bpAe6/yv/7DCJW0SovFhu0nAujRPYQNpE2O\n28BKlALJC5V0J0rLphcIoxIBEVd1L25hsGqfKXJdNrn3U0lR2JjOYDXzZVkK\nCis80iv9FeVKQE+oAzSXfork53zuGVjD6xsCctSkQzswVuiofz9Tn5gP3cSv\nNhvXOYet9aGaz/UaXx3ZMRVbALRh4VF/OoFtdTqWSia5y7dNwzAHE/CVkhKI\n4A//\r\n=nTd2\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCMdL1DFRjxGNjHhJEOIZzqm+Hycq2/oL8tCK/9X2kNVwIhALWoK0uGnv3NUk1hqxkzl0QjCHXuQYtmH2zWftj0Hr8X"}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_8.0.0-3c0f47a679dbdd208a68d26246f7726807d687f8_1627924474338_0.6696485001850481"},"_hasShrinkwrap":true},"8.0.0-dev":{"name":"@detachhead/ts-helpers","version":"8.0.0-dev","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"^4.14.167","date-fns":"^2.21.1","is-ci":"^2.0.0","lodash":"^4.17.20","ordinal":"^1.0.3","ts-toolbelt":"^9.6.0","tsdef":"^0.0.14","utility-types":"^3.10.0"},"devDependencies":{"@types/is-ci":"^3.0.0","@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","babel-preset-power-assert":"^3.0.0","eslint":"^7.17.0","eslint-config-prettier":"^7.1.0","eslint-plugin-eslint-comments":"^3.2.0","eslint-plugin-expect-type":"^0.0.5","eslint-plugin-prefer-arrow":"^1.2.3","espower-typescript":"^9.0.2","jest":"^26.6.3","power-assert":"^1.6.1","prettier":"2.2.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","throw-expression":"^1.0.2","ts-is-present":"^1.2.1","ts-jest":"^26.4.4","typed-nodejs-assert":"^1.1.0","typescript":"4.4.0-dev.20210727"},"gitHead":"3dbf88e68ad54bb06c6f24257bb0e2131691bfb1","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@8.0.0-dev","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-575hRedw/dI/KXk6wKCoeaTQV/lDuBfh0H7nlo2R7vCvNVdWnKp3GJs9ZhyQOI5aOJtEDWT5jItD2bWGUp8vYQ==","shasum":"ef59ddfdc5c40ed654105b17881a4aabf4acce07","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-8.0.0-dev.tgz","fileCount":77,"unpackedSize":999577,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhCPwGCRA9TVsSAnZWagAASYQP/018ZnMuKGfWurXiuKcu\nJ1RL9p99/AZ3BEVPGHA/FqMy8k4Mkhg1LRD/W8LtLZXPKUiEBhRtG8F0S2Rj\n4wvqscBxyJuA5okzeb4zFd2SEF9ap5YZBYK/fIyPxy/huCCXsNembeT7Sycj\nZnBfnkbn3GwunELKes21iyv3gYmTX180e3JMtwnRZn01VH3lf10AM4zxc8V9\nTcTN46Goxf/xgH5rVGj/f9IuaDgIgUbzy0QQOjYfRL92SNdPdhQqDmoe1i/v\nCWiv5gPjPR/k262N9QHbH/fM21RnBaIFXr9pm0jRUpOXRB8xMz+vkaG4itJ4\nCy1BzRqOx3hrDVvat33RjWFW7G52MiUrZiLQZE679QC+yUHQAqbVmaLJ+QUD\nVVCacmKaRbwa9sAVwF2ryQ2/Yo3Ho0exXl86onirVsIsAULnNU0Wd241zTEo\neUetSenGLpWJh06SaxjFbp8pJjs4L1WmcCNm6vQeQkdd3SZklXnHh1CmZNoP\nSxAhSbqcK8AYGyXFyKqSKLvhl8gs27TagGbiXtMZXl7OoN5ltn/dIL04LrHs\np1aNZP/tN5xWOf89IfNpOAoJzebx7Yjt3e44GtqQyyr0/vFkgTx/+pMzj2Jv\nFfKBB7eHGFJ0pEM8JrzRM+cKCSXn2yX720f4mXmlKeIPCN62Pj2fT1/oIqPA\nIwGy\r\n=OiDs\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDxY0oYVcczhuhaYcLT2C+LxvA7tRyRG6WEfZsOwVhvagIgSvLXLwmLDBzb+EPPSQmrScC9wG92z6YLseJldeIiBpg="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_8.0.0-dev_1627978758147_0.20426503940907859"},"_hasShrinkwrap":true},"8.0.0-15cceecd6478e5898952bd5aaef82873d20d70cb":{"name":"@detachhead/ts-helpers","version":"8.0.0-15cceecd6478e5898952bd5aaef82873d20d70cb","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"^4.14.167","date-fns":"^2.21.1","is-ci":"^2.0.0","lodash":"^4.17.20","ordinal":"^1.0.3","ts-toolbelt":"^9.6.0","tsdef":"^0.0.14","utility-types":"^3.10.0"},"devDependencies":{"@types/is-ci":"^3.0.0","@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","babel-preset-power-assert":"^3.0.0","eslint":"^7.17.0","eslint-config-prettier":"^7.1.0","eslint-plugin-eslint-comments":"^3.2.0","eslint-plugin-expect-type":"^0.0.5","eslint-plugin-prefer-arrow":"^1.2.3","espower-typescript":"^9.0.2","jest":"^26.6.3","power-assert":"^1.6.1","prettier":"2.2.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","throw-expression":"^1.0.2","ts-is-present":"^1.2.1","ts-jest":"^26.4.4","typed-nodejs-assert":"^1.1.0","typescript":"4.4.0-dev.20210727"},"gitHead":"15cceecd6478e5898952bd5aaef82873d20d70cb","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@8.0.0-15cceecd6478e5898952bd5aaef82873d20d70cb","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-fPqqtYgsKEZH2gOOS+ylb+CS86JpgiF4oRF+rXfO18CYYlXdnUhOp+omlO0nQ8++Rvf+X2ejaZonjWlODbOV+g==","shasum":"add9621e666177c2116c091657553452d0146944","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-8.0.0-15cceecd6478e5898952bd5aaef82873d20d70cb.tgz","fileCount":77,"unpackedSize":999696,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhCQlbCRA9TVsSAnZWagAA/64P/As8wrgfAt6d+19+rDbv\nQ06xVkX+Qs4saBHx8RhAJForzEjw+GUV16WJ7VafKuC78Z4QstIOvla0Ar4F\nFRoiDesokX0J9ek5UoTEJfHy+7NLpXJ+4lgw8VNzyQzUYi9Xh0S7bRxZE5DX\ndec1NVnf4h3VhRmXxHEkvOYuRgSehiw9D55MQ6nuMiOLEhkBPLY9TH7KyoyJ\nVhfP0iJW0qZTFUv74uZTGtOg12OBuKP9+mRtxRyLnf8fEd5Ih9vlfAFuXuK6\nYTgP8Kc8Xa9hjvIZUBpfiqDj8Re22wSCwFy+klPwzzUadic9t1Xr7TlbqS4S\nJhh4P0o4qFKtnkthJt58Zz9Lcmidaohg+Pre/MVgSWJsbk1gbnyXDlv3r2NC\n2MQrhhJNfyCsnq3K2VcPJm4T/AY4nvrPK8FvE3sNrX1gn1qgjyrW3ifMQzob\nSvBttvtgLKpZT1zivsexevdMFgV+3IDERE/Qh2zMuIUNSvPV6S/im4/pRn9y\nEYZGg2AaCrhucf1c90IwnN5aFtzoWTi53GzeKWs+rKbqmWMBedwHWnaLkYrv\ngGffDEh+7carEN/jPUbfdlvrHsXSvucFyMxi1vjEGdVk5ZvohFztP/DKzJZd\nIUtTpIb+Y6P3J/TKeTFtNnT/SQZxy3/4CaxgFdM7zeiIqUlmWnKnfz/XfOUp\nZvj3\r\n=pr8U\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC5wu4XGfrxD/aHGE/4kxLvW+oK6EclKlyTgdDj/+ytrQIhAM7kmaUwmOdyrlBgruCeHsFa5kRGv6BIG9Ga0Wba0+kp"}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_8.0.0-15cceecd6478e5898952bd5aaef82873d20d70cb_1627982171481_0.23227633197753006"},"_hasShrinkwrap":true},"8.1.0-91466570db6f80cef9c7d772ea3c879182473daa":{"name":"@detachhead/ts-helpers","version":"8.1.0-91466570db6f80cef9c7d772ea3c879182473daa","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"^4.14.167","date-fns":"^2.21.1","is-ci":"^2.0.0","lodash":"^4.17.20","ordinal":"^1.0.3","ts-toolbelt":"^9.6.0","tsdef":"^0.0.14","utility-types":"^3.10.0"},"devDependencies":{"@types/is-ci":"^3.0.0","@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","babel-preset-power-assert":"^3.0.0","eslint":"^7.17.0","eslint-config-prettier":"^7.1.0","eslint-plugin-eslint-comments":"^3.2.0","eslint-plugin-expect-type":"^0.0.5","eslint-plugin-prefer-arrow":"^1.2.3","espower-typescript":"^9.0.2","jest":"^26.6.3","power-assert":"^1.6.1","prettier":"2.2.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","throw-expression":"^1.0.2","ts-is-present":"^1.2.1","ts-jest":"^26.4.4","typed-nodejs-assert":"^1.1.0","typescript":"4.4.0-dev.20210727"},"gitHead":"91466570db6f80cef9c7d772ea3c879182473daa","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@8.1.0-91466570db6f80cef9c7d772ea3c879182473daa","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-4vfTXOT/1bmD7cc+BNTUoa2SWMlND5dlT+aE/cFKDOWF36N4RZ41+Nenui50SfLfNJ5C4zqAsqK4RJQNjSanGg==","shasum":"623ca791f210eb02910c373aaa4e6ac77cceb63e","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-8.1.0-91466570db6f80cef9c7d772ea3c879182473daa.tgz","fileCount":77,"unpackedSize":999696,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhCQmvCRA9TVsSAnZWagAA7VoP/10ywZsEqb+0rc82iHtY\nFkV8ofUub79WiGIUIvkELfrE22z2LC8Gq2kLKL3ODWiwPD+XpUXxDadQmrGW\nqWVNyQeNxne9Uf3rYjXRBjGnRvtR8FMFAIrmFohO7IXzt+X08DSfZ8gcAEaD\nqLZOSBH4MwIFtN5y0dpT5hMjZ3q/BgWjBBjZqfdnJtWQbi6xZU6uAm09U0UA\ndg6qmheOvixWV0bIAEA74wlF5bVTcrXOLJQRjVyd1gbHcdfdPhpkS+RchJkC\nJhPYTB2ko/NRtBNtjArfsY8ak5aNHyrCAUyfz/RaMazWzflWSb43gtIeRKVK\nW+JINLTA/sdhIHJwNZVbigWtYDlTrDx4vVRdyajdAEr4Tr6l+fxO43IIGKLs\nTeQSA1y4vzUk+VN8OlCwY8wFrq6QBWbNrw7NCLfShU+tn8Q715m9mhjEPvJE\na2RhJlw4VJbiLHsMvMK36GTu7/A7RINuHlvUNcO33n+udkDJkB7gfJoGjmsT\n+CfDAhBc55hcy6WWFS+L/WxacGbvzoNSyWco2rZ/aBEhkcoVux8eKNrE0xAC\nJsLN3fbRM4JV+HNc4rdDtwAF/Uy0pWj+E9fC6ir+4uNCQfBIyC4U9sM63p0Q\nNOtBs+CbJkj/UlTPEAxW/dDBpKnkphqIXituSltwK/tZC065d/czBur0HpZ8\n+lyq\r\n=AxXR\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCZ0aVCz867Gu4d40pmP+u5kV00xPnbkgVom2ewgB60+AIgVsKUtHzWlCJK1CPlYlbaB/ks/8LERBez+JIJNdJ177A="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_8.1.0-91466570db6f80cef9c7d772ea3c879182473daa_1627982255639_0.8149929914730516"},"_hasShrinkwrap":true},"8.1.0":{"name":"@detachhead/ts-helpers","version":"8.1.0","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"^4.14.167","date-fns":"^2.21.1","is-ci":"^2.0.0","lodash":"^4.17.20","ordinal":"^1.0.3","ts-toolbelt":"^9.6.0","tsdef":"^0.0.14","utility-types":"^3.10.0"},"devDependencies":{"@types/is-ci":"^3.0.0","@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","babel-preset-power-assert":"^3.0.0","eslint":"^7.17.0","eslint-config-prettier":"^7.1.0","eslint-plugin-eslint-comments":"^3.2.0","eslint-plugin-expect-type":"^0.0.5","eslint-plugin-prefer-arrow":"^1.2.3","espower-typescript":"^9.0.2","jest":"^26.6.3","power-assert":"^1.6.1","prettier":"2.2.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","throw-expression":"^1.0.2","ts-is-present":"^1.2.1","ts-jest":"^26.4.4","typed-nodejs-assert":"^1.1.0","typescript":"4.4.0-dev.20210727"},"gitHead":"9496ec3f7ad67ab2179c082af750f67203413cef","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@8.1.0","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-eX2a/oCwe05jarTPxLyU1QCKfLqIk1ZlJeQOLa/t1L7v8ba5+acJgbWrma6Y21bgS07iBG8cKDAtOLQnj5YWNg==","shasum":"5bd4754811334e82d5c1f3126d5ce23438e54b5a","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-8.1.0.tgz","fileCount":77,"unpackedSize":999573,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhCQoiCRA9TVsSAnZWagAAOtIQAIuhC0K4+tVEz8OnvTVM\nBYTqtPA0GH2PXUnd2f0kLANHwZjoiIMggGGmJ1JOrTIgaaLsR4YYgWF0xD4v\nY7ldP0ldgbgpQj6HOqU0cbkoWuonULKECA2FUCTxEAurbDAY+icL7yD/koV6\neoO9nCLNX+1niWQ7I+aqi0vN1SifxKQVzLHntX54xr44/cXqnQ1ey7ZvyPWY\n2FkeShiYel03UWTELCqhagsbzJnFbvuEeshW/2SeX17tmnDHddsmeUSfM8i6\n8eN2UBfNJKnWnilRvMIsbs+BgkfmUvgDQxIED+rmjGJvwVq8sSZlllCO7g7/\n67KIad9oxD/MjPmCh2Bxd91Hgx6F3Z6YBrwXf4AjxgFtnN7952caBbp66Gjf\n9WHAtV7MI1P8A21vmbmG+u2BWSYo9kf0BH5XpuXy1MwzwjM+5SS7oodbiEi6\ny7C+TdqR3X5izKP7jLnepcrLeb9UqzOkm4IGhP+0eblN5ovBN1gpfDXK2/Vs\nkBcAYuyzBahIVoaA0slfNgKdrUvsEnRklVWiGngdVjkOg53d7JFcc2pw8P2g\nhqjkaoolP9o+XemGJkJTVsbUk6BFqEy/I3SlgINHLB8u1EExpXGCaPjrk3TY\nLj/WFOwq9Ig301dNVuhXE4keooBTA/s/TGf9zJZz31eGjhb6If8c3QalCnrx\nDWQW\r\n=MEIi\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCOhlSg3e5ZLpw+VuWsZFeQsJbZqLaPf1F+Lss+JxDrPQIhANDBF79d1pcf0QkgGJHbRB9kRuRkTmleTvPxW+lzoaGH"}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_8.1.0_1627982370157_0.4835924162765164"},"_hasShrinkwrap":true},"8.1.0-e0eb961072454184d60b0860062257e1c8efae76":{"name":"@detachhead/ts-helpers","version":"8.1.0-e0eb961072454184d60b0860062257e1c8efae76","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"^4.14.167","date-fns":"^2.21.1","is-ci":"^2.0.0","lodash":"^4.17.20","ordinal":"^1.0.3","ts-toolbelt":"^9.6.0","tsdef":"^0.0.14","utility-types":"^3.10.0"},"devDependencies":{"@types/is-ci":"^3.0.0","@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","babel-preset-power-assert":"^3.0.0","eslint":"^7.17.0","eslint-config-prettier":"^7.1.0","eslint-plugin-eslint-comments":"^3.2.0","eslint-plugin-expect-type":"^0.0.5","eslint-plugin-prefer-arrow":"^1.2.3","espower-typescript":"^9.0.2","jest":"^26.6.3","power-assert":"^1.6.1","prettier":"2.2.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","throw-expression":"^1.0.2","ts-is-present":"^1.2.1","ts-jest":"^26.4.4","typed-nodejs-assert":"^1.1.0","typescript":"4.4.0-dev.20210727"},"gitHead":"e0eb961072454184d60b0860062257e1c8efae76","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@8.1.0-e0eb961072454184d60b0860062257e1c8efae76","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-PnO48f/oFTKxgh5wi5DzvJJRJdvPYOLVLB1RpilwGoMNzqNGv+yJpJvPyyOUhdxnDVW2EuTT8tl3dbsvJgNttg==","shasum":"55f11f0941462940f2d6147aab0ee5364eaa4ed3","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-8.1.0-e0eb961072454184d60b0860062257e1c8efae76.tgz","fileCount":77,"unpackedSize":999922,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhCRSLCRA9TVsSAnZWagAAY3EP/0oXisYf6FkLPOMJ71cW\nX4hdksOubSYGmJ1Ek0jra6552P4eDuh/EKKBiP4oSYoLPt2lCYP85GX/N/Yz\n04NB1R72etcQaeVsrPYaDLsFbSxG6kppbn5LcxxkY6gA+lY7Exu5+EuXhwjy\nXkO/Svk+py2lodaR4IB4KTiG9TpoU6XAPTa+tpMhI4P892FJCvxTzkTxwr6B\ntY6HBXwZKMlCdq2zPUX1Q0xrU2TRfGR0fPfgqqQw6RweQQoSxZ7XDQdSUcFG\n2qqZLithF0BfFGO3c6YA8v9BaBhlAi824zDjhLUmD1pjtwgiEccRc8z2L66j\nPu6FKl9DEUm9CA6wkOLcoKWJ1Y8zflEKal4QIUBRJNIojila3x+SBCWdyasG\nVrBMhCft29Kw5nAzVHuTvtAMF9bUaeH3njwvQnY9/cop3Jml9YaakW9ZfLdB\n9Z6v1FC45snlBhZN+T+cUpgcYOHodM8o7m48Ncich454a+3QzFBSS0qvhiZW\nSSUSZ3t4QMVCVuYZSHbIzwEDdkVD79tLkc44Pci/C+Y+EmuIVVeUhrI8XLJD\nLyKwNg8zoXf3xIgCiQGcgRkrp6MMfwiQFOzLHrwW56mj8RGzqgj8tAGobkqa\nrUlllHqwAjBFfdSyCPa3XfQuJ+X4zy+I9WWkcAtuf5oBU5z8Fn+MgB4lFka7\n/0lv\r\n=qX4H\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEZNEYWEC3SwL8qewoqbBb04HZZg0o0s1C1RU85Y4/fGAiBTJUMrIm8Xl/9YH/05XMSR08nLAKsgHazsv+/DY0P04Q=="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_8.1.0-e0eb961072454184d60b0860062257e1c8efae76_1627985034998_0.29672414622271304"},"_hasShrinkwrap":true},"8.1.0-7ddf86ba80b21b05b2efbc62e236174d149954f1":{"name":"@detachhead/ts-helpers","version":"8.1.0-7ddf86ba80b21b05b2efbc62e236174d149954f1","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"^4.14.167","date-fns":"^2.21.1","is-ci":"^2.0.0","lodash":"^4.17.20","ordinal":"^1.0.3","ts-toolbelt":"^9.6.0","tsdef":"^0.0.14","utility-types":"^3.10.0"},"devDependencies":{"@types/is-ci":"^3.0.0","@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","babel-preset-power-assert":"^3.0.0","eslint":"^7.17.0","eslint-config-prettier":"^7.1.0","eslint-plugin-eslint-comments":"^3.2.0","eslint-plugin-expect-type":"^0.0.5","eslint-plugin-prefer-arrow":"^1.2.3","espower-typescript":"^9.0.2","jest":"^26.6.3","power-assert":"^1.6.1","prettier":"2.2.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","throw-expression":"^1.0.2","ts-is-present":"^1.2.1","ts-jest":"^26.4.4","typed-nodejs-assert":"^1.1.0","typescript":"4.4.0-dev.20210727"},"gitHead":"7ddf86ba80b21b05b2efbc62e236174d149954f1","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@8.1.0-7ddf86ba80b21b05b2efbc62e236174d149954f1","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-iyiHk+mvIvxhAqSM4vIJ7CuUp4KeGSlRl9m1uAHOwaiHYoksQ9d7VjzNem3gXysI/iOQuqhx2hgig5dejdBOKA==","shasum":"b38ad33ede8b8ccf34b69e7110d7f1c269c45ff5","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-8.1.0-7ddf86ba80b21b05b2efbc62e236174d149954f1.tgz","fileCount":77,"unpackedSize":999601,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhCSH1CRA9TVsSAnZWagAAhjAP/A2RL4TEe9ghJuO1y9mS\nKxw/dx+LetAhtrZMJX4sUT4un7xnCrUWGbrg49pLLBFQ2sQcNQv9U00NtMEY\nt93DlpBB9IuO2LTp5Rzwnbhxfb4cDQxMbXeqJqdq4c6jEWXOinBLEUQwe111\ncbBu59EzdOD1k9DqsC0pr6w8Fw8f3JeLhn/ssiQOL2cOWPLtwccldClgYVnY\n6QwbjzuL0flsxWzfajPm9Ym8mzZDK4jWAcVTrTt/GVoc+i/R7I4Y6Db0QlTj\nvuGaFcAgq5ibnHthyPyuN7Tczj+YIod17UZ2p1aNUWvZQVy3ZAqI12SlSe+R\nbmsRHN4eOGXVXuZAiAAUxc7Y33AlQCRdEHkY3H7qE82LjCpQvANnu3aMZDyg\nYno2G/+ffZOvIOm2wn9omz41XSiCvJk9iJzGSaMoUpy5dJ5yvpcfxhLQy5Oy\nJzq4v1gEBm7Ve/ntqqfpDn0zJmdg/gbZFARK3+EIJ+YsJpa8pkxqfqKDadIe\nsJF3WFPKeCFbxKPNkoyRtnzl0b8KmWDIqRpe4z6tWQHuZbwlferGvLcrNbFX\n5SyCDtacM93yiFt1bhmncedXS+Al0W+vz5N4wpLBl/cV8xRcw1BSvkN6AyE5\nXUeLeS5/POumuwTAi5stAklCGN9UkZggxpmFjS2us+g8cZeHqQZtUmErSQYY\nCSJp\r\n=FHdb\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDYTKSIIKiR1PODNXWaAgmaG55jdoEj2Iyvsrkzp9pBiwIhAJMxyn7qcJKHrCd3LKlB2p6qjyHgbUlyftIODY69VKxp"}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_8.1.0-7ddf86ba80b21b05b2efbc62e236174d149954f1_1627988469189_0.4540072395318626"},"_hasShrinkwrap":true},"8.1.0-7746764a4a5ed4a83c1861e73332e69fa1d27df6":{"name":"@detachhead/ts-helpers","version":"8.1.0-7746764a4a5ed4a83c1861e73332e69fa1d27df6","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"^4.14.167","date-fns":"^2.21.1","is-ci":"^2.0.0","lodash":"^4.17.20","ordinal":"^1.0.3","ts-toolbelt":"^9.6.0","tsdef":"^0.0.14","utility-types":"^3.10.0"},"devDependencies":{"@types/is-ci":"^3.0.0","@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","babel-preset-power-assert":"^3.0.0","eslint":"^7.17.0","eslint-config-prettier":"^7.1.0","eslint-plugin-eslint-comments":"^3.2.0","eslint-plugin-expect-type":"^0.0.5","eslint-plugin-prefer-arrow":"^1.2.3","espower-typescript":"^9.0.2","jest":"^26.6.3","power-assert":"^1.6.1","prettier":"2.2.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","throw-expression":"^1.0.2","ts-is-present":"^1.2.1","ts-jest":"^26.4.4","typed-nodejs-assert":"^1.1.0","typescript":"4.4.0-dev.20210727"},"gitHead":"7746764a4a5ed4a83c1861e73332e69fa1d27df6","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@8.1.0-7746764a4a5ed4a83c1861e73332e69fa1d27df6","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-f02MvECiiAe1b6XEuuWIheC609uiaPdRn/R5FVQ0zVGJZl6PC7N6zsay1qOJ8PfXbH16MfUMCTpZr/1kTgzguA==","shasum":"fa4e6f9a698231c7acac35f20dfead4700c2634e","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-8.1.0-7746764a4a5ed4a83c1861e73332e69fa1d27df6.tgz","fileCount":77,"unpackedSize":999601,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhCSlNCRA9TVsSAnZWagAAx1gP/1W6+S2daj9mZoVsGxj4\nc+/5w5BLE/AtXCxm6B8o38Ok8h1myH6NOQKUNA65pVWBLqLcZ9hfm1l3P2A+\nC1T7mgyoRd5CnEgtr78NAgTxZ1av0auqp5KJ+SaZ5eIMkMNnTrAp8zwK2P4s\nXRkgGGDtX3UAdPAUp1d4FOey8elPI6fzmP4v469TO9gWoVNu8x3+9cHD09Q/\nT00OvhBO4NzHe3/tuEeSk6RDNLjsPZZky/31wIo2edsaQGIiPEHKsKci3hbi\nfBqID6fJaHKE8VhxB2vhslvdrW/9A3PmnrvHpD4CeYWMvWh1CcfEFb08L/W8\nskQn5qhHaxr0w7JZTabZqOqgwrsRWHlLxP7EqOy5CSm7oeGRX7A+m/ALpMZF\n5WLbZApO4lhGScIuoYLLWvbrLexmuxo4LOzUQdSF3UANBaLt1sY05RAf3uHC\nIQr15pZ0M+unZfCKmZDdQxWXY0nxmDOtLgGp9MgxvNu+2JekYx7+g4uCD06a\ngfUgbqDVH4exayISlloQ03uDa95dvk4Z4RMHaaucl7Uf0ioMBo145P1k9SVq\nPgk4Saij7jAGwrVeh6XndCfE72hpWw9M4CPtRiK98xasd9uY4KcIf8/EvOv/\n1nCrcWmW9qjSPFj1qsPlwMM5WDfNcoZH/s2JQieAu2lNvMRX2exKU4hiB8nZ\nG/Fs\r\n=fehJ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD75g7F8jdkjXlT8paINDBP9wwWdhF9pw/HQOef903flQIhALsEXa3zP78aCp/pppHcSi85kDGgBzMbyysxn783pwR7"}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_8.1.0-7746764a4a5ed4a83c1861e73332e69fa1d27df6_1627990349559_0.22696648692643162"},"_hasShrinkwrap":true},"8.1.0-dev":{"name":"@detachhead/ts-helpers","version":"8.1.0-dev","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"^4.14.167","date-fns":"^2.21.1","is-ci":"^2.0.0","lodash":"^4.17.20","ordinal":"^1.0.3","ts-toolbelt":"^9.6.0","tsdef":"^0.0.14","utility-types":"^3.10.0"},"devDependencies":{"@types/is-ci":"^3.0.0","@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","babel-preset-power-assert":"^3.0.0","eslint":"^7.17.0","eslint-config-prettier":"^7.1.0","eslint-plugin-eslint-comments":"^3.2.0","eslint-plugin-expect-type":"^0.0.5","eslint-plugin-prefer-arrow":"^1.2.3","espower-typescript":"^9.0.2","jest":"^26.6.3","power-assert":"^1.6.1","prettier":"2.2.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","throw-expression":"^1.0.2","ts-is-present":"^1.2.1","ts-jest":"^26.4.4","typed-nodejs-assert":"^1.1.0","typescript":"4.4.0-dev.20210727"},"gitHead":"63d2f9cb341d0b1da4c6bf8dc56afc40efb78e39","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@8.1.0-dev","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-/8lEmQ9I/OJYUuZRlG4odP9zYlLnJcps9NVjE+Wkk850o8mWvrrQQ+gkKLIQJ9W5unJBSirU+rUU1VKQ3xVJ4w==","shasum":"406a919767f504ca0ec4893ac7c13408862a5c66","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-8.1.0-dev.tgz","fileCount":77,"unpackedSize":999482,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhCSnVCRA9TVsSAnZWagAA0x4P/0uDU3NttId9zpgT89ZL\nWcMme2BQ/YJfd2MABnK1vd4UDAJ4j36GZhBmksLxtdA9CXLgORPs+ktBIbGe\n1BS7A8HlLfUxrcSfHKY+y/S1p2bH1+LULFB1r/6Ab8LZgK4dZ0amhakCmnjN\nMiXoSG/C8Vx/bah1kaFQA+iAIZVk3DWeCEbvaKT4/XWgxU6B1OJWD/FCQxuR\nOfe92H28OQ2Krv5NpsEmve1sJgHkbeBaJ94iCF5lbC8IaSCuWA7Uq4l1oYmV\n2Z3dBT70aoYWKXNe6xJ9apMfHUDd5EdXalsne/DmoWXnbT4LUsp37feznhC7\nQ3CRLXzlmpYE8V1lNA1JUeo+Uplhr+CRKD7bwZzFMUJQlLJrRPaWRXmLPrDe\nBXjSoIZDXFfp3sEQpcDvjHUKblWCYQm/6yZIt/dMka9YC7+cWEhNc7Il9E0D\nqZ4O4FZ9v40cTjBJeQLUYrqFxJAzsF6s4KgCxWiI7LUL1srpMx8LqRZySepI\n1xSa3rwJFEuJWnCQir4jhsll6Qu2LYK78O8u1g2R06xhlIWz/rLftcjeVSwm\njoNRsKoHUCeIp9Cg7IiVW3nKYHvOkpTN/Z8BLKdFaEFYKq4O9NdgGUaiW4MC\n69RQ2VJ6TTuBsQkvXh3VAvPE0EziE3cYaB6+UbIUlodIps3ObhOagaGM0lhI\nGPE6\r\n=qViv\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC8+c21+jzikw8eEe25jHk13QtW2/5DZ+22ymHt6Tw7PwIgVUbSzA8/5BNvH3UGIQnLyM/M/d3vYjqUswGtSTku5Ew="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_8.1.0-dev_1627990485532_0.2355323708928707"},"_hasShrinkwrap":true},"8.1.0-0f21095850ed63c2648ef39d07b0ce5c07b84a82":{"name":"@detachhead/ts-helpers","version":"8.1.0-0f21095850ed63c2648ef39d07b0ce5c07b84a82","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"^4.14.167","date-fns":"^2.21.1","is-ci":"^2.0.0","lodash":"^4.17.20","ordinal":"^1.0.3","ts-toolbelt":"^9.6.0","tsdef":"^0.0.14","utility-types":"^3.10.0"},"devDependencies":{"@types/is-ci":"^3.0.0","@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","babel-preset-power-assert":"^3.0.0","eslint":"^7.17.0","eslint-config-prettier":"^7.1.0","eslint-plugin-eslint-comments":"^3.2.0","eslint-plugin-expect-type":"^0.0.5","eslint-plugin-prefer-arrow":"^1.2.3","espower-typescript":"^9.0.2","jest":"^26.6.3","power-assert":"^1.6.1","prettier":"2.2.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","throw-expression":"^1.0.2","ts-is-present":"^1.2.1","ts-jest":"^26.4.4","typed-nodejs-assert":"^1.1.0","typescript":"4.4.0-dev.20210727"},"gitHead":"0f21095850ed63c2648ef39d07b0ce5c07b84a82","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@8.1.0-0f21095850ed63c2648ef39d07b0ce5c07b84a82","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-iq9wB/5yxPWDXWOo0eNdSdqNlAWKBFXRysC1V4PryFxURitgiGxmYuUfnhdD6TyoJVljhf1nfsiI47MWTCEMyw==","shasum":"3fdfb569a4a4f3a9e1aa4f2de1ada6c25056cab8","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-8.1.0-0f21095850ed63c2648ef39d07b0ce5c07b84a82.tgz","fileCount":77,"unpackedSize":999601,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhCS9TCRA9TVsSAnZWagAAMwsP/0Zker65lEL0ImBsnwZ4\nvssomyNakWYwg+tBSVP6ImLcMbpRywzBZKulAZ5ojplznoRv+8pxf8i39jqw\nbjJgMYSKLfscNLOznaKtr8H/ytAz47qXhfmHjUqKDWOJFOqJUbxrcUVwRcMW\nwOYq/ODquoyfNB+POmZpNSfu9fBpuAnJbA/SU7k6tXkDcgj2SbpUIEkSFfB/\nS2oVlXbkc8/2y9xT4x8gZ8m13KfTtbX8DCnjDCD2WxfXWSXTjQ/1pF1N9i3V\nTdQnMCVtTjVZ+D4I7A5FfZOdDRVva4UsFwRHmKZeBZ6IGwuU+smJT5rehK7C\nB1VKy0OsnJ5LCZO8INiu3vQ4ReXzd9z/s4u0z86/2IO8zmY+e2w9WQm680pW\nMtgavaB3AK8xGnnM9iHoo6v6He5TBaYRwUpPn7/L1nSoeS7mwJF5S9t7bVZY\nCuC2fZg8hYDRuVeEkm5hWgiSt4cbNZ+kVjUoYgkz7Z5ePzM0pBn+UKdZHIkB\nB+FiC0qygbIve+ryAywWf+JjIDPeEZ9510lleRF4daGHcB3wHGcZX0H6oYRL\nPcoIEDQAWQ7o3d89JnBXpvHSFDAOMHa5utQDnZsBiwjsnoKd0LNP6Lo4uI4z\nTASZixK+jOs1RXbb/ELPrlQgA1/X8fJzmJJglnx0XON/spnrRmtaM6/k4UyO\nkE86\r\n=PN7f\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIB7SvajbPOGimr+NiZknP2COrHcliEKGpSQ1xmxk77y0AiAHJqr/EGefibBVy5g/O/HySZxjxDavc9XZsXd8e471mg=="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_8.1.0-0f21095850ed63c2648ef39d07b0ce5c07b84a82_1627991891256_0.29287157651214746"},"_hasShrinkwrap":true},"8.1.0-58ced0930338a92a3267df7aeedb7c1c35e71d75":{"name":"@detachhead/ts-helpers","version":"8.1.0-58ced0930338a92a3267df7aeedb7c1c35e71d75","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"^4.14.167","date-fns":"^2.21.1","is-ci":"^2.0.0","lodash":"^4.17.20","ordinal":"^1.0.3","ts-toolbelt":"^9.6.0","tsdef":"^0.0.14","utility-types":"^3.10.0"},"devDependencies":{"@types/is-ci":"^3.0.0","@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","babel-preset-power-assert":"^3.0.0","eslint":"^7.17.0","eslint-config-prettier":"^7.1.0","eslint-plugin-eslint-comments":"^3.2.0","eslint-plugin-expect-type":"^0.0.5","eslint-plugin-prefer-arrow":"^1.2.3","espower-typescript":"^9.0.2","jest":"^26.6.3","power-assert":"^1.6.1","prettier":"2.2.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","throw-expression":"^1.0.2","ts-is-present":"^1.2.1","ts-jest":"^26.4.4","typed-nodejs-assert":"^1.1.0","typescript":"4.4.0-dev.20210727"},"gitHead":"58ced0930338a92a3267df7aeedb7c1c35e71d75","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@8.1.0-58ced0930338a92a3267df7aeedb7c1c35e71d75","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-egXf0447H9PaFae1V46+fmbyUASbMicCrHAv/KuMCQBfXcjc+TggXosd8nf1J1D4S9LsHi5G4Gzz7HDk0qquBw==","shasum":"f3ff2ea1c67f7740653432c45986edc33664f328","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-8.1.0-58ced0930338a92a3267df7aeedb7c1c35e71d75.tgz","fileCount":77,"unpackedSize":999601,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhCTD8CRA9TVsSAnZWagAAubMP/3PdKlg8Qz5x5QwiugEy\ntRkP3/l4QC3l2PIZZeMQB/sy/doLcFhSQM8tk74GMV3ZxFv+mYNuRoiebjTk\nwo/T0hp/3tEO7dub9c/quvLHDp3QkLBd36pFkgECaaG9aiqf+6oR2LjRsUHS\npYN0v8SIU8S5xXY2YPvpQJSnK50hyb4pbNVAFBIY0xxmFiqZaRk/z7tUSGnx\ncsh5FT1Poa89FN4r2USavYifNBq3WAImtaYxnlkVQHeJ0wl2sfXz9blRKs7j\nVRI6+Ew0nCIKksJQRX9YnjBA+4DHHccur56fNNd2V5a9Rb+h7uYGoASI8Cmg\nZvn40r3Gz9HkW7LhWjr5Gw3hqUeA0qsXy5iuah4qX04maPPCRNqsW8bEO92A\n7IO/WXbA42dNr9sNt1Svm1HDaTct30k8eyc5m0L+Lm/808VqdsiWzDvaslon\npZPuMREf1gPQFSUtsZyYb2qu2hKYVNjt8BEF2GIMHzHY5K+iQQSfeB/9sUqO\nqnCOuVpwVrIPD5UxIV9IgKFqKM/FJZjZCt1zq8D1648cYCjFiQBR28SgVCcm\nqdw7YOpCC1RtMDtsVJKAHwrJorR6ECcrNH3A/YZNmEQFz/V3zn0EeJBDoH98\nUo2MJeVA1LuLWDlxgIVBPrJPPAOgHUR7uTlceWKQP7kz2Kb+PqHRpYWuuiC+\nVULm\r\n=tJWb\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDL1g5ti/Sz2L5I+WIrBJMRIr9CnseSXrqSk+9tJCPJHwIgPoP5QPUs7oXeatA21SSQomap3qS10gUenrjCXoJhkEw="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_8.1.0-58ced0930338a92a3267df7aeedb7c1c35e71d75_1627992315950_0.19227383700689993"},"_hasShrinkwrap":true},"8.1.1":{"name":"@detachhead/ts-helpers","version":"8.1.1","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"^4.14.167","date-fns":"^2.21.1","is-ci":"^2.0.0","lodash":"^4.17.20","ordinal":"^1.0.3","ts-toolbelt":"^9.6.0","tsdef":"^0.0.14","utility-types":"^3.10.0"},"devDependencies":{"@types/is-ci":"^3.0.0","@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","babel-preset-power-assert":"^3.0.0","eslint":"^7.17.0","eslint-config-prettier":"^7.1.0","eslint-plugin-eslint-comments":"^3.2.0","eslint-plugin-expect-type":"^0.0.5","eslint-plugin-prefer-arrow":"^1.2.3","espower-typescript":"^9.0.2","jest":"^26.6.3","power-assert":"^1.6.1","prettier":"2.2.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","throw-expression":"^1.0.2","ts-is-present":"^1.2.1","ts-jest":"^26.4.4","typed-nodejs-assert":"^1.1.0","typescript":"4.4.0-dev.20210727"},"gitHead":"00aecd5d232e0ca02c158ad2e4b23130c25743c8","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@8.1.1","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-51g0hrhRb6zD1D/zBfq1Vc1GhMFRiNV8YDhLR6gK+1xinTYfRhtuZNj/EWxEKIyB2kpQTfu3MPlAeCNu3vKp8g==","shasum":"65073994902dd8a3c883958ccc79ea331be775e5","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-8.1.1.tgz","fileCount":77,"unpackedSize":999478,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhCTsZCRA9TVsSAnZWagAAqjoP/iBMAAvvaNRPHM1rLG1f\nPyMGeYAUdDRIV56fUim0BFcLrVCRf5znxZKgqSJGkihMbogCkaZ+0u/1k/BC\nB99ruQ5ERsSjxHDBi4uwuSblnfzFqeLQILtM0vaiYauh+IcGeo+gHAe4R/hM\nPvGKCYSQhEN2LzVoK9PFPw1b0pToYnShVbX4lt65+JeszO1v7yxbvJwH13Vx\nbVDfT8t8y83J/1NuFnZHmLJhOEwi2QOLtHDegqcCxVJBbUcWr7WLm3BPSliv\ngMC+IJtEYutMNDVAlEosdn2LhsKlNqqMCaacR5pGkD8YHJYkEW5N/AyjHHTF\nLmk4+C+hZj8NW++q4hPCXc68IS0II6DDrNKIOylThGTlxKrsY9R5nN0HWnHs\nQ45L2MFBm1LzkAATMfbwl8KufXsYM3wXqg2dVKA1tR2bF5mPPLHAcPAmBfYT\nOYeaYF0k9YRN3iaq79Cy+/HDGGuBVeTGL48UZwm0Gddge0i7UCFa6OeOy9dX\nQXYV4Jow5ER9mEY33AFp/4Z4fkOCLFgRSSBKESsg/fp2ZIjmrtARSi818aut\n/KEpJQ8b1Lq+s+si0hsZs0mwE6I0rb/iyKjPOpUaGA6axRN2RwfqCDB13hY6\nhMe872JI/7142btWEko8CDAuk3g7nu/iUgv6R6/RUL/35TDCUX7DAcTFvVfx\nPqAk\r\n=TJWs\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHFRVB3AS/FhgeJTDgZN67+9UeusvX9faajTm9IPLbjrAiEAqa0gADQ+5QhwufF9+KXYpeGswQqtMdPW3JUSYIJeAc4="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_8.1.1_1627994905493_0.7968242753984458"},"_hasShrinkwrap":true},"8.1.1-0bac80661d986c3a2799e0895507faafaf6eb896":{"name":"@detachhead/ts-helpers","version":"8.1.1-0bac80661d986c3a2799e0895507faafaf6eb896","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"^4.14.167","date-fns":"^2.21.1","is-ci":"^2.0.0","lodash":"^4.17.20","ordinal":"^1.0.3","ts-toolbelt":"^9.6.0","tsdef":"^0.0.14","utility-types":"^3.10.0"},"devDependencies":{"@types/is-ci":"^3.0.0","@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","@typescript-eslint/eslint-plugin":"^4.13.0","@typescript-eslint/parser":"^4.13.0","babel-preset-power-assert":"^3.0.0","eslint":"^7.17.0","eslint-config-prettier":"^7.1.0","eslint-plugin-eslint-comments":"^3.2.0","eslint-plugin-expect-type":"^0.0.5","eslint-plugin-prefer-arrow":"^1.2.3","espower-typescript":"^9.0.2","jest":"^26.6.3","power-assert":"^1.6.1","prettier":"2.2.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","throw-expression":"^1.0.2","ts-is-present":"^1.2.1","ts-jest":"^26.4.4","typed-nodejs-assert":"^1.1.0","typescript":"4.4.0-dev.20210727"},"gitHead":"0bac80661d986c3a2799e0895507faafaf6eb896","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@8.1.1-0bac80661d986c3a2799e0895507faafaf6eb896","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-QQtP7RncHzMPShx+Z2burzTjLABRCvBzx/VtBk7a5BXwYhChWsvuVHVVZLWeQUB7RdMEsm2kcXsiyvJa0Gj9Dg==","shasum":"54aacd51aeca445a3f63a449ed396dfe7b6d31ca","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-8.1.1-0bac80661d986c3a2799e0895507faafaf6eb896.tgz","fileCount":76,"unpackedSize":452742,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhCU/+CRA9TVsSAnZWagAAcloP/1ASfzjJCQqrarks7H/y\nuWanRmKh1k4Fv3vXwgIW8kQlLeQcKxOD4zjpMfFUfBh5pnrKNrrMD2hZ5GqI\nC7y8cCs4Ydv+hPMLdCbEHHJ5kJRcIyny5cUjSlw3yjhFYHEHDPeae1ZdhOkJ\n2tE9j7bY/qWKoD98diHuEtDYqhYqVdRCkVyUfYHH4+hLJon0G3fzlRANpP/U\nqcm7rOjyI8MzUMRppbgXue6MaBsWAyJ1G2A+ywh7QTHD1Jrajm8iC2MJqapy\nGjEBt86T8jZwDUgcbq9mAW9UGMtY5PrT74YShl7AZbcXHh7tuuWh54Nk/toy\niKeo8r2oPiQxu3XWIhlfTtIGQ2/2EFsTtrdnmL8xbg/A3wp2YMeY7R2QAuXv\neKcHfcmrrodrzQ4jVt52bbRrE+3uYPXjrysY00XSP6uOC2mukPvUth5zdrln\nZ3iBI0e4j+wlFKq6qJp5dSlQ5jLU8QeLC0jorCwXst/RQ6BPchsG6dLO0sxn\nUiFps4bJTCukEqzREK/YdEDh3ZKw1T9ctnK0gEXTy2D/rKpISZesoUKZ60OX\n71Dh3sI5JWPpYDJgt9ZUz6nmgY1KS7c7OLY/p+Y7Pzj0Go9o2krVwxpaXowc\nJUF74VlG7PNmPy5PVR4kFBbGE6QFRn4HTsRXDrbUOTwFYV3w2GXmIj7SCSSw\nMUGS\r\n=7aVQ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBCQJhlZs6He5oLJCKboIqAw7cOIHUOXTKpXhAxFaLlrAiBtAj1Oj87m2HgY01HkeY3dla6eG/X34+0yvK3O/pqUsw=="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_8.1.1-0bac80661d986c3a2799e0895507faafaf6eb896_1628000254069_0.4530686210851298"},"_hasShrinkwrap":false},"8.1.2":{"name":"@detachhead/ts-helpers","version":"8.1.2","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","@typescript-eslint/eslint-plugin":"4.13.0","@typescript-eslint/parser":"4.13.0","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","eslint-config-prettier":"7.1.0","eslint-plugin-eslint-comments":"3.2.0","eslint-plugin-expect-type":"0.0.5","eslint-plugin-prefer-arrow":"1.2.3","espower-typescript":"9.0.2","jest":"26.6.3","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","throw-expression":"1.0.2","ts-jest":"26.4.4","typed-nodejs-assert":"1.1.0","typescript":"4.4.0-dev.20210727"},"gitHead":"2aea84e5c170df04352a5cf7b187995b515325c9","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@8.1.2","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-qE6+CG3TYr3fy1+TDoh6sg9jLHkZG5qbvY/Osx/Qc9pSQd/Zl3fz2m/HuNtHYAvggrnf/v9bUbHcCLxVJaqLpw==","shasum":"0f47ca8f2cf5930787cecb4e34e78a607d2cf7aa","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-8.1.2.tgz","fileCount":76,"unpackedSize":452672,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhCVdTCRA9TVsSAnZWagAAc3MQAJ1+ezEoCglGgEcyx6TN\n4SSi0okglCJnxAUAzF4nBq11rFpEhre2Rne/B4zVWP5MsB70a097kTtEXRE4\nfTJJUAMa1xedit9Y7WTFhjUeJzm+fhrFanF7FsexwCtiZLlUiwsrgbCcR+O/\n8kutBjPozywwulYPcT/xB3C016TJ36R6Ie8kf5TCQxkelSB401ZdGgNBpUCE\nx3jIFXHycDoGg5grdhlfWtVE20q9ZwHeQIy+7Yx93Hj4GKy8wxmjxtmnc+hm\nr30csxfGW4Nj0RrSANa3RdGkiq+VkJcR9sfRtN5KwuQOUBZnRb2t6L/Ij0Z1\nwZZ4qAaOHqE+6lwrZxtPRaBdZIgQJD3zKhpVvskvVQoWwsy0yLz4Uv9i5qmR\nwlBKtX65GMgNjQdDjNe4vYNoQDeZQ7DtRf08f0Dv2upzFEb9q834qGCkXZ9s\nLjdVRRaN0pxHeCQT8BwTmETU245ixh9355EHqc6wPyLTBi0kuHsFnUhf+8i8\nyt8G0PzbW7QHckkdpsB1T1iY8aSm41r6+Q3ps7ASW0o/coSJzBB6NSCCdnlW\nzG1WaWoKKrR1AdliApomKXDx47xsAhMuOZsDYTbo6nBgZOjADhG0EdwdCS+0\ni35Rvu1WMLmuhMzRMdEYgDh4pStveozH5x3g18Wh2cRHuVsGuClf1x63IYIL\nvkTS\r\n=ju76\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCbAoEInlYaJ3x2uYa3WPr29b8dHcNy1bofF4QY8kp7zQIhAIkQ+dzqWUT+s3EIBLcnfJjE/85VDcSLlCimDA77+jvh"}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_8.1.2_1628002131179_0.9938794587995503"},"_hasShrinkwrap":false},"8.1.2-f7e8288fdce5a2d52e5f11a7c622265077378884":{"name":"@detachhead/ts-helpers","version":"8.1.2-f7e8288fdce5a2d52e5f11a7c622265077378884","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","@typescript-eslint/eslint-plugin":"4.13.0","@typescript-eslint/parser":"4.13.0","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","eslint-config-prettier":"7.1.0","eslint-plugin-eslint-comments":"3.2.0","eslint-plugin-expect-type":"0.0.5","eslint-plugin-prefer-arrow":"1.2.3","espower-typescript":"9.0.2","jest":"26.6.3","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","throw-expression":"1.0.2","ts-jest":"26.4.4","typed-nodejs-assert":"1.1.0","typescript":"4.4.0-dev.20210727"},"gitHead":"f7e8288fdce5a2d52e5f11a7c622265077378884","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@8.1.2-f7e8288fdce5a2d52e5f11a7c622265077378884","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-uDavZXVxYzBlbOGWmOIypw8z0WVOiepGPCcPl3hkK01yv0Ccww7y6KaZj051Tugx9PDhhqlj1lqVlsnR8zT2vw==","shasum":"6480fe06641d907689fbce84aefc0f6a9abc6f41","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-8.1.2-f7e8288fdce5a2d52e5f11a7c622265077378884.tgz","fileCount":77,"unpackedSize":454616,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhD+npCRA9TVsSAnZWagAAV8QP/0pzD6eJaeo8EdwynrM3\nw5cWpEK3NJyNXyw6727bHvLGftrWkFuzB8tZ18dHKV2MyjRepso/5ZlPCbd1\nRoQS7oxHEI9kmisXy7CPzMOLrGC9xzubR3R/OxYmmFWIffN62ErL9Nam9tIw\naRgyrfL6JRSamNNHXkNrNKv5EGWek6NN6WQ84jZi2kKE+xIqKOu+wg0v9REc\nmueHa6nym97w+3EQoBc84v0miyYM7fig42iVvEigBHJPuf/QMy5khwuxLzhj\nbrp1uKhco/fadlsSzzu3x5/9GMS4K1nqSZkr/JcioXaz7zXf8LGJYZ708YAd\nrX6XG1dCr6Jl+Jdq/cGhQeCsqjGqAXf5GWke6RaYMS11HIqKYIOQLQ73NYd3\naXh0Vkypfb0dfwFPnXTYvvP7uE0kEO1fHhrgX193p/i6ojjeiBbfXddfg6/B\nzGoZTpEYj5gZv/klkXAsPM8I9veS8XkLViGhJOHoEsfGSoN8d0oqu+NA7pgc\nLXEdk4VdFlT3Fo2GfKfQdOxaUm1DLbYIstvuyssoPlMPaZzfJr0UJF9gyHaF\nVhpaHqN50btHXWBSntqbyn+ysgMHLc2BzyygPhu96jLJbxcSrhRSmM0Hver5\nU0wSTHY2IaaLA382pp02s871iDzdAXkcuFsVLf9XGL4t/tM9ZoUtg5sBZRJy\nvokL\r\n=+TBB\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDgzXtpk5RQXVmbdILclKQFlpHYDET9JkzlwuZJmw6ZRAiBPvraqpvzvSzY6EUlugs4XouKpaNfqG9CdNl+RbXT5zA=="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_8.1.2-f7e8288fdce5a2d52e5f11a7c622265077378884_1628432872953_0.6801830585378541"},"_hasShrinkwrap":false},"8.1.2-899150a28560b19758de53a7173fad07b351eed1":{"name":"@detachhead/ts-helpers","version":"8.1.2-899150a28560b19758de53a7173fad07b351eed1","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","@typescript-eslint/eslint-plugin":"4.13.0","@typescript-eslint/parser":"4.13.0","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","eslint-config-prettier":"7.1.0","eslint-plugin-eslint-comments":"3.2.0","eslint-plugin-expect-type":"0.0.5","eslint-plugin-prefer-arrow":"1.2.3","espower-typescript":"9.0.2","jest":"26.6.3","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","throw-expression":"1.0.2","ts-jest":"26.4.4","typed-nodejs-assert":"1.1.0","typescript":"4.4.0-dev.20210727"},"gitHead":"899150a28560b19758de53a7173fad07b351eed1","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@8.1.2-899150a28560b19758de53a7173fad07b351eed1","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-N5+Ud54XqqB83J17haDm7k14NxBAZy+bx9dNCKiNezRNAYUDiqd/0I5vE44yTLDqU+XOH4MSPEBtw8GPmOcf0g==","shasum":"9892706243a4e03d5cc028ea2559bcae41f5e61e","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-8.1.2-899150a28560b19758de53a7173fad07b351eed1.tgz","fileCount":77,"unpackedSize":456840,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhLfspCRA9TVsSAnZWagAA7cIP/ieIBXG+ck3FVAjXQyNf\nlJqAu/uyUmElNTqwT5+3gg1PuDnaXiVG8Xxt1XCq72MV7sLMyWq0Nup8lVc8\n/I2ZFMUeWykzKSmQbI/BO415b27CWRV8/vJ/cgQl9G8ZgbPQenjXAlq67QQ7\nNsda6Tosk63kqrDA62SVxaNBROpLi5n1maAvDsp4jm6oaKN4mpkvpGWIoCwC\nexvzc8qmfQMUa+AlaFRxpf4PmA469iLEdO3ei7C2UDOpSKdAx067t2W1xlZb\nXqiO0ytK3pig/oitZRB4mnKRe/AQiXFxSF5uXSFwrudb4CQW/SGanKTPAI06\n+uEv0HLc/jD7k4A1L6u6mhuoawOf/9mlguirqpKcQf1eWLD6s+SiixRwjo7V\nNpqLZ5z29UIR8N2JBNz3C5axOiRmqfVQl/0ScqUYN8KeONXWpjUbtz5b+TXv\nIptoWThV7SnSsJiBbqO7Y1q13OVAQ/xuP0tXnnum7qPkdafvEsVGxJ8DC3cs\nO6xNU8uUl+urER2fVCwEax2XZMWaDM4tR4+Ccovni1LZhpV/WNNcdh2RUU77\n17GU1yqTo6LTUCM/PL54IE2iMVQZq0Ed886Dnn/KeMIQBcPowd22293+kem6\ns9eisIBvXaA8BaLDzacrliu8b3e1pr5cpg5OFuv6+kTJeZGBwMO7gcpnlHH2\nNf8t\r\n=0/rN\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCcxyEsos24UtZG7XiMV83TYMVl9AobEODCY6Pcc5cF0AIhAP6SMWrt+e0059QESqxkJuVQtuK7wkw0p8d2xFXXogSY"}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_8.1.2-899150a28560b19758de53a7173fad07b351eed1_1630403369239_0.9205751843418424"},"_hasShrinkwrap":false},"8.1.2-ea2cc954da9fd7c42347a575743e9b9f1058856e":{"name":"@detachhead/ts-helpers","version":"8.1.2-ea2cc954da9fd7c42347a575743e9b9f1058856e","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","@typescript-eslint/eslint-plugin":"4.13.0","@typescript-eslint/parser":"4.13.0","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","eslint-config-prettier":"7.1.0","eslint-plugin-eslint-comments":"3.2.0","eslint-plugin-expect-type":"0.0.5","eslint-plugin-prefer-arrow":"1.2.3","espower-typescript":"9.0.2","jest":"26.6.3","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","throw-expression":"1.0.2","ts-jest":"26.4.4","typed-nodejs-assert":"1.1.0","typescript":"4.4.0-dev.20210727"},"gitHead":"ea2cc954da9fd7c42347a575743e9b9f1058856e","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@8.1.2-ea2cc954da9fd7c42347a575743e9b9f1058856e","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-pGNkDU5/tlIT8VREnH7p5Gsdwc/tFknBpXxA5ZE1e+kPFwqGTD7kgsDtLuJm0/Xm/2jhE6lgZUt/gqdf1D9kkw==","shasum":"48d58facced3433638d2c2e404acee5052955c2b","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-8.1.2-ea2cc954da9fd7c42347a575743e9b9f1058856e.tgz","fileCount":77,"unpackedSize":459401,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIH/60tmeDInTdLgd2Iwr5tZkpch25Cdt8CtogaL+9QD+AiAZOAS4g6RXN4Lz10jmoF1fcaMZT8i7DGcfCt7Bo7JEKA=="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_8.1.2-ea2cc954da9fd7c42347a575743e9b9f1058856e_1632803505524_0.15578205621805052"},"_hasShrinkwrap":false},"8.1.2-f554824d42fc6d96d157f8a8f3d4fcd94761a337":{"name":"@detachhead/ts-helpers","version":"8.1.2-f554824d42fc6d96d157f8a8f3d4fcd94761a337","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","@typescript-eslint/eslint-plugin":"4.13.0","@typescript-eslint/parser":"4.13.0","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","eslint-config-prettier":"7.1.0","eslint-plugin-eslint-comments":"3.2.0","eslint-plugin-expect-type":"0.0.5","eslint-plugin-prefer-arrow":"1.2.3","espower-typescript":"9.0.2","jest":"26.6.3","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","throw-expression":"1.0.2","ts-jest":"26.4.4","typed-nodejs-assert":"1.1.0","typescript":"4.4.0-dev.20210727"},"gitHead":"f554824d42fc6d96d157f8a8f3d4fcd94761a337","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@8.1.2-f554824d42fc6d96d157f8a8f3d4fcd94761a337","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-TRGN/Tj1CYgmdnPD3k1JQyaIQY9Cis7e1lM4IcVFFqb8Tziw82thv3AtezljO+/M7NjzUzmny9EkbUb84MOBlQ==","shasum":"d22163e4622987c574689a880c66609a332d0bb5","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-8.1.2-f554824d42fc6d96d157f8a8f3d4fcd94761a337.tgz","fileCount":77,"unpackedSize":456840,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFg+7ptHfEHImWwAG70iFl2riY0bcOv/tmtV4s7L/t6mAiAGFQ6WY2q38E/TiHUZc/SSn0EbNZA42+lmL8DXnTzndA=="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_8.1.2-f554824d42fc6d96d157f8a8f3d4fcd94761a337_1632908752327_0.5628222992472087"},"_hasShrinkwrap":false},"8.1.2-ed4eeb021944556e05bec24ff3e8da42032a01ca":{"name":"@detachhead/ts-helpers","version":"8.1.2-ed4eeb021944556e05bec24ff3e8da42032a01ca","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","@typescript-eslint/eslint-plugin":"4.13.0","@typescript-eslint/parser":"4.13.0","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","eslint-config-prettier":"7.1.0","eslint-plugin-eslint-comments":"3.2.0","eslint-plugin-expect-type":"0.0.5","eslint-plugin-prefer-arrow":"1.2.3","espower-typescript":"9.0.2","jest":"26.6.3","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","throw-expression":"1.0.2","ts-jest":"26.4.4","typed-nodejs-assert":"1.1.0","typescript":"4.4.0-dev.20210727"},"gitHead":"ed4eeb021944556e05bec24ff3e8da42032a01ca","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@8.1.2-ed4eeb021944556e05bec24ff3e8da42032a01ca","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-aZwNAeXP7CK6+Rw4zwJKXlj2KvQCR3dGEbE5CgEs2NqFxAJ4ml6aEDnutkriFtQSPAqgkRH2ZFXFh5mgvFmYgA==","shasum":"3734c772e30daa8e237040b5f5ed85d167c52c49","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-8.1.2-ed4eeb021944556e05bec24ff3e8da42032a01ca.tgz","fileCount":77,"unpackedSize":458593,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAtvMgqu9LHDVA2rqEyxnZ7Yy3AMPeAk3wonaX5V8Y2gAiEAwetNfGbmEvtqIOz2lpEW5PwWCnlSR9MaA3qLJk2gtys="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_8.1.2-ed4eeb021944556e05bec24ff3e8da42032a01ca_1632909003987_0.4438960110171555"},"_hasShrinkwrap":false},"8.1.2-3bfe9bf6557cfad21438dc32db5f6df2fd59afe2":{"name":"@detachhead/ts-helpers","version":"8.1.2-3bfe9bf6557cfad21438dc32db5f6df2fd59afe2","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","@typescript-eslint/eslint-plugin":"4.13.0","@typescript-eslint/parser":"4.13.0","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","eslint-config-prettier":"7.1.0","eslint-plugin-eslint-comments":"3.2.0","eslint-plugin-expect-type":"0.0.5","eslint-plugin-import":"^2.24.2","eslint-plugin-prefer-arrow":"1.2.3","espower-typescript":"9.0.2","jest":"26.6.3","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"26.4.4","typed-nodejs-assert":"1.1.0","typescript":"4.4.0-dev.20210727"},"gitHead":"3bfe9bf6557cfad21438dc32db5f6df2fd59afe2","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@8.1.2-3bfe9bf6557cfad21438dc32db5f6df2fd59afe2","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-1J8yC4Meyv+OrqcCyKM/jHkeLimEujQcE0lLgUCkRCRsm3D6WV2loCa1DFcNhUVOZOtjuH15/gjrgpj/UvsXEQ==","shasum":"c01ffd7b5cc7e039ef0be2ae9e2ebda318e4229c","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-8.1.2-3bfe9bf6557cfad21438dc32db5f6df2fd59afe2.tgz","fileCount":77,"unpackedSize":461083,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHEPAcJhRjjNl0u6xFNlGeobXqHQTf9njIrQyYEbC+FKAiEAs0iQrSx7MPTHhkQ9ifbbVAnYYbTMxjTfsjteUbo6AcE="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_8.1.2-3bfe9bf6557cfad21438dc32db5f6df2fd59afe2_1632912254577_0.128367682032283"},"_hasShrinkwrap":false},"8.1.2-aff579af3ede45bda7fac3d0822d8d30a42654ce":{"name":"@detachhead/ts-helpers","version":"8.1.2-aff579af3ede45bda7fac3d0822d8d30a42654ce","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","@typescript-eslint/eslint-plugin":"4.13.0","@typescript-eslint/parser":"4.13.0","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","eslint-config-prettier":"7.1.0","eslint-plugin-eslint-comments":"3.2.0","eslint-plugin-expect-type":"0.0.5","eslint-plugin-import":"^2.24.2","eslint-plugin-prefer-arrow":"1.2.3","espower-typescript":"9.0.2","jest":"26.6.3","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"26.4.4","typed-nodejs-assert":"1.1.0","typescript":"4.4.0-dev.20210727"},"gitHead":"aff579af3ede45bda7fac3d0822d8d30a42654ce","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@8.1.2-aff579af3ede45bda7fac3d0822d8d30a42654ce","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-u0LDh+Yw5RTCv5NjLrkFRma9ShRMWXeTIkA4/lvWwxsThh6F6AZ/2fPmDKOPozrifebQGeaStml40sOnBT9Seg==","shasum":"451f961285bd89f162ecc5b9fcae1e53b312b0fe","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-8.1.2-aff579af3ede45bda7fac3d0822d8d30a42654ce.tgz","fileCount":77,"unpackedSize":466313,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCI1MVSZQABBT6vwI0wn6tTnFjgmAGLLt77nCiz9yO50AIgDHgY34Yq5NvOUs9m8VWGec+kuZ/ht2l+qm4onWNySAM="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_8.1.2-aff579af3ede45bda7fac3d0822d8d30a42654ce_1632966386647_0.5193571379915254"},"_hasShrinkwrap":false},"8.1.2-8dd5c95cbc509110a48e199f6dbb2c726c256d9a":{"name":"@detachhead/ts-helpers","version":"8.1.2-8dd5c95cbc509110a48e199f6dbb2c726c256d9a","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","@typescript-eslint/eslint-plugin":"4.13.0","@typescript-eslint/parser":"4.13.0","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","eslint-config-prettier":"7.1.0","eslint-plugin-eslint-comments":"3.2.0","eslint-plugin-expect-type":"0.0.5","eslint-plugin-import":"^2.24.2","eslint-plugin-prefer-arrow":"1.2.3","espower-typescript":"9.0.2","jest":"26.6.3","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"26.4.4","typed-nodejs-assert":"1.1.0","typescript":"4.4.0-dev.20210727"},"gitHead":"8dd5c95cbc509110a48e199f6dbb2c726c256d9a","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@8.1.2-8dd5c95cbc509110a48e199f6dbb2c726c256d9a","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-hneGfe9xFTGrxgWz+NTLDUCdCrbnE4OXMBM8MRrhYk/chXMnrTSlyubjA9JAKllwXlxFU+ueq7Ef5F1pWk3nJA==","shasum":"16b30e232eba89f45fbd58d3428d08cbda6cc5ca","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-8.1.2-8dd5c95cbc509110a48e199f6dbb2c726c256d9a.tgz","fileCount":77,"unpackedSize":464800,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC8S+9l1jplFEd2CUFToAwXx8gqBLcnSZMosCqgaYM88wIgLCRSSkzf0PdyND6if6u4xj47fOCRtRNEnpJyBLnObuk="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_8.1.2-8dd5c95cbc509110a48e199f6dbb2c726c256d9a_1632998055790_0.81839872144377"},"_hasShrinkwrap":false},"8.1.2-cb0871e586ffba387be818781f7bbd3150e08cf4":{"name":"@detachhead/ts-helpers","version":"8.1.2-cb0871e586ffba387be818781f7bbd3150e08cf4","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","@typescript-eslint/eslint-plugin":"4.13.0","@typescript-eslint/parser":"4.13.0","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","eslint-config-prettier":"7.1.0","eslint-plugin-eslint-comments":"3.2.0","eslint-plugin-expect-type":"0.0.5","eslint-plugin-import":"^2.24.2","eslint-plugin-prefer-arrow":"1.2.3","espower-typescript":"9.0.2","jest":"26.6.3","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"26.4.4","typed-nodejs-assert":"1.1.0","typescript":"4.4.0-dev.20210727"},"gitHead":"cb0871e586ffba387be818781f7bbd3150e08cf4","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@8.1.2-cb0871e586ffba387be818781f7bbd3150e08cf4","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-5tgGYJn9wIiOV3BY4b/FN1AS1gEBZOh2FtaWufl2MF3AQXVp7I+aIZ/ZKi0Bujntvz/9/Pihw3752j00ztP28w==","shasum":"1038c1c8a54d7b10df53f8b08a0d97f49eafd1be","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-8.1.2-cb0871e586ffba387be818781f7bbd3150e08cf4.tgz","fileCount":77,"unpackedSize":464979,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC/AaKGO1n394Ot+oAr6m4mA5l4FM50sCeTCKlUPfXoJwIhAM2kpECV41hsSbgt51C480lxNVDiWGTTwTXPA+zTIg2S"}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_8.1.2-cb0871e586ffba387be818781f7bbd3150e08cf4_1632998569258_0.25631156361524754"},"_hasShrinkwrap":false},"8.1.2-8d67c3a8038d76b7981fd6f6bd6b926c1c1b22c7":{"name":"@detachhead/ts-helpers","version":"8.1.2-8d67c3a8038d76b7981fd6f6bd6b926c1c1b22c7","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","@typescript-eslint/eslint-plugin":"4.13.0","@typescript-eslint/parser":"4.13.0","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","eslint-config-prettier":"7.1.0","eslint-plugin-eslint-comments":"3.2.0","eslint-plugin-expect-type":"0.0.5","eslint-plugin-import":"^2.24.2","eslint-plugin-prefer-arrow":"1.2.3","espower-typescript":"9.0.2","jest":"26.6.3","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"26.4.4","typed-nodejs-assert":"1.1.0","typescript":"4.4.0-dev.20210727"},"gitHead":"8d67c3a8038d76b7981fd6f6bd6b926c1c1b22c7","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@8.1.2-8d67c3a8038d76b7981fd6f6bd6b926c1c1b22c7","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-6uxv5UlGfvEfBrb+c7p4VBbj1u230e43/PmJItIaIK4JteAvlDCezdB/Em6hho+ykTjwTFdhE224UmBNuum8Dg==","shasum":"b3ae7fe1747d2ded6bf08520e5d9f3fa32e91b44","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-8.1.2-8d67c3a8038d76b7981fd6f6bd6b926c1c1b22c7.tgz","fileCount":77,"unpackedSize":464979,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCuW8Aoo2Ux2XX3XhJtcxFE6aCdatmKRg1kGS1V+EWvogIgD9DKvDV4+4uXQ0VdDYGhP49MV4CCa4rNda4jflktZN4="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_8.1.2-8d67c3a8038d76b7981fd6f6bd6b926c1c1b22c7_1632998746332_0.9526147060264851"},"_hasShrinkwrap":false},"8.2.0-f46604613b8263b1e1af8a490c46dfa11b935c37":{"name":"@detachhead/ts-helpers","version":"8.2.0-f46604613b8263b1e1af8a490c46dfa11b935c37","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","@typescript-eslint/eslint-plugin":"4.13.0","@typescript-eslint/parser":"4.13.0","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","eslint-config-prettier":"7.1.0","eslint-plugin-eslint-comments":"3.2.0","eslint-plugin-expect-type":"0.0.5","eslint-plugin-import":"^2.24.2","eslint-plugin-prefer-arrow":"1.2.3","espower-typescript":"9.0.2","jest":"26.6.3","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"26.4.4","typed-nodejs-assert":"1.1.0","typescript":"4.4.0-dev.20210727"},"gitHead":"f46604613b8263b1e1af8a490c46dfa11b935c37","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@8.2.0-f46604613b8263b1e1af8a490c46dfa11b935c37","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-tF8YWjJPZ45BAsj6JE+Jr6+j2PEFy3jeLg2B3XsVevii77tPH0ba0/+Omk2gHEvOg48fK5urfBG8eXNmD81gIw==","shasum":"bf09fa0499bf2e5d70ada78ce53f2844b8de2319","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-8.2.0-f46604613b8263b1e1af8a490c46dfa11b935c37.tgz","fileCount":77,"unpackedSize":464979,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDz0AZFBWNRr9appbvGBZfFjNRltvdMUJlyk+p05A+ocgIhALVHiHlgH9IBZ9InwKLh6TppMul3Ay0pZNrNEFOJA37/"}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_8.2.0-f46604613b8263b1e1af8a490c46dfa11b935c37_1632998901847_0.1139724355235785"},"_hasShrinkwrap":false},"8.2.0":{"name":"@detachhead/ts-helpers","version":"8.2.0","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","@typescript-eslint/eslint-plugin":"4.13.0","@typescript-eslint/parser":"4.13.0","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","eslint-config-prettier":"7.1.0","eslint-plugin-eslint-comments":"3.2.0","eslint-plugin-expect-type":"0.0.5","eslint-plugin-import":"^2.24.2","eslint-plugin-prefer-arrow":"1.2.3","espower-typescript":"9.0.2","jest":"26.6.3","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"26.4.4","typed-nodejs-assert":"1.1.0","typescript":"4.4.0-dev.20210727"},"gitHead":"4531c2a8198dc8f74dd8f30047ffa3df477c8950","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@8.2.0","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-7L0I070+Vu+sd6mV7b0GsSDgu+BTyrww2NJ2Ce0q1lX/FbAx3wDTbNDQngfUA4ZQvShRK7ct1vYZ7/ps0LFdkQ==","shasum":"37e877f486d0f2207641dbd68793ee7fca9dc3a6","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-8.2.0.tgz","fileCount":77,"unpackedSize":470168,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIH9rdkQX6GFU2r0SenMcg6uyH/htZFZXm6vDpoj39diOAiEAhKymzRXtBL2Oqvgf4E2HdorAZu1qCoOhlz1cfm81AfM="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_8.2.0_1632999067102_0.7283447128713749"},"_hasShrinkwrap":false},"8.2.0-eb282bb60205e4b29d53b30f347192afd5391056":{"name":"@detachhead/ts-helpers","version":"8.2.0-eb282bb60205e4b29d53b30f347192afd5391056","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","@typescript-eslint/eslint-plugin":"4.13.0","@typescript-eslint/parser":"4.13.0","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","eslint-config-prettier":"7.1.0","eslint-plugin-eslint-comments":"3.2.0","eslint-plugin-expect-type":"0.0.5","eslint-plugin-import":"^2.24.2","eslint-plugin-prefer-arrow":"1.2.3","espower-typescript":"9.0.2","jest":"26.6.3","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"26.4.4","typed-nodejs-assert":"1.1.0","typescript":"4.4.0-dev.20210727"},"gitHead":"eb282bb60205e4b29d53b30f347192afd5391056","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@8.2.0-eb282bb60205e4b29d53b30f347192afd5391056","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-7Zvj2L0CBBXYpINa0KjtNGvGsuo2+OctGA/Gj4Uk3OpW5F7I5G47Tro7UoY6HzQ1SWYQWbZWoszcYwSN1/jixA==","shasum":"5ac443e225f6dff4040cbe7c6f1beada04880994","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-8.2.0-eb282bb60205e4b29d53b30f347192afd5391056.tgz","fileCount":77,"unpackedSize":471873,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD2hGwVpgv+PD9plKMOH7CiP9X4fkB3i7oKmLj2/lg//wIgOehBsTYGRJY64E/d47EOAwKfSMiHf+vx9XZpii3vajY="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_8.2.0-eb282bb60205e4b29d53b30f347192afd5391056_1633057471791_0.34546495000581645"},"_hasShrinkwrap":false},"8.2.0-52d3faa3e233894cdaf00858e287a51c82f3fa3c":{"name":"@detachhead/ts-helpers","version":"8.2.0-52d3faa3e233894cdaf00858e287a51c82f3fa3c","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","@typescript-eslint/eslint-plugin":"4.13.0","@typescript-eslint/parser":"4.13.0","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","eslint-config-prettier":"7.1.0","eslint-plugin-eslint-comments":"3.2.0","eslint-plugin-expect-type":"0.0.5","eslint-plugin-import":"^2.24.2","eslint-plugin-prefer-arrow":"1.2.3","espower-typescript":"9.0.2","jest":"26.6.3","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"26.4.4","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-beta"},"gitHead":"52d3faa3e233894cdaf00858e287a51c82f3fa3c","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@8.2.0-52d3faa3e233894cdaf00858e287a51c82f3fa3c","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-B8UZQ8fNKqw4VVhR8qSWlMKcIoec996j8uoPvDJ+qNQWxmnY4bveasbtonoKK4EX3jZLlNW6cG7qrgQF2z3qqQ==","shasum":"4e9706ad1577f485cafa75b0b5adcce7995ee930","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-8.2.0-52d3faa3e233894cdaf00858e287a51c82f3fa3c.tgz","fileCount":77,"unpackedSize":479496,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFH5s3XKdbkccVc/6tByxSoAiMKG9jnHI4oQxjUz/t88AiAyhO2hl9aziXpIAbC6l7IAsAEkiEHfvTRyPgKuaZzBaQ=="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_8.2.0-52d3faa3e233894cdaf00858e287a51c82f3fa3c_1633337374597_0.3919011497524796"},"_hasShrinkwrap":false},"8.2.0-11b48ceb3d76a4b6c955ad327b9878ed241f2ba9":{"name":"@detachhead/ts-helpers","version":"8.2.0-11b48ceb3d76a4b6c955ad327b9878ed241f2ba9","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","@typescript-eslint/eslint-plugin":"4.13.0","@typescript-eslint/parser":"4.13.0","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","eslint-config-prettier":"7.1.0","eslint-plugin-eslint-comments":"3.2.0","eslint-plugin-expect-type":"0.0.5","eslint-plugin-import":"^2.24.2","eslint-plugin-prefer-arrow":"1.2.3","espower-typescript":"9.0.2","jest":"26.6.3","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"26.4.4","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-beta"},"gitHead":"11b48ceb3d76a4b6c955ad327b9878ed241f2ba9","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@8.2.0-11b48ceb3d76a4b6c955ad327b9878ed241f2ba9","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-aMhesPE137zLYabhkXAlqEi27d7vInLTj3SubcWgN6TFYWF/s91rzVYdCBuSrI2EJzgx4gh/P+vkN9w14xi0Zg==","shasum":"4246b3e59ce5570bd5abf519de7afb92f103a97b","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-8.2.0-11b48ceb3d76a4b6c955ad327b9878ed241f2ba9.tgz","fileCount":77,"unpackedSize":479411,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDGBV4ghQxUiRT7hbgI6mhYe8x0mA3QvcKQrn+Xofq0LgIgZf7P4j1MlH3LzmK+LGqdNnH9QfOcIR76tNLUQ5x5UE0="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_8.2.0-11b48ceb3d76a4b6c955ad327b9878ed241f2ba9_1633337629911_0.04897782699856146"},"_hasShrinkwrap":false},"8.2.0-59c1b79e4a893815e33d68ab21d1fd5dbaea8337":{"name":"@detachhead/ts-helpers","version":"8.2.0-59c1b79e4a893815e33d68ab21d1fd5dbaea8337","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","@typescript-eslint/eslint-plugin":"4.13.0","@typescript-eslint/parser":"4.13.0","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","eslint-config-prettier":"7.1.0","eslint-plugin-eslint-comments":"3.2.0","eslint-plugin-expect-type":"0.0.5","eslint-plugin-import":"^2.24.2","eslint-plugin-prefer-arrow":"1.2.3","espower-typescript":"9.0.2","jest":"26.6.3","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"26.4.4","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-beta"},"gitHead":"59c1b79e4a893815e33d68ab21d1fd5dbaea8337","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@8.2.0-59c1b79e4a893815e33d68ab21d1fd5dbaea8337","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-w7wyuqeIdBdRYdnWvkak1kgMX9W64W1BYd1ty2AlsyG4e5eZx3tCd3F10D85zKGyAs5w4I38PneM0GPNCDrGmg==","shasum":"5883b62c4f2d15e8e5293d2d2daaa990d5af05cf","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-8.2.0-59c1b79e4a893815e33d68ab21d1fd5dbaea8337.tgz","fileCount":77,"unpackedSize":479921,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICkkuxIRRokb1vzqfTxV06iRBrl2toyJVx6xpWkgPcwZAiBZXpFapkbPPcsBHgs+yUqTfHYcqWuBd5/f8oFgFOTjNA=="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_8.2.0-59c1b79e4a893815e33d68ab21d1fd5dbaea8337_1633338509015_0.272490148476239"},"_hasShrinkwrap":false},"8.2.0-7196c6856372587dd5c3a7fa47bb2ee06b38ee68":{"name":"@detachhead/ts-helpers","version":"8.2.0-7196c6856372587dd5c3a7fa47bb2ee06b38ee68","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","@typescript-eslint/eslint-plugin":"4.13.0","@typescript-eslint/parser":"4.13.0","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","eslint-config-prettier":"7.1.0","eslint-plugin-eslint-comments":"3.2.0","eslint-plugin-expect-type":"0.0.5","eslint-plugin-import":"^2.24.2","eslint-plugin-prefer-arrow":"1.2.3","espower-typescript":"9.0.2","jest":"26.6.3","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"26.4.4","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-beta"},"gitHead":"7196c6856372587dd5c3a7fa47bb2ee06b38ee68","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@8.2.0-7196c6856372587dd5c3a7fa47bb2ee06b38ee68","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-U0OiiYtoW5bvzPK0g6FU/cjeq0tWXxyl+wBmndNMc4yiwaRyHC5pVFFxKywbVEsfPsBXprAtv7uHQBHXWXJjTA==","shasum":"447ad20188474c96c1a7ae9ce12cb2e43639bf74","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-8.2.0-7196c6856372587dd5c3a7fa47bb2ee06b38ee68.tgz","fileCount":77,"unpackedSize":480555,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDEQoVdWHLAq4ikJxuet0Y70k3UPHzBGugVZvh5DdTEkAiEAjAoYG8yOmRBAs+0/UFPzRtR0VZDXiHqODohxsFVCJ00="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_8.2.0-7196c6856372587dd5c3a7fa47bb2ee06b38ee68_1633354401440_0.4758354914615206"},"_hasShrinkwrap":false},"8.2.0-55c37563b1e93119efced6851248a8b9090d2443":{"name":"@detachhead/ts-helpers","version":"8.2.0-55c37563b1e93119efced6851248a8b9090d2443","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","@typescript-eslint/eslint-plugin":"4.13.0","@typescript-eslint/parser":"4.13.0","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","eslint-config-prettier":"7.1.0","eslint-plugin-eslint-comments":"3.2.0","eslint-plugin-expect-type":"0.0.5","eslint-plugin-import":"^2.24.2","eslint-plugin-prefer-arrow":"1.2.3","espower-typescript":"9.0.2","jest":"26.6.3","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"26.4.4","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-beta"},"gitHead":"55c37563b1e93119efced6851248a8b9090d2443","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@8.2.0-55c37563b1e93119efced6851248a8b9090d2443","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-g4ak2lcwV4Ja+3fKphXeiRT/1YM9aiMJc3JwVskgEnnvas19MDGy+IH2HNjnX/ihQZadenRwIgO1Gwf6GQQDIw==","shasum":"e98b9525aeb937bd22516459b92fd0f4acbc211d","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-8.2.0-55c37563b1e93119efced6851248a8b9090d2443.tgz","fileCount":77,"unpackedSize":480672,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCyK6hx0I+erDmMrQ4ew8J20lmbo3iqOUqMRwRktpZ4jgIhAPKkLvC3slFPQBiImEqNrY0Z8U7CZMG2ALCK8E7Yg2xK"}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_8.2.0-55c37563b1e93119efced6851248a8b9090d2443_1633360109931_0.7070382131157686"},"_hasShrinkwrap":false},"8.2.0-6a10da8d339e902596396e52e2fb7f0071b82f16":{"name":"@detachhead/ts-helpers","version":"8.2.0-6a10da8d339e902596396e52e2fb7f0071b82f16","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","@typescript-eslint/eslint-plugin":"4.13.0","@typescript-eslint/parser":"4.13.0","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","eslint-config-prettier":"7.1.0","eslint-plugin-eslint-comments":"3.2.0","eslint-plugin-expect-type":"0.0.5","eslint-plugin-import":"^2.24.2","eslint-plugin-prefer-arrow":"1.2.3","espower-typescript":"9.0.2","jest":"26.6.3","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"26.4.4","typed-nodejs-assert":"1.1.0","typescript":"4.4.0-dev.20210727"},"gitHead":"6a10da8d339e902596396e52e2fb7f0071b82f16","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@8.2.0-6a10da8d339e902596396e52e2fb7f0071b82f16","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-Ku2zNp07FGi12ESiNyiF2Mocrkf5Fqbh7oqCLMYUVPOeGFKmn+XhxsYusc1XlM79vL9dRxFu4J4/K2Hn98lc7w==","shasum":"a0372074987be77de93adff75f38a941f1fb4063","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-8.2.0-6a10da8d339e902596396e52e2fb7f0071b82f16.tgz","fileCount":77,"unpackedSize":475391,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCWAAfGOBplQE0UQF9JSZ4uB54ZYEBBF4aP+dwF0g8i7wIhAN0pL2ymej6LQUzRnLjEWh9oooArd+0LVso3oWRREWoK"}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_8.2.0-6a10da8d339e902596396e52e2fb7f0071b82f16_1633873214871_0.8193049631908309"},"_hasShrinkwrap":false},"8.2.0-55c4a8f39c9a92fdc325b20cf52858019b418173":{"name":"@detachhead/ts-helpers","version":"8.2.0-55c4a8f39c9a92fdc325b20cf52858019b418173","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","@typescript-eslint/eslint-plugin":"4.13.0","@typescript-eslint/parser":"4.13.0","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","eslint-config-prettier":"7.1.0","eslint-plugin-eslint-comments":"3.2.0","eslint-plugin-expect-type":"0.0.5","eslint-plugin-import":"^2.24.2","eslint-plugin-prefer-arrow":"1.2.3","espower-typescript":"9.0.2","jest":"26.6.3","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"26.4.4","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-beta"},"gitHead":"55c4a8f39c9a92fdc325b20cf52858019b418173","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@8.2.0-55c4a8f39c9a92fdc325b20cf52858019b418173","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-7FW67tOJTd10cktyvkemjdEdDI1TknYGmFt3xQ3bTNsWzsTNqwkgxn7tnvEqufKUKr66WOMqLSymoDJA/xLaIw==","shasum":"b588d6ca926ba47d4b13307dfe4e9284ed45c59d","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-8.2.0-55c4a8f39c9a92fdc325b20cf52858019b418173.tgz","fileCount":77,"unpackedSize":477569,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCGeaNZAp3g863Xu3XrKVs7dOY7jP8fqap1zEEjsy6blgIhANFB02V5fTAeQ61uiPEXaSUgl0OCfCn7tdQLbBlxccyg"}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_8.2.0-55c4a8f39c9a92fdc325b20cf52858019b418173_1633878366959_0.1659875331226337"},"_hasShrinkwrap":false},"8.2.0-d8ebcd4f9782b60ca9fbd935b711a8ce67e3d7fa":{"name":"@detachhead/ts-helpers","version":"8.2.0-d8ebcd4f9782b60ca9fbd935b711a8ce67e3d7fa","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","@typescript-eslint/eslint-plugin":"4.13.0","@typescript-eslint/parser":"4.13.0","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","eslint-config-prettier":"7.1.0","eslint-plugin-eslint-comments":"3.2.0","eslint-plugin-expect-type":"0.0.5","eslint-plugin-import":"^2.24.2","eslint-plugin-prefer-arrow":"1.2.3","espower-typescript":"9.0.2","jest":"26.6.3","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"26.4.4","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-beta"},"gitHead":"d8ebcd4f9782b60ca9fbd935b711a8ce67e3d7fa","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@8.2.0-d8ebcd4f9782b60ca9fbd935b711a8ce67e3d7fa","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-XqzDXkhqn0X1xZZ7edjJpmNv2QK2wz9S8HDAC9pLkSPdhMLWIVN41xuA2dMabY/AgokON+ZGeTuHF+fgA7g0Ow==","shasum":"f6085b70f5cd9586f93cb09b54167da5460ba5bb","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-8.2.0-d8ebcd4f9782b60ca9fbd935b711a8ce67e3d7fa.tgz","fileCount":77,"unpackedSize":477827,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHhLomWfWByqY8Iy3okxRboBdCxKD1Uf7sf7Gpe1tpXhAiEAxA7Gsx+Ak5CwYc/8BNEWNA2gcH9HBKaNCM58jlIPZ6o="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_8.2.0-d8ebcd4f9782b60ca9fbd935b711a8ce67e3d7fa_1633904476322_0.1484701300738862"},"_hasShrinkwrap":false},"8.2.0-2338189488360f923a401bc06db26626e0b8607e":{"name":"@detachhead/ts-helpers","version":"8.2.0-2338189488360f923a401bc06db26626e0b8607e","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","@typescript-eslint/eslint-plugin":"4.13.0","@typescript-eslint/parser":"4.13.0","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","eslint-config-prettier":"7.1.0","eslint-plugin-eslint-comments":"3.2.0","eslint-plugin-expect-type":"0.0.5","eslint-plugin-import":"^2.24.2","eslint-plugin-prefer-arrow":"1.2.3","espower-typescript":"9.0.2","jest":"26.6.3","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"26.4.4","typed-nodejs-assert":"1.1.0","typescript":"4.4.0-dev.20210727"},"gitHead":"2338189488360f923a401bc06db26626e0b8607e","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@8.2.0-2338189488360f923a401bc06db26626e0b8607e","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-UtKzLsDb0XeXZ+/p9Cfxme+PviYK55jrA2DMkVxDuhSz4I6XTlHtFFHADdoDJt2sj8guoh3dNnSUXRNM6WUfRQ==","shasum":"8988c3149480760377b88268415921f265ef125d","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-8.2.0-2338189488360f923a401bc06db26626e0b8607e.tgz","fileCount":77,"unpackedSize":482653,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCvPQwDVGGTkTeVbyiuTd38kR5/61oNb0f2mjLQ5GIWMwIgMzZJon6FYqw/i0UO3GhZqx/77lbhddiZmnHohgnl6JM="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_8.2.0-2338189488360f923a401bc06db26626e0b8607e_1633924556169_0.22851896214885659"},"_hasShrinkwrap":false},"8.2.0-21a2079c5fa694b9782f33d9fa7b7c3e1880ce49":{"name":"@detachhead/ts-helpers","version":"8.2.0-21a2079c5fa694b9782f33d9fa7b7c3e1880ce49","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","@typescript-eslint/eslint-plugin":"4.13.0","@typescript-eslint/parser":"4.13.0","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","eslint-config-prettier":"7.1.0","eslint-plugin-eslint-comments":"3.2.0","eslint-plugin-expect-type":"0.0.5","eslint-plugin-import":"^2.24.2","eslint-plugin-prefer-arrow":"1.2.3","espower-typescript":"9.0.2","jest":"26.6.3","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"26.4.4","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-beta"},"gitHead":"21a2079c5fa694b9782f33d9fa7b7c3e1880ce49","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@8.2.0-21a2079c5fa694b9782f33d9fa7b7c3e1880ce49","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-gtoKl4/umuRTkNvc5tZFZeyarU0ujug/xyG2mFn9arqO4ZxYPjcl2vU4uoNevWuMMxCT0q4rsDO2AZ9sndyXzw==","shasum":"c9a52268f9a10c185b3e2f4abf03a20228f42202","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-8.2.0-21a2079c5fa694b9782f33d9fa7b7c3e1880ce49.tgz","fileCount":77,"unpackedSize":474460,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDSFp+vK3Kf+EqVJ3DytAjK6buGHqghBWkvaOxA6VvkkwIhAOQ2GjTJWBOMM6M553QMUH4BukG8s7hjRHdHV+rX7x+5"}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_8.2.0-21a2079c5fa694b9782f33d9fa7b7c3e1880ce49_1633959577381_0.8119239938562144"},"_hasShrinkwrap":false},"8.2.0-11609dadca6957eaea883f6c54b52733357731e7":{"name":"@detachhead/ts-helpers","version":"8.2.0-11609dadca6957eaea883f6c54b52733357731e7","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","@typescript-eslint/eslint-plugin":"4.13.0","@typescript-eslint/parser":"4.13.0","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","eslint-config-prettier":"7.1.0","eslint-plugin-eslint-comments":"3.2.0","eslint-plugin-expect-type":"0.0.5","eslint-plugin-import":"^2.24.2","eslint-plugin-prefer-arrow":"1.2.3","espower-typescript":"9.0.2","jest":"26.6.3","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"26.4.4","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-beta"},"gitHead":"11609dadca6957eaea883f6c54b52733357731e7","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@8.2.0-11609dadca6957eaea883f6c54b52733357731e7","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-UU7znVmyNDgOvB11UctEfbWD7WwWjRBB+Q94K+RmvfGtIzk1M5a8D4DFEtZslx9nnnc2y/EB56ug16RlHb+mmg==","shasum":"fc6c83416bba3a111d23d269c5e57f0a30546b63","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-8.2.0-11609dadca6957eaea883f6c54b52733357731e7.tgz","fileCount":77,"unpackedSize":474698,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCjuXk0F4QvI6li4JX+uif9b4yT0CGGgDnOsYUA9C+HBwIhAOXQ16gOgBwdGra8YhSm5FRYArE0ECUthJFwuV1qakcx"}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_8.2.0-11609dadca6957eaea883f6c54b52733357731e7_1633960007159_0.03628646872760366"},"_hasShrinkwrap":false},"8.2.0-09fe190ff602d48aa3876acbec40bae12b7799fe":{"name":"@detachhead/ts-helpers","version":"8.2.0-09fe190ff602d48aa3876acbec40bae12b7799fe","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","@typescript-eslint/eslint-plugin":"4.13.0","@typescript-eslint/parser":"4.13.0","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","eslint-config-prettier":"7.1.0","eslint-plugin-eslint-comments":"3.2.0","eslint-plugin-expect-type":"0.0.5","eslint-plugin-import":"^2.24.2","eslint-plugin-prefer-arrow":"1.2.3","espower-typescript":"9.0.2","jest":"26.6.3","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"26.4.4","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-beta"},"gitHead":"09fe190ff602d48aa3876acbec40bae12b7799fe","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@8.2.0-09fe190ff602d48aa3876acbec40bae12b7799fe","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-7FKeO88ZdYbC6rD/9nsFYCYPav0RGjwc2GIElqNPCej0CuCYoGnCyz3jP2/S098x4znvwrNT3ysUO4Z1aUB9iQ==","shasum":"669a73e6939c7c5193207ca880cbdf0bcd1c4c85","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-8.2.0-09fe190ff602d48aa3876acbec40bae12b7799fe.tgz","fileCount":77,"unpackedSize":475385,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCQ0trvAe8INegZs5K+qLGrTMlt8QmYsqayHPo6QzQGYAIhAIPYlC99ib1pTGu3QJaC4dN4Opqbtc03rZitN3bIZvaE"}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_8.2.0-09fe190ff602d48aa3876acbec40bae12b7799fe_1633962483966_0.18488486902391532"},"_hasShrinkwrap":false},"8.2.0-146ccc3eac581bc83bb5af99a3bb28a353116144":{"name":"@detachhead/ts-helpers","version":"8.2.0-146ccc3eac581bc83bb5af99a3bb28a353116144","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","@typescript-eslint/eslint-plugin":"4.13.0","@typescript-eslint/parser":"4.13.0","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","eslint-config-prettier":"7.1.0","eslint-plugin-eslint-comments":"3.2.0","eslint-plugin-expect-type":"0.0.5","eslint-plugin-import":"^2.24.2","eslint-plugin-prefer-arrow":"1.2.3","espower-typescript":"9.0.2","jest":"26.6.3","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"26.4.4","typed-nodejs-assert":"1.1.0","typescript":"4.4.0-dev.20210727"},"gitHead":"146ccc3eac581bc83bb5af99a3bb28a353116144","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@8.2.0-146ccc3eac581bc83bb5af99a3bb28a353116144","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-MrqXaz911sAAljDBKH7viSt7wzLFlKj+3EavPWBBDhxBRlCkBoUvdnp4SnsPqlOZd30UlpcQpPnIasXrb6HGMA==","shasum":"eb1b2f59d88ecdecb17c291cbee1f46868e45848","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-8.2.0-146ccc3eac581bc83bb5af99a3bb28a353116144.tgz","fileCount":77,"unpackedSize":482553,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIA3rts9iRq6+Aj1OTkaLnXzoceJZirPZAnb5OaX3eFlYAiAC9PulHkiGjs0f0UqQtc3E40VS72vpXlP3bhNbe1h+/A=="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_8.2.0-146ccc3eac581bc83bb5af99a3bb28a353116144_1634018983857_0.7935027436192557"},"_hasShrinkwrap":false},"8.2.0-4f0d52eefc438907e945059f0c3294ede493c034":{"name":"@detachhead/ts-helpers","version":"8.2.0-4f0d52eefc438907e945059f0c3294ede493c034","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","@typescript-eslint/eslint-plugin":"4.13.0","@typescript-eslint/parser":"4.13.0","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","eslint-config-prettier":"7.1.0","eslint-plugin-eslint-comments":"3.2.0","eslint-plugin-expect-type":"0.0.5","eslint-plugin-import":"^2.24.2","eslint-plugin-prefer-arrow":"1.2.3","espower-typescript":"9.0.2","jest":"26.6.3","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"26.4.4","typed-nodejs-assert":"1.1.0","typescript":"4.4.0-dev.20210727"},"gitHead":"4f0d52eefc438907e945059f0c3294ede493c034","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@8.2.0-4f0d52eefc438907e945059f0c3294ede493c034","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-UvbzPl/KX3z4/lGbpPuqas/5gNuQnLMSdTeVMKIEgZKbGHfoZdN/t95cSCApr5xMG8D1cWyEwkM0lZ0spgXBiw==","shasum":"4f7a4a5721b7aded729f123bb7d26cc437d686c8","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-8.2.0-4f0d52eefc438907e945059f0c3294ede493c034.tgz","fileCount":77,"unpackedSize":489815,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCL3p1dDdRsfDHVApcahY3UucWTsNrr1zLMjIem2QzPCgIhAOmeKmTR0l2e7M/3QCCu3Sb1q8EJIjbqxJ2LYMVLdW5h"}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_8.2.0-4f0d52eefc438907e945059f0c3294ede493c034_1634019159131_0.2999860206662035"},"_hasShrinkwrap":false},"8.2.0-4eb4d3571408fc46f754ecf3383fb03e6062d235":{"name":"@detachhead/ts-helpers","version":"8.2.0-4eb4d3571408fc46f754ecf3383fb03e6062d235","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","@typescript-eslint/eslint-plugin":"4.13.0","@typescript-eslint/parser":"4.13.0","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","eslint-config-prettier":"7.1.0","eslint-plugin-eslint-comments":"3.2.0","eslint-plugin-expect-type":"0.0.5","eslint-plugin-import":"^2.24.2","eslint-plugin-prefer-arrow":"1.2.3","espower-typescript":"9.0.2","jest":"26.6.3","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"26.4.4","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-beta"},"gitHead":"4eb4d3571408fc46f754ecf3383fb03e6062d235","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@8.2.0-4eb4d3571408fc46f754ecf3383fb03e6062d235","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-gCeE9b1xbsgm1R4Ix7RWId4mKmFOjTaBQKQVMfcyWInV+M1mvXJaVprz109K6r6LjRg8xmMaN+5ICZ2DoI9Rvw==","shasum":"6d8d924b21cce628732c28446bbf502cc35d04ee","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-8.2.0-4eb4d3571408fc46f754ecf3383fb03e6062d235.tgz","fileCount":77,"unpackedSize":484205,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIF9jMgDVmYz5Axwubt5tgyGFwX4PLP+UDdOGaAjAEkRpAiA7J2h09LCDe8D+VHWM8uYpBnD5wYT0Y2e7j66NLjUMtw=="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_8.2.0-4eb4d3571408fc46f754ecf3383fb03e6062d235_1634049992670_0.6058694569342662"},"_hasShrinkwrap":false},"8.2.0-fde9f2eede1001a9ebcc6f41364296d59872b2ea":{"name":"@detachhead/ts-helpers","version":"8.2.0-fde9f2eede1001a9ebcc6f41364296d59872b2ea","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","@typescript-eslint/eslint-plugin":"4.13.0","@typescript-eslint/parser":"4.13.0","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","eslint-config-prettier":"7.1.0","eslint-plugin-eslint-comments":"3.2.0","eslint-plugin-expect-type":"0.0.5","eslint-plugin-import":"^2.24.2","eslint-plugin-prefer-arrow":"1.2.3","espower-typescript":"9.0.2","jest":"26.6.3","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"26.4.4","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-beta"},"gitHead":"fde9f2eede1001a9ebcc6f41364296d59872b2ea","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@8.2.0-fde9f2eede1001a9ebcc6f41364296d59872b2ea","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-0mUREXksAJTHrnv2no36T5zU5Xl9iANb1oYM3+RvrekgOPz2gT+/KnWyiOO4xGuhNtW5XAph+GOvmhYbGJimYQ==","shasum":"21ea8e0dadfece8b163d83d9cdbe43a4e470ed81","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-8.2.0-fde9f2eede1001a9ebcc6f41364296d59872b2ea.tgz","fileCount":77,"unpackedSize":334436,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCLjDx6ZTTYGnjHx3TiUQC0/i+4G/ZyRoFmnRN8a/lu5gIgfODYpallqOlNcyU5EeER4PDfckBhRDABD2mvxHpaWHs="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_8.2.0-fde9f2eede1001a9ebcc6f41364296d59872b2ea_1634054013162_0.0013793204661067815"},"_hasShrinkwrap":false},"9.0.0-9b4a478c3a63affa1f7f29aeabc2e5f76583ddfc":{"name":"@detachhead/ts-helpers","version":"9.0.0-9b4a478c3a63affa1f7f29aeabc2e5f76583ddfc","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","@typescript-eslint/eslint-plugin":"4.13.0","@typescript-eslint/parser":"4.13.0","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","eslint-config-prettier":"7.1.0","eslint-plugin-eslint-comments":"3.2.0","eslint-plugin-expect-type":"0.0.5","eslint-plugin-import":"^2.24.2","eslint-plugin-prefer-arrow":"1.2.3","espower-typescript":"9.0.2","jest":"26.6.3","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"26.4.4","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-beta"},"gitHead":"9b4a478c3a63affa1f7f29aeabc2e5f76583ddfc","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript 4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### supported js runtimes\n\n-   [x] nodejs\n-   [x] browser\n-   [ ] deno (https://github.com/DetachHead/ts-helpers/issues/97)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@9.0.0-9b4a478c3a63affa1f7f29aeabc2e5f76583ddfc","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-/6SP4qSxRBnEi7XrJUb4s6Uwa5/QqG9wtCjsA40kCETv72S0Q9QY4aR7mc6MKxeRUhVfKrp8yKdDrBVLM/CMPw==","shasum":"f20daf1f603f393a99f8ffbdd5907697b965580b","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-9.0.0-9b4a478c3a63affa1f7f29aeabc2e5f76583ddfc.tgz","fileCount":77,"unpackedSize":341988,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCID2kTUBj5P+gdv/r5TgIcT64Kn9UP1jXWgHh3EU9BddzAiAYgQHw4beThsqn4GKbbPJUtR/LSIJ0vI/KqbXseCMcqA=="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_9.0.0-9b4a478c3a63affa1f7f29aeabc2e5f76583ddfc_1634055221096_0.556820293137376"},"_hasShrinkwrap":false},"9.0.0-98e7f1fb467ec3c8704a197482b3548cf96e88a6":{"name":"@detachhead/ts-helpers","version":"9.0.0-98e7f1fb467ec3c8704a197482b3548cf96e88a6","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","@typescript-eslint/eslint-plugin":"4.13.0","@typescript-eslint/parser":"4.13.0","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","eslint-config-prettier":"7.1.0","eslint-plugin-eslint-comments":"3.2.0","eslint-plugin-expect-type":"0.0.5","eslint-plugin-import":"^2.24.2","eslint-plugin-prefer-arrow":"1.2.3","espower-typescript":"9.0.2","jest":"26.6.3","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"26.4.4","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-beta"},"gitHead":"98e7f1fb467ec3c8704a197482b3548cf96e88a6","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript 4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### supported js runtimes\n\n-   [x] nodejs\n-   [x] browser\n-   [x] deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@9.0.0-98e7f1fb467ec3c8704a197482b3548cf96e88a6","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-sZq0PybvKjj0J0jW6VQy1hhfvOXRuUlZB8J18sh9OtdLd0s3x7pEKQRANNASF6ureRtKKyDnSqj2uXQUYqK7gQ==","shasum":"c9cc44ba19751fdb5f8314ef3b13c1641ff48a17","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-9.0.0-98e7f1fb467ec3c8704a197482b3548cf96e88a6.tgz","fileCount":77,"unpackedSize":342048,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDdCxkYBI5l7v5xrVubm+WMOUXY+yTv0n+VOPYOMDfWCgIhAJve01X4a4Yhs9zDBzinIwIbKV8/P5XNqGrWy4IHMYNr"}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_9.0.0-98e7f1fb467ec3c8704a197482b3548cf96e88a6_1634078673716_0.9552677107023915"},"_hasShrinkwrap":false},"9.0.0":{"name":"@detachhead/ts-helpers","version":"9.0.0","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","@typescript-eslint/eslint-plugin":"4.13.0","@typescript-eslint/parser":"4.13.0","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","eslint-config-prettier":"7.1.0","eslint-plugin-eslint-comments":"3.2.0","eslint-plugin-expect-type":"0.0.5","eslint-plugin-import":"^2.24.2","eslint-plugin-prefer-arrow":"1.2.3","espower-typescript":"9.0.2","jest":"26.6.3","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"26.4.4","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-beta"},"gitHead":"1af80f7938d6f840ad8486d25b57a8a919f8a0a9","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@9.0.0","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-kmerPDgpQHzPQaD88ybTfBfJPlkjghqpTO765WtOSbauiMJSGzGmiyUSrM3dimx4XU44FGpeBDJLa6frWQWPvA==","shasum":"aa658d54fc4e43ba50f10dcc02493577235579fc","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-9.0.0.tgz","fileCount":77,"unpackedSize":342007,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDSNckKJwnYLucD3sth7bUZGrRYg46pCDTu0M0hjMjjJQIhAJfDxy/J4Y34PX7KWolfwdNjePYl54f3gMIF0b+2QqWU"}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_9.0.0_1634092130292_0.5633248238896054"},"_hasShrinkwrap":false},"9.0.0-23ada89220af6ee65456fa5dd9b8ac5ec8b1ae53":{"name":"@detachhead/ts-helpers","version":"9.0.0-23ada89220af6ee65456fa5dd9b8ac5ec8b1ae53","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","@typescript-eslint/eslint-plugin":"4.13.0","@typescript-eslint/parser":"4.13.0","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","eslint-config-prettier":"7.1.0","eslint-plugin-eslint-comments":"3.2.0","eslint-plugin-expect-type":"0.0.5","eslint-plugin-import":"^2.24.2","eslint-plugin-prefer-arrow":"1.2.3","espower-typescript":"9.0.2","jest":"26.6.3","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"26.4.4","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-beta"},"gitHead":"23ada89220af6ee65456fa5dd9b8ac5ec8b1ae53","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript 4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### supported js runtimes\n\n-   [x] nodejs\n-   [x] browser\n-   [x] deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@9.0.0-23ada89220af6ee65456fa5dd9b8ac5ec8b1ae53","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-l4uZby/chA1DrNP/3AMDW35Hu/hrBAysG0Si3reDzAYcipgjEl2rGdjgy24/HQ/ZDTI0YXrr8QShun3bAIy9sQ==","shasum":"7cef71dc81e13401c8421f2548fbd76c53ba319d","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-9.0.0-23ada89220af6ee65456fa5dd9b8ac5ec8b1ae53.tgz","fileCount":77,"unpackedSize":342216,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBiU5itC8yWVAfuF/SxPS4DNHvJfEGM328qJvettxvVxAiAZu4R1FWbb2M9YNnBY76GHtl89I1ERXfAnOYSMmgkTOQ=="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_9.0.0-23ada89220af6ee65456fa5dd9b8ac5ec8b1ae53_1634113737195_0.3838431967406568"},"_hasShrinkwrap":false},"9.0.0-fcd3c5481300abf5038f675ae092b8f641f0f52b":{"name":"@detachhead/ts-helpers","version":"9.0.0-fcd3c5481300abf5038f675ae092b8f641f0f52b","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","@typescript-eslint/eslint-plugin":"4.13.0","@typescript-eslint/parser":"4.13.0","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","eslint-config-prettier":"7.1.0","eslint-plugin-eslint-comments":"3.2.0","eslint-plugin-expect-type":"0.0.5","eslint-plugin-import":"^2.24.2","eslint-plugin-prefer-arrow":"1.2.3","espower-typescript":"9.0.2","jest":"26.6.3","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"26.4.4","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-beta"},"gitHead":"fcd3c5481300abf5038f675ae092b8f641f0f52b","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript 4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### supported js runtimes\n\n-   [x] nodejs\n-   [x] browser\n-   [x] deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@9.0.0-fcd3c5481300abf5038f675ae092b8f641f0f52b","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-Wvo7qubXbEbZnxJJS57PfGAdpro1IhBhXaWqwIjwjo4UfvtCWZvm7cnCl6iPzUdciP/e8ixpkry7bQaeRuX8Ig==","shasum":"0a92d6c558c0348437f175ecf990ad05e47e1509","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-9.0.0-fcd3c5481300abf5038f675ae092b8f641f0f52b.tgz","fileCount":77,"unpackedSize":342232,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDKMEPGl8yqJ1isT+iTIDgwvSlNahhw8yHpG/4jhr03PgIgUfLlN27MJDwFYIAaW7y/9FwkTRUjazI6rVSdJHUc+Uo="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_9.0.0-fcd3c5481300abf5038f675ae092b8f641f0f52b_1634114042514_0.4204849312121268"},"_hasShrinkwrap":false},"9.0.0-8b2927ca0f4c1d3ce92022dd7bfb67ee006f4fe4":{"name":"@detachhead/ts-helpers","version":"9.0.0-8b2927ca0f4c1d3ce92022dd7bfb67ee006f4fe4","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","@typescript-eslint/eslint-plugin":"4.13.0","@typescript-eslint/parser":"4.13.0","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","eslint-config-prettier":"7.1.0","eslint-plugin-eslint-comments":"3.2.0","eslint-plugin-expect-type":"0.0.5","eslint-plugin-import":"^2.24.2","eslint-plugin-prefer-arrow":"1.2.3","espower-typescript":"9.0.2","jest":"26.6.3","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"26.4.4","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-beta"},"gitHead":"8b2927ca0f4c1d3ce92022dd7bfb67ee006f4fe4","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript 4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### supported js runtimes\n\n-   [x] nodejs\n-   [x] browser\n-   [x] deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@9.0.0-8b2927ca0f4c1d3ce92022dd7bfb67ee006f4fe4","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-WfpysD21LlVflxs63ovp0gNLNq/hSTdMBKJg5KmZjH0Ktj7afLr2wrRxr5ZvWCdlbkAeymDL5wPdmAmbI3bbBw==","shasum":"541966be923e1cde13eecc1fe6c11ebd3e4be902","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-9.0.0-8b2927ca0f4c1d3ce92022dd7bfb67ee006f4fe4.tgz","fileCount":77,"unpackedSize":351087,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEDkzbrgyM8PvgR9mk7UFBmcx9z8KQpvwz7oHfI+uTIdAiEAgcYC5XiLSNOdWQCELhHnPPrpYcTFXpW8nTFZeVnhCgM="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_9.0.0-8b2927ca0f4c1d3ce92022dd7bfb67ee006f4fe4_1634184425860_0.8937357863152446"},"_hasShrinkwrap":false},"9.0.0-0d6735c98d3160c67b13828ef4550d4f8b1f45b0":{"name":"@detachhead/ts-helpers","version":"9.0.0-0d6735c98d3160c67b13828ef4550d4f8b1f45b0","scripts":{"test":"jest","lint:check":"eslint src --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","@typescript-eslint/eslint-plugin":"4.13.0","@typescript-eslint/parser":"4.13.0","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","eslint-config-prettier":"7.1.0","eslint-plugin-eslint-comments":"3.2.0","eslint-plugin-expect-type":"0.0.5","eslint-plugin-import":"^2.24.2","eslint-plugin-prefer-arrow":"1.2.3","espower-typescript":"9.0.2","jest":"26.6.3","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"26.4.4","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-beta"},"gitHead":"0d6735c98d3160c67b13828ef4550d4f8b1f45b0","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript 4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### supported js runtimes\n\n-   [x] nodejs\n-   [x] browser\n-   [x] deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@9.0.0-0d6735c98d3160c67b13828ef4550d4f8b1f45b0","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-ZzJ87avitCIFVd0Ey5qK9MUj45xo7yr3niPMH9baA3zaG96chrwtgfR4/7lubP/gvLuoS1lai+OVDFWbIJH2lw==","shasum":"de0f2cfc54f6899b3ac775bc321c569ae2e3e3c6","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-9.0.0-0d6735c98d3160c67b13828ef4550d4f8b1f45b0.tgz","fileCount":77,"unpackedSize":353623,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCD+/D8+TjBW6/V9TpgvGOGGjrl1FGKD1Z23LPgBTAjEgIgVG830UvF3uDNmAzAoY49j2zVwBvRMziLpc80if0RVkg="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_9.0.0-0d6735c98d3160c67b13828ef4550d4f8b1f45b0_1634190116949_0.8135240878036163"},"_hasShrinkwrap":false},"9.0.0-da1d6326a81a14fb2622e4828de865ce238cf92b":{"name":"@detachhead/ts-helpers","version":"9.0.0-da1d6326a81a14fb2622e4828de865ce238cf92b","scripts":{"test":"jest","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.7","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","eslint-plugin-expect-type":"0.0.5","espower-typescript":"9.0.2","jest":"26.6.3","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"26.4.4","ts-node":"^10.3.0","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-dev.20211014"},"gitHead":"da1d6326a81a14fb2622e4828de865ce238cf92b","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript 4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### supported js runtimes\n\n-   [x] nodejs\n-   [x] browser\n-   [x] deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@9.0.0-da1d6326a81a14fb2622e4828de865ce238cf92b","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-gVZnA7dZyUiBf05gKaaxq6nn5CQiHy/W4dPm3kSjcsP4HIhgYleTf0h/7lVrHkX2+YrXpUmJ8bMNYH8zmYQHzA==","shasum":"7cf040fbcc673ff3494eb03ca8d3e9a23432e885","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-9.0.0-da1d6326a81a14fb2622e4828de865ce238cf92b.tgz","fileCount":77,"unpackedSize":351023,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFqR/SIDzNp2+mpSK4S/s+tlNHfTAVZaGDNuFKKIY5qUAiA8INLAYfPS7LOvjaKvQ9W0DNzJbV0owDzJujn7WqZcPg=="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_9.0.0-da1d6326a81a14fb2622e4828de865ce238cf92b_1634224256065_0.15561330883096014"},"_hasShrinkwrap":false},"9.0.0-dc727ef00d1e00d86a6c60017465a01073bae7ac":{"name":"@detachhead/ts-helpers","version":"9.0.0-dc727ef00d1e00d86a6c60017465a01073bae7ac","scripts":{"test":"jest","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.7","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","eslint-plugin-expect-type":"0.0.5","espower-typescript":"9.0.2","jest":"26.6.3","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"26.4.4","ts-node":"^10.3.0","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-dev.20211014"},"gitHead":"dc727ef00d1e00d86a6c60017465a01073bae7ac","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript 4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### supported js runtimes\n\n-   [x] nodejs\n-   [x] browser\n-   [x] deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@9.0.0-dc727ef00d1e00d86a6c60017465a01073bae7ac","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-P6HUzaF6Rp4aSF4/m0Hq0QzsLKSblYObfZsT7bsGZO9iDbvIITAgAJWsWCoKBIBE9aRjHXht/Yk7lLhOWrhWAA==","shasum":"cd41d96666b2ab41dcb46c9dd8ce9dbc612ea18e","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-9.0.0-dc727ef00d1e00d86a6c60017465a01073bae7ac.tgz","fileCount":77,"unpackedSize":350662,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDSeDUoxFuwhmkg/hsJ9qhDAotDXjuxcH9JRrPsHv+HZAiApXA1qFg3znpAzRlW5Xey2zv8flV8mAL/G+iL9CU95wA=="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_9.0.0-dc727ef00d1e00d86a6c60017465a01073bae7ac_1634224730424_0.7585345054758268"},"_hasShrinkwrap":false},"9.0.0-89222eda972350690624dc5f5f8c7c4cfd439c3b":{"name":"@detachhead/ts-helpers","version":"9.0.0-89222eda972350690624dc5f5f8c7c4cfd439c3b","scripts":{"test":"jest","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.7","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","eslint-plugin-expect-type":"0.0.5","espower-typescript":"9.0.2","jest":"26.6.3","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"26.4.4","ts-node":"^10.3.0","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-dev.20211014"},"gitHead":"89222eda972350690624dc5f5f8c7c4cfd439c3b","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript 4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### supported js runtimes\n\n-   [x] nodejs\n-   [x] browser\n-   [x] deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@9.0.0-89222eda972350690624dc5f5f8c7c4cfd439c3b","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-+FM5KF7GF10QzsYb3xReZDXDWEtPeO+4ASKfzIvNVSJs6Q/BwJRWJA5QgCrjbMZAl93tzAhi1GrbNjsnPPgySA==","shasum":"f8a5e618fff03c6da1070a8f0d7646ea85000ddb","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-9.0.0-89222eda972350690624dc5f5f8c7c4cfd439c3b.tgz","fileCount":77,"unpackedSize":349841,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDgSn8XVxIuUy75LPV9wbECOREUgFSiCmRC1QVFOGQXpAiEA9u/0e5RFLk3i/B3iqf0RiaEtJ6ecZWaYX+1toHPRBEs="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_9.0.0-89222eda972350690624dc5f5f8c7c4cfd439c3b_1634225307313_0.8427650195720546"},"_hasShrinkwrap":false},"9.0.0-4db5a47c2fc9d64c65b725f2eb3c03b5aefc6475":{"name":"@detachhead/ts-helpers","version":"9.0.0-4db5a47c2fc9d64c65b725f2eb3c03b5aefc6475","scripts":{"test":"jest","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.7","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","eslint-plugin-expect-type":"0.0.5","espower-typescript":"9.0.2","jest":"26.6.3","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"26.4.4","ts-node":"^10.3.0","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-dev.20211014"},"gitHead":"4db5a47c2fc9d64c65b725f2eb3c03b5aefc6475","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript 4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### supported js runtimes\n\n-   [x] nodejs\n-   [x] browser\n-   [x] deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@9.0.0-4db5a47c2fc9d64c65b725f2eb3c03b5aefc6475","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-tzD1b909jgudQ/Yib1POKbBSVjBGC2POIyN3JaR5HmcO5WmZ5O/YxIFAtPcyIyz6KzWJlO2Gmax4iwo2Dp+b2A==","shasum":"5222161a3dcc6f00d096d55c2e76a054e76eb501","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-9.0.0-4db5a47c2fc9d64c65b725f2eb3c03b5aefc6475.tgz","fileCount":77,"unpackedSize":353935,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEMIEF1l4xaECbeGhKY3a/y/PYm2YilIw57J7EwY1ZV1AiEAiMrVpkZ9bcZYNzz30tpZrMwZdnZMQEyFX9I+3yzzQXk="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_9.0.0-4db5a47c2fc9d64c65b725f2eb3c03b5aefc6475_1634259724134_0.5785108015171414"},"_hasShrinkwrap":false},"9.0.0-f94c208201b0881e2e2c08fe501d8acb59bb7301":{"name":"@detachhead/ts-helpers","version":"9.0.0-f94c208201b0881e2e2c08fe501d8acb59bb7301","scripts":{"test":"jest","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.7","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","eslint-plugin-expect-type":"0.0.5","espower-typescript":"9.0.2","jest":"26.6.3","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"26.4.4","ts-node":"^10.3.0","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-dev.20211014"},"gitHead":"f94c208201b0881e2e2c08fe501d8acb59bb7301","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript 4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### supported js runtimes\n\n-   [x] nodejs\n-   [x] browser\n-   [x] deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@9.0.0-f94c208201b0881e2e2c08fe501d8acb59bb7301","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-LxhjqK3h5z0Y94EHrdk6LMG7knViexMk16X5t8wAeNdvQKMQRNPEwwOzMtL8sYlk5q9WzSIXGkMsJEQa7/FtCA==","shasum":"9a34e84fdb8f38dd19ba06d63f366024fb01fb1a","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-9.0.0-f94c208201b0881e2e2c08fe501d8acb59bb7301.tgz","fileCount":77,"unpackedSize":357370,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHHuL2C4KGU5VkYB37He+EfTeYEw7d00n1CX1fZ+zzXkAiEAhDiCMQHY+nEkv0cuD9k7JHs54jAal2WN3MfeKZzlSio="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_9.0.0-f94c208201b0881e2e2c08fe501d8acb59bb7301_1634268857527_0.5135604420791706"},"_hasShrinkwrap":false},"9.0.0-9602327dec6aee67fa7a22249f518c24ae88878b":{"name":"@detachhead/ts-helpers","version":"9.0.0-9602327dec6aee67fa7a22249f518c24ae88878b","scripts":{"test":"jest","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.7","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","eslint-plugin-expect-type":"0.0.5","espower-typescript":"9.0.2","jest":"26.6.3","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"26.4.4","ts-node":"^10.3.0","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-dev.20211014"},"gitHead":"9602327dec6aee67fa7a22249f518c24ae88878b","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript 4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### supported js runtimes\n\n-   [x] nodejs\n-   [x] browser\n-   [x] deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@9.0.0-9602327dec6aee67fa7a22249f518c24ae88878b","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-lOlbbQThQu7ItmqFk3lW7Oy89Ehdh1biiTIfP2MGMmiqo/SFbRF8C/1O507lVdyNDGjUAMRROQpHtBXm5bQUgA==","shasum":"39be1440aa4f6728a1920fe2dd1ccfe7328d5c7e","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-9.0.0-9602327dec6aee67fa7a22249f518c24ae88878b.tgz","fileCount":77,"unpackedSize":353939,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIB/BR8EyDO1UmKL8c6Xvd5VbuP54X/lvR+uBMeLXaC42AiEA4l3SqyEiNuATMBnJgjSdDglZ2OB65lX/j6H9PSmvfuc="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_9.0.0-9602327dec6aee67fa7a22249f518c24ae88878b_1634268935859_0.09277961826684722"},"_hasShrinkwrap":false},"9.0.0-c0eb663b032c342b194bdd1cd1e3143a0990e9af":{"name":"@detachhead/ts-helpers","version":"9.0.0-c0eb663b032c342b194bdd1cd1e3143a0990e9af","scripts":{"test":"jest","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.7","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","eslint-plugin-expect-type":"0.0.5","espower-typescript":"9.0.2","jest":"^27.2.5","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.0.6","ts-node":"^10.3.0","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-dev.20211014"},"gitHead":"c0eb663b032c342b194bdd1cd1e3143a0990e9af","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript 4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### supported js runtimes\n\n-   [x] nodejs\n-   [x] browser\n-   [x] deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@9.0.0-c0eb663b032c342b194bdd1cd1e3143a0990e9af","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-oak8+P3nBLDpS5EIFx1ma3SZde9/9fHKnfwrKK0LX7G4RDYy02lSORW4I4MwIQVjbFynCozgXiGDOr0rW++zcw==","shasum":"af8b2e3b964ffe722d649cbc29dddf5156cfabdd","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-9.0.0-c0eb663b032c342b194bdd1cd1e3143a0990e9af.tgz","fileCount":77,"unpackedSize":357776,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC1LULU7xudYtplW7Wb/M1hv5kXGSq67Fwd0F+WOQ0XywIgAz22Srz+mc8YOSesNx63R8bC3GjbuAntLxq0aqMhfJo="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_9.0.0-c0eb663b032c342b194bdd1cd1e3143a0990e9af_1634442000768_0.42221507264486724"},"_hasShrinkwrap":false},"9.0.0-d8f1473bb11f9f3cb6c6b5205038d6d06206e9d6":{"name":"@detachhead/ts-helpers","version":"9.0.0-d8f1473bb11f9f3cb6c6b5205038d6d06206e9d6","scripts":{"test":"jest","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.7","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","eslint-plugin-expect-type":"0.0.5","espower-typescript":"9.0.2","jest":"^27.2.5","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.0.6","ts-node":"^10.3.0","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-dev.20211014"},"gitHead":"d8f1473bb11f9f3cb6c6b5205038d6d06206e9d6","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript 4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### supported js runtimes\n\n-   [x] nodejs\n-   [x] browser\n-   [x] deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@9.0.0-d8f1473bb11f9f3cb6c6b5205038d6d06206e9d6","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-4MzJrRa3X5toC2hjboA1D80lcG6dxRwPW7ehTnjmtBcHyJKKfR2MktX8RE1xxmVPrGmbxp5Kkg799H+acZzo8w==","shasum":"0bb51ccf646bd236f8290dfa6285376c1b4730ff","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-9.0.0-d8f1473bb11f9f3cb6c6b5205038d6d06206e9d6.tgz","fileCount":112,"unpackedSize":355652,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEDiVuvMOfK8D8ZclWANwqWZl4KREqP1ApZnQUFY+6Y6AiEAmMl0S4AF1iP1QzFRy+xEpGo5akcMDe/AHNIz7JSzpgs="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_9.0.0-d8f1473bb11f9f3cb6c6b5205038d6d06206e9d6_1634442780672_0.012620705832437684"},"_hasShrinkwrap":false},"9.0.0-fd883d6c832fe5906af34e94ec4be8a50d4aa3d1":{"name":"@detachhead/ts-helpers","version":"9.0.0-fd883d6c832fe5906af34e94ec4be8a50d4aa3d1","scripts":{"test":"jest","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.7","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","eslint-plugin-expect-type":"0.0.5","espower-typescript":"9.0.2","jest":"^27.2.5","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.0.6","ts-node":"^10.3.0","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-dev.20211014"},"gitHead":"fd883d6c832fe5906af34e94ec4be8a50d4aa3d1","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript 4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### supported js runtimes\n\n-   [x] nodejs\n-   [x] browser\n-   [x] deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@9.0.0-fd883d6c832fe5906af34e94ec4be8a50d4aa3d1","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-SFi2b4mM71brBuLybdzEG4IVr4nDDu+t8us/80V2il1//aE5KqA8cpsAOCIanbGM5FcdCclhwfuRgQTzuAhtew==","shasum":"4251b4b9a59702ef10db8c52eb76e60fa7d378ae","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-9.0.0-fd883d6c832fe5906af34e94ec4be8a50d4aa3d1.tgz","fileCount":77,"unpackedSize":358839,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCzEokUJiRir0ZmG6BRHKk6vSEOuMqQJejT/pd1dPiWrwIgRQ/AJuQDKk5bVSQmc1Vuzq7gn/+5zGYrzEJZpcl39gk="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_9.0.0-fd883d6c832fe5906af34e94ec4be8a50d4aa3d1_1634443009239_0.23284820782421511"},"_hasShrinkwrap":false},"9.0.0-ad0067ba54b5c7560339216705abfdc86f4f109a":{"name":"@detachhead/ts-helpers","version":"9.0.0-ad0067ba54b5c7560339216705abfdc86f4f109a","scripts":{"test":"jest","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.7","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","eslint-plugin-expect-type":"0.0.5","espower-typescript":"9.0.2","jest":"^27.2.5","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.0.6","ts-node":"^10.3.0","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-dev.20211014"},"gitHead":"ad0067ba54b5c7560339216705abfdc86f4f109a","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript 4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### supported js runtimes\n\n-   [x] nodejs\n-   [x] browser\n-   [x] deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@9.0.0-ad0067ba54b5c7560339216705abfdc86f4f109a","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-ld9FepMSESluZ0fMvlOGQRCaGbzdZLCuw34+77pLHgHAG/AhJe77n5u96mf2dFR/d/oSQkABYJG4RoZhaSEEgA==","shasum":"77496a01a41ab257fa0077e057b2a91b824c6e5c","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-9.0.0-ad0067ba54b5c7560339216705abfdc86f4f109a.tgz","fileCount":112,"unpackedSize":356715,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDaYvMPWLBKoj9yifhIAQ68mAmQKm0YF24vIYhj6hSXjgIgXz7/vfGF2/WC3Bzy7ID10LYc8KxgqV5m1hBkVGcwflg="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_9.0.0-ad0067ba54b5c7560339216705abfdc86f4f109a_1634443205167_0.7998494756463184"},"_hasShrinkwrap":false},"9.0.0-9e5f4c025732d4b26a592f18bf55b0ca27878536":{"name":"@detachhead/ts-helpers","version":"9.0.0-9e5f4c025732d4b26a592f18bf55b0ca27878536","scripts":{"test":"jest","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.7","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","eslint-plugin-expect-type":"0.0.5","espower-typescript":"9.0.2","jest":"^27.2.5","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.0.6","ts-node":"^10.3.0","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-dev.20211014"},"gitHead":"9e5f4c025732d4b26a592f18bf55b0ca27878536","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript 4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### supported js runtimes\n\n-   [x] nodejs\n-   [x] browser\n-   [x] deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@9.0.0-9e5f4c025732d4b26a592f18bf55b0ca27878536","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-TUgDmWUypZGrmayle4XIWf1/3xlv9D8mS0mFeL98/lTAwbVY/N0ftLU9g7LJkiDi/bxdeRELMYy3C4riPtNz8g==","shasum":"2daf37a8e3942660355097f02b25e488be77823f","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-9.0.0-9e5f4c025732d4b26a592f18bf55b0ca27878536.tgz","fileCount":112,"unpackedSize":352286,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDF+M7YZZGJpPQSHs3UcXuyhuZRqrNNvukUR1jkKmsyxAIhANWwnzk9YiFZ/H1XIuWHPJHOHfWk2oWfrYEULgyZhPzm"}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_9.0.0-9e5f4c025732d4b26a592f18bf55b0ca27878536_1634480298959_0.18289380708839698"},"_hasShrinkwrap":false},"9.0.0-c874b695e8ad2534f4daea0987f07f1c70282503":{"name":"@detachhead/ts-helpers","version":"9.0.0-c874b695e8ad2534f4daea0987f07f1c70282503","scripts":{"test":"jest","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.7","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","espower-typescript":"9.0.2","jest":"^27.2.5","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.0.6","ts-node":"^10.3.0","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-dev.20211014"},"gitHead":"c874b695e8ad2534f4daea0987f07f1c70282503","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript 4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### supported js runtimes\n\n-   [x] nodejs\n-   [x] browser\n-   [x] deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@9.0.0-c874b695e8ad2534f4daea0987f07f1c70282503","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-9RdksnwIGpRcrFYzzBaJtuQT8E5UPKN6WJ0rZQUb2MFFSJ5r8p4B4QKgYXU8L0N49pY4kqPzyHQ3x/roSYSwhg==","shasum":"6dc1dd1cb3b68965da9f2d2974d931da6c577c78","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-9.0.0-c874b695e8ad2534f4daea0987f07f1c70282503.tgz","fileCount":112,"unpackedSize":351601,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHmbKsaK9WPqlyTVOoHMFKkRJ+w4TJUzjBo/LCutMx3dAiEArttEWnSGP9nQFxIBqF9+nXrqrfMEB+Itwshoy1+79DY="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_9.0.0-c874b695e8ad2534f4daea0987f07f1c70282503_1634544636355_0.85059185565507"},"_hasShrinkwrap":false},"10.0.0-83d2b0f70ed41ec8273501b3a2c3fb547cda4cea":{"name":"@detachhead/ts-helpers","version":"10.0.0-83d2b0f70ed41ec8273501b3a2c3fb547cda4cea","scripts":{"test":"jest","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.7","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","espower-typescript":"9.0.2","jest":"^27.2.5","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.0.6","ts-node":"^10.3.0","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-dev.20211014"},"gitHead":"83d2b0f70ed41ec8273501b3a2c3fb547cda4cea","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript 4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### supported js runtimes\n\n-   [x] nodejs\n-   [x] browser\n-   [x] deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@10.0.0-83d2b0f70ed41ec8273501b3a2c3fb547cda4cea","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-nfL41Ba8+JvzmiWEO+6Sm/VY5Wrg9852CkVZ383CyXCapSZjK1Dunm/TKn/Duh+dYEuYMxjSCJQpJdgEh1l8pw==","shasum":"6d15115ff5a19accb72f91fc559e0301efd12a2d","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-10.0.0-83d2b0f70ed41ec8273501b3a2c3fb547cda4cea.tgz","fileCount":112,"unpackedSize":351602,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDOeVKI2zCYZf0GDLkopgNSdMb3Tycrsa5vA6M7bE/RagIhAN3GcN3ia9fgXzM5jBlBwxdfmEMkYVKf3x3orscPUN/0"}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_10.0.0-83d2b0f70ed41ec8273501b3a2c3fb547cda4cea_1634554356014_0.09417006473158418"},"_hasShrinkwrap":false},"9.0.0-729f310f5608acf01a487071191509cb32dd555e":{"name":"@detachhead/ts-helpers","version":"9.0.0-729f310f5608acf01a487071191509cb32dd555e","scripts":{"test":"jest","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.7","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","eslint-plugin-expect-type":"0.0.5","espower-typescript":"9.0.2","jest":"^27.2.5","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.0.6","ts-node":"^10.3.0","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-dev.20211014"},"gitHead":"729f310f5608acf01a487071191509cb32dd555e","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript 4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### supported js runtimes\n\n-   [x] nodejs\n-   [x] browser\n-   [x] deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@9.0.0-729f310f5608acf01a487071191509cb32dd555e","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-oBrtvPS4sSUQbPI/1B2coo1nWXH8wnhqnIm0/2SfCOCiDTonLii3PvmgnhJpiO/iS56618jb/EnEDse3tdxpbg==","shasum":"7a71b06b13043da0ea46f942b82d757ec7651743","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-9.0.0-729f310f5608acf01a487071191509cb32dd555e.tgz","fileCount":77,"unpackedSize":359137,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCHKsVi/L87ASeOvpBOG+M+OtaDFcdYjYS1onijI5BA2wIhAIflt06hjlJ1xAP4enjg8t2rxWLzQMZQL7VOzczzYt30"}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_9.0.0-729f310f5608acf01a487071191509cb32dd555e_1634555876817_0.8661004868058519"},"_hasShrinkwrap":false},"10.0.0-9cf68674a0a192c65e4f0d6fafd80caa9285f1eb":{"name":"@detachhead/ts-helpers","version":"10.0.0-9cf68674a0a192c65e4f0d6fafd80caa9285f1eb","scripts":{"test":"jest","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.7","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","espower-typescript":"9.0.2","jest":"^27.2.5","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.0.6","ts-node":"^10.3.0","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-dev.20211014"},"gitHead":"9cf68674a0a192c65e4f0d6fafd80caa9285f1eb","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript 4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### supported js runtimes\n\n-   [x] nodejs\n-   [x] browser\n-   [x] deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@10.0.0-9cf68674a0a192c65e4f0d6fafd80caa9285f1eb","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-8DzGNOEgdQG6+DxtTlkZ3NVyqNIIH0+6oQjA6PE4chMi9YTTXvbAHu6D/bDKFG0gTM9xCio1etN8lY/FzlWtSQ==","shasum":"eaf9d6c8ce254f3e36708151eb9882d803bbaddf","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-10.0.0-9cf68674a0a192c65e4f0d6fafd80caa9285f1eb.tgz","fileCount":112,"unpackedSize":351900,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBvN7AverEe9M8X2HU2Gxm/TbWqggI9j0ASN4pVnDavPAiBVzkGyZ2o2DUDEoc+keogStahrNYBUhR7Hql/0ZZU4Ag=="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_10.0.0-9cf68674a0a192c65e4f0d6fafd80caa9285f1eb_1634556090045_0.31952651845863644"},"_hasShrinkwrap":false},"10.0.0-9dd54755d2b76651ae644bdbda7204f2191321e7":{"name":"@detachhead/ts-helpers","version":"10.0.0-9dd54755d2b76651ae644bdbda7204f2191321e7","scripts":{"test":"jest","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.7","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","espower-typescript":"9.0.2","jest":"^27.2.5","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.0.6","ts-node":"^10.3.0","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-dev.20211014"},"gitHead":"9dd54755d2b76651ae644bdbda7204f2191321e7","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript 4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### supported js runtimes\n\n-   [x] nodejs\n-   [x] browser\n-   [x] deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@10.0.0-9dd54755d2b76651ae644bdbda7204f2191321e7","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-KmzWH1g9wiMyKrGNNfWVty+rTXUDAt04CixWhpHQ1HjY8XFRMuaf9eyQaB7boLwk9ASaH9fB6FhvCQU/xPEkPg==","shasum":"dd3e5d13d1d607f9b06f29428701bc2ee5288ea4","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-10.0.0-9dd54755d2b76651ae644bdbda7204f2191321e7.tgz","fileCount":97,"unpackedSize":306971,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEXAzTH6yKw+wklAisATIE63lqlmcrM2iZqHrdHsjg+MAiAF36Iq5EAylG6puZ7N5O1klytTJ8AD7+9yoJCjcer4Qg=="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_10.0.0-9dd54755d2b76651ae644bdbda7204f2191321e7_1634556707407_0.5638340865145999"},"_hasShrinkwrap":false},"10.0.0-e439b680a400b0dfc77a9f380c5a1e12695915fb":{"name":"@detachhead/ts-helpers","version":"10.0.0-e439b680a400b0dfc77a9f380c5a1e12695915fb","exports":{"functions":"./dist/utilityFunctions","builtins":"./src/builtins","types":"./src/utilityTypes"},"scripts":{"test":"jest","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.7","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","espower-typescript":"9.0.2","jest":"^27.2.5","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.0.6","ts-node":"^10.3.0","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-dev.20211014"},"gitHead":"e439b680a400b0dfc77a9f380c5a1e12695915fb","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript 4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### supported js runtimes\n\n-   [x] nodejs\n-   [x] browser\n-   [x] deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@10.0.0-e439b680a400b0dfc77a9f380c5a1e12695915fb","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-2SuwKIio/vbmUbqN7T1G9NR8XZwAeKuysPW8cw0L7S6UeD7uziv9xRIfcvjwIFbJdHH4l9M2JjfrUG4Fl7Wx5g==","shasum":"851f2cb9b036731b0bc55a023ee7338a5d493c31","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-10.0.0-e439b680a400b0dfc77a9f380c5a1e12695915fb.tgz","fileCount":73,"unpackedSize":298826,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC/JuB565NvAvYLSzENR63DtyZ3jtFCn7NaRsifGk5kWQIhAM/KmANtJBgppipK94ki207FZyqJjCj9Fg5x833bBRfP"}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_10.0.0-e439b680a400b0dfc77a9f380c5a1e12695915fb_1634559144916_0.6883406500965608"},"_hasShrinkwrap":false},"10.0.0-234db3b4b4bb683d55c13d819f3abb94dd9d6cc3":{"name":"@detachhead/ts-helpers","version":"10.0.0-234db3b4b4bb683d55c13d819f3abb94dd9d6cc3","exports":{"functions":"./dist/utilityFunctions","builtins":"./src/builtins","types":"./dist/utilityTypes"},"scripts":{"test":"jest","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.7","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","espower-typescript":"9.0.2","jest":"^27.2.5","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.0.6","ts-node":"^10.3.0","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-dev.20211014"},"gitHead":"234db3b4b4bb683d55c13d819f3abb94dd9d6cc3","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript 4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### supported js runtimes\n\n-   [x] nodejs\n-   [x] browser\n-   [x] deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@10.0.0-234db3b4b4bb683d55c13d819f3abb94dd9d6cc3","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-1x10A+uFaiziBIionhbG19fI3GJDHxn/vT/sRiEQWszE2jrd8gAslr0KZp83mL/1cAz50QGqQ3MuotGpTOye8g==","shasum":"e7650736c64222c18a04018a3a2c25b984fe4a82","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-10.0.0-234db3b4b4bb683d55c13d819f3abb94dd9d6cc3.tgz","fileCount":73,"unpackedSize":298827,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIA3Ci2mwWqB3meuD3GYrcGkUbvpYklrfBP/Ussr9AyVmAiBFXK3HrKjQWN1IcL5QYTFZUCVThDRzFtMIHQ9ICp2Ybg=="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_10.0.0-234db3b4b4bb683d55c13d819f3abb94dd9d6cc3_1634559695290_0.07071454702116031"},"_hasShrinkwrap":false},"10.0.0-26175c52de298661f5b33f38025268e2785bd641":{"name":"@detachhead/ts-helpers","version":"10.0.0-26175c52de298661f5b33f38025268e2785bd641","scripts":{"test":"jest","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.7","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","espower-typescript":"9.0.2","jest":"^27.2.5","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.0.6","ts-node":"^10.3.0","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-dev.20211014"},"gitHead":"26175c52de298661f5b33f38025268e2785bd641","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript 4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### supported js runtimes\n\n-   [x] nodejs\n-   [x] browser\n-   [x] deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@10.0.0-26175c52de298661f5b33f38025268e2785bd641","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-EEO9nVPCUu1t7tLkE+dn4UlDuzib123594nK/FgHq9CJXjuwN6rv6mjp/qEujoyhFVgZfI7tw8M7DtMVTNO2BQ==","shasum":"efdd3216674ae6e1d07696f153f63aa7b218ae22","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-10.0.0-26175c52de298661f5b33f38025268e2785bd641.tgz","fileCount":73,"unpackedSize":298694,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDl0EF2INuvklIhYK+t38MH2BQdcIqmpFZzHHyK0pDngwIgVlOAeEiEXfaM5lyQtcIVSspd+VitbjuvH4GfLwmAICE="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_10.0.0-26175c52de298661f5b33f38025268e2785bd641_1634560195230_0.3815667183939828"},"_hasShrinkwrap":false},"10.0.0-9edc3bd098e232a01c5e2a6a107c2890db73aa55":{"name":"@detachhead/ts-helpers","version":"10.0.0-9edc3bd098e232a01c5e2a6a107c2890db73aa55","scripts":{"test":"jest","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.7","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","espower-typescript":"9.0.2","jest":"^27.2.5","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.0.6","ts-node":"^10.3.0","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-dev.20211014"},"gitHead":"9edc3bd098e232a01c5e2a6a107c2890db73aa55","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript 4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### supported js runtimes\n\n-   [x] nodejs\n-   [x] browser\n-   [x] deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@10.0.0-9edc3bd098e232a01c5e2a6a107c2890db73aa55","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-tJA/6ylKeJgeHxgYgLhSXAZ5ZzgDn7KEOJvo0LMYJ8s5vzdimeGhLPg71F3QYFuw5VDA/e+xZ2YoAP3Db2NCbQ==","shasum":"917a7142898238bb0a0e278b4ffbb8c1b6627a46","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-10.0.0-9edc3bd098e232a01c5e2a6a107c2890db73aa55.tgz","fileCount":67,"unpackedSize":308315,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGG7RnSUBiGifDHOhvcP038lxYl9zTmpfHiEd2Fv0Xd+AiB8JtVL8OWdRgGOWC+TqmvFAIjq7UfrzWZ/4fgBLss36A=="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_10.0.0-9edc3bd098e232a01c5e2a6a107c2890db73aa55_1634567537360_0.624498239313592"},"_hasShrinkwrap":false},"10.0.0":{"name":"@detachhead/ts-helpers","version":"10.0.0","scripts":{"test":"jest","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.7","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","espower-typescript":"9.0.2","jest":"^27.2.5","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.0.6","ts-node":"^10.3.0","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-dev.20211014"},"gitHead":"460460a07914d9691a9c86c1f8cacacc036fb0c1","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@10.0.0","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-Tf0veYuZeZuDW6fkzoV1KoGRcDBEO8DXOYiiaX+gTkdA+420QqsT2dTkq/fssB+psK8H7C0WPGRPqq+plgOr2Q==","shasum":"78aede17617563ff42f815887fb33c75c537c79b","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-10.0.0.tgz","fileCount":67,"unpackedSize":308274,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIH3rkDcgVyOkyrSrUBfw6RJhwGbzt72V7bXd9oUgE6uiAiAT4flHgIHNhhJj6un8hRuHsfmqA/gRwp/2zSF/g1+yJw=="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_10.0.0_1634568046135_0.8519514478378307"},"_hasShrinkwrap":false},"10.0.0-12efa73e3504fdefa1d71a511819ed0e3b1cb6e7":{"name":"@detachhead/ts-helpers","version":"10.0.0-12efa73e3504fdefa1d71a511819ed0e3b1cb6e7","scripts":{"test":"jest","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.7","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","espower-typescript":"9.0.2","jest":"^27.2.5","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.0.6","ts-node":"^10.3.0","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-dev.20211014"},"gitHead":"12efa73e3504fdefa1d71a511819ed0e3b1cb6e7","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript 4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### supported js runtimes\n\n-   [x] nodejs\n-   [x] browser\n-   [x] deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@10.0.0-12efa73e3504fdefa1d71a511819ed0e3b1cb6e7","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-fkWk+vdMV7bAegAXTMhkcu3B+TksINCxGlR/YOGRQpKwmlbERh2ftpQ+9TBWwTtVr/BMSI+CWlI6d6ay88kiDA==","shasum":"762a8fed8ece19b6c5c16d31d4a56b80fde782c1","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-10.0.0-12efa73e3504fdefa1d71a511819ed0e3b1cb6e7.tgz","fileCount":67,"unpackedSize":309170,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDbR7dis3xkU0SuTQLQ89Ac/p38b0zayhPShm14P0bsXwIhAN5MmPZnyUH1NqygG9wvAilVONX8oKHcpw/M0Gw2Lwkc"}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_10.0.0-12efa73e3504fdefa1d71a511819ed0e3b1cb6e7_1635302533409_0.015273965639728715"},"_hasShrinkwrap":false},"10.0.0-22ac6e836c99bdf344671e401f9d60749c416809":{"name":"@detachhead/ts-helpers","version":"10.0.0-22ac6e836c99bdf344671e401f9d60749c416809","scripts":{"test":"jest","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.7","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","espower-typescript":"9.0.2","jest":"^27.2.5","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.0.6","ts-node":"^10.3.0","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-dev.20211014"},"gitHead":"22ac6e836c99bdf344671e401f9d60749c416809","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript 4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### supported js runtimes\n\n-   [x] nodejs\n-   [x] browser\n-   [x] deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@10.0.0-22ac6e836c99bdf344671e401f9d60749c416809","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-PkUD2c8GKiUHhFBRlrIqmXkohbnU5la5UH7WJIHKseKb7OcItkfFqmSSA6O4vS/JUY1eZp21B9IEBVgZ7mYLOg==","shasum":"a7490c6791e7e0aebfeafa893c52841abbbc30d2","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-10.0.0-22ac6e836c99bdf344671e401f9d60749c416809.tgz","fileCount":67,"unpackedSize":309158,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCVImUtm3Wzpo0Vhdvk/AZ/KGaZUE3guqaTOwlaqskNSwIgRgcvRVKDXfFjkEQLSKx1loETbIeNui499qkIBX0OUl8="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_10.0.0-22ac6e836c99bdf344671e401f9d60749c416809_1635305250262_0.8799805053294212"},"_hasShrinkwrap":false},"10.0.0-412c64d040327c7f4df7680dd409f1a3fd771e2b":{"name":"@detachhead/ts-helpers","version":"10.0.0-412c64d040327c7f4df7680dd409f1a3fd771e2b","scripts":{"test":"jest","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.7","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","espower-typescript":"9.0.2","jest":"^27.2.5","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.0.6","ts-node":"^10.3.0","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-dev.20211014"},"gitHead":"412c64d040327c7f4df7680dd409f1a3fd771e2b","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n## install\n\n### npm\n\n```bash\nnpm install @detachhead/ts-helpers\n```\n\n```ts\nimport { exactly } from '@detachhead/ts-helpers/dist/utilityFunctions/misc'\n```\n\n### deno\n\n```ts\nimport { exactly } from 'https://deno.land/x/helpers/utilityFunctions/misc'\n```\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript 4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@10.0.0-412c64d040327c7f4df7680dd409f1a3fd771e2b","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-Q+H1X9fKWVi7iBKuXEo2W9EpJWLAypbWdSa6sxWlXcbmwmP6qEBiIvE52WYo/AzNZ84/5INIxFHWD+/mXodMxQ==","shasum":"447224b6518227e4e97558160a0d3b5276997f71","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-10.0.0-412c64d040327c7f4df7680dd409f1a3fd771e2b.tgz","fileCount":67,"unpackedSize":309226,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhmeV3CRA9TVsSAnZWagAAZWkQAIraAm9FD6XLhI7AbFGD\nolb92feUAzAD/5LQMRbRBl1YwIPIthSwaVRWGuXFRlkj+9pLiQ1DaZ9AhkJs\n3oL/JxGNSgL+Ern4mQdutTpjO0JfGLVo/PauZWssyGFATn8Y3m746hv9qMdW\nPRtkrzdCVmXNYg7NwdcsDPPtzW13vSEJzbupZ/zUjkc+/BEQzN89kOXN9Qsd\nA+R/Z1qmZY7drrU5O+fB/3A6sDACMGWeL1/VBHhrZxUAM53qyficIFTbMsJB\nUTbefbS/CB9RjTmxacSbdZfdiHDfGseXBUAG8lJRVh7NZFiNPFgVt9G4PBzm\n0R4GmS8zFH03IfwIltl1xOcjUjlAZiMsce6cfkSJKfrG+XsuuSj8ZaGMBV+Y\nh+oIOJ8tHaGrIYrzwPWkyX+jRhmCOH1kzQAlC89M8BjhCwCJUw6bE+mWZdzc\nZSSGpEqPJLl9WRgDUuHfQoweGDrhRj8Izgyy7aC+WXko7xABvpNyPQFEo25q\nF/0EFEnIUV56FiSbImEMxlRwKe0QzZkJvW5+6oqsOofpoibKLequ4o6PVIHk\nwuSPAw4/1MekXhFeTP+SuW/VM8y6XW+w9rnWMvcwsXAPiEBtwkmNgvlV6VyR\nHvVvEZJR9CYkVPsMqIHu9cLL+VWz0JYEqVukbzVgz5N01T15kGSrPzSd0g/K\nwbXi\r\n=3t/H\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDBJP/qFu3DBqNJaaJvPUvI/fwhilkSLqT6nhe5XqOz5AIgVho+HVjyR59/Bw5i7WT4QMfpXpWrnNRaoJ97i/GUIw4="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_10.0.0-412c64d040327c7f4df7680dd409f1a3fd771e2b_1637475702948_0.39001188436554246"},"_hasShrinkwrap":false},"10.0.0-8bf569e50aadc156b87540fc6df9df04163d0788":{"name":"@detachhead/ts-helpers","version":"10.0.0-8bf569e50aadc156b87540fc6df9df04163d0788","scripts":{"test":"jest","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.7","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","espower-typescript":"9.0.2","jest":"^27.2.5","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.0.6","ts-node":"^10.3.0","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-dev.20211014"},"gitHead":"8bf569e50aadc156b87540fc6df9df04163d0788","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n## install\n\n### npm\n\n```bash\nnpm install @detachhead/ts-helpers\n```\n\n```ts\nimport { exactly } from '@detachhead/ts-helpers/dist/utilityFunctions/misc'\n```\n\n### deno\n\n```ts\nimport { exactly } from 'https://deno.land/x/helpers/utilityFunctions/misc.ts'\n```\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript 4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@10.0.0-8bf569e50aadc156b87540fc6df9df04163d0788","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-R9/tJl44AXjKI0tfrqtC7paaVtKuIlhCbRADJvdgYVYrakGf/JOAPMX8N70fmqEHH5fieHMKRYve4UcoBB7xCw==","shasum":"e536a06bf37b34dec1eab427cb4f47ed50bdeae5","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-10.0.0-8bf569e50aadc156b87540fc6df9df04163d0788.tgz","fileCount":68,"unpackedSize":309505,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhmelRCRA9TVsSAnZWagAAnroP/3ZrGblgxi/8vLTIc2cG\nPd66f8XhmqM3Nu12rkq2PWLNDhJJuq+FChSARt+AeNdTUyeEWpYhDGM34l13\nTrhhQ+AL6iMnhsz6fav1ki7Vd9o/7ABXUsH8ut3kG7fKdGIL+nLa6u3LyGgs\nP0WJHUV0ZPodJ2xJ7+IlSla4nAyXNYgglD3EPswxGfHoH4g8kACCvgwXXedP\nMRrOlMTwI9dkuyUkR8Gcxe5UPseBnRbhtbSVkR9jtehldPyHEI4wROhH/F9P\nfwGeEz7L02LJhIgl3WCEEL/udNFxrK73rGumAlvwtzrdG2kIQoBqyK8HUF+T\nMK9cwYLLOmpwe8lKOuSM2/UZapyFj4SVhwLYWgqyUsn8R1u39Cz16vMbV+Ff\nXNObT8ikQKSPxu2n5spe2KVh4O+GidGhbZRB8zPjX541gulskVk/oFFPYrzg\nQjxlg1LRkuI3fN8LtNhDy7JtV4/i+pI/hhKdcE35M059EXgrR0QTUPbiOESv\nWWaWALap11YAizTtPS691Zm1kDu0hUYM1+kR9B3x3j8Mhoj3v1wUcyXxnFBS\nkrBfq8PzfeigWeiRkdAbPrwKaeeZguW8WQ8mztwwL/sOe1n0k7f9KYfeZuEN\n2gyY7dR7IFSIbsNeLh1k6tzPzvragN68UKjkukOK+UKAJVjahlVrlbXbiCT3\na1cf\r\n=hoXQ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDfZrEK3BreJ25S+v0s3Mvrtht2PeZfQPEkqsaVfw5+RwIgJRai3Ls9KLtm3iHBBpGNCMa7kvOSKGDm6pF6/oplvQg="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_10.0.0-8bf569e50aadc156b87540fc6df9df04163d0788_1637476689054_0.39186401392589754"},"_hasShrinkwrap":false},"10.0.0-e1cf04756fcae368b6d993af342822e000008587":{"name":"@detachhead/ts-helpers","version":"10.0.0-e1cf04756fcae368b6d993af342822e000008587","scripts":{"test":"jest","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.8","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","espower-typescript":"9.0.2","jest":"^27.2.5","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.0.6","ts-node":"^10.3.0","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-dev.20211014"},"gitHead":"e1cf04756fcae368b6d993af342822e000008587","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript 4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### supported js runtimes\n\n-   [x] nodejs\n-   [x] browser\n-   [x] deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@10.0.0-e1cf04756fcae368b6d993af342822e000008587","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-aAVzyxbrlH/GdY3y+aRPquaIDTf+T00C91sJz0AbqgozXgNlDpTvIkOfIs9+gM+2SYc+YVqT9aJPXfBurATzEw==","shasum":"97a02d48c8479ce303f62c0b83f37244f13b17ea","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-10.0.0-e1cf04756fcae368b6d993af342822e000008587.tgz","fileCount":67,"unpackedSize":309156,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhmkxOCRA9TVsSAnZWagAAEd8QAJqpk6WLGn6frdZBpd6s\nygag51TwQRobX7B24fKuwgZ0KAzNCykVG1XcoSw3G/jOATq6eQbCgsQ/nRhb\nvtiKCuP3JL0kgZ2oaLKX4z8H3Dasmtg6OVWwjAv1ggul6Cbc2YJ1hZdUxlwI\nN2QlxFxiTn99IEVMwODdHx2Ds4RRBTw+flK2rJnn27FLjnl2pc+WqOwYAWUN\n6q/6C2F8C2rPehnfH2EuFrdLlCnHiJJjsxhnNfP9yoirPaiYryVACzwM8C9B\nGaIJ+EEkKK6xclsGmoU6j0Pa37nmHc9b5DjkRDDKYkz0qM9LvgyXuTnOCSVP\ntdO7SvposjtJlc+b8Shw2VNpOu6pi+eZNlfD6DCZtMRnsGJgFDY2PBTu251Z\naRtPsxL5XmfOiqPtW11Tv2/PNTEqqG6P7dwgvzca2Ks5H0wR0g4+XvLtr0GP\nNJBoHO6yYysjIXHnHPLszHX13R/2LQQzPnS70DTDlOy+wvf/V2vRIUpVoVyr\nUVicJTaIbXtEqibTCAguqK2JbP3iSgCHUMw4Ml5dFZyXi4NYdehvVZGrIRKo\nwCLR0EVKAMt4WU09mehaCY27IPAxgFNbcCu8bJYJcN/vu3XT2n3CNs66/7R9\n8EZEKDf32LRJp614AaX9vDoWtrr92PtiKRDppDGnZeYkJYSMf9OMO06Js0E0\nHLm2\r\n=sRaP\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDLMTUFwZ6kabELcC49C4esh0o/zv5i2h9/stDvWdtg0gIgUVR2RQ1fYvfqVY8q8t2U42QmBGnSLXYfwNSorcbwWig="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_10.0.0-e1cf04756fcae368b6d993af342822e000008587_1637502029985_0.2196353309289083"},"_hasShrinkwrap":false},"10.0.0-d61e00f6a8a82e6395a716a8d41e98a407f27028":{"name":"@detachhead/ts-helpers","version":"10.0.0-d61e00f6a8a82e6395a716a8d41e98a407f27028","scripts":{"test":"jest","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.8","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","espower-typescript":"9.0.2","jest":"^27.2.5","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.0.6","ts-node":"^10.3.0","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-dev.20211014"},"gitHead":"d61e00f6a8a82e6395a716a8d41e98a407f27028","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript 4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### supported js runtimes\n\n-   [x] nodejs\n-   [x] browser\n-   [x] deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@10.0.0-d61e00f6a8a82e6395a716a8d41e98a407f27028","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-zlCBrX/jhC92skZsecG54fxS8NkC7OWNCPCjatNRGUGFOTuGmBLouZ7SuJ4BsTpMvA74NXYqraEZImTUxZtnpg==","shasum":"bc8f6354c19b15cdfd63ac6e57a4b1640f3cc6ad","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-10.0.0-d61e00f6a8a82e6395a716a8d41e98a407f27028.tgz","fileCount":67,"unpackedSize":312172,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhnCtwCRA9TVsSAnZWagAAw6AP/j4hj/dn3bfXVwIYwqsL\nNCjXiOzASOfyMWiukEeU63b6NwVbEG7azDA/4P91cbFNyakm7UJfElR3HhAN\nFE/xObmTn7HUie0AfTtq8Je7Jim3lG6YQ6Qcxso5zYUdAGYFuZ1wY17GTKEo\n2Ka/oIUSUYQH5Z6vL9seTNVJEPNUQp8F7pKqwN2H0PY6DgdatH5KC30RcaZ5\n6qTvLUkVXFhfMZJZU6G2oPD25ZxfFQko0Etz/JvhBdoiu6I5+7CXzSkNaKDP\nq1o0Q7p8qBEnbnyj+DmkopH/PXNE/ThcVGkczaLCJiRDD0pT7HcbekIrwwzJ\ndDBrMeuwF82xdY2/D4S8s0LxQ3AXxO9TAUh6WIx9r8Sgr9vVt21NWTPq//8f\nyJ1VnaCK0t4CW431jB7UkM5qCQwUywFkoJv2IacivFmaH4VBqDjeg+0pIbUv\n98T6K9HnKbmn3FwahONwXu1JGH+puFllcqSHK9psh8Dc+cVeBbPDMjIUEIx+\noZ9Ga62dZC1kJSbMdfeQ9l+CMJci4yuQ3D33HezFg7KSJjj0HZTyOiwMms27\n0ZYAjLd1KxC/4teu4kJG6gljo5SQDInYIlVhGdYaWVoGJdW/zExBue9LOJya\njt/7AbOHSijMXOufGcf0qdKJ5RBEUJLNsDMegCexdyyK9qv8Pymi8iF7HSa0\n4NLu\r\n=3uBE\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDSnNWBKIXZIRD7M9J2HqT/boT9xYrhwpdv8dmvmwpqpwIhAM1O/9yBrnRb0y2KIcpr0DluLGkE9ikQyZv+j9BU6OSa"}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_10.0.0-d61e00f6a8a82e6395a716a8d41e98a407f27028_1637624688601_0.5012168000999391"},"_hasShrinkwrap":false},"10.0.0-fa181fb376601bf0f3e0e16c3446b5661aa0bc43":{"name":"@detachhead/ts-helpers","version":"10.0.0-fa181fb376601bf0f3e0e16c3446b5661aa0bc43","scripts":{"test":"jest","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build:commonjs":"tsc -p tsconfig.commonjs.json","build:amd":"tsc -p tsconfig.amd.json","build:all":"rimraf ./dist && npm run build:commonjs && npm run build:amd","build-and-lib-check":"npm run build:all && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.8","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","espower-typescript":"9.0.2","jest":"^27.2.5","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.0.6","ts-node":"^10.3.0","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-dev.20211014"},"gitHead":"fa181fb376601bf0f3e0e16c3446b5661aa0bc43","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript 4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### supported js runtimes\n\n-   [x] nodejs\n-   [x] browser\n-   [x] deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@10.0.0-fa181fb376601bf0f3e0e16c3446b5661aa0bc43","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-JCw5iRFnzGdDdzJPMhhRRfKG4nhLxVY6abkMKRUQUnVtfprtaJ3almJUkG3gY4+6LZL8GPA0owLguSe/mXFNog==","shasum":"280c5de90640602bd768a2b7378db0ab1448f384","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-10.0.0-fa181fb376601bf0f3e0e16c3446b5661aa0bc43.tgz","fileCount":119,"unpackedSize":531473,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhnDYJCRA9TVsSAnZWagAACkkP/1t6YwZSyTCxfBSkDxfS\nSMQ9d7c5GG/Zpw4atDWtR/gbEqTd5iW40RgWFKTCT8qSOOGUaPkU+3iV6Rfa\n59L9e7Wgewese8U4D8pN8flI+KJ9GaHP0kGZ5EoL5iWbLpEZ7cEJ4e4d3zsB\n5EMYf+4f5T4+Far7X/yj/qKMkxNs6mQH7ZpEAaHne9vQ+HLsMCYfs1OKZRKh\n1vIeZ/FOHVY0+vFypHJbjBKXGA0jXhPtq4cNPYlywkfZhvw64V9Sgo5cUYo5\ndhaJ8I9wYDkJmzIZDm2VOBcRSjejQvfOD7vv4RUQcMMOUGFZ0Z055MnNlR0t\nxA9MDelrLawdXCMSuKoWXqkTJDAKPC35MedBMJHTQIJswpdh1PDQPZkp20mO\nBqcj3K+RZK21IyNORIb6uuAE2B7U3IR4cj9o/pm5wKC7zEvMFXwY6zBqjnrV\nQjoCg7EyFotZIOBqg4+OrMM+H/2V+94fG9bknvYW7Sea5VBFxai4JWpBJKWn\nUI1hmhGQKNGLGOWGhf30nYGEHCdrhK6Y8Ap19i5cNt89oMrpGf/tjPSDJVF7\nZIrFPjd/pWDFMsqEZoBPLIGZOfgBy90XdTC2i8mG+8Ztb820ZWQDxAjA5IOm\nQbuaQ88HOnbhsiWUQ14w6ZWhIERfgGmtnAMB2t5KsIvNKLSLQH/jsb0aCOTr\nVLgU\r\n=KAeS\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCIs97AS12a+fvVEQcpVhYgAQTI2RnUsgWDDMsdbr0cJwIhANJ/ioZyeHG96UamvI0YeiBxTGKrnGShq0wEciDqQzgA"}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_10.0.0-fa181fb376601bf0f3e0e16c3446b5661aa0bc43_1637627401537_0.17394665957520528"},"_hasShrinkwrap":false},"10.0.0-33601ff5a33f3339b12ee231878af3913f1cf3a5":{"name":"@detachhead/ts-helpers","version":"10.0.0-33601ff5a33f3339b12ee231878af3913f1cf3a5","scripts":{"test":"jest","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.8","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","espower-typescript":"9.0.2","jest":"^27.2.5","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.0.6","ts-node":"^10.3.0","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-dev.20211014"},"gitHead":"33601ff5a33f3339b12ee231878af3913f1cf3a5","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript 4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### supported js runtimes\n\n-   [x] nodejs\n-   [x] browser\n-   [x] deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@10.0.0-33601ff5a33f3339b12ee231878af3913f1cf3a5","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-8HplYOmgDZy9G5Nlih2l4X8/jEoi+nbV0mye5crxGrWkaiNILFJhVyE6SvYM5hrgxmBd+/wmwTwkK+SJLKTcEA==","shasum":"cb00b90f52a7cfa10725a83fd398b7dcf104da94","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-10.0.0-33601ff5a33f3339b12ee231878af3913f1cf3a5.tgz","fileCount":67,"unpackedSize":309732,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh7fmXCRA9TVsSAnZWagAACVIP/3GMKJUs9H0z/QvWpUOK\nOPZW5cQ/9C+1s31H06beAFPd2m9ZVx1yfJKvUvjhIE0ni0Tw0a8+qeGkiCzj\nkuCakn6EfRYfsk/AEOOXvfEjj98IQxqrK2b+PlaoURnbjZ7Et1a3Y3QzFDu9\nOkCbyDf2tXMTkMzfmz6gs5Q9wscVqbynR1BduRKJj+lWMsXDDeHwsAErAINM\ns1KIOEDG/ARLGZQO+8AZ/WJ7msaaQqYQF3zWwHQKqao4rcKFJLRtu6dYjJnI\nE9bvqBIDWA7mw5e8a6LNYDTyuK0AzTtbltERfiIRYUNPblfovEORLD/xb0Sb\n1rZTKCpd2DIYHh5ATsq2IULNFbeSdjnjYrsZtr/CVkGkyPVdbRugZ+sQXfwn\nQ1xCNqntqDdSNst7FfP0G5meH/i7gStFMv05D7gpMHb3IMLfE3bnWegHDO2f\nKIpG8rkiugyUu7Tg0lsnBKt6vb+co1blixQor1S0eaLY6IRj+MBc5attzwSn\nMOBgnoMRFr6CVWzgDogVxF6kkaTocBu3K38Cc4vZ6TD0Djd1AbDIyeJNWevh\nKsf8JD9P+gjMYBG5MTjbtvHwpJwAL9aU4ErKhplNAhnk+xN4fV+j/crOwCa8\n4MNs8CQhwGqmaMN7+PgKk8Iswy2Ah5Gp1Og6iRy0MisKacM2Xw0+eQUw3oqy\nq5Il\r\n=s+1y\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDTWGHDtRpx8tvymxn8CoYXKGpUzR/vS6gdw3Eoqp06YQIgRV6/sfx3U2D5c6PPIcpf+d2kINZNztHi5XDGgjDU100="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_10.0.0-33601ff5a33f3339b12ee231878af3913f1cf3a5_1642985879184_0.8318014517268335"},"_hasShrinkwrap":false},"10.0.0-1fc2d938ad21e56e82ba21e25a8ae821ad9f6424":{"name":"@detachhead/ts-helpers","version":"10.0.0-1fc2d938ad21e56e82ba21e25a8ae821ad9f6424","scripts":{"test":"jest","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.8","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","espower-typescript":"9.0.2","jest":"^27.2.5","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.0.6","ts-node":"^10.3.0","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-dev.20211014"},"gitHead":"1fc2d938ad21e56e82ba21e25a8ae821ad9f6424","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript 4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### supported js runtimes\n\n-   [x] nodejs\n-   [x] browser\n-   [x] deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@10.0.0-1fc2d938ad21e56e82ba21e25a8ae821ad9f6424","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-f/rfI7fMfpwWM0UcGVfDUpHFS0dcRpiWp2gkNkfxoJhA6xmqEs4nAv7vyuIwFb+cgcPnbiDQBrShkkE5HTAz8Q==","shasum":"1ee15973a41475a12d17be088e8de50fe0c7904e","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-10.0.0-1fc2d938ad21e56e82ba21e25a8ae821ad9f6424.tgz","fileCount":67,"unpackedSize":311253,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh7gVcCRA9TVsSAnZWagAA7SMQAIPrMyZCSGXf0ong8coa\ngOL9SyTVy/BkBtIis6STyXKMjJGH7WJIzjmQMwCFTXyWk871J5aRHurSO/y0\neEaFh14sYVDPFWgyomwyDpEMr+RtmvJUTRlNi0RDmOgkP0qHRqKIN7agqadq\nEegCwFdCr5ODMIaFWv3G5UYj1mTCJ0Yx4yqcLfrxyI1gOMCJu++ZfISYp70G\nbyV5jnftXsPif6P17QQzHTp7JLMS5qHETL442sv2b/g94mlm5Si8ML5tXUSI\no7NjSpoz4kR1MHss8re+B8GCxckvXiDhjHuBvtDF9C/TqdwuwEA+atHQ/bbb\nZJL1mi2NVt/Itz0bFUI1YtCXwNkpDPqagwGvmvoIf4N3xriuN8We/1IrDV/j\n8GxgB6DkGelwHpWO42LyK7VNECPCoNQgyYBfcvzw02w77ZD5g6wxKBp4QsI6\nfqs7vnBqzsm1UOsAOBJbBL8EvP2sRfu9q6kCHw5yAnIEpqqslf1wQEgKWLvm\ntAqY/RJ1v+gO+a4osUgh0sUEVUNFZNQrkd5mEDJkGz4i8NGyfMhX22yx5haX\nvF2qcwcS/NwRhzShyWpIiUJYdAwJtHITWJKoCnwJesGq4BLnHgPMtu5KQHuX\nR/qHfO09sXvW+wqiQernhOVqTB7S9G4ufZu1ZGIcORuBPDIFCsUU8jvM9YK+\nMaiG\r\n=FXFK\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC3IpB71e0JGYwxQnDWftYty/J65C/oWeYP9i5u05qX8AIgYKCP0iEa5sNe6Vg59UkpBOO614Xgz/etaX6ZSYmSaSw="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_10.0.0-1fc2d938ad21e56e82ba21e25a8ae821ad9f6424_1642988892489_0.4717061662530362"},"_hasShrinkwrap":false},"10.0.0-7a3c319a8e83032f4869d721744829b80c53e10b":{"name":"@detachhead/ts-helpers","version":"10.0.0-7a3c319a8e83032f4869d721744829b80c53e10b","scripts":{"test":"jest","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.8","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","espower-typescript":"9.0.2","jest":"^27.2.5","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.0.6","ts-node":"^10.3.0","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-dev.20211014"},"gitHead":"7a3c319a8e83032f4869d721744829b80c53e10b","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript 4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### supported js runtimes\n\n-   [x] nodejs\n-   [x] browser\n-   [x] deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@10.0.0-7a3c319a8e83032f4869d721744829b80c53e10b","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-H7VbmxwvpVCAEuqwoBu1+UNEQx+dvgy8St33uhyfYviF8m776V/94B84nPIRS18SFmbHmaPYazBb/VNkJGRSwg==","shasum":"92f994b798144722c16094a808d0d56a816d0c69","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-10.0.0-7a3c319a8e83032f4869d721744829b80c53e10b.tgz","fileCount":67,"unpackedSize":313246,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh8zW7CRA9TVsSAnZWagAAaiIQAKN3xeLDQXEj/WTMC2GI\n/QdxIJHBvYJS4+U0oKfRR6eConJUbYbAgu5LPNTcv+x27s/LEuj1njvnPmae\n0cUWbKQ9EF8gdegft/OFMIe4LelsrJhDCHb55e1W3i/goDlHgVNWlAI9vqfe\nwTAQ+Ni6U0RGO03Cv99+fT1TTMQkbFnft++njps2oLZYE8ue6szIWibFh7pm\nI3vF7r+eX+/whAc8IZrPoQxAvz6O2JTKIHqITu/n+hgX8AfK5JaRWOrLW/cH\nM7fw+Fwttnb2WJvvtFSIs0Z7cfkycTTBdMxtxrOejVPqm8Q5c3ye6JB+XWbE\nQwB2qenPzcB2GUCe4AlYfOwEb9z2qRO+YTEkWPlT2zc0PxlHkfEeShop7BYp\nn5siYN6SYvGUKTBto+05EkAlDz2qkE9C/EB0KsHqeDj0O7CQykRX4WEVRF+2\nY5kxvbQJ56OvDXeWfd2IwzZgmJMnsC7zEFD5bCC/DR26SsOdSKFSJyiZcp3g\nerxu7+hVqPXna1P946QQivKTsKWcWYndzM7DulTZoxlx/Tsj9EwQZ/veMzuV\nt/WL7r1LGsumiEaWqP6CaL68R4L2vkdmW2bJ8P7c7k8rxSfoHTaRgAqytPDB\nVEy2Ply+QqFEamuqgEwZiJE1aro8pUhijne4vGiAieOH3NAGKALYpYjU4qvK\ns4+V\r\n=LXIf\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICO3HURDLpV4Fn0rmrqNejhpLgWgHtNzOIOXfp1B/ZGpAiAa6VdEMBRvPLTVL7r6Bi3e54Mcwd0Z7Rf4QYQCAdyEQA=="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_10.0.0-7a3c319a8e83032f4869d721744829b80c53e10b_1643328955191_0.6990641819000034"},"_hasShrinkwrap":false},"10.0.0-9e128422305d65cbd9cf50254ef2d994582ff216":{"name":"@detachhead/ts-helpers","version":"10.0.0-9e128422305d65cbd9cf50254ef2d994582ff216","scripts":{"test":"jest","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.8","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","espower-typescript":"9.0.2","jest":"^27.2.5","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.0.6","ts-node":"^10.3.0","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-dev.20211014"},"gitHead":"9e128422305d65cbd9cf50254ef2d994582ff216","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript 4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### supported js runtimes\n\n-   [x] nodejs\n-   [x] browser\n-   [x] deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@10.0.0-9e128422305d65cbd9cf50254ef2d994582ff216","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-tcOXLCYyI1kJmSv9GS4xEn+cCFwCgjS6GkJxg5mnJl4l2Kn7WAvJ5wl6V5Zw0TW5m6Wfx64v8Pot5zcj1FgZDA==","shasum":"ba296c59a63fb6c79e83e05e8dc29c85e26d59bb","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-10.0.0-9e128422305d65cbd9cf50254ef2d994582ff216.tgz","fileCount":67,"unpackedSize":317538,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh80tnCRA9TVsSAnZWagAAcBUP/j8uAIxZFat/plcAd0rD\n4vLZv3J8/6RmKfJ4irMqJlXGNm9pWTB5b8vy0UliYO0F1BZGKkag9N+sASDX\nalJ+EcSpvMnFZvMjAbSuSMPHVs9xZCR7uHAj5JgmL/PG3l8mGs1jxyEXCQkx\nh1DkekZbsTiKGW7LKLM6aHHPROpwZwk0dwooWUClnkOmxopQJhxYplon1w5Q\nGYOOcHEmxXTK5oWz3ujcZSahQd6qdzc0BszTj/okxZ7+dV+Tfkj3KuZwubV7\nhzrOND/9BtrzXVRjuFxEXuOnSRYQzz+2DlW08gNyVkyGpzpfppqm4ahVKw3L\n2mMmPuk+0VP1Tiee5FAKjds4nmwQfkob6WQm/nW94W+BwDI6KTzl/slpdDPC\nNOYbhXwhLhCs3TonGt0MzEpVFO+7j3Hso780hlkEHDMnNTZylnJZqo2m3rrg\nmaNwp1GJ3Fp1TqSwyR0wdo6B0UQBE5DVf6jrnGA8P1prTe0mmAXD3KcvvyD2\nfHCno5CF6Yr/P/d62Hcw7DN0YrUkdh+5ReOCnLOZKMyGxPXPINEzUVsNQrZG\nlzFU67auZBJBUyBOeHmmMRhK5NdrvpOM9DBw/VcsWG/wFwpWUVKXzOr8YSi5\nyd28+jqmbPIqG12EFdzQXy0Tgd4vofkR4UxTQAvc4YXUxQJt7XwQnBp5ugYX\njruo\r\n=MgbJ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAqFMTBgfUsUiqiyVhLeP6wr2lwqFWrJ0JO/0HpZKGxTAiBVsJ6dVfeWZHSKZeU6PA8/py1GgZ/gb/xVBReI1G/bZw=="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_10.0.0-9e128422305d65cbd9cf50254ef2d994582ff216_1643334502993_0.48917794207531506"},"_hasShrinkwrap":false},"10.0.0-10f63434d1bd72c8d86a912a3595348f5bbf88f4":{"name":"@detachhead/ts-helpers","version":"10.0.0-10f63434d1bd72c8d86a912a3595348f5bbf88f4","scripts":{"test":"jest","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.8","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","espower-typescript":"9.0.2","jest":"^27.2.5","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.0.6","ts-node":"^10.3.0","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-dev.20211014"},"gitHead":"10f63434d1bd72c8d86a912a3595348f5bbf88f4","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript 4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### supported js runtimes\n\n-   [x] nodejs\n-   [x] browser\n-   [x] deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@10.0.0-10f63434d1bd72c8d86a912a3595348f5bbf88f4","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-1aV5tpTaygnAxQTGtFpbuTXUvQWbil88bj3ABMdFJ/K2KmqImFLpxAfMNAOHvCcxRa3BfdhHfPqpMgImrsl6NQ==","shasum":"9a29c17c2f22294a1722b1f5480689a896510404","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-10.0.0-10f63434d1bd72c8d86a912a3595348f5bbf88f4.tgz","fileCount":72,"unpackedSize":322488,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh83gxCRA9TVsSAnZWagAA9gIQAIbAVbREpgGZGTtFsiFV\nwM8PM78N1VUohnnH+bL5SnZ1tDGhq+kRbT2g8664W+5hQl+R9XKvm4qamiiT\noQNjYch/niQnlYYxYCSgAjoVso2f5zchhqgmL3tHjTCXIHXO66It0YQT+s3x\nvNBsO0+yDWgC1ixgWpj9eVlPljl8Wqch0XLPaM1oBoE/ttaKeotraqlJeDST\nduSc2ciUKbZEBm79uGxSODQPs+VaUfum/8bI9P2QfvTiKkKvfqQDqhRqpyoN\n87PScbauPhQD2gzs5Ow1qK3AUdD+mCeXc6H+EXxl4+52D+Cycxp6euLsTPre\ntJY6n2IervyGUC8/sv9AqrMmsuotK6nQ6FqvTP7xxV68vKd+ElYR+NoplCrU\njPTJUfTRFCWJrQqlWZsmU6cMKnMdkinpOT4fLjVUjODbU2h874Dn3QhWSoja\nBVPVLvoMC3BKnbHLfR/rSHICO1US52sCSi4qU9Q0WmPxa0Y/gyKASWa+5+7g\n7by2FwaTVTY3S0gI9i5pY/9aC3zI/Vf6ymLiHBHzKLV0nhZ6FZjiQE58OfNE\nCvtgaqdQ/xs4fOh7yTnYOUhhwDEVUWkN70n+o5Gw1WDegUY+cA1A+Q5/0hy5\n11dwJXJs7ewxF3kzR6f3+H2gqm19QHCBBXzwD9bVvpCBINUFIZs4HclPwXvo\nGQQo\r\n=GX8G\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDfhLNEgIkb+ixcTOQVAMTlSRfucgzkxivLqewy/eJkcAiEAgwiueLu1PZDJmvWBwZyR338Ye/PqUs3a2n/H6tztDEI="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_10.0.0-10f63434d1bd72c8d86a912a3595348f5bbf88f4_1643345969486_0.4099702410272783"},"_hasShrinkwrap":false},"10.0.0-51ed9a74b1a0098157ac9ad7f898d4191cafbb92":{"name":"@detachhead/ts-helpers","version":"10.0.0-51ed9a74b1a0098157ac9ad7f898d4191cafbb92","scripts":{"test":"jest","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.8","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","espower-typescript":"9.0.2","jest":"^27.2.5","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.0.6","ts-node":"^10.3.0","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-dev.20211014"},"gitHead":"51ed9a74b1a0098157ac9ad7f898d4191cafbb92","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript 4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### supported js runtimes\n\n-   [x] nodejs\n-   [x] browser\n-   [x] deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@10.0.0-51ed9a74b1a0098157ac9ad7f898d4191cafbb92","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-qTbfLZNhWjbbRZWLXZ9uVlQvd20qG9+q/gSn6Qlp7HYKq0xo32fOaaZfIl75OxDYYr2Oq4YzdBlmYje6yvgVaw==","shasum":"b8425757dd7b5c457f839cac8d58a2ab0364331d","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-10.0.0-51ed9a74b1a0098157ac9ad7f898d4191cafbb92.tgz","fileCount":72,"unpackedSize":322660,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh85PbCRA9TVsSAnZWagAAQAEP/3HohMuMviOfs1TxpTWy\ndlRnd9C/wa8sBeB5/FcW2oQjrQ7U4vP0UXZTt1WuTLnNPzHG9plqqC2upUdo\n2tSjshlphI4cSLs63qypMCyZwCHa2TGznwMsI359RBZEA5YTpF6LZeAiCg4j\ndObaxj2yi4vsyocK2PEq/vAyrkTZtYnRUCpyorFg3r0CnIeTWIm8bLK1Exbr\n6pCIXlgpowB9YXBWpbjUGkbaysjxIUjubK/ZbirAl0lYEaVMD0HTPfpIVTTD\n+HELvgO8plSqgqXpxjf9136EmJYVfHmuledVYpzAapvnvFmB1MX1DGjf0hIX\n5oawxRlnFHVkz7ivesI8f+nTkMiaavoJGq5ksqx+2UhVQHmZHl2jw39TDg0o\nKScnoWUKxuJH14QI2Y8S14l9/tUu/7cXbOE8x7a9sSMiTDo2P0c1VtR+iQUH\nOYtfEDKURcHB/pepaIW/aTBog4cL9mhAcuyReScnl7MIt3oIzE7N0AIt/vho\nINuLx0b4fEdZFywQpIvzvN5fD/B6oUwKZe9zVnoyha51ZIh9uMJA3ljnkH80\nBqqBn2V42B8M82xKB/U/zne73GKFJ8MHgIF7UIFJXWpZ4pER5hYT5RaO6zDY\nFRKG/MhRvLcyRCP4KC1tSTqAP/t8fplFu1RQACag2DCbnnw/hIHqqcEPVp80\nTIj2\r\n=lCw5\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCL+3t+6LkcLfALlJCvPzxsPYaZXxh7EkC2HUiz/GilrAIhAK21apuyOxlKk9o9tF8Hl3cbE8IRnB5VuxvO7jl99mP1"}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_10.0.0-51ed9a74b1a0098157ac9ad7f898d4191cafbb92_1643353051475_0.7522331611154705"},"_hasShrinkwrap":false},"10.0.0-f1b2c9d4466923613fcb7215b058064f25b79905":{"name":"@detachhead/ts-helpers","version":"10.0.0-f1b2c9d4466923613fcb7215b058064f25b79905","scripts":{"test":"jest","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.8","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","espower-typescript":"9.0.2","jest":"^27.2.5","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.0.6","ts-node":"^10.3.0","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-dev.20211014"},"gitHead":"f1b2c9d4466923613fcb7215b058064f25b79905","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript 4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### supported js runtimes\n\n-   [x] nodejs\n-   [x] browser\n-   [x] deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@10.0.0-f1b2c9d4466923613fcb7215b058064f25b79905","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-x6C1ya3m2czpYUHAsiQLTss8haICLpthYMFgEeBIMHqNP4xV8DQz0Q9E6haNwvrZ99NEg6tqMcFtVh1Z9ANqvg==","shasum":"063c65d954d141de608b2445aba7d1e3ff38770f","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-10.0.0-f1b2c9d4466923613fcb7215b058064f25b79905.tgz","fileCount":72,"unpackedSize":324324,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh86NICRA9TVsSAnZWagAA/8sQAKO+L6p8DKw6XB9/9nba\nrexSEW1WsTpv8dpameecAKLRnoDfJO2Xt2R1Flm/kolECH9GPqNUdx3uCbTt\nlcZnBIqSwstxnv6yvuyoNs2khIju2jQJtKCHECZ/7fMWCqEqwQUQVSfYq5Dk\nQPUBeCeYaI764SfOyvOpLd2NtXmg/wxaZRIvLpJUpO7hAQ/2KNtDqAfRgvdJ\nY5Q/pLHQei2gTGi3k6IJ+KNM84jir7r0BHQmgDSXFGkNMyowsdCKxvgZhFLM\npCSr9vh2oKuzZsxeMasgWalwWBApGTRG2ENcz80OMFIlnDvaZkpVGzW/XJDm\nkZ3G9Jc0IZlCUZl9i6tOCCp7LU17WilH/5BWcF/evteNmIyK4hEM4VUwSRiH\nx4BLmowzUt+qaGKhihT7fv/vbvPv6ewGWdSfBLyFqxESv6opHHnYAryaE4DJ\n5RWBnWjaPRuliO8ypmSXf+qO0kKp/1+26TH1qB5FhlQc57NmYvNccaZVLmPv\nLNXX+fR9LdQKGrbXXbtewcVpJjzys39lbIJ9zr5E6A5kmNYz7GHnUcMfpIod\nIWxHWEcrawqx9176bgevK2jCQ3sVGuJqXZpJ+DXR8XdM/GO10zgq8FuP2z8h\nfv8OUgBrZO+DS1eaTNKMoylzsRIzJTueCPRdqWIMb5Of9EKWTxc49ej/2Tv2\ny9ju\r\n=IvLc\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGP4piASUit2TzJYQ44EzZy1+5LLEIZiZL6+Qh2qQjJNAiEApSs4e80/6JO/j81zKH5Q0h41UkmxHZKVZN8ZJzYiPHQ="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_10.0.0-f1b2c9d4466923613fcb7215b058064f25b79905_1643357000634_0.6278345672642065"},"_hasShrinkwrap":false},"10.0.0-43f7d8067c85d9939d4cb88d688f4cbbb06c9ad8":{"name":"@detachhead/ts-helpers","version":"10.0.0-43f7d8067c85d9939d4cb88d688f4cbbb06c9ad8","scripts":{"test":"jest","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.8","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","eslint":"7.17.0","espower-typescript":"9.0.2","jest":"^27.2.5","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.0.6","ts-node":"^10.3.0","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-dev.20211014"},"gitHead":"43f7d8067c85d9939d4cb88d688f4cbbb06c9ad8","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript 4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### supported js runtimes\n\n-   [x] nodejs\n-   [x] browser\n-   [x] deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@10.0.0-43f7d8067c85d9939d4cb88d688f4cbbb06c9ad8","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-V7YoNStEQ5Yz8gi4xL385zqejJNNu/+YyrlOSVn3IX5hEb8Aiod87Y6v4QHd4uq5KLo45NK9b7aHAEpeCTrKFg==","shasum":"e7d94e780f421509bce8fbaea6628534ad90f98e","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-10.0.0-43f7d8067c85d9939d4cb88d688f4cbbb06c9ad8.tgz","fileCount":72,"unpackedSize":326438,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh+ObtCRA9TVsSAnZWagAAHzYQAJNxV8EXqBJ4Wk8SNoDI\nLz2vS6bNZ2VgooeMoJKgvtmcpnrCbQcF8cjm/Tga0kFEkDRL4raQoTiJzsBl\nDOEsjjfryjQXVCALsybF/1JjaLQwG9+XGQN5GrgSlsR/ELeO1HIVQ6yYacK6\n3vgw2nW0l8UXgXP4u9B/xd6xZz68Qk2nKEOxMl8qoER5MG/uuNTy29rCTkAM\n9wxS/vCJtmMlA+58MHqciPqlehrB8db6Aqe+9UP6mAoXRJuHuD29cWiO8kIy\nhLR7g+pe/Iteuzt8kDBbTFnZtKIMkkHiuPnFwANWkx9pM1+CrjyrpkY2Wlap\nSI7pTcbI9h5JtPu4e0Wh8W7DU1mIlofNwdF7BNmspuv2+yvQfg0PsxR3PeNI\nq17nStUjjXa3tgOWSBju+1DcQmlfrD7Ly7E0Ezf7Eb2T6oQYKC1L1hdD3tnG\ngaLQWDk5Vd8PdvDnrHFjfo8tU0ma2nlWx6OLS159kNTUvEVxVed5Jc/jf5Iw\nWNy1Jh+a9JpNLkQ2EqfxdzH9dB2/SDq01XH3RBEw09FRUMBN1+bTgpriO+Hp\nf4GM1ZkLKVKYhD9sksmsDIZOwqLfQwLc78B5YHaVbiEPMKtA6Y/sFG0Z/yk3\n3s092d/bjnHMu8XhQ6Lua8c8SjylcFdQc95BkD0y994TSS1rM0rwjucnAcWH\njrYQ\r\n=LyxM\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBqn45RPX4JBdtE1Pua1CGN2+F1EVVV63x5pi3lwt/9PAiEAhI913eht7sVCImEv0WgBvot9bf7whrx3jUQe/gimeUA="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_10.0.0-43f7d8067c85d9939d4cb88d688f4cbbb06c9ad8_1643701997707_0.7624916015100338"},"_hasShrinkwrap":false},"10.0.0-7f5767d7af52e84e3f78f34b4e3339fd1b666982":{"name":"@detachhead/ts-helpers","version":"10.0.0-7f5767d7af52e84e3f78f34b4e3339fd1b666982","scripts":{"test":"jest","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.11","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","espower-typescript":"9.0.2","jest":"^27.2.5","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.0.6","ts-node":"^10.3.0","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-dev.20211014"},"gitHead":"7f5767d7af52e84e3f78f34b4e3339fd1b666982","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript 4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### supported js runtimes\n\n-   [x] nodejs\n-   [x] browser\n-   [x] deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@10.0.0-7f5767d7af52e84e3f78f34b4e3339fd1b666982","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-vCmCPbpfihGpiX7S4tULlJ3JZhAhW0gP1r7YUb5FOXYu6yAMJJQrqsE2o0mATru9qHhDqj6w1z20tmQ/Y2E50A==","shasum":"a35a02c68e181833dfe7223877c3ad20b8d9dc1f","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-10.0.0-7f5767d7af52e84e3f78f34b4e3339fd1b666982.tgz","fileCount":77,"unpackedSize":329805,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh+R1MCRA9TVsSAnZWagAAGHoP+gMsfQq2P4mTCoLjg5Tq\nJx8Dpiaxm3Ttiu0UKW35yN5nKGk+Yq1FGJKtaJ8pPTukPWYs8X7TFgRUM/9i\nxEg1USZme1p4S8LRkGZfDVpvybhnjV9UTcLKeYyKeoLiI65r4groG7ENY9xV\n9pE74wfZLEptzWBUENOdFownJmUqCwrQ7r5tAasIKv9RnZKEOKBHRHkMo2Y7\nF/mPaZxDKvXlXWM5if0vWXgOG4a29IBPOJymj2SN5cs5VpAN8kxgfGJAKeTL\nZfY3WM4xPdtqkAhzD+4l3oBQA3zwjgf56uIM7aQRDcB0N+OlHlimrhHfokdC\nBpqACcIjI2k9cGaxr/uUzIrqMh4ry7ACaQRV2oZHFj4Tql9bYuEdJPFCMt/6\nkeCaLdlT5GpRCFAHIQKtG3TbN8GNEoRPdBMQDwsQ33GzOMk+GPdeuIZ5pFEu\ndwy2MBs1ExdbtnieD2v26TdROXhAt/wEi4V0s+w//KdrqfaiKqrV8YajJeOc\nTFrwPzHSnwP0bA5mzB5P3um4BBUiXOlyi7nJkkRGPptvUYDRVJfDCRphcoat\n6XcXBbEe3OSI2FszPPzTmP4QsMr0zet0YHgNuYrKFCPCos7T4Nz+gvcJrE8J\nKEjZtDiG6cubBc3pLzZm+wYqfS9/8Av9J6XgBPhJfwR4JmSKGTRPU1BBvoRR\nRwuO\r\n=fc/0\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAY0+uUnfKYV1ZKQpdgsN0fKNflE+Cl7XIQwRQRaYsqIAiADlYlB0z038zhtSRqEHpDqM0WOG5yW0P2gGeV4BHaGMg=="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_10.0.0-7f5767d7af52e84e3f78f34b4e3339fd1b666982_1643715916620_0.982181409903341"},"_hasShrinkwrap":false},"10.0.0-aa3e476b4e3a6ec1696942d0c4419c8881344531":{"name":"@detachhead/ts-helpers","version":"10.0.0-aa3e476b4e3a6ec1696942d0c4419c8881344531","scripts":{"test":"jest","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.11","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","espower-typescript":"9.0.2","jest":"^27.2.5","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.0.6","ts-node":"^10.3.0","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-dev.20211014"},"gitHead":"aa3e476b4e3a6ec1696942d0c4419c8881344531","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript 4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### supported js runtimes\n\n-   [x] nodejs\n-   [x] browser\n-   [x] deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@10.0.0-aa3e476b4e3a6ec1696942d0c4419c8881344531","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-z6+GGrGbEAm8QX9CgQZD+V4a9+E7g5WnHb5xdxDKbZCi/M1s5l/grL9oRk7grRlExLzi2wub3ncMhmimWyIcPQ==","shasum":"2dd7b76ecdcfb8e2aec455426003b5da183d6f53","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-10.0.0-aa3e476b4e3a6ec1696942d0c4419c8881344531.tgz","fileCount":77,"unpackedSize":331480,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh+gGJCRA9TVsSAnZWagAAe34P/RAv8Xh3Sv3RLn60VhD4\nC0GoSWjrm2Vm4kfmRuNWZvwpLvzPof4NU5+n/SuznamF5k4QKlThXlezoLdl\nIXaTV095bi1U6pqz0j9WNZxshnPREsXuZAYeG/MoNfq5EKF9n/L7XZVvX3EX\n041i/tzR3Pzm8XL2+aWpahrcmPBJtujnkLKMDSfaHMZh2S6c2bUtEhIu4X2/\nrqFIUDve+3FcK0/I/BSnlw5e83kXEaEfOpgDJ7czv/OCh3Ifo37nJFAp/1vl\nEzCl+bCit6bi3v9IVS/pec7QKKkAUN0mvVu4yJBOdNJjl6gMAG5PENxzXEbS\n4+RtrGUz5JPIe50vtOy7n+t7erAestOCuQ0mExknvzNFiQjLbuSbozugYz43\nze17N7A9UpOBz7IYu4q2wQkmVFazLLVKh+dsBQJnRJdvUfJx634zJniWBn6m\nQSkswYJolTSufFQfCBIQ5jGFsUJwf28jgyqTJcybaCMvD/pz8P7B149Pan35\nDx6GNgObgH6lF+rxKHauded9pBdsuIK23RR4WtcNdcwGkJMMCl+8SOxhyqXY\nNRWDZJMUWrKYX/IY7BtqmAoWA8HpsjUSFmVN30l0hGgBlPZ/QulLnoWTFBIt\nHrpqr0ILoH2yICZLS8lAdqQd8MPoBMaBQDT+STw/9Ra92Ri1tb3kcPJwrMPK\nJ8kX\r\n=tLsq\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCwlcqJ2kD9d2LAj2oP6Ox3mk8xdgyZ+uboPewDt78OQgIhAN116ngcqjKqPeLIHL+Jak1XY6L3bhes1F5RMQsBCAzH"}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_10.0.0-aa3e476b4e3a6ec1696942d0c4419c8881344531_1643774345589_0.9808248206706134"},"_hasShrinkwrap":false},"10.0.0-16153cb1c8f6d906b3fd3b2d4a834e25a8ec2053":{"name":"@detachhead/ts-helpers","version":"10.0.0-16153cb1c8f6d906b3fd3b2d4a834e25a8ec2053","scripts":{"test":"jest","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.11","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","espower-typescript":"9.0.2","jest":"^27.2.5","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.0.6","ts-node":"^10.3.0","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-dev.20211014"},"gitHead":"16153cb1c8f6d906b3fd3b2d4a834e25a8ec2053","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript 4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### supported js runtimes\n\n-   [x] nodejs\n-   [x] browser\n-   [x] deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@10.0.0-16153cb1c8f6d906b3fd3b2d4a834e25a8ec2053","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-uQwmFy4Xhw9HJvLN55HaZT+RKHh3VrVNw+U2EMyH6+UulCx0rr1idje2FaWCcMJ/it+c99pUfSqtPHhOwXNiaw==","shasum":"89dbbf358e16a0a38bb4e0615fd8203419a43dd1","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-10.0.0-16153cb1c8f6d906b3fd3b2d4a834e25a8ec2053.tgz","fileCount":77,"unpackedSize":331579,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh+gndCRA9TVsSAnZWagAAbrkQAJWhu/vgYC5wUVftofWi\nP0i+bqcibykhuY4N7MkwY/J067CW54WvYrEgf9lFdP2Ot0ZM0IoBJxW8atRb\nhgYGoDNBR1/FUpZ2M0/tPHJYNU/gi2lLuZVQyHFKhT/Ri5vlbnlwgyBphys0\nnF+LD0frKy2G3FMN66kKTwVf1KQ2K79G3PmhGljDcd/0TUU45470ix9tnTXZ\ne5q6XO9xHuGTUNRcBn6fPzmolFMvenNmteX/diXl1pdZ3yipq/tJtudmYeWL\nGewcxuJ/IApC6tP6hcxgyG71qpZfW03HU22ftOKoWpBduwOZd0XpQDfqsAua\nb/tM8rQEladhH8juOTkYLhj1YDmC7tDWBnn3XrDaSIpFzjAfHH43Q0RdIET9\nCqSeyHZDVHSsoZUvom1viCFNFAS4y9GWFR35woMH3rJOgWBBgx01FLGUv0jS\nFjUJiuPrf+KXtohnEpXtKFFMgx5IHqNLMZghzB9j+QYwfFTXqpW3VotxW55S\nEUYv1LFIKHmq2jllMOpFT/K0AqNrKJGyGKCFyWjO+2RCIIepG/XUDFzzzQUe\nA3Kzp99vgdO2GCmYhqfQvcMiq00OKboZFkLhBT5f2dbMozukdLmHq949Iiic\niTYgfUZKRdpjHQe0Jv2+PALrSLTU5kowkExgJkwoh69+SrhN48um8rc7gf+l\nYH1i\r\n=ruw3\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCgNgeczADJjEwj1jtbWRHRYrOJ14/u78pVycQBsmK9BAIgbKstqXYc/jbybad/wHCPG6xrB7IlGgnm6BXAk488F3o="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_10.0.0-16153cb1c8f6d906b3fd3b2d4a834e25a8ec2053_1643776477399_0.2504521680197098"},"_hasShrinkwrap":false},"10.0.0-bda05592857ac5f431028aa0b172028a954eb5ab":{"name":"@detachhead/ts-helpers","version":"10.0.0-bda05592857ac5f431028aa0b172028a954eb5ab","scripts":{"test":"jest","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.11","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","espower-typescript":"9.0.2","jest":"^27.2.5","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.0.6","ts-node":"^10.3.0","typed-nodejs-assert":"1.1.0","typescript":"^4.5.0-dev.20211014"},"gitHead":"bda05592857ac5f431028aa0b172028a954eb5ab","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript 4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### supported js runtimes\n\n-   [x] nodejs\n-   [x] browser\n-   [x] deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@10.0.0-bda05592857ac5f431028aa0b172028a954eb5ab","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-UBZq2tP5luHPFQBR3tQgDLWsd/nAB0gljWJHuwQ+oM/qzO5CyOgTTtwq88pLP6/iTTSzSHM8tcByvQQFtMPuhw==","shasum":"5f265f876c200dd0fc1c10e120c43ce21536783b","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-10.0.0-bda05592857ac5f431028aa0b172028a954eb5ab.tgz","fileCount":77,"unpackedSize":331438,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh+jtHCRA9TVsSAnZWagAAhTkP/3FwoZa971k+X3chItnh\nW4cNB0DEU3tkk0/wGFqsZO0Wp8p6h/lAmo5DaL1PvDieUbx/s02YrvzZaPW/\nmmgFD6UYbKPDwTld2LcKVw+X0cIGD0ox8t5i3qRfayqkLxoN7Wc2/YBJXhbp\nP3G30+sSznFL5wuZKpMa45J0L8kin7iJKpQjL4jGklxaePvWfarQlB136sg9\nMRVBuq0OCFt2nYOlN22ZYOjOo3C4GvjXEMm/WsOOPXP0CS3yPZmk/Oxr5rxk\n7eRjaXUsYaeisQuZX5zqcEekIsYIflF8Ktcxl0RFyFTFwJJfB1837ujgMNNF\nhMjIz60LXLML9c02hlJGzqAtbF66cFephqzdLM7HsNPMHHXRt4XqEfUEjPiu\nZ9sCH5FHFRbLS5HkbrTPw1rqOlgtzbwKo4Cg4T+0qKQrISHQJC6kxYJpPJcL\np3mlnFlZ1czrO5k7smpIeWwRhXi9EsLiN8b/3wD6BNketdukpiEReYh+T6k/\nubb/QnN2GVPY0g75SBo2Rq8fWzdg+efVmwwszO6a8e36B1nizNlB5GtJDOnR\nsahaYACe7vyy/MKejYBgeJwUIiR+hIcRcuNLA8Zuy/ZxcXO1kZJ63K3yaRnT\nLNhhBtEx21wlxFrIMO4tIJsZN7KAuAWDsFbKHW8T8FOExY1FD1kjNmSksXhr\nzyBI\r\n=rYXj\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGe9LxDs1zWEk87UkoKqAEE/bhWTnnKECN+/kb0QYLhOAiEA4C/CzRHhB6M2dI9VI2QqMIel0jDVyAymEOMxPj/zLEA="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_10.0.0-bda05592857ac5f431028aa0b172028a954eb5ab_1643789127504_0.6030680194656786"},"_hasShrinkwrap":false},"10.0.0-a2b9a4fee69be4a45ba0d5b5023eebabe784ee9a":{"name":"@detachhead/ts-helpers","version":"10.0.0-a2b9a4fee69be4a45ba0d5b5023eebabe784ee9a","scripts":{"test":"tsc jest.config.ts && jest --config jest.config.js","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.11","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","espower-typescript":"9.0.2","jest":"^27.5.1","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.1.4","ts-node":"^10.3.0","typed-nodejs-assert":"1.1.0","typescript":"^4.7.0-beta"},"gitHead":"a2b9a4fee69be4a45ba0d5b5023eebabe784ee9a","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript >=4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@10.0.0-a2b9a4fee69be4a45ba0d5b5023eebabe784ee9a","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-mKmH+LzJ3qkislkTABMiaufRy62BXddzWm4wJZYrM2hlRXRGqR5gQKLuhLzu3mKAT/IcuEf9H6ow+UjQKLQc1A==","shasum":"c0944af8f4ca55adde7bf7b29313e5b96be8f164","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-10.0.0-a2b9a4fee69be4a45ba0d5b5023eebabe784ee9a.tgz","fileCount":77,"unpackedSize":336347,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFNa2kAq/+4cc9qUEiRpOCb1tfNWRJfzj71t4XIFdYutAiEA8lVYIn5dIEhTOVn8uP62RmDZRXBFTYC3R8vWNy3uSQM="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiUW5lACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmr9EQ//YENT2aAEhIMZRwF2CO1aGpsS8K+neeH2EkEX/4QsGkDr7QDn\r\npYz6cXDujUJo9P0B0Of0wi9g8zGpfN2AlDRuYMPzIgsm1pm2yAoOKEAUqJXD\r\nx2g83JGH+1JHahEPaUTAr/8Yzu/Jc9UXGmwklQ0mRhbbsXbPZS3KT26kCl49\r\nL4REvhli5trNT0TGrV14ft85oCwvtliguRrw0X1bnNdc4nYF/DSFEKN4c7SH\r\n4LPzCevwUQ2z9yRjhv+opNVbxkfDoShWrLnWsTHEma9vpgGpV0RBYP3xkiDM\r\nWxFr35ICoSGf0LaeFhfa8rhUICJKhMfyESQcWdtXx3VKmyoXRxkLaEWJB9HD\r\nHHXch+C5MBb6AZOBh12fgYrY2wx5nQaFWXKhlZB/z9HZJnQMtUJ5oPD2Bm0/\r\nMuGr+2H89Mb2Wz2lp1qcvZHYCIOuzimtV+b0nzd3IjzhyBzLsBpnorpY5KUP\r\nRH0YR2sQvYKqrC675XljlFndl0zBzzKcLc8NGiI+pJJ9AXcRETPWffL2gkZN\r\nuKuL94HsiQmvGJ4+oRC3HT2hEjHBPYzNfWasAAKTFovY6NrlIaJZARXl62Ni\r\nmox6Yk8AVnToAwpsYBqrXaprS7dTIpYKz7F7a8/GRUS2S4ypYXXnTftFmuvp\r\nZmPkdqIGkEw6uD4rPUDbgvmpTVl7IBG01Go=\r\n=x+/u\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_10.0.0-a2b9a4fee69be4a45ba0d5b5023eebabe784ee9a_1649503845354_0.49820402243133755"},"_hasShrinkwrap":false},"10.0.0-fd264d0567c6c054705a87077e0973c0f504596c":{"name":"@detachhead/ts-helpers","version":"10.0.0-fd264d0567c6c054705a87077e0973c0f504596c","scripts":{"test":"tsc jest.config.ts && jest --detectOpenHandles --config jest.config.js","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.11","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","espower-typescript":"9.0.2","jest":"^27.5.1","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.1.4","ts-node":"^10.3.0","typed-nodejs-assert":"1.1.0","typescript":"^4.7.0-beta"},"gitHead":"fd264d0567c6c054705a87077e0973c0f504596c","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript >=4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@10.0.0-fd264d0567c6c054705a87077e0973c0f504596c","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-x+0myYtQglmuyib/QsAwjU9GL5IrPIfmENYXYoUdV+Qcnf9oUlZjEgMMK4MwrJDtcGli2hm0ZFj7TNGt0gG0Vg==","shasum":"534422308199503c5581c4c44181964c036bcecb","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-10.0.0-fd264d0567c6c054705a87077e0973c0f504596c.tgz","fileCount":77,"unpackedSize":342475,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCE8zgqL8RV890I+qPDmrVYgkJ6cZ/1tKg3BHG+4rdc5gIgcB8KT4cz/Kc33RZ/W5rWkyoLmbkEiN8u6ftyvJBl5XE="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiUZsKACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoRNA//Wic5M1GFdmfRG4waK5xQW2MY9EvlaRZ5DtZuskvCvicxE1FI\r\nnD4AFTSVCEGVzPBYDdOVtnPk6P+L1DfZyMLeuJ+NudPhusYgB8eRwrIaEW1F\r\nPh+jqFztsUOWxUP/ft1DuZatgUriXfEJOKK3bvd0KFRufryoigyLQrp/d++m\r\nLSzJXf0NAZBzP4lMJzJG3iJf4Hv1ZoqsMdiHvCimbFLBMSq/4EG8X4bvhbdZ\r\n/WAVCNt/7nXArli5O0bQB/n4nFqhgmDIHLkS5uevG9qAJVsZ33KMMZHA9jgI\r\nZmyFlTh/3E2xJAD5ixy3ytTCmk5ACk3FCAuMQofAbp3MlxE75B/Fs+JqEbiw\r\nUXcb+3espxRKQzRMJZ+6j0ZJjQk9XMGC4O2DlUsUy0btYWI2TIyuvA0L7HfH\r\nMZnSfIAVL4cpS1FEyAT1UYx3Ub/uLjjmELTlG9eIIyovgIAMxHaX34C7ER+E\r\nBn6vpvsAk5gORPRJjyRo84t9JzB/1xIcIt75gubOWJ6Xr5zojgy1LpjRwVAm\r\nGqLQ+A6zlNcU7CY9LWL66cUUpuE8VL+bp6poJPg4x66DWxj9YGHb9jcH0itK\r\nmi1dVEi+d2weepZsuqOZsiJmFvMlYEMMcrhPeC3bOJHTp3pevvNxF5JlylNc\r\nwdU7iiq7rF/U7xVG/q9gqkbHvcOubnA7EH4=\r\n=3ZZP\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_10.0.0-fd264d0567c6c054705a87077e0973c0f504596c_1649515274553_0.9197675509952459"},"_hasShrinkwrap":false},"10.0.0-c22d30e85e9716d9d89a0e9dac2dd96258bcbb28":{"name":"@detachhead/ts-helpers","version":"10.0.0-c22d30e85e9716d9d89a0e9dac2dd96258bcbb28","scripts":{"test":"tsc jest.config.ts && jest --detectOpenHandles --config jest.config.js","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.11","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","espower-typescript":"9.0.2","jest":"^27.5.1","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.1.4","ts-node":"^10.3.0","typed-nodejs-assert":"1.1.0","typescript":"^4.7.0-beta"},"gitHead":"c22d30e85e9716d9d89a0e9dac2dd96258bcbb28","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript >=4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@10.0.0-c22d30e85e9716d9d89a0e9dac2dd96258bcbb28","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-XjPoUyBHUzgQ2DDIpob5q2TarSwIWzjCLDjwxpm9Q8sGnnPDrCC+JmgULY470aN6yIC/RjA+oK0HLIsywg/PvQ==","shasum":"289f1125bb985f66cb5e0527cd25cdaa24b62b3a","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-10.0.0-c22d30e85e9716d9d89a0e9dac2dd96258bcbb28.tgz","fileCount":77,"unpackedSize":342407,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICdVLGSbj1G0BCDKSFhRzOMTDMaSm0eZEW0cwVROS79OAiAEkVov6AmjDi3iJ3X3l2gVcfv7GKmSVeLt8YYWXeB+dw=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiUaErACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoPBRAAmeNciR047S7IpRBwC5BpjQMIkxJ6/dPXu4N1lsY5A+cHJbJ4\r\nkTb/9kLNq0q3jtV0HTFxm7Vt3yYxc/S2aZL5Mj2AJh5EiJfQdUi63LURlBhZ\r\nr5Ep3w/VdEhbBaaO7/ccBVDgIrunrBOMpkYKQV4jnXd3VdDTMRDaCQ7n4PEV\r\nnwXJtZxPDcSIVTo26vzeYMmGcSNR4xQa9GvxapzP3JRiht8HLod5CI9i1e4q\r\nBTCJFinpIA+lsiGTH8RYKYmEfxbBdGtvbb8QNzi2EFxDhQzaNAChO+X6YMCl\r\nOo/l/1CLrqYWvwyVtpz9577K8sSq+2oE4wR85uYRMspBxBP5HjmirUAkg2gA\r\nwAI1xr7iJuGEFe/c/+l5Jb9eOgo4G0kOLjWjgiP2LpCt0368wW4H02ZJv8FD\r\nWorWuud49gd8/GeSH4FY+1Q635J3NorWAzO+SaT32oa/4eSUuiQj9hmKlcoD\r\nRN1OSWzOpCel3N6PE4kLPiE8o70dlRoYRhSIOfg6hJyr1XHFGKAeve1sRcF4\r\nr0xwiGNPzZtGzkKKsUcpSHZV9p77qyT5unBjoMSInlBQetp9QxeyW2XzUFvZ\r\n55y1YiihQoGahoNbvmufcARNfrLSX67C+LufABw2hBWT8NEkz1SwlAARu1zl\r\nJde5Qo1f+Wm6JKYWlpotkkOhrKihhANWvGk=\r\n=x5QZ\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_10.0.0-c22d30e85e9716d9d89a0e9dac2dd96258bcbb28_1649516842801_0.9569576016923582"},"_hasShrinkwrap":false},"10.0.0-013c49e4557b9ed83fec311ee209fcae92016cb0":{"name":"@detachhead/ts-helpers","version":"10.0.0-013c49e4557b9ed83fec311ee209fcae92016cb0","scripts":{"test":"tsc jest.config.ts && jest --detectOpenHandles --config jest.config.js","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.11","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","espower-typescript":"9.0.2","jest":"^27.5.1","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.1.4","ts-node":"^10.3.0","typed-nodejs-assert":"1.1.0","typescript":"^4.7.0-beta"},"gitHead":"013c49e4557b9ed83fec311ee209fcae92016cb0","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript >=4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@10.0.0-013c49e4557b9ed83fec311ee209fcae92016cb0","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-O3jMKLF8iMmPdXk1ybaRhlHY+5Iqu96hXpaKxO5s4nqEmJkUMfy509QRDc/kxi5IA1ZK5CaRZbSgcVnlTCmVjA==","shasum":"4dbebc215ed33a967bbba5e76735dd978c65d8c6","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-10.0.0-013c49e4557b9ed83fec311ee209fcae92016cb0.tgz","fileCount":77,"unpackedSize":342407,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDlRvT6Y31hp1Sd9j9USg1jPcSiQA8eSM2BftCQyKG0+gIhAMuXLO7VSgBVXE09LtXhMuBBFMpbO/MPzll/bs5SRIkK"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiUak8ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmqsow/8CWctCVGxylIic5T07X0zFswr7fJiuouhRONOATmWNLUBdkx5\r\nQXDy2d2ihM5jyJPc5c1Ki8C3wkaPzBPLJWGZ/PPIy9c8iPJ/6RQehWD2Bw8J\r\nvTf2JYBE8lDrwX0GW4QzvQhvxEFF14ah7LoY5tLMrR8abFVfsrJnvz5YxIac\r\nz5DRMY/9b0oEG4U+AhMvxBih1fisOMy+uwbrWa60kKwahOk3dmCjnZXwNc3M\r\nzt0AUm6Jiud129ulya/AxDbx1mgKYyzxD0vApGJj/IsUsRkj47dPix9UI1ld\r\ndFLdJxtKG1unUZR0dRu7R6cRrZ/ayV0yfZoL+dYuMAT/eS5uqx4VEcerqgz2\r\nbKv4Zim64lYoIteJHDBKek7PqP8Pjm42ZkJ8oJ0LQKs7zIKvXk7X9DTbgwmC\r\nxlQO1h2UQZGYpfyfc57lXf+2AgiUHa3XuyHf5E6jrhMbnvNKYO8ifxoIPixq\r\nDZgKWz5DkvFgclzFRpUQ7yNmh0uhAx5hHtCqdezPfUaOYkAgZ/4tVtA9M9Ei\r\n4XOgpczAxJ6h1lM03zyk5VHct48n2hL5+Nh1/I/oR9GgYP/l35nAQ6BQoi01\r\npDmdzIJtudvAY2OFgbZq8rXzy3M5FQb0FnFtKwN/kd/JtztSCxpTvTHwNi+i\r\nG8KU8mEV7iS7tSMbQ4bTzUxXol6I1zht/Lo=\r\n=E6+2\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_10.0.0-013c49e4557b9ed83fec311ee209fcae92016cb0_1649518908001_0.10928879369942224"},"_hasShrinkwrap":false},"10.0.0-7c4c0d416966411080f54f86f316b0de4c6d6409":{"name":"@detachhead/ts-helpers","version":"10.0.0-7c4c0d416966411080f54f86f316b0de4c6d6409","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.11","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","espower-typescript":"9.0.2","jest":"^27.5.1","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"1.1.0","typescript":"^4.7.0-beta"},"gitHead":"7c4c0d416966411080f54f86f316b0de4c6d6409","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript >=4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@10.0.0-7c4c0d416966411080f54f86f316b0de4c6d6409","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-1GN2vz2lza+c8GE6I7DZ+f1zoMbCPStyxaVFJtihzmKDDqkjOZrT1pd9UrMXG7YHsNpD+aiX4t5iyRyX/+XIyQ==","shasum":"443197fe2683761c82f051c5ed70cec0cdb91078","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-10.0.0-7c4c0d416966411080f54f86f316b0de4c6d6409.tgz","fileCount":77,"unpackedSize":342361,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCbZxivMF2sETlxg9qVypEKt3pSZEvRIsc9+rGlDoTu6QIgBveT4eo8zxf8HbwtxzXfPuLZEN/J2+qB9jg5pavdtNM="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiUasoACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmrb8A//ZJXbtXt0BllO0HSTgwEQxFoiWpS+PEkjHd3R+PRldkgqoFin\r\nepl3M03FPW8WeNpMc/tNuR8CPSUDUBOd72kfwHTKzLkuQLf/z+6J/GKlodIJ\r\nMARJm3PrBoTOm1N9lG/3WToyJ7VxOB82kGWj6mFJVFBmBmbWG2SeOad4vse8\r\nze7IvTZRuQsklVXIu0lXUaGGDKTDz1fxgdMHaPZ5zv2hP4VH+9pmYGLeeWiZ\r\nFtwKzSveXFJFjfaFAAZ2EOoGoqO1VIwAFH9LOgNDsiiOgnfcOYk/OLVrqujz\r\ns2Ma12O7tQR8lg/gul627qJXH9WZHeWgTD7PgaPegI8BYkv+5yS2Ii/5s+vK\r\n8MDMm1K1qA+mArrb+sv6a/T9c0Pchyz4coGfZ1XERifATMbV9FBboP4D+BWn\r\nWnNsQ5y6DZJCu0e/r63YMnhIwzN+YyRsg/Mpsdw74nOCnbcWVmn8dueyHlw3\r\n0ni7kUtJvQf6aae8CqEHuEBRNAA+Drw/k7CietXY2AYTd/njvYO5owvvRke1\r\n5rY9pyXVMZX7LsbYi6XuVCb8fEVaooW0lIzdHzc2wDUxwxZVyL3Rva96DOgz\r\nEY4UxDU2ma+DqoeOor6up8iI+y6NIz4CSvxf333U6a6NV4myAi/pLJzXbmQ+\r\n1Ox54Th4rGz2ETROFXa54ukSI/kqae2vT+M=\r\n=y+me\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_10.0.0-7c4c0d416966411080f54f86f316b0de4c6d6409_1649519400381_0.7278467526051429"},"_hasShrinkwrap":false},"11.0.0":{"name":"@detachhead/ts-helpers","version":"11.0.0","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.11","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","espower-typescript":"9.0.2","jest":"^27.5.1","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"1.1.0","typescript":"^4.7.0-beta"},"gitHead":"8fc0e2f92e5d812b9da8773d0cd3fe0aac78da92","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@11.0.0","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-hDaYtBNr80uvY2xTXPJSqCxBxwIOM/Ujp88UBgT9w01yJWQhjbEKlGZbf/1OlorNlJypEcD0LOCUQ3yCHjUOUg==","shasum":"1269105cb53f9b89b7a1ad5d70bd220cfaa7105d","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-11.0.0.tgz","fileCount":77,"unpackedSize":342320,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAxR0k9CmgJsK0adMN6rOxHes6MFlH0+VoaH+pZZRGfSAiEAoTxGqPDF1Wt+NIRAcSbfL3rvpeRoM7cFVzIckhIswQg="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiXlFFACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmp+yg//dTFAS1e6z6avg7piKKTgB0fZ008Sic+ZssURsYp5M2kf6E5s\r\npcpRYRFH8GN5Jn3c69h4MAsp8dKl5TQirsi1hBe8kdLzp+xGAeHnKDJQ5vOE\r\nTqIOexCHgWVrT6oS7AnqQg+D5Z9UbOMn/TrfHlu9n8rrafLcBlj9FFJlizB/\r\nK4lQ/W3dcLDIVWqPPe3y6nZp+Wv6rM04snJiUf8vkpj1Nc9zzx4xoRHHpII+\r\nazBWjydD6ilfN9OqR78/fB9V71MWIdn4tPadRoMnHpKufAHh/Q9ZrdEbQiEx\r\nDLwzVwxKon0jMwbVd+2H3HCXpmpjui8mC4/Ape9bNGgNKtAObrrfdfQVPeOq\r\nDyTuOFD2UlMeD1+3uESF0rJNh657jC10fMrlOQZuvHAbUpKAe+iqOsigwOm5\r\nLHTUDoOCAVRa6KSf83fL8AH9unyLj+JUdtkishD1JmcTGU7M6z9eOYEFbM5z\r\nUb1h3DgL2ajYefCzX+Ody1u7ryt+JrfSy7ACttPHKx8S3bl4GFgViy9nx9iT\r\n46Hdd1yfUw0AJNqSntUo7hIhXn6tSpKE5yhK5x3to88KV/SL7oARwwv3RhPs\r\ntvwy3qvdrIeX6sLbbg/sJDlIwsHMCPUYtHfSaQvOjjkHLGJYeUf/jiTymvaf\r\nENDSdWHrVy3aYrMO5yqtyobm0/+GXFY1qrA=\r\n=otoA\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_11.0.0_1650348357560_0.7395256348331838"},"_hasShrinkwrap":false},"11.0.0-8fc0e2f92e5d812b9da8773d0cd3fe0aac78da92":{"name":"@detachhead/ts-helpers","version":"11.0.0-8fc0e2f92e5d812b9da8773d0cd3fe0aac78da92","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.11","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","espower-typescript":"9.0.2","jest":"^27.5.1","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"1.1.0","typescript":"^4.7.0-beta"},"gitHead":"8fc0e2f92e5d812b9da8773d0cd3fe0aac78da92","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript >=4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@11.0.0-8fc0e2f92e5d812b9da8773d0cd3fe0aac78da92","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-loM294TFI8cu+k2CSM31qM29XOEvFzRDKlGL/q5GDYKi68nHW8ZXVRZyHYVeUJiER4NY++fQ3FujOq+f2jXOKA==","shasum":"21ccc834d3cef61de8231cfeb4ea18dbe83b62d0","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-11.0.0-8fc0e2f92e5d812b9da8773d0cd3fe0aac78da92.tgz","fileCount":77,"unpackedSize":342361,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGWAuI6QlorROr5F5wSTOrqeygz4qNWju6v6CuDiKX/ZAiEAylReu0iOmRW4tLmeik8wD29YdqEs6FhdP6nx9ibaUqo="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiXlFbACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmryVQ//dLkGaD7/OOctpK4GgQgjKjobWvPbWyZXNfsy75uxkQGcsXPi\r\nH8uX8RR+1673Z4GzzhNAmczropNyKpDeyGoHxn6rir5T/x1P24bdC3dJ0oYw\r\nNv9repRdTsg/ro40W1KBt+LFuSReNd0g4BnSdIY0+9Nf89llR8UIRurbXlyE\r\nFqU4CYCG/o/xPoD2E+fGHOm/6KhjGup/WDguzD9/9rf07ix1WmnYZ3Znutpg\r\nihPq+bCj23VHX7HQS0H0EKDSd2k1G70MF2hTb1GDrdndKDoHMiKZaH3t6lc8\r\nEt/pZkCn6CYCRvAFtCNGPNFxkI7u468/uRDC5TH4tBLMckGTGhMN33MLCCFr\r\n2ANSw3byge02NlVQzGsNlqvPAXVTCB3UnLidOyS7g3RbwspRNaMY9zfdLiOn\r\n07fpW6oFg+hbH0DcoIg475Ht1YeHRLcBYOCb8ThhpvVHkMCeYh54NtapmpRd\r\n5VPEuu+3pKHcFIDBXCBrjNkdLG4R+ZoNEdhzDvwKfsUIO/7gU7tHPas7f8IM\r\n2QUgxtVhx5uW0ggZ6yeBH7fiR4q0rWL0rpVPEHmCmcnpDYKRPX2llA2dAYRs\r\nDRUfbpo5czeANgR9eHenumBUlaVzdAsBfzUf3uXzCBPcTk2ASDQ4cZaoXjpY\r\nPtoWNJFtBw6R3dw5bQBW53sExAcv3AXhlq4=\r\n=ZVji\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_11.0.0-8fc0e2f92e5d812b9da8773d0cd3fe0aac78da92_1650348379231_0.35319324611150416"},"_hasShrinkwrap":false},"11.0.0-08a8238f722ea4639b7e0ce62cd6ab62047823c5":{"name":"@detachhead/ts-helpers","version":"11.0.0-08a8238f722ea4639b7e0ce62cd6ab62047823c5","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.11","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","espower-typescript":"9.0.2","jest":"^27.5.1","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"1.1.0","typescript":"^4.7.0-beta"},"gitHead":"08a8238f722ea4639b7e0ce62cd6ab62047823c5","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript >=4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@11.0.0-08a8238f722ea4639b7e0ce62cd6ab62047823c5","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-NOO87U6ZO00mvGhJWzWR9EhTYfn1LncnX/oDCg724cfH0wpTiJZ1Lmcxkc1WHQ7ANOt3ppqLwnlH5mEomIfP0w==","shasum":"231da1fb008387581ecd69a8a4cb30ef174f33c9","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-11.0.0-08a8238f722ea4639b7e0ce62cd6ab62047823c5.tgz","fileCount":77,"unpackedSize":343935,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCMqB0LnaoSHU/pd7wmg4g0O0I7Qdf4AiS5eL7thq4zLwIhAKaioUINR9NrrvcQ/9GKWubiT3C2W+0ZQ5PHPJlESzti"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiXp+8ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqGkg/+IiIdnQzhx2quptI+Jqf8cK8pTAYsB3ma39Rqven/0GgHMMQ+\r\nHE1X9yA5MCzeA8HnA8T/afiB4bXMc3T7Rh0tAKE6eSSR/7cOT2X0VvZAaApa\r\n28z6VSg5REo7gqqLsVUYOkHsVLIml7YSiqgL6JaNBYc8UVXYMH1YkFNGlotU\r\n4RVGniQlua57dqkbTTeNI3FFdiU2wR9R0EqYt7+TgaxuO9UliY6wI0Qau9Ak\r\noAacxAhF0Hxryhhr8UIkbTTddhInYv+16Vu4yz0cE9IEVUYBLDAsNtg0kKF4\r\nYfeH9OgTaYet800Y9Nw+KJIAbl+Brgn+J9b48VtQeuNI+uxggp211dWRe+ah\r\n9ddTvBu08/ukS7DQ8zITKwbFUWoa/Ezuo1EwQvuaK7we+0gaxRB7ic/rAo3J\r\n0o2rPVSD6zib8+toVNP2TIWRydKVRyLjMMhG3yv3MHIQOz522QnZZjPyWlJR\r\nZhFjZLgE1j5kVMqTeNG1mQ2TaZWb1G/NoqpY+/OBAZ2VCGa7CptOOPS+QB3Y\r\nKsIOqbCZelETAOgcJXmg0xszzBL/oK74C2imzFxJ4WWGielB/tiXZbSCqjuA\r\nQIBQgXyQ3ZfPNhBrYO6rbK8TdsoIscBgiiubbE90tjX5LHJ2uQ7ypC7yuhHB\r\nbBT3lww+UOtPQEQPw6EbwcX9zYAwCuMCSSo=\r\n=GyjG\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_11.0.0-08a8238f722ea4639b7e0ce62cd6ab62047823c5_1650368443881_0.3029381153277708"},"_hasShrinkwrap":false},"11.1.0-a04614eccede7c863a4c5eeeaf845d2849a446c2":{"name":"@detachhead/ts-helpers","version":"11.1.0-a04614eccede7c863a4c5eeeaf845d2849a446c2","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.11","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","espower-typescript":"9.0.2","jest":"^27.5.1","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"1.1.0","typescript":"^4.7.0-beta"},"gitHead":"a04614eccede7c863a4c5eeeaf845d2849a446c2","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript >=4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@11.1.0-a04614eccede7c863a4c5eeeaf845d2849a446c2","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-ShriaU0gdfBBZtTb/lZJNsl2s3OS2/6R1Dq/EaMrqTTEEnW9OB8uNccluEZEV38d3cFHdRM7rF5sRNMcFqGQ3g==","shasum":"35ac5e5f90026332bbb3fa24cd155a9ef46c044d","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-11.1.0-a04614eccede7c863a4c5eeeaf845d2849a446c2.tgz","fileCount":77,"unpackedSize":343935,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDuiS2esRs7RXCzjn1S4iO9LOVDDhxh4GXclEcFMc8A3AIhAMiUZWfnI6M+G9zGXS3+G1PpsFAER+n8qlRckL9EKDGs"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiXqEWACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmowlw//Ue4rXh4H8JQMO8YzOxyn0X88CU2gKb0GwhCErR8I20A8y4QQ\r\nMI/8DOT/D+EEbqEjDstjwWbJArtPa3evBZZFM9wGjeb5OUJfrdajdbDjrUdb\r\nowARVJq2YQwpIljqweJYybuif5HSdDWg2r8mmjAtQ80VH80LSdNPjAooKZy3\r\nxoQ40yzXzK2rGjULNrjMkYLdraIk+Y7YJVw92PrYNCPYD9YYj8kdVwH7i+7q\r\nMdUGc3PHpNJo8bptMxuuebMI71WwUZ/bkM2O6u7aEYdxyw1e+4b62a8fUB0Z\r\nIKXfcVj01z2/niwCWmqhNr9FlYa3HFcW26iofn/DSVI7kadIikh3mHngubA/\r\nGWasrBsOqAhCGqkl3iuGFARN6m+clS4QaqCQCmp1SHLHTSlrdjaPsnTR9TzX\r\n6Dxidkfz8rjYodOns96OLmHQDNtIvymBZ9hV/gqKgvB4aCKJxpq6glouLu3F\r\nJAplc5Je4msGLwEUHGiWHJ8m0jU7N4DI8WNW2gPdswFo42QHsoqyTXTzsSRc\r\nUi++vbU3coqsOKC57KCxBj4j/PmZNtHEhOR+meR6NjBZfo4NqWXZWe7AgA8Z\r\n/ZwctlmltY/bHwOjpzEbZNIxMZy2bGliixsQgFb4u+CfYNnkHm2Z9q6+x5EF\r\nGF4zQZfOZZ+frUOG1oC5CRQ5U3K6qX3n7hU=\r\n=xjjU\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_11.1.0-a04614eccede7c863a4c5eeeaf845d2849a446c2_1650368790652_0.10224818796120161"},"_hasShrinkwrap":false},"11.1.0":{"name":"@detachhead/ts-helpers","version":"11.1.0","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.11","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","espower-typescript":"9.0.2","jest":"^27.5.1","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"1.1.0","typescript":"^4.7.0-beta"},"gitHead":"3b1f15d815778a4039954714b34aa0da4dfb401c","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@11.1.0","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-cEVV/CS/357YSWIo53XdphjB4TKi8nRrxwAqLMkkKWJkm6fi58LMIpi27R2OjpXztacXNjM/4l4xgUNYVeP1SQ==","shasum":"27c2b1261acee9b7b8a1e907be285f74a41f2bdf","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-11.1.0.tgz","fileCount":77,"unpackedSize":343894,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCJQvyAEgN2kh/ieu14PNH3Bg3+bnzchLY2kIW5za6JpgIgdcmtEs/T7bP9iIzr5vx4GN9Moevf7RhtNQr+j4Xuclo="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiXqG7ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoHww/9EbOlpTjbxTowudIoUuSrw6+/1dxNzJlNYVACbR+OUxG5C5mN\r\nbf+OBp7HSAVWsmNNpMoxEk7oymuzjwz3QpVL6/OEaYVJh1c0c6lT8P9OFMsH\r\nuk/JVhtgBuzQ2k8P6bscseRnxKnEuSucUdmJ9jhlk5K0V+hiaFOctDLhB+sR\r\n/OnxCQTxda2c85KG9ej20XMQdrDb3AktO6pioj1ZyuJ7nLlYFA60SnfG6qWb\r\nd8Wo7/zm5y2LekkANrhXvfOvGysK0kxfMjWxrlbwZJ7DyNgjz9JOhQWa+vrR\r\nzUdEXbXsKHsgsvBkskluQoY4XiJFooX2Fg3A6QD6qzk0iqe7QyWcwGKZnWIt\r\naLjSa0XE+2eSz1yHbdrSaBvdIFkrk/2Ob20Y5gJ7bJnkZS0TQ66KCDQmDXOJ\r\ngCYrBBHQ1yj1E4gpr7FYOsOaTr/f2NLcvLJg+0vnKMlP2uOpMcCCXCaz/CNz\r\nAToNlYogfiOeY7iY4PgUl8vqYu/BZ8vKY4QgaDzDQhjhdkeK1rBn48ashxq8\r\nICZtAGMFPEOpfnWDuJe/gBfXc3A5WC1r8nY75a6ZDLuGcRF6/VNKWEn5fyfT\r\nKSdZbFQRgZOhGWpMY2MJCkkFEkJq905LI1HRQkVHj4PvJz5G3QmeYOukV2vY\r\n+fzXhDY3WwvIOz7RLTf/WpcNglDvDelMZOU=\r\n=1d7M\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_11.1.0_1650368955484_0.2168746649895852"},"_hasShrinkwrap":false},"11.1.0-349780eb8075f51c0662e5c9671338772df4cebc":{"name":"@detachhead/ts-helpers","version":"11.1.0-349780eb8075f51c0662e5c9671338772df4cebc","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.11","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","espower-typescript":"9.0.2","jest":"^27.5.1","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"1.1.0","typescript":"^4.8.0-beta"},"gitHead":"349780eb8075f51c0662e5c9671338772df4cebc","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript >=4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@11.1.0-349780eb8075f51c0662e5c9671338772df4cebc","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-d6Zu+xD8s4DLFsUGlDNLINTYJlgGIJzEgVrR+ZhTFgIob6U2ZXjgHcTdud+/7X2wZ8cKDr2Ps1ki/MV1Gb46AQ==","shasum":"9aa6eec0782087d4b8e5f9c448ca70ba8e030c81","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-11.1.0-349780eb8075f51c0662e5c9671338772df4cebc.tgz","fileCount":77,"unpackedSize":364064,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCNVzIofW8cc9U+a60Qp387ti6Brr6fRox8Keioz3UeuAIgSaYFeTrEkKCETWUK1M68zIut1tCjcIMxomieCj5N4Ow="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJitRhAACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmp7zRAAjASW0o5IQZsFX5nitQrILyVgNJg+Iwe92vAy8HFMTWPd86m+\r\nEmXFvnxfGZC7MrmDZVLHktuAnI3+rkpgOYQ2DY0zFCR2Ytlj6drmtbNVDc5U\r\nE2yGt2TmbXEdI6nLWzpOrg7rjqHVsUV2zaMDKZx1Vt0xaPwLBDz8hYN3N+ci\r\n/QIia4VBeocvmXq2bpY2O70tXpa5qbg2oadBfIHgRI7G4SApAJ3abjwfLFjV\r\nIae+BTjgS6djNzqymPo/VFsDbtvnIXxbFXdb6HRVIcde8nFH8S/sWblMvNJw\r\nKV+KBYHz2nm/buxVbQPAEz4Og/FuWY96oPBtZedcvrDJwiOupN5UCvR0CJlv\r\nfct1Fa0RBjsGj5h2RcHU30h8/Dxs7RXxBlR51QAyV8PK0EEepmjzsuCj00Ec\r\nJkFdCxqsJTXcAXyZNK9uAoRt1Y3yr4BOEeDCgt1foXn9FYWsL4EjfQD8EGZv\r\nvSMznhWv7tUZQPSTWtYFsV/ZrOlutWp5C7zAkFbw7VIWf2nK0DY9oR7v9rtG\r\nFY8bPGl7Awf673lvcGCf3I5Acees8egTVz6/Rz0hh7Flg+NShOxqHzu+iIT2\r\nsIBkk1rhG1i+3eKvlJaI8fxET83TNQDOyTKweDxj1UJrG1HfpOrjjRh3hO3b\r\nAmy9WCHB+7IEMVHVCYzsvpHVQdjb2vIKQKE=\r\n=UrYj\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_11.1.0-349780eb8075f51c0662e5c9671338772df4cebc_1656035392374_0.18789860131205094"},"_hasShrinkwrap":false},"11.1.0-76d21e9573fed569d76bed953b7d13b810e23d0f":{"name":"@detachhead/ts-helpers","version":"11.1.0-76d21e9573fed569d76bed953b7d13b810e23d0f","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.11","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","espower-typescript":"9.0.2","jest":"^27.5.1","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"1.1.0","typescript":"^4.8.0-beta"},"gitHead":"76d21e9573fed569d76bed953b7d13b810e23d0f","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript >=4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@11.1.0-76d21e9573fed569d76bed953b7d13b810e23d0f","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-9H7JZpOIm47Q+XfwJKUWePH+uk+mFlWw2IR+VYqxq5rWxcgUfL2XNCf9KaoFDujL5o+LPG3yhOHpj4CAUOMMdw==","shasum":"3873936af6cd4156331e82aad7b1a068057f945b","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-11.1.0-76d21e9573fed569d76bed953b7d13b810e23d0f.tgz","fileCount":82,"unpackedSize":368993,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDDpbS3h+eaUJ+sRMTQS9XbD8cMk3xF05HspLOyey3HeAIhAIID3mI4BifWdvH8wQnJH6YhU9S/Xm03w9rA07sSJEdW"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJitxHoACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrEfA//Wo0663YwNktePumyPwXMmcPjpkDCWOwtr0HWVSyT5husBjCU\r\nhw2tS0KpxPiCKhuIrll/2/2t1p4aBVr0g36HYynKI5uQK3ue1oHYTjiK1H8J\r\naA+sPTDjfNPnIR/uW6bzdMshvLVnrCG/IdmPZVpQ8V/vo00dSkDX1TRdURFT\r\niR48miKUj16iQLIoyrhbtMmP6ijkqdiy9scmk664dIm/J4BsV1Cw7JjlvMXV\r\nvUORQEXKsSzsPDHDjDXD9as6ldLBXXPOrJ1paWhgqguWiM7MecEeWqcticrD\r\nia/c8XdTcDXRlEizGv6HalQBL21AfKI1p0eWXowmfo3dsoJ0ic4rIZ3Y6hUU\r\nhRGqSmXM5sqNDHVMsf7O0fjtRX8mZZ/KW97/XTwoBs6fSbFA7bPu5/fIvVXa\r\nlMfuY4NUn5TT/GH0M9RWao9bRqkuK5AV7vu4jyAq/P2prCfedfy5wuB5/2Ay\r\nFg/BaGuPGR/6DzphTpqFNtHmpdY86P4t2ZfRMa6lPcd58FpnBVIMEKrsN6ih\r\nsNezCie4tYUci4JuU3buhejbIiKF4ockS6xc/bFziDvXg65DV3J/tqgMlVGM\r\nW6UREHqfuJzLeuL8R+LPAfhKZ33QA/q0MseF8juP9AouPYt7RR00bZrCb7gm\r\nyvwxgyJGaefVQgpBDQmhzAqOequRkzieKY0=\r\n=lsgt\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_11.1.0-76d21e9573fed569d76bed953b7d13b810e23d0f_1656164839782_0.036370529973373644"},"_hasShrinkwrap":false},"11.1.0-6d1cd4d0bbf9ce3ce5013a29d615ff9ebca9baf6":{"name":"@detachhead/ts-helpers","version":"11.1.0-6d1cd4d0bbf9ce3ce5013a29d615ff9ebca9baf6","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.11","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","espower-typescript":"9.0.2","jest":"^27.5.1","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"1.1.0","typescript":"^4.8.0-beta"},"gitHead":"6d1cd4d0bbf9ce3ce5013a29d615ff9ebca9baf6","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript >=4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@11.1.0-6d1cd4d0bbf9ce3ce5013a29d615ff9ebca9baf6","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-1qAkHsUvjKcYY19RdT7NYnj16HYyapQuPA3Acs5EzHRUWn8uHfRgwZ3MI73P/q5SyUVATkIf30XcevLyLxtV9w==","shasum":"4781e2e4cc1dc1e269cffcfa0437c2ac9ee1fc7e","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-11.1.0-6d1cd4d0bbf9ce3ce5013a29d615ff9ebca9baf6.tgz","fileCount":82,"unpackedSize":369275,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCAZdv6ws3cwieJXCvApCP5pUM6XrFGDcqoesG9mTYbtgIhALyZYOIOMW+R51llUg9qqDYPuoSXsc/bBjRjJIw6yPTY"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJityb+ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqnOQ/8DVDfj0LdM6dlqlxrZnH8DH6HooCxWPEEsiwLAy+5MW2L49pm\r\ntq5Vddov6bXvNSoDsd7nDrjZDBcVHEp5wWd1I5qZT33Hgd3SpGlOJQxa9uBH\r\n5vZ99pYILEURWK5veU+a8hy0+Ez/wCMSwEGPA3m8V+7c+65yDtgp2BWdbAfk\r\nlfgyCAVQqcJ5WTpXVxR2dGifvc10nj3UU8/fNVyLkQ0Q3t8gaolPx/gIdbbJ\r\nlD1XzprpGn08ybjHUVaW/tJOh2nWmw5H8aCd9hxaixAzYU65R33JhRB9PSDw\r\npxV1w3Uf/i9te3nA/LuM9On+d72jhQ7HcCSXLc8F6SFdNE7vLD+t/fMUsQAM\r\nU1JdnMdjuXfgRrclijNsKHH61twT/bzPi9/bkaq/pEG1NocCQl77cVVKMuaz\r\nSAylbOA/VfrQifzZzM7fJmPsDIQd0+ZTSn1nE0eMMxskN6lSzORMPVG733Wo\r\n3r2CBI1QnolGRNwhYuUipgbzQ9IfwH8lVTPTwnjXet/8czvJtSPyx1kYswWT\r\nUqpeNUk4jBhQx6bw8bK9D7G2jweJIpU9mtpF2aYWWOxQXILE7M+XHWKqsBY4\r\njNmrA/PPE3YxAAgzEuO8Mh75eI7laDYAOzqsc8O0Z6kDezzGaLgu2kP72e4P\r\nGwhRNlHiQDdPXWq9jhS+ynpPi46+vDTDKQI=\r\n=XEtM\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_11.1.0-6d1cd4d0bbf9ce3ce5013a29d615ff9ebca9baf6_1656170238429_0.7697199452655017"},"_hasShrinkwrap":false},"11.2.0-55ee8574cdae688cdf615e73d40b232332b76cd9":{"name":"@detachhead/ts-helpers","version":"11.2.0-55ee8574cdae688cdf615e73d40b232332b76cd9","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.11","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","espower-typescript":"9.0.2","jest":"^27.5.1","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"1.1.0","typescript":"^4.8.0-beta"},"gitHead":"55ee8574cdae688cdf615e73d40b232332b76cd9","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript >=4.5. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@11.2.0-55ee8574cdae688cdf615e73d40b232332b76cd9","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-zKXzhTfsJ191OqNzoHNJiSm1/n/EHtPBaBML6D2RJu4vKjzwDcepFQV0d3y3kc0CWdNnE55XDGzJ6hr0IBmtNQ==","shasum":"23c023421300ac5f60b675c62014e309cdac47ed","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-11.2.0-55ee8574cdae688cdf615e73d40b232332b76cd9.tgz","fileCount":82,"unpackedSize":369275,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFJ0lLlDvUV6J+HFCZ1cvMME0gVV0lvYf5hMczfmNsmpAiAMnSbvKL1wYksMMLkF9tBIZXLezDPBrhCIEee75esVoA=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJityqfACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpcGg/+LC6z20iifZ41A9mjQ6mPE8TRGlnc+1VdmOKHyM5Dp5nqhoMM\r\n68qfRjEXuhOubbA4Pn2OWUhP/ncrwQM6S8sqnSLBnflB/CxSEgGFsdkmUOP7\r\nrUqkO6/+cOlrI3BPUMKSs7IZJfp0A0xtTAFCaI1LAMfpa8fslqSU28uhdq9S\r\n6WeZ55Ks8vkgMPu29ySwVDLWqjBrkCH1gfmEG2jTysrp8lgNDcKfjZVc/+CK\r\ntYpXgUU9VoAkUA0ZExyV39kBNOLzktQhUTic+QGTa5yQJYyIoOZ72YsIotAr\r\ngw8MPOW7jqDJdf+Wk8yaZiZSrdDh2YrMR2eGt8NHRxZY/JKtZPP1AzMR84wB\r\n0TAKNchpTO/QJ01tolNQrxmj4rm0mTWI4KxzAxcdtsGbPoA1my4OtacUJdxO\r\nReJsWeH5CzuDjYDaCF/pFZOhUpokGoNDqEKtfFeZW6MBkWufTq2f4tYgMMuH\r\nNDS1dop9nKJnJUjQ+p2TY2MMWOmHcd3m1cw9LW+bNAY545Xug6wmTpkNk7dK\r\nr0qnUqTb2afyxtFPRpP/xr0S59fM29GALLHIDZrEf0W9fOcmfSDIG+3KoIl2\r\nKeD1CEwyWPvPI6YDlUx+Dwy4nH1Y1VRFe5dDOvxznrJColdV4jz4DR1Thsjl\r\nZyPsJE0cMyKWzuV2NYbOn8n4noMa0aIXrEA=\r\n=G2Tm\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_11.2.0-55ee8574cdae688cdf615e73d40b232332b76cd9_1656171167351_0.8215689630543908"},"_hasShrinkwrap":false},"11.2.0":{"name":"@detachhead/ts-helpers","version":"11.2.0","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.11","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","espower-typescript":"9.0.2","jest":"^27.5.1","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"1.1.0","typescript":"^4.8.0-beta"},"gitHead":"32d918e0da2399450b7769e4d178a1a2adfb7d81","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@11.2.0","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-lJGnxDcspZ+82J3fvTUZ84AaSuvg7P71Vhr75eRgBa28gsOiG5oyfCku1p0O+IOWwqE3VDFqYwdIWiwsu7w4bw==","shasum":"e436389bfebe22aa1f924e9b04fd9c23c15ba8c4","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-11.2.0.tgz","fileCount":82,"unpackedSize":369234,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIARhG4/eaXNvXh6N426aeEwqvohpw6ltNqSaFsyOzuwZAiEA0aqF76bIax+fSqcafO6WsWLqSYk8HvNUVSNBfhobHQI="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJitywMACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmp5Qw//UcES6o0ew+myRoCrvNvsa0kCUVILwKU6NxE8r6VwjNFunXAf\r\nRZJSVKn1ILI+OpcCd9Wjgz8m9PPxrtDqhKiD/RH/GNFM/6fbT8HXVB5ryrQ+\r\nXj8e27X5WNsvBD+fJV4lWvDl+g+xZdJwGum59fUkLkyqUtrxFnarehy29oAY\r\nm6lAv2iDgMQ8CLlu9VFl+fzOtBLnPSbgfnXKCbF93X2SqzmPh7c5ZT9WF9M7\r\nmhX+2EaekfhRnWOpfJJGZLCcCWu3Im0Xqnva2vO8wpdfVsq4Jnr+w6ITmOSW\r\nVVY9xWPlv/8TKXMcwSSZMgZrRWVbh9qbxRrWr5KoXXeuBX9k2rXDtzApOiwl\r\nWG0jFQgsLTeWuzQRyfaOEmOvs4JIEXXZQ+hosQbgvVaEq8LXbVx5QNDWlY3C\r\nKAECqzF5SjlS2nX3B5gSWajLMn35iNnU8epOEenBtyWSznWA78kYO5KBZdDb\r\ndJaKUVFh330leNifvkcjGHjr4q7EKUK1W0ZQ+GI6Lx3W3f2jxPyqim02DB5y\r\npMJ2DWv4h0HU5+HfGvVDr3aNnsXNNG/6QfIMshuPLhmxl04DlzFvdJ8p8XZx\r\nUKmeuM6OzZ4rKhSH3/ow0FJJVAk6sHF0jV+Fj9y5Kw6Fp6zPa5sCL/GCAuBX\r\neFr2kpMHDVmM/XjAR2fXGKj/4Xz7eS+k3nc=\r\n=fKlm\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_11.2.0_1656171532223_0.26671893702383853"},"_hasShrinkwrap":false},"11.2.0-998e54e1591c6b1436b433ad596791eab9a98ca8":{"name":"@detachhead/ts-helpers","version":"11.2.0-998e54e1591c6b1436b433ad596791eab9a98ca8","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.11","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","espower-typescript":"9.0.2","jest":"^27.5.1","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"1.1.0","typescript":"^4.8.0-beta"},"gitHead":"998e54e1591c6b1436b433ad596791eab9a98ca8","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript >=4.8. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@11.2.0-998e54e1591c6b1436b433ad596791eab9a98ca8","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-w2aEdjAy+fLUbbpejIYqWWg9OjcBCxSYX7vip72xtTiZ/LpoQ55fOUYHllMT8hJ1GrsP8MmotqDbya0ur9KKdA==","shasum":"86fa8b84ebb360c10cf70befa31ae3a484522441","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-11.2.0-998e54e1591c6b1436b433ad596791eab9a98ca8.tgz","fileCount":87,"unpackedSize":372549,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDIETw3aROtuMm+oJunRyyVv9ZxhFI4Kmocl8gkzOy8RAIhAICnJthXOJhYh5DpWzJo0XDRJJzxankkhH44m4nurBmG"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi0nA8ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqF+A//anut5CGjlQNC3K+sCA+JUdB8go/WGRO4CKGao3gfvBm/o2Jp\r\nXN/Zrnl6OVCAtUqDwHtD1eeBdztULlJdCvrHkgOrxvxfQIK1G4kyi6gFj0lG\r\n97NAh1TJgEpDZNnZNmLJ7cjqV4dwtv8gV+DKwaAdWVC8xAR0cKiSxaGX99Ck\r\nXsjNy7xzeVx1wgt28agWxezakAmUFRgTMFsYlv1SI4A0syfaivHp7H+naTna\r\nHIWkedVi6wEu60JfG2ZDkNy3x2c1GIHA6R3ZpgIgixX51ykmHCAMoioZCBML\r\nxNkeUojJe6jxH3kDyKXG7K6cIo1QWNssVuGv22/5e/ZAFxLswyiulafqZ4Jg\r\nHrVPYUWAGQsd1tmw51GAgnPVXoKjW81uyTyWOGGmyHKralQlXPC7OWbZ8zhK\r\nDTBw3RbMbpy4MJlO2SIrJH2ZhWutmFsHbQFQrNzhUi1bhUk38D1Z3bWgFvQj\r\n/egDj0QS//VRsn96+poW25rvEyTuZELbjokKDpysA03oyb1PTESMRa8CpJc1\r\nBUo0/JsRgv1T0AJPCv5t0QINeCemXm4TprQIb8UQAeLvOdexQyUaSolDnRwi\r\nvzZABBJamU1b00FxOsHK8xO337ZAJfn00avofL3icPm0P2vwZ5GRsGRN4Ssa\r\n/N43Q5N4Yw2Fm7vPn+F61Onc/X/FGE4jXuo=\r\n=+p0Z\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_11.2.0-998e54e1591c6b1436b433ad596791eab9a98ca8_1657958460312_0.5927008752860718"},"_hasShrinkwrap":false},"11.2.0-b13c5a915aed60b127bcb3051d5a592810a7ca7c":{"name":"@detachhead/ts-helpers","version":"11.2.0-b13c5a915aed60b127bcb3051d5a592810a7ca7c","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"0.0.13-815ade9a5bd4c08fa5cbb542d9acaa29b071e376","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","espower-typescript":"9.0.2","jest":"^27.5.1","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"1.1.0","typescript":"^4.8.0-beta"},"gitHead":"b13c5a915aed60b127bcb3051d5a592810a7ca7c","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript >=4.8. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@11.2.0-b13c5a915aed60b127bcb3051d5a592810a7ca7c","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-bOAmq8UTUVVL+BgSKI4R6yG7N2xWDd3kaqzJuVRGMMny2vcBE7K2kQIynnHRLIhA4zUBJafOsLwwzmsVESkDJQ==","shasum":"ee10e2a71915afa0b890fe4c3c46be0764813fbd","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-11.2.0-b13c5a915aed60b127bcb3051d5a592810a7ca7c.tgz","fileCount":87,"unpackedSize":372773,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIA+8fRfwQKNHNHLM+sCnArDgZIArEIkduOvgsvJz5kqaAiEA7BRb1m1pf8DA6iHGzlAzB/kwTUGsciMB6b7YXQsjhfo="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi0nIBACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmqm6A/7Bk1lmJ+tE8H5/Euu3xP2z1xahBE6kRhyIs2piHOVQqWtiF0r\r\n0lSKDwqeUm/bts87PgUDgS2FwAzCAk7d50jdVbWX1ctx4uBX3eAa/5LRbgm7\r\nDKq3rxm5KpzlxD48Mve5nxO72ZVorax1Rem6aXv7SMvWnwNNvz7Xl5KOmOIt\r\nyY2GfbogWdsZtEv4g6dh7RlAYhn6NgaaC5BAbbRxt82ldyJogW8aSPPqPIjB\r\nnRIv/GXc/PyuY6oqWh5zlz6LOJEg6dijwzbjkH/mJUdFwYDl0cngRInIn9Kv\r\nmZea+6WfbDNVxQx2KvwzBxKJvwWS0vpjtDXzWroVwmq1dtB77MCYmgPlLZv+\r\nD8iAvErkRE3FwkOSZHQiyvt0Rf00cbuu8lCMQLotq5rGV7GgQ2WAkLUh2bA7\r\ntsAutNwOE07AkruNMnLE+uvOIk8yeJSMc4pIU1sJiBxrI+CKP0SvFWc6a5yv\r\nxruY2KPbFwWvh3zqix+1HPiH8fe4QGMqrbpulQsYbAAUPEV2X+Q5/KKDtOd6\r\nXdraguNxKzhCIVjPdSLtPaDjGv5D2ayAlkyA+eIZ6W80urrFgGtt6WELLouY\r\nLs0E7rDQI6ep9GzwVz0/lad1Cs3VqzS4Sg9AWcoimdtvkRaNlz67RdwEO1YF\r\nPY8RFggRI1jfF3zEO8GgHOJ9sjPERmWOtXc=\r\n=91eR\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_11.2.0-b13c5a915aed60b127bcb3051d5a592810a7ca7c_1657958913179_0.07964715427378333"},"_hasShrinkwrap":false},"11.2.0-bf142628b69f9107169a5b307fc7910281209636":{"name":"@detachhead/ts-helpers","version":"11.2.0-bf142628b69f9107169a5b307fc7910281209636","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"0.0.13-815ade9a5bd4c08fa5cbb542d9acaa29b071e376","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","espower-typescript":"9.0.2","jest":"^27.5.1","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"1.1.0","typescript":"^4.8.0-beta"},"gitHead":"bf142628b69f9107169a5b307fc7910281209636","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript >=4.8. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@11.2.0-bf142628b69f9107169a5b307fc7910281209636","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-03GF3uKGCmX/d2EMgu/bHBglLnoRtRTHsYa5w/6Mgv7h8DoaB56Kk0GC12T10zWKstW8pjRqiYh3DpjDXTMITQ==","shasum":"b0d36cc71902fa4b1b8a240734af9cea0b685c2e","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-11.2.0-bf142628b69f9107169a5b307fc7910281209636.tgz","fileCount":77,"unpackedSize":371753,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBKk7IHfL4cQySG+zmuoNhLiIG5lOsTEkGiuLsOCYM4HAiEAi3OaZQI1Owk1xlZu4jBSREWo0AYbgE4U1CcuXl/xfQ4="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi2SOAACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqlyA//U2rRVmP73CGBqntc6iuvfscb9CpM64VmV/nkO0NHxuw2s+T/\r\nmAcJWup8RmQmFhEMwP2yViW+4SeeiwVkMkxiGJHCa5b7dxf2xa9T9+O4OTJb\r\n3ad/fBh92/Dxb2aLHgtQ0Z4zT+bxRLU2xuT8MpRszlOWeyBB/6tsdGcoebD9\r\nG/DkMDRZRAirbrRpoh0mMh0hZy9/LcWVhVwQ/wR0FoWN0m8rxrcvQEX1wPHa\r\n3yT4hoIaAqxbRqfYa0/+fwR2he/W8pnvD+IDgIOFPlP0ZJcGwkpEKc3Pbtw7\r\nAuyKsZK+s/SHDnnVkb+lI9j78NO1l3X/IeCS4p0reA0fKlyqwEC8ytG9tnkl\r\nGxM/DAxzcdkEtbVokpYw1fG5CiuxVTQoUM4eviaxUfyYRwCbFgr7BqAiyf4g\r\ny5F0WkZp+Sk49TCepQIY37jdTdV7J2UtpDO9fcNR7QEq/Jd4KqSce1bDyz1E\r\nPQAKXUMJSbLhLB7TwVlC+QMRlLzq5PFYJV98nBYGG8PR3Sbu6uDCnnn30w57\r\ncqgq7zF/Jj0Nmo65Un2SvYmPjZ3eHgl1z97N0IlwQ+TQaHxZ9yZus2yhqXVI\r\n1ul+tXdlia7xZ6/Ea2y0arIq/gjZB5TbGXXXnemaEazJ5s/xDfhtZcR8+BVi\r\nfSo0qyme2iza5VprxckDossG7u0uIQQR9Ok=\r\n=unpl\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_11.2.0-bf142628b69f9107169a5b307fc7910281209636_1658397568205_0.3385838861767958"},"_hasShrinkwrap":false},"11.2.0-8c7bf2285afb89daaa272d0bd6dd2a18c35b156d":{"name":"@detachhead/ts-helpers","version":"11.2.0-8c7bf2285afb89daaa272d0bd6dd2a18c35b156d","exports":{"./**/*.js":"./dist/**/*.js"},"scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint . --ext .ts","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p tsconfig.build.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"0.0.13-815ade9a5bd4c08fa5cbb542d9acaa29b071e376","@jest/types":"^27.2.5","@types/is-ci":"3.0.0","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","espower-typescript":"9.0.2","jest":"^27.5.1","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"1.1.0","typescript":"^4.8.0-beta"},"gitHead":"8c7bf2285afb89daaa272d0bd6dd2a18c35b156d","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript >=4.8. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@11.2.0-8c7bf2285afb89daaa272d0bd6dd2a18c35b156d","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-mdQ70+TADjDgcK8cRUZ6sgTYRxWo61QnIe52c7xn2tfKultr5jPqGYMKG4rKS39oXSYwlHjyK21bbcjlumiTJw==","shasum":"8b2bf841bad1045abc29b3d36777e6fb5d142b1f","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-11.2.0-8c7bf2285afb89daaa272d0bd6dd2a18c35b156d.tgz","fileCount":87,"unpackedSize":372827,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDgnrl/gP8eb4AKPXC9meg+9G6ikAHECFzFc6NWKH+I9wIgMDURMaHdZZ+IJnUlHjkqagjaSSYvXYPVZoqJekJSbRE="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi2SrsACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmql6g//S2aPSg4LIbLhNURm9K4Ho+45Ww7fLghJl8SnHteeJMxkh7CC\r\npLluvbyoTjZ6mLV4IgbB3OXVd1vDlK1OWw560TTPb1kjhCo+aLBmTu4CRktr\r\nLL2nODp47UY9R3nXmOutcmFd/eTsyGjhmUOzMoxXBianqIhwcBzLjrsRSqYt\r\ngx818V4aKFnXufastrTYfiKzWwhpJKqdBja0oh2lU9Vxl9NXsJEErFPM89SF\r\nop1hfzuSVQoOO38NplBsatiSZDE/rxvQDdxc+rJ9pdatEvwmlSoSWM0j15lf\r\njHsSZA972gqcyWZkI3OpCA4iH6/4GKQSxYrk4iFvTeKEWp8sUBysX7ffTGxs\r\nS20bB46ifyUbvJYj7XrHGw0uXOsvvLivVrznBSwcmFFVgUqVqyWtRVPUsABV\r\nPj6Dsa/IN20/yHssnlZ0h7EyuPtEE55qyCQKdWn0ceLr9qIadlhmep/a4gKk\r\nksEu1NrFN6aIevwrp1RuNr4hfcIl0ddEpPqh0Q5co0dPxT72JbIChdq5osm9\r\neEtJyRnmMXDgsNy+7LLqhi9bAZGhKYik78AULuaDzYhoUR9PnCAIPiT/osSl\r\naXb30Ed0meCR/vpUpSzLBGXO5HnBx5v0c59JGvBjRopjf7Kvb+q/tNLk1aeE\r\nXFtUX7CzaAmTaoyZmFa5oOcnUGzjx6C6ZTw=\r\n=Tubn\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_11.2.0-8c7bf2285afb89daaa272d0bd6dd2a18c35b156d_1658399468170_0.004483697668191233"},"_hasShrinkwrap":false},"11.2.0-1990231fdda53fedb9f5fa9af39550b6a9215249":{"name":"@detachhead/ts-helpers","version":"11.2.0-1990231fdda53fedb9f5fa9af39550b6a9215249","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","assert":"^2.0.0","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"0.0.13-815ade9a5bd4c08fa5cbb542d9acaa29b071e376","@jest/types":"^27.2.5","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","espower-typescript":"9.0.2","jest":"^27.5.1","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"1.1.0","typescript":"^4.8.0-beta"},"gitHead":"1990231fdda53fedb9f5fa9af39550b6a9215249","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript >=4.8. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@11.2.0-1990231fdda53fedb9f5fa9af39550b6a9215249","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-pk65FZKV9xGeyFtZpE+AEFdsfoZcly8n04mOWsRjxpVW0o3VDjhfSe7GsFr3ql3JPMfyurbTuqh3uK+X7MrhqA==","shasum":"5675dc1ffd905923929a1cba095576af06685d11","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-11.2.0-1990231fdda53fedb9f5fa9af39550b6a9215249.tgz","fileCount":78,"unpackedSize":370480,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIA7gIn9X6XnGpC9rbPukNKbOgXuj4xP+Ts/rXQCE5aw6AiEAkTsqN+5eo0nY6+/CqzvFL5sYcpKMDcHH2bQj6qpBGYg="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi281OACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqN1Q//WuecPmlkuA3HE60cmxVDdpyt3Nn9NTZcLG/OHlO8VPFBwcrN\r\n5bhNdcipapFfN+BF4fGFsGsTXHHTFVVTn6js+MoGLAv56jzYK0KW6YeLPnDR\r\n11EbE60LVB5TYFt9/RKkuvrrArcJEwf+9OBvL1y2Rg/iy+Mc+TRyex4uiCUn\r\nqzXyl5ddm5BH/Xni/U+a7LZOeI91K6QD7mrvmdJy6appoOBl6cBEzB2ZyvSm\r\nloD/LHwcEiQdZbLHKAYYSBskICqs0BsCwPLOEAz0g5EeAHNMCIGQkHm4io8Q\r\n97G+pG25KuPCxdPYjZHgrPyq9YRluL6yB4+FxUiNmJbPB3FWb8yQtmAQHpWc\r\nYTcsAS3QZ0At7VOjg5MOQ9ya1NUVLaaFO5QztU93lozVcuOty7pUN3cWlqIW\r\nrP4fLDXOjT2yBYkepfRT7Fga4A/BJPbi79JzX65UfApZp9uhYG3uWkL8rvbB\r\nLQSWzqFL/N2Nz1M9/SUerSPVgochRO8BkQ5ID9dU4Xn52YQTEJn6mulsB5IT\r\nPDliLPeHSeFfDtQ/SWXl1odmQV1hstutvVBXFM5RjAfR08t4pJ4jYKVNnh6a\r\n93z06oq6HHYtNTvCxDJBWqxA4Oj0Dkf79WVg6pFHkwkvjF8b4unMRHOon8BF\r\nA0s+uYZNxn8GhMEtyKgQ6FNYLN+H/r5CWoM=\r\n=ls9+\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_11.2.0-1990231fdda53fedb9f5fa9af39550b6a9215249_1658572109858_0.8795381856564455"},"_hasShrinkwrap":false},"11.2.0-2d6aa49a198ad82bbb89c7f622eecc5c928ff305":{"name":"@detachhead/ts-helpers","version":"11.2.0-2d6aa49a198ad82bbb89c7f622eecc5c928ff305","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","assert":"^2.0.0","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"0.0.13-815ade9a5bd4c08fa5cbb542d9acaa29b071e376","@jest/types":"^27.2.5","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","espower-typescript":"9.0.2","jest":"^27.5.1","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"1.1.0","typescript":"^4.8.0-beta"},"gitHead":"2d6aa49a198ad82bbb89c7f622eecc5c928ff305","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript >=4.8. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@11.2.0-2d6aa49a198ad82bbb89c7f622eecc5c928ff305","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-vcFO0g2rNfBiGBYog9cGttjvGDo4Ei/XVGBCrmv6aagyQmMZBFyozW5WnUikPDHuta3uvM7rtt5JUWtp52jrww==","shasum":"1ed50cf8da280db9c30b7bad5df2d2b1a64ddf09","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-11.2.0-2d6aa49a198ad82bbb89c7f622eecc5c928ff305.tgz","fileCount":78,"unpackedSize":373523,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCNfs/VJviWNOpx2aaBB0WcYWwoz9q4tB9jrDIJO/xjbQIhANLjtRvy224SFMF88fOLHd97hSDA4kKNhF8pXdEv90X3"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi2+hAACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpBYQ/8CVvgSPMPYgRu3t7y1QCngiYGX4AELiqYKV76X3Hhvvngxjk4\r\nb2v19LoCenWJ0mePyix1xEZ4Al62G9JzSuawLEpWQxIiCEFKRuODLr+N21l9\r\nqCRhXlmIPxttZhq+4xAIkCihXln9IvByH2S1+2Qv27uvj0nRR01MgvFGyrTW\r\nkP1se1hW3HvEqEbSIe8Yq2oeJDJCBvRZ6OnkJ6uVhFW61O6lEN6RSjVV5vJ5\r\nPAW82SB1aTeiehBTsr01cbw/BmLFX9QHNEJZY35i9emuSpA3i+MVBe1BKfoO\r\nrIPOwszx2okRKwGlL/AeE072/cq3FDmSZkOetqVaCxxTDRqkaUYTKSFhlVNH\r\nio5flubhDeqZrbKBrOmL+cOHIOeuyHETpK8ErA9xUSRqGPXOo4HtqxMdZKSb\r\n3w5u2NoIo4cH+VH6H7iCWQW+H5amL/hNcjOZVinkInQg21bl2gG/YdeENtay\r\npPW1ct+SrrvzW1ha/hdbwEPWiGVH/IqXyuXyBEUFpWG3ylnpIkcOtBe/G5fv\r\nbagzTUXPwFB/pd/ARqgiEd8xXyUzan8x6e7claze0HgFcDsFkRfGVHgzZzrz\r\nHLsJAnz/86yfbB9a7eY7z3iG5IqgRUP9vAxZFdJwliwqhcfZ+72ozyFwD3Ch\r\n502m5SH6e1+WwK7LU4q1t7X+2zed+JM1f2g=\r\n=iK2B\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_11.2.0-2d6aa49a198ad82bbb89c7f622eecc5c928ff305_1658579008581_0.6690371112851248"},"_hasShrinkwrap":false},"11.2.0-af91a69fa0f8e70750deb5b87714ef8659869aa7":{"name":"@detachhead/ts-helpers","version":"11.2.0-af91a69fa0f8e70750deb5b87714ef8659869aa7","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","assert":"^2.0.0","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"0.0.13-815ade9a5bd4c08fa5cbb542d9acaa29b071e376","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.3.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","espower-typescript":"9.0.2","jest":"^27.5.1","power-assert":"1.6.1","prettier":"2.2.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"1.1.0","typescript":"^4.8.0-beta"},"gitHead":"af91a69fa0f8e70750deb5b87714ef8659869aa7","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] no error, foo is casted to [string, string]\n}\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript >=4.8. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@11.2.0-af91a69fa0f8e70750deb5b87714ef8659869aa7","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-HHlbTgqyl+bX0nV32K+jI8lMUiw1ZRav9YTVnm18FBU3Fc2yZb63vuzG1An6J/fJRdVeayxKb3bWDbghKkk8Cg==","shasum":"473e54479d5f82a359facbb6d409c24685dee9e1","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-11.2.0-af91a69fa0f8e70750deb5b87714ef8659869aa7.tgz","fileCount":78,"unpackedSize":373577,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD0MUby04+V+8rOjfdgTVl9xObFw7oiLRooI/0Naz77tAIhAMSOaR4aVtgeKmw4YJf3R41OwCspmADHp2q2PX/jiwep"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi2+zhACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmojpw/9EfXg1UmKu6yoEvoSq9D0YOAO0mZPmeOFnGJxO55WO3cPkj6z\r\nSPc8oOjgUlPgrb/FGL6vsawIfkpqnWbdCio664KLG5r5r6IgI5Ln0XUcP/Bj\r\nhfniryzlPvDGc4YAqNJOPycYzZJv87Nrqs5ly6df1tEVLbirFW7ywb/rNbp2\r\niB/w5/bBGV+qQGPqmaEZdq7Xf2RzkUtLuh4P7X8PJNlWmfxZUJnAfaBZzXGU\r\nJNNDQ8Hhe9zP2PqL89edJfMnUmTvFkUXca81UdfS64Dtln8DXwaH9rMKGgUU\r\ngv8fDlt18rAcv5HDLrBmduhz6luPiQ43tMa0uj6npXSAzq7+bQRKxiemToGP\r\nZEwwhUzs/sk3ObB5NxZ5Zttoolm2AYWpoNF1NYOJNxQcMiWcRfKcZ/IJeZ80\r\nbMB57+8Pc9gVH16hDvdkrZiuGn6Vq3LvUkWuZZ2WrzSrTk2aScCwtun4zrlJ\r\nNGwubU0OwGEX2K/9YTqLE12GuRFaW3EWAp3FooI0Z0SlyvQ2ZcWATUABUMxW\r\nJvOZ+r9iCp7BjD2nY3O4JMYvPHAR+LIKpvKUeX+93I21qwwyD5Hl9jtFoLwd\r\nV0rnFZD6VUrlOHlBIeFHfSrn166SsdCIk4Qpz9u0AF0SsgXdktzowzzpvOR1\r\nExnBYBRFebaZnzmgpC0/0hgnmvCj7aTpg6k=\r\n=KWbP\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_11.2.0-af91a69fa0f8e70750deb5b87714ef8659869aa7_1658580193355_0.8143470764273468"},"_hasShrinkwrap":false},"11.2.0-75a96db8abf9a19e9b1edabafbdbb28611137b10":{"name":"@detachhead/ts-helpers","version":"11.2.0-75a96db8abf9a19e9b1edabafbdbb28611137b10","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","assert":"^2.0.0","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"0.0.13-815ade9a5bd4c08fa5cbb542d9acaa29b071e376","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.3.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"26.0.20","@types/node":"14.14.20","@types/power-assert":"1.5.3","babel-preset-power-assert":"3.0.0","espower-typescript":"9.0.2","jest":"^27.5.1","power-assert":"1.6.1","prettier":"^2.7.1","rimraf":"3.0.2","source-map-support":"0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"1.1.0","typescript":"^4.8.0-beta"},"gitHead":"75a96db8abf9a19e9b1edabafbdbb28611137b10","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript >=4.8. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@11.2.0-75a96db8abf9a19e9b1edabafbdbb28611137b10","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-bJzZIxvDX0e1p/A4PIicU04YuOEcWXNgDdQaLy33s/JGntiDCYsaxTfyyTASVARfE+9LKrJ2g+wQiRPI5VfoHQ==","shasum":"c0a5eaf5dbc691331168f4ac3ce9a4c727baa554","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-11.2.0-75a96db8abf9a19e9b1edabafbdbb28611137b10.tgz","fileCount":78,"unpackedSize":373666,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDe+9i5NA8OKDTJTWmrErtoVZ/vjR2KSWJff8VwJHfX5QIhALIWxAUoldYx8G07Bry7v4ylH6iajgFmtdL4qBJVijW1"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi2/HCACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmozuA//U4iWa1aNrAZQms+o4bJGdkc1vUxgB9TLSumG6CZO4nO7Ka8l\r\ny07e90s3a1POWDSmnbTYS7khZ7nGN1Dtej73qVS+kxoGGXFhmeZfCgJEHNTm\r\nFRcyrT9CO//li9wuPXdWDB7AEtQ/1SpLMDoKnULWrt62DfOVqPH//p6TIDsa\r\nFzPHib+wQgPrBy/083/D/kpJ9p6o7nRcFGiqRV+GgnyW73UgK4gry5AKf+S9\r\nsrJ8oIslScN0WMKIpVtPPfIR9FBc2W07plz7wDalB5WTwY5gJWNKPR9Nx8FY\r\n556jLEIyRGD1W7n5BIyRb7mMjzQoR1LuOOEwDU8CXU42cPI91ImtGTImSudF\r\nlzSQCqf98l/Qf1rwG7nGYUcH2jGRz9khAUh3XV2wNAK9TCcVT3YQTtWeajpO\r\nISpQUhCjNIs7aX/ztIXpr2Rw546QZI3O7lYgNtaIU9B8pGj4Rcm59TlspOGE\r\nOnLdXvc/DY2I46d4e5P9fNXZzaZ52kioizQOwZkvANxQpfTPCzFBgcJkucRD\r\n035e+swfjSVDVhhBlaIVMMfqf1ENCzjFENIG/2T+DQBOMzn6Rs2uhu4HxXSD\r\n3NVvx81SjCrvvwgjAk8APUS51Hf4BBdEi7/zeMF1+5kn9w0QkXv1QEjvd51P\r\ng/xIx8UAsueYk4NwviEZ/lXjirQENoCzCd8=\r\n=aTZf\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_11.2.0-75a96db8abf9a19e9b1edabafbdbb28611137b10_1658581442452_0.7110401941602731"},"_hasShrinkwrap":false},"11.2.0-90ac5e7a256c9212870a9e2c95b938871556d84b":{"name":"@detachhead/ts-helpers","version":"11.2.0-90ac5e7a256c9212870a9e2c95b938871556d84b","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","assert":"^2.0.0","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.14","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.3.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^2.7.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^4.8.0-beta"},"gitHead":"90ac5e7a256c9212870a9e2c95b938871556d84b","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript >=4.8. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@11.2.0-90ac5e7a256c9212870a9e2c95b938871556d84b","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-dVmPcKV7Tzeg9OdVrHyyqO58/DqzSU1E5MNtvlMlBtKy2uF88yzenRpGs/4SqzKjn4nFT/zypMJ+nxO2Kfzd4A==","shasum":"3acc3b804805bce0d649b70a4499c40f080b58b0","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-11.2.0-90ac5e7a256c9212870a9e2c95b938871556d84b.tgz","fileCount":78,"unpackedSize":373635,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDcCFScQxzSDkpmGP2CUXnOw9T4SGXI5NolSwU1DekHlgIhAI8kzE/a0DMte9LQI3DHuccv1WVXGq2esIaJQXFjtdPL"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi3TkwACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqE9Q/7Br/M8oVrq+lE5cwhySAsv06r+iKkQlfx35WOp5vw2Ni6eWLX\r\njoQMZw7OQYw9ha2QYRM7jRMrykI+6vtX5Gnbpn26l1znM42D1T2UVKCdQhHc\r\nSh/LyYoRBCnKm6RqkDeTbRmlLYSrnFwaiHOa+jFKcWDlqJ4Rp1wD2TnNr0SL\r\nxRJJp35LyjT5/3L5EDGSI21EDM99jzIlbhBL4Q+h2c3PObdNH5TNl5N0ExRV\r\n+EAaO50GVqcs3mGf0nzuLNJ9MUZ1NyA0JLsG3PsphJhbGIj41H5NRKxfCx+c\r\nkyuFIZofVxOkJ4ET0BVmp4cVLsQOKgE/H/OhYSFncEZXvwrhqDBhNfYP74at\r\n8aajRnOLu40fe76WyNOhQmCjt2WZ1r22TJjuHEsJ89XWGz/QVCPstrFwIl9r\r\nQiv4eepkaz+L/BdpNHmiRdW+nADhXPAfQJWV39bfPoxEGUvrXQZ7CQRjMfNg\r\n1WFUqUq3ktf7vgnleEMHOxMjJqUSXHwIcPb+aRXq7EIGhHvFCgMwItJrV5DF\r\nMbzVNzRc6AkhqvrOE9rmk1HgSIO+qZ71Gk1Y2e4oqjnGbKXF54JmC38ZA50Z\r\naDjLNepZxP3bb1vEYu0RkB3NrL7JvcqbKZhB9SUoQBcLv5xjE2Dd6sEXRAzS\r\nbamktKxkmpT2KBCR9DiZytq2VvRXkFK58lI=\r\n=xPZX\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_11.2.0-90ac5e7a256c9212870a9e2c95b938871556d84b_1658665264150_0.15822709159338078"},"_hasShrinkwrap":false},"11.2.0-1059c400260abfe58b651a0922ebcb50c5cb3812":{"name":"@detachhead/ts-helpers","version":"11.2.0-1059c400260abfe58b651a0922ebcb50c5cb3812","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","assert":"^2.0.0","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.14","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.3.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^2.7.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^4.8.0-beta"},"gitHead":"1059c400260abfe58b651a0922ebcb50c5cb3812","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript >=4.8. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@11.2.0-1059c400260abfe58b651a0922ebcb50c5cb3812","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-IPY7BN07Hcn87XvXiVN9fMUC6TVPNfJNutVhLeSVt3zNjK+knAwx0aA9R1kJd1jqHRlnAk6oyr4Vyll2qQBoGA==","shasum":"11a7a7c0c3e04891c845b50805de6051448d76ac","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-11.2.0-1059c400260abfe58b651a0922ebcb50c5cb3812.tgz","fileCount":78,"unpackedSize":373323,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCyhbfuAAbh9ZuSNVZnYPiFVtqklfSvkLXSJNZURFSEBQIgKmZa30LWftr7vTT14dTtSxI6HgvUkXnKnEf091uNA28="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi3T03ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmorsQ/7BBqkiExM4LpjJaRTG5iATInJ6Q2Ub9MzXnF1vlfVyf7Knd0i\r\nbtOPWZshA1tyuBPkAMxGRuIXOXsq3Ufv1OCcN3umyPTTVUv9xZlorLV6Wdfi\r\nvHRrPZLSfgNg7X4UsqhshyiSYYZB/GMO837FucKeWpSc71B+Tgly3f2O6QsW\r\nnXdpwFMoKLGaGmN5N1X3yZwqeq5GUukmDQbU8hOjiziBWuTTYLJKKDlRKMiv\r\n4XE1uplhiIS3vdhQmlQC2PXBwDY644JSdlQ18RiGLWnz2RpFwjsd3xrlHfhP\r\nESX0HAYVuUG2fmC/SOKYJMgJAYuIuqBVQTIALtu/FIT6wE3DUKJ3Wv4SnqJH\r\nXJrcPKqIN7VYZ07VO0HreLwYgptFbQ8/4sHUONOPrpAO+lwNX9EJXvskhjZf\r\n0tHAcqe91QPqsU4zlosUQ5jGkOqGnHoQH8dhqyn2uhfwpq+N4NDkl+o30Z0c\r\nww3/ozp/JCUNMiWl4apmHzHWa90/qrugSkMJwNvNYgo5cj0JUS1/dNzU5KDf\r\nc7apRdxaA3ynVZvMMr7hGSAjTuTKFUNNXn1bpCXvzrSEoDzAbNq68AyzDoty\r\na08tpnEwebj7v6nXQbvNxbwYG4tm6ZLIREjaxvQ4V2sU4LAvi8A/z6Hliyay\r\ndkDXVtOwYca0eGpin4Dpak7KFrVSuTM8ktA=\r\n=xiL7\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_11.2.0-1059c400260abfe58b651a0922ebcb50c5cb3812_1658666295346_0.19515053612596933"},"_hasShrinkwrap":false},"12.0.0-6680ab03742414b74c7322db49ecc94061ef7bec":{"name":"@detachhead/ts-helpers","version":"12.0.0-6680ab03742414b74c7322db49ecc94061ef7bec","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","assert":"^2.0.0","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.14","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.3.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^2.7.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^4.8.0-beta"},"gitHead":"6680ab03742414b74c7322db49ecc94061ef7bec","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript >=4.8. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@12.0.0-6680ab03742414b74c7322db49ecc94061ef7bec","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-GTZ8An5yuqJGFCkH79B1e54UeFPS6/FPAdUi555S5vj1W2wcknpStRYI4E3QDlB6oNSQvJdwNJI/ba3/vz1OKQ==","shasum":"3a69ec70a4e82c25487287da8a18e708045b63ee","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-12.0.0-6680ab03742414b74c7322db49ecc94061ef7bec.tgz","fileCount":78,"unpackedSize":373350,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDi9jTqNB1TZ6NFOB2FMxr6YGZIysjBUnlSH9+2B8sOwgIgL9mYoFDY/JIcwj2Zl9Bb352HDPts5l8cwc+54oKx8H0="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi3T8iACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmq5IQ//REE0g/r3rGhZnvhWhu4HcEdJzZIe/wJRsCoHK28sZAvpEgZr\r\nIUPJGF1HZNn1DoYlPB6gpuA7t6VvZztVAfnQklt1IcB5gti3xkSZw/fRfpy6\r\nTtqzmQi2J10NYeB1ltPfIOJ+fo2UVL+fcJ6/iHGDuylsSdXwQrPjuV8ORSqR\r\nUUI8yGqHizx44CBrY21iNeM8V2rXtrP2LSAujmJsg86tJ5PqLI4AWoVy6Mcx\r\n8vmzg+tCr3K2VkajPNKZ23d2ptEPQSz5vxWQjxkeOVqw2MPgd3dj3KKpGxkL\r\nQeLT9gDuVMR7BlJkHIbhMecr2S41VwgLlg4LSsPZxFgEYDPTHjeNkljgdyuU\r\n9qAyNLbOVU9UQed5c/20i+uGNMElltCVibMtHdlkdQGTDnAkiUOuiVll0kRP\r\n78fCUZ6EDvE1G+DX8rG5sStR02qL3vnNlXmGZWYdIxwj7yFDKQLZGERHgC25\r\nVgi523p3SAmPmHjHONsck6l8GGKtdXc7MoyxZAG1LNEdgMjYObsAVNagguXC\r\nYmkJNguHjsk9QSSYM2KnU/oXTntsagzcCogcTd2raN+EosvQRWwpvs48ztWK\r\nuPvD2yz049i5CrLEhTBDu0QDpU8L5ttFfigS39X/F7f7ZO8AG3LzDP/mA+lX\r\ndrZYzgdp+STaGai5NOjUznzq5iVTZVeb7Fg=\r\n=493c\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_12.0.0-6680ab03742414b74c7322db49ecc94061ef7bec_1658666786196_0.614756828589506"},"_hasShrinkwrap":false},"12.0.0":{"name":"@detachhead/ts-helpers","version":"12.0.0","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","assert":"^2.0.0","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.14","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.3.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^2.7.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^4.8.0-beta"},"gitHead":"6680ab03742414b74c7322db49ecc94061ef7bec","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@12.0.0","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-h4ahWtqU7kl7xZrBqfvUuOjo4zKAMim2dh34eRApwaEFgnWOe/gv9+W2moQenj+3+T1iTgDix6oEevtGgds9xw==","shasum":"52dca1e87625333b194abdf6433f1de6eab18548","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-12.0.0.tgz","fileCount":78,"unpackedSize":373309,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDXZQR+PcYZQ+KBpPkOyTfn27wPCwCjiHAfiKueHHWV0AiEAqM9fv11eq++4KXYLs4OfOAPilXsMCGuVF6t7oZC2Aew="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi3T+MACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmp8pg//Z+ylYqs3YbT+F0BGECZ6NDZfVSI7cXMmzVfucj6TGIPx9Vm7\r\n/jZsmbqIHbSul2egPoOBMfoI1pOKUTUDAHCGFJEQnt2XucfyGZShqBrUbSzl\r\nSWy1AMkYw39ij43um/H9DrEJpq+r8zO/xI1IsGVHny3WGcz1wRy4FQq4dVCR\r\n5tz8MW3qu1DXKszBuFZNm3czFqNeVaHYxU5GH2yTIgJ7mBANolLqP2D1WR5b\r\n7shz4A9fZbKY9dvJ31Kxd7Me6v75WexCCTmfRN1R/XE64yJcdKucsRQSAAkX\r\nBdvsGIGMLFIpWLxNpaM0MiMI/48a31Bc2c7+LPY49Mvq6Ww7SVODWOUYOKfU\r\nKEn6itOLCB1tbcdqYNcONlEbAF90vJgAyB6j/A53xjaC69KsOhRIuRdDnaj9\r\nkQoeR6I5iF7x+wjk3TrcQjtV4TPtYxerYzWTUX+oKS0AfF5rpBgzrgmJI3sl\r\nxQmB/v5hvS+u0PpB5TZahEz1u5Y9oMt9wF9QTKG3CEq63JE9rqqVEkpnB/K8\r\najyKLC9zODBG0j1uQF3CRRQJOHZDrHrOUEOXyskW7SYhEdr7qwyoJ/dgPF+5\r\nlVvIpjZQFY9e8jTTJDkY8eKND5d6WegC/mq9ynlawIaotLsYEupPeqi1uHbV\r\n1AmI81RNCkrFQu+8XI6J3zGc0iEEz2u5xaQ=\r\n=fYmQ\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_12.0.0_1658666892363_0.7826670767294284"},"_hasShrinkwrap":false},"12.0.0-9d12d6f8920566ac4d9481d15d1dbc9669d39b90":{"name":"@detachhead/ts-helpers","version":"12.0.0-9d12d6f8920566ac4d9481d15d1dbc9669d39b90","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","assert":"^2.0.0","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"0.0.14-43959a8a9dd85b573b01bae9139c42b838bdc4dd","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.3.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^2.7.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^4.8.0-beta"},"gitHead":"9d12d6f8920566ac4d9481d15d1dbc9669d39b90","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nEquals<number, 1 | 2> // false\nEquals<any, 10> // false\nEquals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript >=4.8. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@12.0.0-9d12d6f8920566ac4d9481d15d1dbc9669d39b90","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-ZglBM1vsoGSVSJlw2uHuRv5+iL6tW9pIZ+IywIJZG+eNz4PINFw4509Egz0bfPHTobCiyy3PyyMJ4d16NtvCzQ==","shasum":"8fa5785b0e80b5072f1a5d9e70f5b41f7240d133","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-12.0.0-9d12d6f8920566ac4d9481d15d1dbc9669d39b90.tgz","fileCount":78,"unpackedSize":373163,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCE7y66PWqnaRoLF+Jm1vvEzeLwOpvHTkVBPjMyBXG/mQIgBEDb3NzaWC8ZKqLGAueJyw8JypVgMhsfRih475Nn/x0="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi3oAxACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpWGhAAlfFbfopP9xhrBLY+qMoIBQPBwjS5APvdFvPZAfM9qziniqLX\r\nGG8xRd3pWkia9T13/7ROWJL9OTQkGFbFsj5HRiy+z0CBf8zMw2KeaQLNWhul\r\njrne8+UEw8PVALMlwHgOchwReoPkO27EipOMzBvwSraijjaNhZWMKFqqgddb\r\nml55ByJHKDf9L+dUMugK5r9fqWNpWz9Onq5Uhpfi0NLwHiRUQuhpuOpd/WOS\r\nztxFjdhWB07GhFRaqE1Kne7cj8YPSnxQVl0rPXmI0cUfCA5t4XtIj9tiZyEA\r\nOO8mhOR0RSLhSMBHzM95aiRhrs52Gd9aF84o9YYopR2cYMnT6pQL13qvY+kl\r\ngBe2bgEGlZFQLf+OpW5csqFRqPN1iTD7Y/yNF3u4037h9t66zqIZv2+KPIBw\r\nNjVjaE30/TPpHzS8HEo2P9WzBNawOdFQiuvU0aQ2vzcnUXLrAWdBUvoPz6/8\r\n6fqe3QAJYqiBo9qKik/6RnHphRn2bstBcEVLOi7om5tHZ7lGQ0623Jij58jh\r\ntpexSXY+TmQraoK+Ifo8Y4nO4uM3aeMLC8hinkTYH3D6/yA3Aj1/K0g4rKwE\r\nUE/4daZwODTH9zay/fIrV3CmHyziOCZWnKRxsv4RfKk7jILf8BSaewEXC/UQ\r\n37USOSKXC/RoJbz/IOvm5vR14wCo+QPEtk8=\r\n=gbgA\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_12.0.0-9d12d6f8920566ac4d9481d15d1dbc9669d39b90_1658748976943_0.7284167747998522"},"_hasShrinkwrap":false},"12.0.0-3f5b78f95224c63e37310e7eb736fcb94af8cc39":{"name":"@detachhead/ts-helpers","version":"12.0.0-3f5b78f95224c63e37310e7eb736fcb94af8cc39","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","assert":"^2.0.0","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"0.0.14-43959a8a9dd85b573b01bae9139c42b838bdc4dd","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.3.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^3.0.0-alpha.0","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^4.8.0-beta"},"gitHead":"3f5b78f95224c63e37310e7eb736fcb94af8cc39","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript >=4.8. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@12.0.0-3f5b78f95224c63e37310e7eb736fcb94af8cc39","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-9OVmEiK/R7z3N6BP/ORdbgOnKG+XGxtpjH1ww9PmhF2FSdoLk4J4SMG8AypA+32eKVvjeixd7IkBMPZ3oaPvXw==","shasum":"f6008ef0fc02ff65eeb69b81e198239fed91694b","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-12.0.0-3f5b78f95224c63e37310e7eb736fcb94af8cc39.tgz","fileCount":78,"unpackedSize":373340,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCL3QlYtK9bcNepA2FYb5rnDcG34ryb1+Tjq2wZHxQZZQIhANnFSHG6nk3VRrcNwG3sR3vqQ3mImQBjgwjrKIEGQr2c"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi/xnZACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqaQA/+NN+9n857nH2nm5ShUUFS6esP2sbLTeCh3jvloYPuk6NiSapW\r\nGMdZ2YR9wKjhbO9A7u7sLAEKpLqoMdauwR7XdUIZu3ELguR586vN6b/cFVpn\r\nvQlYhH80wzcRVfs4t7qg+YPbbOlo0KlsaWtmR3DyXamC6/Fh7BbCVyXLcxee\r\nFETsNg+Q9cNacZRytTAxpCJUqrM/T9jSXBarHAsy2PWkDAiFO9tNfPINrqPC\r\nJqJu/vqUj+w70bm3EKFYpzRnnfZPQEHghEziHfKNP340nxCPP8gniU8P8yWn\r\ny4Y2QDrCDr+VNJuTkIKjdXTk/WIw0ul64e4UldeqsU7M7G+rBt43Xvr09l52\r\nspYB1Au7XRpH4qA/3RRXG8Qy3i03RV7mV8x8suPY11hlu7NVAy894xjbMcnw\r\nama+p0X1K28gnDUa4MVsoTebxKqfLlanASPqwwQcUiy3sILSlP4Be/4bNaAr\r\nPsp7ztg6jjkqKo/SEoJ457UsxmfdxcH95HEBger6u0uCVt0H2+7o5zf8vg7A\r\neZ00K6QetMmnCt5S7xFE7VXkxIKjbrsiuBS+iRCKfcOLoLgp8cNunfAGslji\r\n9N75bJh9O7xQBG6gbhEsZAi82b2YF+/kBDs66Ce4dQAbqG1hoOjjyWULFoSf\r\ngfoSXE+W5ff63UH6ZiEOOUwSQdBhR4apOZU=\r\n=em9m\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_12.0.0-3f5b78f95224c63e37310e7eb736fcb94af8cc39_1660885465109_0.7655561113772975"},"_hasShrinkwrap":false},"12.1.0-ce8821800ef9863bb2a7616a35df870866aee880":{"name":"@detachhead/ts-helpers","version":"12.1.0-ce8821800ef9863bb2a7616a35df870866aee880","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","assert":"^2.0.0","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"0.0.14-43959a8a9dd85b573b01bae9139c42b838bdc4dd","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.3.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^3.0.0-alpha.0","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^4.8.0-beta"},"gitHead":"ce8821800ef9863bb2a7616a35df870866aee880","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript >=4.8. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@12.1.0-ce8821800ef9863bb2a7616a35df870866aee880","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-WTGSj/T+uQ/fBfAYrGVk2Ckzve4eOf1GI5NibIOcssILkZ0IcuaRM+YxCk+LtA8Jbf6q5w3gFHDuyGbmCZTKzA==","shasum":"e3bd44ddbd214a1c7423cebe41488df2ed5f2c30","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-12.1.0-ce8821800ef9863bb2a7616a35df870866aee880.tgz","fileCount":78,"unpackedSize":374722,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCsVnBDUiIlNZIJk4AvgpiRtA/okQWONkPulsMkN9yJ5wIgBurKjX1PUNohK4rqL1pVlL7VB0EWuKAtFeSzGY0rEQA="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjFVaoACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmr/Sg//QTajoUax9ywTBg4OIDXIMxy2v1ZmhEjI4ww0HK8gx+vAsdOC\r\n6fTCMiXO3WlznvIrNPT8d0Sx9VhybKX2esnw0Yd4+YhbBoS2zu37OCde3t5Y\r\nQADATQe85GSLyarEkqpjnB1ZITDq4uRuKcDZpmMUOvAyzqsEJw5/wptyyYpI\r\nDsmp+0rP6PmJX8tsvTsZywOXa6IXqkYLdIJ3HhKr1E8P8/A2LadF6KOET7OE\r\nBw7+qGCIElr8oUu4qoK5z2O0rJ+nENrF6Xkdu2Qfrzf5+j81D31NluZXkYZc\r\nFYOF0lh+2mNsgXFjev9K4HI5QMpUcPmYC1ig9kaQqvUcWBFh2MMJVVkI0bB1\r\n2U2VGuCYGl45ae4RWcQTXpkQpTW9qiyGgNRg9a/oGMKvNthz/+RFq7VX9D94\r\n6fCD2p6B10izZ5IrN43nog1kQppv3R6WM8BRWI/Z9kZ3ZuqyG3g4Y7ejYp7j\r\nUSVksbj/LB1o8sk43A68yvaKafgaqzyWQXnm/yAMttLGOmr3v2I+rUiAq+Bd\r\n2TYjTdY3Gn7Ht2aIHhJgucqMCBhVLUI15YJnGsUpIL16nbrCx2JhYpsxnWdy\r\nEAKvCqQEWZ7DhDmH4Pvrktxcg0KTC4hHIvi40G7GZumbTItnVv/ZV824RIPO\r\nkww2LnPwsCHsL4QtgjNuT8ypBPb9YLnNP7Q=\r\n=6rEU\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_12.1.0-ce8821800ef9863bb2a7616a35df870866aee880_1662342824329_0.3599078167397709"},"_hasShrinkwrap":false},"12.1.0":{"name":"@detachhead/ts-helpers","version":"12.1.0","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","assert":"^2.0.0","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"0.0.14-43959a8a9dd85b573b01bae9139c42b838bdc4dd","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.3.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^3.0.0-alpha.0","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^4.8.0-beta"},"gitHead":"79427534b1387501cc6485b7816d34a338da3b8e","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@12.1.0","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-2Cbc5T49Ke8bo8EyqvW36mPT7ixyS/Lmm5OXnT1xPb5KlDHCnzIPxleSKpG04k2yntX3y9+9Wj65+H5OPMQixw==","shasum":"d04716c31f47fbebd8bb84388ab9a9de8b0cd0e8","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-12.1.0.tgz","fileCount":78,"unpackedSize":374681,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCUWoUYcxGELcAcS7dzIJHyCPsgEcpFVtBiYQKebRp0VwIgH9sJGYjyHSuMe+K0FH6ygflvo5EXYthh616ahl2+dVU="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjFVgNACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqiAQ//f8uIfJiH4hiO6xsDVywDP7qOiKE2U9VHy6X8qnzvg5QvXxZr\r\n2Yf/mTaZaG6XvoQKZmCy7/+qYFKpMtgmDQryImvW4A/Prv0RI74erw26kWsv\r\nM7I/7OhIffsWu7wdoj5LkY91ss5jYxdut0Caq0O90fFpLFWIj2lIU3UbB351\r\naxQkoiWvUSh0+SmVN57hX/Nv5ztzuvc+kTSW62WxO04dfofspWJsb0AkyVze\r\neITS53wk+PxDVJLrt2OsNQdLzmGmEmU63LONXdzhXk660kk3Fp9YCnc7/RBk\r\nW6DQcubmS1d3nNakVjYxiHWAhkNIybCjViBGTf6DjX29dqzpFnMNw6stEXK/\r\nApoWVgSKCJ3gXTTpfe2BsuDfKPRgGvpnxPbo2NdJrlpgpiaEIQoq2BFOuhxs\r\neoetSSpWDKWZkZT/1JPiCBQjAebvJ/d+oakcYEb7ZWrfZ6115c3DUAwjA7jQ\r\nncTaMMTcS7E3hEQO4zl3uVXp6usH6fqaKrlXztrD86WAz5kLVZMmyL19UftI\r\nU6zwIj3ZbsHADAqHP3t5cM2gqlvbTcf/5iYrFtkdQ6w3Z/Q4B1/Z4u4qDRBL\r\nKIDOwhkso4wQIhb5S2EKbqX7V+mhg8wa+Q3Rb/n4IjFFbLhgMXCt/607Mxbf\r\n6T3oKg5l2smXKensOrPMLAE66OmCvBXmZlI=\r\n=5vvx\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_12.1.0_1662343180923_0.38134220815321407"},"_hasShrinkwrap":false},"12.1.0-e3ed006927b98f306d52e363fc2e06c9720a9caa":{"name":"@detachhead/ts-helpers","version":"12.1.0-e3ed006927b98f306d52e363fc2e06c9720a9caa","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","assert":"^2.0.0","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"0.0.14-43959a8a9dd85b573b01bae9139c42b838bdc4dd","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.3.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^3.0.0-alpha.0","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^4.8.0-beta"},"gitHead":"e3ed006927b98f306d52e363fc2e06c9720a9caa","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript >=4.8. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@12.1.0-e3ed006927b98f306d52e363fc2e06c9720a9caa","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-bTDb5uYNw3MuLgkY3Asu4paN+pqz+YQPpAKmqzieJq2uCsMyuaHyiRE5xrTmeFL2J767RkVaXCqezv0tGydHoQ==","shasum":"41f2c3a52bc4127d56b31ce28d24fbc9ae11fadc","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-12.1.0-e3ed006927b98f306d52e363fc2e06c9720a9caa.tgz","fileCount":78,"unpackedSize":375021,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIArEqFq/JFWZZE7Jxl8ldVvU9BUmxI9k6oFKd6oIaSdOAiAH+h5bATXXnKVLpY4u6zuGO8T+0sqZf4zrgbynB2v3uQ=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjFWTsACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpiTg//bsctyqrm7cpGmH+0/NDH0BiQwP5DgvchWN5LaJF/zO86t0f1\r\nCEXNBH8Y9fKQ2a3ZQ0UAAJKa6xXaL4svEKHHa094EPMGDDxor0IIkZ/VkUTb\r\nTEZHr+w/5rWp7uj+vzcWaIckP0BHvqxcnhuMYMuzXoQ8VW4Wq6gKD4zvnm5v\r\nmgov3qlZgxnq70dSGCvoE0n/CVMea9nq2Gpf9BUiknr/gSCHqkF61p2aqxEM\r\nEhdhx//S+i5Bo6eJB7E5fGWbqCBSPbOlFx3I3zptBRVXr+I/1FcAQJo+pgjI\r\nHQ9w22mSHJzGuJpud342ingc1RzUN/PvHApE9PKewk9uUih6XhMFPo1yiDRa\r\natRUwLsRtKTH1uKQnK4p6PsHrI9fvQfz7/24UvtdMsG2uSJncc7h6qe5iEXj\r\nWkuq6ltV0hVsIr2hUg8yVPn9wI7OcJCvTDdoHtc+b9YJSpRKI8l9U0ajrSra\r\nexefn+8V6ezF0opYWKhsec+COb1KS44A30qW6gYtKK+6fJRtdCoHXDuC9+nb\r\n4c4HOxPn4BS4YGt30+awH9qdV3Nf7eNijiq7YM6ST4i0amHgnt+yfmp7gHUT\r\nbun4/LrB+YVA9Rpdrk1sE2Dy9KzGbyVCjwjY1fSqc8Bd2XMD7t1SQCx6PTJb\r\n8Qu6reHjTCEVOOzhFigKyJvTc/JL/6VCGlA=\r\n=V1i5\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_12.1.0-e3ed006927b98f306d52e363fc2e06c9720a9caa_1662346476264_0.27551119338013574"},"_hasShrinkwrap":false},"12.1.1-981d780df2ee0046595feab23007403afe38b258":{"name":"@detachhead/ts-helpers","version":"12.1.1-981d780df2ee0046595feab23007403afe38b258","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","assert":"^2.0.0","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"0.0.14-43959a8a9dd85b573b01bae9139c42b838bdc4dd","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.3.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^3.0.0-alpha.0","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^4.8.0-beta"},"gitHead":"981d780df2ee0046595feab23007403afe38b258","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript >=4.8. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@12.1.1-981d780df2ee0046595feab23007403afe38b258","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-ASEryTJl2zPdKyKNBdUBD5cIL4Stc/0e2YXvM9Be7lTTvDUmWkFpSDYWXpX5SqUkWeO/nTDgCybOeHHZ+T3q0Q==","shasum":"57ff10ec22d63d06a6d137c98114779b3eb962a3","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-12.1.1-981d780df2ee0046595feab23007403afe38b258.tgz","fileCount":78,"unpackedSize":375021,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIC+62i2kj0k1xTQhC0p/zliW+F/P85eUaTNfmptJZOEKAiBYIJNirN6LkI/RNnuHvXSwxZXgQKCl7mCSYN1IY2GjIw=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjFWVlACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpFUw/+PJHD2fyKXmMSKbR21InaTXxWq2cjgvzvLTZAZRb3HJfOuRLQ\r\n9DdObIdn9+XWF8Asf71hVadKonhp4whhZ36ELoCHFIYYusHDjaXquBeKmbo6\r\n/9Q0yqy8WWrfpHN2RGaSTW0odKOdEisiMPqmlX1g590wP8vJXHa82vZjavMo\r\nicllM5vXftCf5a3CiAme6t2P55zYf0dUglXLhsEMXpkjK0AhVA+e3Ff7rKZy\r\nHWN7OPU9IbqVhl/zLaVk/SjERP/DX+SKVHEKLSKtcMSlSrambEdU/R2LDT2F\r\n4QWobjKGIoK3f3U53/ehkPWVVH85cyV9JPgYAcnn/L8yW/3/puijiDk389Qw\r\nmxV1mBe83cvlC883r432qB2q7dWj3krEq+VpEKk5dzdcnkRuXtVq0TFQ0dkJ\r\nlyrYy8DlleDll0bU1DQUcv0Ra1TorKA6q2qUrbi1OzyYM5/XYvjZPcqfHu7l\r\ntJfpmIcl9kC1JKnmfTagitVVziNYDaXH91IKFvjzobjUs0dM6PWdbCOok/QA\r\nDGkBceUCtZ8TPi6nTJbE96PedCoug7nuA8VM3/B9ohbHGLoBDwEpPUqyLztZ\r\npKbs1P7NypnpC5VntqRk0qaOgZEGRebC/PdDboNBikIAA7KeXB8k7Z5aMCmH\r\nYDH4FNYIPhVFUY99a370iW3m8oRAtUJYimw=\r\n=wUk9\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_12.1.1-981d780df2ee0046595feab23007403afe38b258_1662346596899_0.02082247749871291"},"_hasShrinkwrap":false},"12.1.1":{"name":"@detachhead/ts-helpers","version":"12.1.1","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","assert":"^2.0.0","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"0.0.14-43959a8a9dd85b573b01bae9139c42b838bdc4dd","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.3.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^3.0.0-alpha.0","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^4.8.0-beta"},"gitHead":"cca735229d2c8a310acc45e86b685d192ef82963","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@12.1.1","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-Ez7aZdh3sUF7JbM9bgSB6kkftxoZc1sS+aqcJEYCzPPhe0VA678rkkjzsLOjCUIfHisEq5Qu3++sFFdWv1z6rQ==","shasum":"f491b4d955b8410448768d38f9afff23d0fd1bc0","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-12.1.1.tgz","fileCount":78,"unpackedSize":374980,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDPYZ01V9U/anuqxycHCeNYB5cT1CRPW3Iy6/hkOxU8pgIgc0SUGuMApTBM5t86BXu0xRkCkyVpi8pdLjRwk1eWAy4="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjFWcAACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqmWw//aOrmiI09Flu1BmDbHcGCLqhp9FMRLbn5uXwTtkjqnCXhll/k\r\nJ/+JU25KmDKUQs2TPrCUAElOq8Cs4wsLmqCDRP1r3f3QeD2H3YFSGuW/EED7\r\nBdM8pzHwhUHwlnZ6AMn+rYL6WOefC8WagRGeq0SEuoHSqRQ/tZFm1NCyX9qv\r\nRUmTRru8VdLQ7cxwZt7Vdlp/x+i30giurk8N3lOFLF4B5ZRJEjaBUwGNIKQm\r\nezr9rajvGZzWEoYvF5Md/D6aUBITYUruotFZ680QzYM0ofYaeYN5ngB1srvO\r\nd4lQkDdoYoTHpCJVUljoefchVoSt84rYF9DNjGJJyF4rdChY26vUx/c0W9dS\r\nEcPuoNoYG8cutaMV2FjtF2NA8Eb8iYdqe1IAlTI+RXaOsdeyz6xYmfxmKx4r\r\nYVsKow4NsKErRi8dgdHUqh/HE7mgbvIovJZdldKWrKaQrSDHkC07aq2DHDuF\r\nIBEWeIOFt3jqEZxxFVnV4gHo0WOl16N9vXB0ToP1e2iz8Lcui2OnYRnrl2pF\r\nS0dU98wVSx/eyv0ebuMKoYnbgnMKkniRfr5eSe4Xp9NMZymVRCWYcj1OBFrH\r\neW/dr+yReU0zScVLgIoDndDuBqRRkBMJ45TwdlASb+gr/gsxiYrGlSzLbR5B\r\nBkPUYqPkQ537Pkw1iKNz7yb1IopVBuCBViU=\r\n=1sYN\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_12.1.1_1662347007938_0.14925423072060418"},"_hasShrinkwrap":false},"12.1.1-8e0cdeffc5156f6718119c52ae5224ed36822562":{"name":"@detachhead/ts-helpers","version":"12.1.1-8e0cdeffc5156f6718119c52ae5224ed36822562","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","assert":"^2.0.0","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"0.0.14-43959a8a9dd85b573b01bae9139c42b838bdc4dd","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.3.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^3.0.0-alpha.0","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^4.8.0-beta"},"gitHead":"8e0cdeffc5156f6718119c52ae5224ed36822562","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript >=4.8. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@12.1.1-8e0cdeffc5156f6718119c52ae5224ed36822562","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-xzyuRbQafaYbLh37RGPQuKh8j/3t8syJj0jZ1aqZGbZYyp88v1MOz2WP1Gm/XlPP0cXadjDu17/GXo5JivtL6w==","shasum":"1665cfc7f1afad23cbf544a992884e9fc0ade0e1","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-12.1.1-8e0cdeffc5156f6718119c52ae5224ed36822562.tgz","fileCount":78,"unpackedSize":376908,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDtvtq7Vq4VQBxaZC+x4SdAAsEhJ2xt5iLx/xuMrVGI4AIgLuZ2jTTXXmQWoq2+uvXPgqnv0hQQTpF3P9L0B6MuboM="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjHwMRACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpZZw/+K9tZtWV5Z5/D3p4PyGmnzqnzkJAD970qL70Ujd2P/Ls786je\r\neadJ53lg0T2C521JQSS4fPxnO5SBhyVEkaLdca8jPfkxsXG7mIwaM1w7eSXn\r\nOMs0VMeGeCn9pnzJutBmFs5vvq8oaxocVn07EZrtcZaQeWntn9VWCT+p8HEW\r\nPAbyYjOHSBgtOSn5OOKE4oSCQyVXPidqJQtEgxhuZVF3swE91NEuFuuMB0Pj\r\nmpR4k+vtnahXiiMd1TNMsFGNoHIAvmpzlEPydTbcWztxz/nRxTDm16MODbQh\r\nYtaBzWGYGBBxgSPgcFN+VfU9lYuV894nh270ZQbEGNkuSvpIUZgzxOoz9GSV\r\nvgfjTiSWysbHQYp/gaIle7q3AOOlkzCut2WB0XbENwLjl4BcfKTEARa0eryw\r\nf8EMEIPVfKjF7d7hjVwnnvWf14ZbQ4V9S+USINZ9sH7ECjxE9XJXRIXyWQFm\r\nPSSKHWin4YWycn+8GdqBU/PC7uHfbLEPGbAs3rSakt/CFwZ8Drj71YR2Cinf\r\n8AqzMax4jrDiywjO3Y9scIhVucyaVRLhywx6WiMKlkpWMOIyhlHBFw+Ngq7D\r\nu4lV8MUKYirReCHIezd4XYnHFiDXtIqwNLjV8+6j5X2MDViMNs9nqyX52vjN\r\nBaQQv9SgQliPckbWUfQ1pzfXkD29GtLxfBA=\r\n=XErm\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_12.1.1-8e0cdeffc5156f6718119c52ae5224ed36822562_1662976785259_0.073914675649144"},"_hasShrinkwrap":false},"12.1.1-86512c3d5a4b1511f5c4304f1b9c75593c822322":{"name":"@detachhead/ts-helpers","version":"12.1.1-86512c3d5a4b1511f5c4304f1b9c75593c822322","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","assert":"^2.0.0","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"0.0.14-43959a8a9dd85b573b01bae9139c42b838bdc4dd","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.3.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^3.0.0-alpha.0","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^4.8.0-beta"},"gitHead":"86512c3d5a4b1511f5c4304f1b9c75593c822322","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript >=4.8. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@12.1.1-86512c3d5a4b1511f5c4304f1b9c75593c822322","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-Zgqr0R3fzRUsbaD3/2orxoc/QFzUvHWlcml1IpdmrNCVpps+oRunKxc4QgiKWb2H85BFFF0EwbkmnspdXr4KFA==","shasum":"7cd24f84243e2efc5de78ffac98e530fd66c7c69","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-12.1.1-86512c3d5a4b1511f5c4304f1b9c75593c822322.tgz","fileCount":78,"unpackedSize":376819,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDCERHDenQSN5En2z3QUwsDRT81iqIBLmXdwMJAzsRI0QIgQWuTzqFLWNlrI+5WAilLXzY+mCIwUCEV2q+tcXbsFkk="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjICirACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmrk7A//QO2baV8y4V9oeI3CdRaiZW7pe82zx0uf2jFGpkGSZPUXS05X\r\n0PoBy7xASxS1IbItTv4Zc22STWKdVSPiJDQ4X1vTD4VSk/W3Xm7oNPbSIJyb\r\nn/B2/u1TkFJNE5wVVBV169WMCyZCw4AWWIknTvaJdqXDqh0+mtv4XUsrb4VU\r\nKb7MWkoEGxW6f59a21Fg4qr46huHwRaRXJ/95wqk1ZE71xgSz5UfgqPsIHmW\r\nTAQkMbGRtrLKmOLdgVbaHdpJemmx1dNEsmSEmghITV3fSWJhqnbmLp5T5Ayh\r\nsOocNiNsW0YCI9XXyVj2BSgJXOg96TVbJ7dNsFOtFLSWdplCn0t1etgOQh1x\r\nqaTXPhxakOTr/EZbEo79L+Z7bUCokoeoaikjpSo0eykwyocyqmMZTpssWmjC\r\nUcJsiWiFrX+1zpDZvrC/JAvyC9n+jEAgNE3gNkGOewBb3OMk2+Vdoc3+QY+D\r\nMvuA59d2rf6StnHqlRfoHVvP2UYHb8A6J1NHMtqeWlp2tINi1BKdL6zNVN++\r\nSyiaOnUhVZwvyXjMao3kuy//0nBLrca1IOPFKnRiIyTurcBTMoc11VlirRax\r\nlVx5ArpdiGHgpG3GsLOxjOMqrf32JnDjCkxGGaHh19NVAScf3VvlafWu2aP9\r\nMOitOuWQVo1i9CvTNA4auAxTJomXAm2pt7U=\r\n=8nXV\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_12.1.1-86512c3d5a4b1511f5c4304f1b9c75593c822322_1663051947084_0.198727110046667"},"_hasShrinkwrap":false},"12.2.0":{"name":"@detachhead/ts-helpers","version":"12.2.0","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","assert":"^2.0.0","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"0.0.14-43959a8a9dd85b573b01bae9139c42b838bdc4dd","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.3.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^3.0.0-alpha.0","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^4.8.0-beta"},"gitHead":"1907fe0bbb006dd3d0872a429900779e3a30ce00","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@12.2.0","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-ClY05OW46t3+3Fx4rxsBJqrLUwTTvHXLmHXCIvGSmRqpTXM0gCEFqWaF0VEePuL3M5glZdyaGSDvM1orieU9Tw==","shasum":"70f67297756298b1f3fbcc4eeac50cb286d97b98","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-12.2.0.tgz","fileCount":78,"unpackedSize":376778,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD+/ozUEXFP6JWjhBRzmDdu62SBdGAWi4gEwGuVk77yzQIhAOJyg17fbMbEUzMKJhBvsf9g5PQDvQKuEnSPpWhQDHmk"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjIC05ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrVPA//d+STDdtxg5huTuZbrG3jl1Ik/rpc+9zQORB2Qli6shzF/7uu\r\nH1cRPWMnYk3mTHpFYNpIMFCou4W95fdX7paDrYJU47SKO+skxdCSJd5I1We+\r\nOmhGvpTmy/fq8uNXQe8gKyyGtTz5XAUrbUSb7rGpqv5ERO+UNtL3+Wq6BuxY\r\nMPysVl3jbNcOe2qHUgBrUMYiHnRa829+ezEPmPwrT0WdWzqnfNl8yjXinENH\r\nLcd3PYDLUEdtKnvOmsOHa2lPFiyqFjTYzn+irECNF8uxQWK5XUu4CHcMJZHq\r\n+r1qHJv4DpIW8843hiFm4hyR+Ctr7g9z0Ooy78Xcwt/OzaPUMg/k5SA4gnL0\r\nYC/Y5DwyksI/pvpyL8orr6+p4Y6fC3RAPdNHmlQL1WHg/4Ncfj4nYOuhMBF9\r\nOv1MtkV6fPXFy6pIn16p/7IT5cWf9hoFCJ6mkhd8Yu+Q/rTDxjcZCWZo8K7E\r\nD6sbdCxwfYMy1VRpo99XU+PqoCwdCIvh9eBZNm9e/GBUFm+lSLFOjh+d5VxT\r\nSCnmHjuHVcpUl1bo6Db03YzLZahyCR4LObm4heklon+D8lX7hfQX3xOhTdz1\r\ncxNptzCp3ruLAMMO0LccaURRJi8BwWUvsTJ3Ul0smGgnqzvjNgi8+i1+LPlg\r\nz0syEV/lZM65KCmnjpPm71+RQCJ7MlP+dvI=\r\n=gWsk\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_12.2.0_1663053113093_0.606790537428419"},"_hasShrinkwrap":false},"12.2.0-21e7f082b424b3599de6886dd19c33174bd85428":{"name":"@detachhead/ts-helpers","version":"12.2.0-21e7f082b424b3599de6886dd19c33174bd85428","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","assert":"^2.0.0","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"0.0.14-43959a8a9dd85b573b01bae9139c42b838bdc4dd","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.3.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^16.11.62","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^3.0.0-alpha.0","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^4.9.0-beta"},"gitHead":"21e7f082b424b3599de6886dd19c33174bd85428","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript >=4.8. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@12.2.0-21e7f082b424b3599de6886dd19c33174bd85428","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-P6y325TuLOvnxakx40kACDn0XKwT6ZH73rnMvKJbWDTJ4HG2Jy7wVMrgrqBal1wHpmnwgjs7AJ0sfUMz8T0TyQ==","shasum":"f77b499072409154283c392f20353243d1b757e9","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-12.2.0-21e7f082b424b3599de6886dd19c33174bd85428.tgz","fileCount":78,"unpackedSize":375583,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCy8M8LOYqhgnjYqEWUCp2lYPz5GjdeMbKzStK65AmcbQIgUC7Vl6mh3yAuuQU1JA4CLaInURQFVocE67fJcbxuqR8="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjM4qZACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmq6/xAAhVY6XJou4qCGKM4JUcPP1Y9r58Kl1y1RyaIuPH6MCUC+YSZ3\r\nwYbr3OH+StV3YOFPK5aVvYyDF+vG6SuEJ12Smrzbeug2Ve+oCrLs66oJ4Kj3\r\n7jw9xcHnfRLPm4AvHUSRPFfEwVi6QI6I0IhmB7/fuSFFfBsuHQeCSdzyeT7O\r\nobhWfv2D8Ano8pnl/R9yur4iO1OegAc1uWDqSOgvnW2RaUX5ad1ZOkMByb18\r\ning+dCSn3EgXnSR2AiP/B8a6YvwfP5/BAoX76b1LvjpMmkpb4wj8DNvGuz0x\r\n7vJ3FH8LGEo6d1J3A8BLzLQQwvYJSMw8LORg3DTey3F0kl6tBg53RTyhB2D/\r\nhUdZJseO/bAYqcnpu0aUs6rGtx4rumPXgEfAOM+b1y5J72jofmfm2D+h1mC+\r\nFOGevACzfPaRH37gL0N0N3TJCWHzudLgPwhCGEWHjACv8zEBaPs3yfJmXIDn\r\nxL1NNaqCi6f9xRVKjOD4APIbYC/B37czH/kMyaRXyKApsso1K0w+XYyyGbcb\r\noD5KONetcGN5Z6Qrh2fh6vQ658KaD2ydiJKRKv7s6e+pZavCV2lpjPN73yAj\r\ns5MxiFBq8GY4GKiRM4v768yIoEC4EVoa6Bc7TCV9kBIv3jRaZskBLsrIQqUs\r\ncmYGkptsYvoZ4ujmMqWTIe9Z4ExFhPmgYxw=\r\n=A1rO\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_12.2.0-21e7f082b424b3599de6886dd19c33174bd85428_1664322201281_0.26711900762871776"},"_hasShrinkwrap":false},"12.2.0-e8fe993df2b38c52e45274bb557114ab01b6542e":{"name":"@detachhead/ts-helpers","version":"12.2.0-e8fe993df2b38c52e45274bb557114ab01b6542e","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"4.17.20","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"0.0.14-43959a8a9dd85b573b01bae9139c42b838bdc4dd","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.3.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^3.0.0-alpha.0","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^4.8.0-beta"},"gitHead":"e8fe993df2b38c52e45274bb557114ab01b6542e","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript >=4.8. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@12.2.0-e8fe993df2b38c52e45274bb557114ab01b6542e","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-GPn2kOkYdHgkKJIeyVCiymYCAkJ8slvgzKmJbsnHeMmdflNPa7XFpmBtcgtPRc38uGJNgN3QUL+Qc2D0MptEGg==","shasum":"1d1b5e266c912933260fa7521935ada76eb28145","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-12.2.0-e8fe993df2b38c52e45274bb557114ab01b6542e.tgz","fileCount":78,"unpackedSize":376830,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICu3eLosEn9nvdJI7udEJ2HELBWml4UMYkcO6wi/IlRnAiBN/CPg923LuawXlY0jRMT2fSLZDRkylhQ1L4TFjUpTOw=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjUhS2ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmq5fRAAnFi3wTPU5cEvvotxS6SJLa0egMhvHoSOxNDhtzJ6srCqOgar\r\nPGMOpriQMg/RFN/m84E8VZ2lQ3t4tvztBlkc7QnffLqNMQ/h+SmaGP1TiXjM\r\nKDNZOMvhtWHa7mkEJ6nMSzW1TPSnvSKr+60BbiB6auN7S1lee0lzjBq5AkPl\r\nwozBHx2w5bcVKcOg2CqacT/zWx+IVvbMBmVl1pLOvDtuplAzRYODwMcQWJJs\r\nsPwhnDK0l2G5VoQqh6QwK7Mp/kaILrJgYwfH27NFAUfXHaThgoX+8eEx7usq\r\n4L/CdXrMsQUvbzenVad4/UUTC8WaB8VIww4NUEw5IALwUOiQrMH5BuzI1Bg6\r\n+0qF2KIXsRI1HoOUklTybT1t//hgm9Lzke0BiFxodFKnHReXPYV+zyT9G/Vn\r\nf2NX9dXVeyy9LYxmL2n31JxcMKGYnN9m6Tk1Joge/CF3hwa9LiSDEgq485ke\r\nDi3b1o7spyQwIWQFDAwg301Mq7tJIUMqHG88H2ZJpYqVsiAYeIMMaVOegnqC\r\nysWIXPTYGwxz9RMtb/Or/X04HYTyMsFS4qEthGt9fIDB/zu7tqCodgC1FKBF\r\ntPfVpdofdCZLGJvo7C7KXbI+0lA6veoI5DToH1D5a5VibhZ0/QMgUQdJW9k2\r\nF9jlHIp0ey2QF2ojMSIPcCiTPfsgwxXKF6A=\r\n=kYCa\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_12.2.0-e8fe993df2b38c52e45274bb557114ab01b6542e_1666323637790_0.8720440327842451"},"_hasShrinkwrap":false},"12.2.0-4a6d093441dbc3826c84b3aca3d4e72f0975b09e":{"name":"@detachhead/ts-helpers","version":"12.2.0-4a6d093441dbc3826c84b3aca3d4e72f0975b09e","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"0.0.14-43959a8a9dd85b573b01bae9139c42b838bdc4dd","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.3.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^3.0.0-alpha.0","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^4.8.0-beta"},"gitHead":"4a6d093441dbc3826c84b3aca3d4e72f0975b09e","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript >=4.8. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@12.2.0-4a6d093441dbc3826c84b3aca3d4e72f0975b09e","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-SsIZN88PdWmO7YTI4y3yaf9918DzUdtE3AAmg8iVbDoV3U8YhEfleWVWkzal8X35YiMUndVFZaIfclAF/HVHqA==","shasum":"f115acb8038355640a9202a591426cd02a3ffc7a","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-12.2.0-4a6d093441dbc3826c84b3aca3d4e72f0975b09e.tgz","fileCount":78,"unpackedSize":376831,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIC4cLJStdMRVvwwBXrOhMLLyOMdi7Xs3sAf5iCUQolBxAiEA7MbmNkheKGB6YHTaZQNyi34dysP6cElTzn669ps8Ji4="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjUhx2ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqIUQ/9Eq7AH8fpluoUN6Q9hcum0L+9gHDdgH4v9nu/MJQxnQgvqXv8\r\nNRZX7+OI74zHAzd50tNpua/nRbB0eS275JfrPcKAlniF8zXO2jZM1oaSNxE1\r\nZcozEIS4gyDuoF2/mgogdv7AqL1+h9AW5V+qMrPL31lojmxxUWrr4cZg4KNR\r\n7VTY+8hSxt3hmsaaxyt72aGpjCr03SUJ6MEdvtTXFzMDK/3KvFbuUxJP8jDd\r\nEkTEGHNulESYJQtTGJ4Tl1NvYZwJBWpK+1iw+SyGlXIlbNqwnxSlg5ImVPU1\r\npTdiCG1Xz0WLX0w8ZhgxxXgXsWSOPlnTFG41VvN5npWGj5eF7GRld4swJrlP\r\nrfEkgxLylYlkFtc545Bjv1hao237ayu4HMUouwYFD7Jd1qyFOlkEedtpbOeG\r\nS6aV6uqzKquNUuiiUPNhj+9k9lL2Qs4wzN1UxB1wf/GgPDQ/4i22LXybUlib\r\nz+6AysBIT1NvXt4mZujHgzHTCaB5bTnRpwO9UxPcZVRFMn9xy4Lfw5d7cCQk\r\nr3xHbCLLr0FUzEUYQRGt+jlJ0J+CQMhDy2TJnMiDOoqQ3u4lHEfpEcOri2uV\r\nUNd5nyWSdVpbSx3vMMb9IZ9flY9sz3qYHkpaPHF2BI0mkW/P6uInrcLuFf8O\r\nsdnKGBQe9RYQ+eHLCbSoY5JH2EXA73Mr6tk=\r\n=xtYC\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_12.2.0-4a6d093441dbc3826c84b3aca3d4e72f0975b09e_1666325622707_0.6035193313664413"},"_hasShrinkwrap":false},"12.2.0-48682ec3fad0800019a639c63ae75af701b1bc38":{"name":"@detachhead/ts-helpers","version":"12.2.0-48682ec3fad0800019a639c63ae75af701b1bc38","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"0.0.14-43959a8a9dd85b573b01bae9139c42b838bdc4dd","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.3.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^3.0.0-alpha.0","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^4.8.0-beta"},"gitHead":"48682ec3fad0800019a639c63ae75af701b1bc38","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript >=4.8. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@12.2.0-48682ec3fad0800019a639c63ae75af701b1bc38","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-/LiVcmCu4r3BqUTUJ7p/wzOnoIe1FABpkf+og9Sz4POeU9v60wmYpaHfd+muHNnPB2vLjN441JzZew7wPFXmFQ==","shasum":"f4a8d5ec3bbe9ab9f0fdcad88eccc0265b040218","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-12.2.0-48682ec3fad0800019a639c63ae75af701b1bc38.tgz","fileCount":78,"unpackedSize":376615,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD0j0LU8jpd+YFCIDH17faBc/T8WQH5yQMt97kVljnkCQIgUGcgiGnStRD3/fx6pQ+p1g4g5txHT+zcOBeujPCPJfk="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjWUAgACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmp29A/+O4MrOuL9x5bjDZtLKVomByJClz6fkBco4lvQGI3TiXhPoFM7\r\nv4C+ex/ZIeNh1/meK/07VUwz7QGVLwETDZyoeCnkM5fKleNPJjR7ld+jZR0c\r\nvZ16bKMh3wc7mItKYQwen/OaEHOJ+x9/9CXfDjMeMHSZfUfPKndJ6niAaiuW\r\nk/cQ+Ze8m2Gx3vf/asJyaaPELtNKScuMf5yL1G2CkLAxziweGBQVbuYrfFcD\r\nrRuUBtGk2QkITg1kBQFB/U9AFfyIoLRVXGSgNv2xEMuJb192dyx0zLlAH3a5\r\nV/T0wVxImEyggZVan6U02+NwsOCpzS1mYoOn3e2n5bubF8hCzRa2mwR/NJHI\r\ndyRAsScO6Giw3zeZbNjeOAa6+Soen1NbWuy8o12OFnscjpGTgyLS9YaB7FLa\r\nnAhNf62buYgn3Z2XqBInmZ02mfexru0KR3w4YXuV4BHKnCjZ7N44fqEyi0hq\r\ntVSM+k2UrvwWXWezKiON/Zr1BlV0HxrXbRu6Uy9DF1BBw5oD/hWIYryJvYmW\r\nA64+YjTDBpp/Qc7ACK/q8E/oEsw5xj6VzEny40K3Q8Bl8KgixImoX7ScaQV3\r\nc3KEUHOysypcksZ9YnLQDj4Qg3KD4cVshKhkq5FzTlui79KSORqZhUrOzkSP\r\nLR7SN+kIpQNCRgAanGijz5tskSGcjiR4XW8=\r\n=gcw8\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_12.2.0-48682ec3fad0800019a639c63ae75af701b1bc38_1666793504346_0.4867288420542255"},"_hasShrinkwrap":false},"12.2.0-d20a203a26f67ced14848cb153645f3ae7962aef":{"name":"@detachhead/ts-helpers","version":"12.2.0-d20a203a26f67ced14848cb153645f3ae7962aef","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"0.0.14-43959a8a9dd85b573b01bae9139c42b838bdc4dd","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.4.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^14.14.20","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^2.7.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^4.8.0-beta"},"gitHead":"d20a203a26f67ced14848cb153645f3ae7962aef","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript >=4.8. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@12.2.0-d20a203a26f67ced14848cb153645f3ae7962aef","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-Dq7jkQ7HwhhBLxlg9YghomGxW82oxs+5csJG+3uto3UzWvHvX27KdRIvpfdEzn8u+OLZSsqkW85KvMrbiDzvFw==","shasum":"d64e5c99fee815efa63e1f57bb38121b6e47b2fe","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-12.2.0-d20a203a26f67ced14848cb153645f3ae7962aef.tgz","fileCount":78,"unpackedSize":376823,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDW8/WdTDVRX6XyslOJfmVIX0WvJeY56w2DCxenQA3nPAiA7hvT5pG71R8EiuKI05TTM5wgDT3cs8GAgUT+hgbzw2Q=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjWUFqACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoOORAAiyxNqOeiBxaDUQv/3W0OAKGP46uih8IBaKQ8mGDtD7RPnVgN\r\ny2tcLWxV8Ds5UPBbMgBx8t/kvQ/tqBBlJBXsj+IyFPpMc6NlyuDo8CDa9TYs\r\nLi9Y6eEBM6438kCbeV0s+KbqXNXgd1zSPT0B6UIy7wcpqMUQUAA3nSgUW9EZ\r\nuAVwdvAIbpBmdXG60m7BwvfjppmwSUyvgCWf9FkLv6dMVfcER+f8Mmhtsoxx\r\nSJFBWWmH1eE1ksIP3Z1MroTalHGicuzlOTYcvnlLgYxhHAKJBgtWdXWagEeS\r\nFhUXcqT9L02LA3sM9rBb5Ft9/8CxQati46+UrnzSahiSwB66ODbfDA23FuRH\r\nMZqO23gIWKYRS6m/OLRI69hnmAMal/l1FaYNq9sKWgIZ3yrKGdwWlan2okGW\r\nRQCdgj9IsZB51CqsoWEfsWMfw4a6IwaRATBa5vNj6uokJluncBdd9WxDV9G7\r\n6lcZYvUcyemKFnjp6eFytgj1Z/Wavglf1p2rQpDgJdViEQfuDkMyaEggftjV\r\nt+KO+JavvCqeX/mj+sqjo66se6bWSZJRTOBFu77EscdjvC425C/Ixelbvu1r\r\noOTzASZaOXqhE5CZ6ANxHYaGRL3TVImIzWEFQ8i2sGx6FRtX5Z2AtUKK6iVw\r\nlqqUOVVAYxIjlN6ZU8UhuZ+FKcARu1JESDY=\r\n=TuWp\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_12.2.0-d20a203a26f67ced14848cb153645f3ae7962aef_1666793834319_0.19660007285653824"},"_hasShrinkwrap":false},"12.2.0-4212bc7ec14e1f105031a3c94479089faa7f61c5":{"name":"@detachhead/ts-helpers","version":"12.2.0-4212bc7ec14e1f105031a3c94479089faa7f61c5","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"0.0.14-43959a8a9dd85b573b01bae9139c42b838bdc4dd","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.4.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^18.11.6","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^2.7.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^4.9.0-beta"},"gitHead":"4212bc7ec14e1f105031a3c94479089faa7f61c5","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript >=4.8. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@12.2.0-4212bc7ec14e1f105031a3c94479089faa7f61c5","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-XTbGmgfgxjert1gMznNwBkAjyIMJ9TUSyV/P02OIizZfuQ9p3tcA0U7vHn5hlvsUxDqk6iQ1NFKxm4gpYtYS+Q==","shasum":"fbcb4d0e84d83addfa3ae202304b65b054784eaf","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-12.2.0-4212bc7ec14e1f105031a3c94479089faa7f61c5.tgz","fileCount":78,"unpackedSize":377456,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCy9UhAU33eohKoskJfo972bx0q4gKUEkZeoW9N/9lIkgIgY2lS2FCPtstVUUkCTzTuDBSKq/PLt7OfVVxj2JJpQ+Y="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjWUpwACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpJHg//WYJY2LJEwIZwQaPjIpku9jCVNw8sWpcr0m4qWkfgiXH/ov45\r\nBDUuTQKyvwexrbBFM9Xebi1ewbh0uUR6HswRuSn5YXD9PppGGOTfWeiGa3+f\r\nPoN7eA3FjkdJKI1LlMi1eW5k2P0I/Q5rQxb5JeMJidTracfPrd7luFpWl4nV\r\nxCEHBiIn4Iep1jHuugnPB8Pghzrn+g07A2MitgW4wjRwG4YTSzD3zQDZJ9BD\r\n0wgaJbrZOOlFr9+T8wOYvtN70uz1eCp1GGZfgAcsNBWELRXPghzgC3D2YPac\r\nNmHUC4PyKtZuT5pV/z2fIdHOp/eq7Oqwihd7JrSL3s6EpjrE+BwjSobkZRQY\r\nlgQp9gRGWygbra6EUP0CgUSuo1j85UZl/aS85kEwLrRcZ7XIKI6xHXB8j4fo\r\nYAmWukH9rpyC1DEoZBBQqcgQbqwTywSiT5uW1Zfzid62iutJrOk2TbLTQtLZ\r\nHI8gxIhPKeviPgHMdw46V1phlNSzTCiWBW4Jamiz9v5hhsMYw3BxI1YLEiT5\r\nJxYM6+4XH89JQVXREsQrX0atH+X4QPVF/MoAg8/eQmhAF6Ogb839G4+HX/lH\r\ntUfyDIEXKFxCxMTgcvrGSEi19v5Ka9rXrM9whMdTDOU2X10t/0hJGO9julE5\r\ndTUOAVYap/BXR1MHOamXmnpTiNiKK6Hs924=\r\n=wp6L\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_12.2.0-4212bc7ec14e1f105031a3c94479089faa7f61c5_1666796143950_0.5955916583001681"},"_hasShrinkwrap":false},"12.2.0-1747a9f032c3e299fc5c3d7ebdd6487476583b3f":{"name":"@detachhead/ts-helpers","version":"12.2.0-1747a9f032c3e299fc5c3d7ebdd6487476583b3f","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"0.0.14-43959a8a9dd85b573b01bae9139c42b838bdc4dd","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.4.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^18.11.6","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^2.7.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^4.9.0-beta"},"gitHead":"1747a9f032c3e299fc5c3d7ebdd6487476583b3f","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript >=4.8. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@12.2.0-1747a9f032c3e299fc5c3d7ebdd6487476583b3f","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-cfkn61roZpc+E8O/fc64oLzwT0PgPgwBvih4ysIAJgKDR4ohhJnGZ5D8WOLUsqYkwziPMN1w5OE07+eM5E9EIA==","shasum":"6b9817dbc547ea6ce96ed1b109c6367eddeb63a9","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-12.2.0-1747a9f032c3e299fc5c3d7ebdd6487476583b3f.tgz","fileCount":78,"unpackedSize":378961,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBINlhazHORLfcgFI7E4xpqmY5AyKaeMYbkqfxZQ1hODAiEAzsV6lF1QrL6ueqvYlkJAiK6MmMPoIMUze51bEL2zinw="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjY1ZnACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoNjw/+M7bDVtOQ6NZJxiNERsIPd0JM0X+4axnWkHuKlpmiMUAtEpPL\r\nsw0Z83D2fNJBD5sBdfU3hSejCSYCwER7VkVI3GnMj3T0/2ARCPLuehBYzE26\r\nL3S+5vyHo68shSJAhDvEk8BDWn223sTgBguvHz3URGZkXsPw4NSBeNwbSMvM\r\n3KyZRHsiaqhRPOWlZNMVc11ngYHuBt4yyUimyvy87ti2sZ+xNKGrmZRJqHh9\r\n4TNCUZKKqkXhIdkJ57VsN+603Nn3SYg42vjWxWpWcjJC18ZD1+EAOkGNQojQ\r\nEy/TwCUGwvq9ScdoyY5ZrjHM2JpXH7jddR3IKLw1Rmd5GeqTY/cF9eWI40KA\r\nkiNAu2TDqdrbVqwKJcu43xqiRyJgjCSsJ/RG/gyYm+oZO2P7NxGg/YDfMABZ\r\n4c873+SVzTb1RjrQpf7VbhkPqw1xNs4AvD5ePPon00btkDaLIFV/+5rFK86o\r\nhLIbGGSgkMfMNk+k8FPD82qzhbd8pCnXE5BCS2dZuNZ4PMAhn0d2Y1LoAQwH\r\nc1NStR+KzE7aUwZPkE7d4a7HALjxsuJbcr2l3s49jJkBuBLNNe1HKF7WVgWn\r\nrWuRTOCbkT/v0aagKu/gJGx/DNbfVyMVz9Jf3u6ktMwG8Z/oBeVreJf7290s\r\nw4jTdFTYkhYuyKXtbwcW1ZyU+MLvXY0OGbs=\r\n=X/uM\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_12.2.0-1747a9f032c3e299fc5c3d7ebdd6487476583b3f_1667454567528_0.5186006707057929"},"_hasShrinkwrap":false},"12.2.0-ea9c0219597acfd5a80422f61a24d3b42e0a6014":{"name":"@detachhead/ts-helpers","version":"12.2.0-ea9c0219597acfd5a80422f61a24d3b42e0a6014","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"0.0.14-43959a8a9dd85b573b01bae9139c42b838bdc4dd","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.4.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^18.11.6","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^2.7.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^4.9.0-beta"},"gitHead":"ea9c0219597acfd5a80422f61a24d3b42e0a6014","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript >=4.8. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@12.2.0-ea9c0219597acfd5a80422f61a24d3b42e0a6014","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-NMX/w0FTM/SqemmmZXUGayIevs44s7f5R1Q6m7qaYbrLvswUQoQx6Up/ySWIThAzJwyvuvrAxX0E38l1OZyLkw==","shasum":"e45020b16ba59a1c1174cf1304ef1ee3f91ef6fe","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-12.2.0-ea9c0219597acfd5a80422f61a24d3b42e0a6014.tgz","fileCount":78,"unpackedSize":379073,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICJa5tRIFOTypvkQ0GtjGuV6DYX1bkhWBp3RWwWxZ2kqAiEA0gI/Saao5hzVsIrbYX1F6EHuMmYy8Y5FIWxduZNvy/0="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjY1geACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmokUg//XH9wSpZPu3kIR7kUcmnR8L5VHAYc/uYvEUY6fsohlzvrNYMJ\r\nlcDtyV3B4fEtKX57FwwujWv+P7t3ZS782RI6ugrRVcg3W4A7nsTe9xWH+/56\r\nwHYDP5kDZEfCmLqIo8DW+ElsFMJAOZj5HGAwSQA0RyG/ejoGQADSwV1cPSlf\r\negHKE0O4RvfcwQ+L09/63cFnsoxtHDWdDQwBOZsHESMHGlFxFD9GZW+z3Nyl\r\nXaPbTr1RC4ge2uwMYMDHrdcamZMm9covOzc5C9A9Izx1FAa/Xy6oxzoUGo3T\r\nYnGFhyJK4of/rl3Ff1U0dJObJv5PLkEunnqPii3CnUc6ljDs0W3jqMtJSIKd\r\npfAUOIZ16J7Qv9cWwR2yq172UZlv73X5NWBdlaaApvK2HpylzveDn1mQremj\r\n+toJEew520o/PbkxFe+iXvkmcedI+T17liywPgOoyZT4T6OEV/fFjNCxE56d\r\ncPxm0Ofyb0MQydmr/pE84CtREMjYk6kSu25sNR1nQk6/4HuLfaxvBapvDckH\r\nOxqicJq4v+JhRmzMSz49XVzNv50c4R5sp2JMCSzwUrHGuyQt3WhogfYahVvD\r\n8S7rgY3NfAly4Z1kN0+dFeuazuLG+yXjBnEmZfXaUnoSEKzbRe0ro60QkWqk\r\nPkJBEuFGCIaDsRNbA/gNAp3S/r0sucngTkg=\r\n=xd3O\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_12.2.0-ea9c0219597acfd5a80422f61a24d3b42e0a6014_1667455006200_0.7492348408540133"},"_hasShrinkwrap":false},"12.2.0-ec487ad211b6d8fbea808d084b6b24544d029556":{"name":"@detachhead/ts-helpers","version":"12.2.0-ec487ad211b6d8fbea808d084b6b24544d029556","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"0.0.14-43959a8a9dd85b573b01bae9139c42b838bdc4dd","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.4.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^18.11.6","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^2.7.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^4.9.0-beta"},"gitHead":"ec487ad211b6d8fbea808d084b6b24544d029556","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript >=4.8. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@12.2.0-ec487ad211b6d8fbea808d084b6b24544d029556","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-ntNFRTnXEbJi8MVJMrevJuldx3pys6KAOb6sNGnUw+QTsdUthJb1h6/1sWn+mAmhmaOF9xJO5r6khECcifrR4w==","shasum":"030af6f781994b61b8c5eb1f52edebd15c35acc8","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-12.2.0-ec487ad211b6d8fbea808d084b6b24544d029556.tgz","fileCount":78,"unpackedSize":377240,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCdF5Zv/DTXQH1JgFfqqFiPup8ZaBepja/vS7RW68Sa7wIhAMpy2ngPJK3UjbsJG0AVf71MCGWmjtGmz3uvYDU8f1cm"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjaOrJACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpaOA//aB3oVMgtB/jBT0DsMShYPsEdlhScdFD/eF1Fv/vc93qVPTNe\r\nmRimIb0hGnvcyUUfKALpNLj/MuZWHtDf256w8cLEIAofTYdAD1E/uhavwjvv\r\nQDB6A2aa0t/tl7gCI0DZWYa/aJTqlEc0pvHV2UokFBVJdFfaya5Qn/XyvFWM\r\nQa4QTPGiNMLgeplwKgSzVnsxakfI8KYlJFHioFz044nhjtB+xf37+tU2c07+\r\nXUW/CclBXikQmb/21N71/o5GKMQcjZ9KoYQmvIg9bxsLwJHkZ3n0d6iE8GEK\r\nijx/ptuxvJJ2ShuciqnaKVZUr1eIAI4oOSC0LfCkqg4WpTYda2nszrH+8I+N\r\nnt44HQBExHZUVVEQaJ8ooJIQguxaBi2VK0MD+sc5tHwvMSPrbcOGCVm1mPZD\r\n2TP4wXbtcDCA3mPiXX1rrwYXKo0rPxFWECo2k5DpF7wyuk4CagdYmwo/TTxH\r\nfQzX40b1JUSz67FKPGQyE3GyBNePH4kYgvoec27tteUHGJb9GweKVT6QyE40\r\nsQitUiRCAjKhKRYg0SSrMy9imNGABJTm6TFf42EBdYW34xQeHe2+WHweZRZB\r\na7K9BAYSSvOhDGPuNZtfQIyhGL3v2JNov2tfETP/Em8+Jw/kco1bbRAzFnTg\r\n0BTarIpTpgaSsTGvM2w6kvvW81/xGANruks=\r\n=YSqW\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_12.2.0-ec487ad211b6d8fbea808d084b6b24544d029556_1667820233606_0.3046570614603108"},"_hasShrinkwrap":false},"12.2.0-1dd1f4d2be163501e6227de74cfe229bd71a4a84":{"name":"@detachhead/ts-helpers","version":"12.2.0-1dd1f4d2be163501e6227de74cfe229bd71a4a84","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"0.0.14-43959a8a9dd85b573b01bae9139c42b838bdc4dd","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.4.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^18.11.6","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^2.7.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^4.9.0-beta"},"gitHead":"1dd1f4d2be163501e6227de74cfe229bd71a4a84","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript >=4.8. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@12.2.0-1dd1f4d2be163501e6227de74cfe229bd71a4a84","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-oF3jNMecrUdZaUOSAWNLHj01YlwFX3vi8Vf9j0hHEX6bLzoShTwDdSyzP2WnSP+RvxZQm+2jhEqV5PSQ0iYyqQ==","shasum":"6ea2b4d544c954e318af300ff9ca3f5e0c59150a","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-12.2.0-1dd1f4d2be163501e6227de74cfe229bd71a4a84.tgz","fileCount":78,"unpackedSize":378706,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAsxhkk5z1DHXb0vrzkRleIckH5ArzBYIenUuv3ZU5HxAiAy4Y2fe3BnXcyvPYct7Mwp884GnN+9Exapz6Xkl+wlXQ=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjfw2GACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmqu2BAAiIMNNMpszWBD4yGGuk3lFhwOQ+sXb0jgCyKj0YULo53Qe6mF\r\ngqMZkWZQTVycvf7TT1ob2iLUCAOeri57khhXfZC6s8teRa0zMHjYaD56/APo\r\n2MwNaqJlFrzkLCp0tiChfTMq8fXQFBGd8TOOlcvNNVUZBt7K1+yo0QyaOqQB\r\n6tzNg1du5SZaQ84z6RcQU8lu7geTdurUfvuOQkIxFPt3hluvsoE0a2DI855N\r\nT93tHMCkaOZ9UQbOF5fwsEi0R5wGZNoLS+hgjFX+l8k1vitDdSa+YJJYXoAl\r\nOnKeMXYpvxIE4TtkRaJ/VGtfl71LXvL7kSi+4C8/6jhVEnpFe/E/sOI9BfZJ\r\nwjOU0r+Nk/dNiXDvUSMHz84F84PO0+vsPrriIgD6UMs+znMHMEs6KOA5eIBv\r\nyrDRmgfUhosAcF9wBkJH1+3zvHlsLDxQYKeRMlsHvQOg5AqhUazs/BSh2fB1\r\nMz+RsAffWc79KxU+3wq81KKurZ4bdyc0x+OGxfxi+0+kHY6jAZ0UMjCdHWkq\r\nJQrVT0oWQnxjK8mvh5xlyaRitcln1Ws965uizN/SKQS+p0MBSODcC7F+w2VH\r\nfKLF00cMU1RDk1g3o3UMT54+QrpDIAy6UBuRRNsm2dMx6JEtvX07ol/Dr1LK\r\n49mpAT3UxrpIYkDugzYVpqiQlfiYEzn4O3w=\r\n=Oeqf\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_12.2.0-1dd1f4d2be163501e6227de74cfe229bd71a4a84_1669270917873_0.201726378786782"},"_hasShrinkwrap":false},"12.2.0-28289c8f5170256e66f123969dfef56bca801524":{"name":"@detachhead/ts-helpers","version":"12.2.0-28289c8f5170256e66f123969dfef56bca801524","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"0.0.14-43959a8a9dd85b573b01bae9139c42b838bdc4dd","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.4.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^18.11.6","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^2.7.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^4.9.0-beta"},"gitHead":"28289c8f5170256e66f123969dfef56bca801524","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript >=4.8. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@12.2.0-28289c8f5170256e66f123969dfef56bca801524","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-fHbGDzMKhMaF+t2PDyYI6JgHLOQNhXVZTSUso9qXbZW0OB3DTjq2FGqhZ3uoZcYO/xmMnOKQ1EWLNGX5YLcCIA==","shasum":"81b5cab1fa2ad7f976d8f799af143eee43a838e7","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-12.2.0-28289c8f5170256e66f123969dfef56bca801524.tgz","fileCount":78,"unpackedSize":380516,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC8WR658ThetIxcmPsafDaeD37tUaIa5iY/nZ71fBAXmAIhAOrHkmrP1M9WY+UIJPDEsHN3l43RlX7P6blCOaKH5kwG"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjgDUuACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmp8ig//SFJQfJqDh9Wzqp5xfPgOgE02JrzJhViugzCSTPn3BoKILlcK\r\nrv6GPwfYY8CL0qVbP8FyU5tcLF2h20jPT0bBd+sPYl8XeXuj2JfxmE+ZwF18\r\naxYgCa+9qbksGyX1D56UdnXx+vAphFnm1BY1MOY7LfwAiJhQkSZSbfNPZhxg\r\nlPp+9KPVgtT8BTv5kBDEzCGk1ypSW2W9bToSGmXvUGaUGER8XrXUUteH9Vtc\r\n7V4qgN5esI8JX+q5M9bC+VIGmG57sedvAur65c/9w3ScBJEJHhOJmKMHrhco\r\n4+nzGxj6EqRUmbptxpXt2/j6vtEBYpgedfjAEd/N4XpA2mmaiGnchJalUh4M\r\nWfNWNuQuXxBQq+EzTdaAP5VdtLqqHFJC893l8ZqIp6gC1bpxbqZVJf/+e+2R\r\nT1LIgpeCn1P6Iaol2lqy6/X/fP+BAkkoBQQIoxZNzZv8SUSusLXMRHKbvDst\r\ntwXlbOCuRF6h9MSBYaLwFHUuEXKqaOhLKxO+6AcSC+NGF2imRsM93RMHeOwU\r\niqLlofoxgs8kMANmOzbq/u2JBdsmdt95ziODA450DF8H1E88Owep0c1a7kZx\r\nlsUDlCaYZ1u9lyh7Mx/6FDam/lIwlHavDst9SCbKDsV9C2x8JrTwv2rIwKPX\r\n6jna/2cznhH+2WVXXGRncqFdxhbmcn4Jz+0=\r\n=4T7P\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_12.2.0-28289c8f5170256e66f123969dfef56bca801524_1669346606614_0.8772447134858841"},"_hasShrinkwrap":false},"12.2.0-be99caa70295068607721d47c2105b82f60f6884":{"name":"@detachhead/ts-helpers","version":"12.2.0-be99caa70295068607721d47c2105b82f60f6884","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"0.0.14-43959a8a9dd85b573b01bae9139c42b838bdc4dd","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.4.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^18.11.6","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^2.7.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^4.9.0-beta"},"gitHead":"be99caa70295068607721d47c2105b82f60f6884","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript >=4.8. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@12.2.0-be99caa70295068607721d47c2105b82f60f6884","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-gobM2t5rHMUd4onnpDjKOSbyw8XbKKbZX0jWMV7ZdcNzOJuJrcVbJuOj5ti6KuOtRMc18QtghQ4K/UN0kPSbqg==","shasum":"271053f53cfbe8ce0a77d68667b3968823360529","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-12.2.0-be99caa70295068607721d47c2105b82f60f6884.tgz","fileCount":78,"unpackedSize":381543,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDr+Vzr9x4rBV0SNMA340JsPAO677o6aQKsPbxh0CL9twIgZVSzc52dncbwD9AGBH0u/yVXmwOttZYvUzMx2YoxiYM="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjgGHPACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmr21Q//ddVzXFIVKBY0hSeVQBnam5GJzJuqHkVlwfO8AqG0RQGbHf1z\r\nRyLSHdd6W0gphbo1v+G2pBR+wW4CIA9vFeuzwQ6lgDWVoQi/LDdJFRAr9ugG\r\nC6GAkzxolbA3g+Km1+k4DXNc5dXZfTOsT1+whOZhPxljl+GkTry6SpXA+lpR\r\nyyF+3GCYRj/g9cxKZOgXukPEkxHAZi9t6oC8aNLU/S5nVBIYZ1brPPslv6UW\r\nYYYGAzxCjT9kHyVn7V7m+zrTGd1Fr9dBWPxwkZqBnFeRC70ZX6FcyZSxN0WO\r\n7+YFqGyAdYSmL5W3rzkj0VC/dknCUscTtBIZ8dZbOwzJALbu67i1mcoxEWRe\r\nYxFn6ilvqws4Q/yApfMcTQ384ysWr7xzMNo9iBOjpTBt4dR1j6uB5jBGo+7O\r\nZ3xmyTTjLGbaGRKPdsqEU5up0DS1MwTqF0Se542oUvUzFwVOAJlJE8a2kPr6\r\nxDSfK8D+jA0z41CtZyqn7OTj5agYE/TK0yJPo1MQZNqBwfhEdwa+Mw15IZ1G\r\nTqj2YFhxbZFQ1Gp/3S6ejm74CeiyCOB4dp7N9xNmC0dJ11SFCA6wPfSPkZKG\r\nWgcS2KfYZ4V1cLB8Q8BeQBKd+DMrgglEfUumhmb05jh2WQRIG6cIKpoZ6y6J\r\n6eGiDArJzAyN3eKN54JuZGu0DICK8JpTYNQ=\r\n=gmR0\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_12.2.0-be99caa70295068607721d47c2105b82f60f6884_1669358031197_0.27624719696675504"},"_hasShrinkwrap":false},"12.2.0-b4a523694792629511bbe65c79fd32cc34509d3d":{"name":"@detachhead/ts-helpers","version":"12.2.0-b4a523694792629511bbe65c79fd32cc34509d3d","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"0.0.14-43959a8a9dd85b573b01bae9139c42b838bdc4dd","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.4.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^18.11.6","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^2.7.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^4.9.0-beta"},"gitHead":"b4a523694792629511bbe65c79fd32cc34509d3d","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript >=4.8. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@12.2.0-b4a523694792629511bbe65c79fd32cc34509d3d","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-rVTmKt0YMI9ojVWKzFgh7J5fa3ZawvekhTcOP6u45hFocoz7qL3+zaoEtXTmUf4lxKP04tGvB8idqrXG1NfqVQ==","shasum":"e180e61806914e3186f7986e6f03b184f532eb4d","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-12.2.0-b4a523694792629511bbe65c79fd32cc34509d3d.tgz","fileCount":83,"unpackedSize":382093,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCfJvek7L48UayVAYY1I6QmQBiq0uGTeLzfmWY14GGpZwIhAKt1obIug587oBnY14/w8dX8bLDl+HDbbhAHg1P51Fgv"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjhAx4ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqRgA/+MqcDiGNV1LVncypJLTHFu+kJNqWZIVqs7ReoGmDijdYtll2H\r\n1/PfJnBJJdC2g7hEF/29/O1XYsWJFbbsX87OR76DV134YqCFAz4Lb8OK80sO\r\nlHdG6JyP6USFPYAVAD7W1hA31dPHX0REBCjzSuLHqReMdCp/6O+fa58OeSYV\r\nI3JQYovh4AmqgJWm4xVTTiWx6BKMLtnI+KanaD5Hz5g7Asu45S63UI0MZTAA\r\nHSH+AsfyY0Y6lTWZ+rLIyB+ysp6DDhourAqhSfszpvSq3Pjy5GgqEucxuh+S\r\nQd0WNXhzh7OjMyLxqKYXXtifODTFM7d3qxa62kjOBiAn7549CoWajUlRBnl9\r\nHKvo5PyOgjClDLzsebcfCWdkQu69EFIN43/b7NfuShwNfQ/bF9c7hsmlqQrW\r\nSK15tBkll17RpwhwbzBm2GZ7y5EhA9FoxK0V0psJGAh3RDJfrJ2bMLI3eR4X\r\nDYXA4GxSvwEX6LObUMYkgotfRyt5lYL2V2sNzX4irhrU46Hg5seSMDb+bUkd\r\nBoXds9Lu8KvHHu7TBqTB3XGPrNVpn911Dov8GUgk1W8IX67jwslofaBAywHj\r\n5pKF5q4jHm8Zpt7h4lYMe3JT/BEs9ip/GhRr/2IkqG9msJNz5b48O/GphkXX\r\nDm660XD5+YR9IyLjza6dpUWm9LoGTyh+m2Q=\r\n=3/cf\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_12.2.0-b4a523694792629511bbe65c79fd32cc34509d3d_1669598327973_0.927976460171605"},"_hasShrinkwrap":false},"12.2.0-a95db206e7b5c12f4cd2bee94b2dddad507bd9c8":{"name":"@detachhead/ts-helpers","version":"12.2.0-a95db206e7b5c12f4cd2bee94b2dddad507bd9c8","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"0.0.14-43959a8a9dd85b573b01bae9139c42b838bdc4dd","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.4.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^18.11.6","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^2.7.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^4.9.0-beta"},"gitHead":"a95db206e7b5c12f4cd2bee94b2dddad507bd9c8","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript >=4.8. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@12.2.0-a95db206e7b5c12f4cd2bee94b2dddad507bd9c8","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-3Pf8smPqEZX1QOVk88sDtRQWsbWd6eVrahWpeXYmIKc1mHkTJAat+e5jNgWn7KMsXFlL0MtJMDk4hNlHs8sPpA==","shasum":"8400dcd4bf8770816ee7bb876016172595011859","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-12.2.0-a95db206e7b5c12f4cd2bee94b2dddad507bd9c8.tgz","fileCount":83,"unpackedSize":382154,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCg6Th78kLf99QLBwMJ/mwAnd5qS8wJ6r95hyf1gBUZIAIgSXj4Se9ZPK9JmPGgxEF3+i8ftqtuf0PWw2BWm87qeOQ="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjhBEuACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmpe0g//ect9jF98TFG5qHXYE0c2Ulz+CHlPQl2PCm3TD6KKK8LWmbjo\r\n3p6GQ8Fo7a4jzC9IMvudzPSJsfDXFxW8V8wPKnuB/szhME966Eb4iLKU2lyI\r\n9/RGYqRLwMgFPL1s6nD4RxutHL9mR+CJ3BONXX5oifxWfJqVAvnoJbLOLJwf\r\n4MqwHBceVJENQiMa4BYSc/28x6knxD3lxhN7+Z8AFZdJd5SZEqRXfrkwygfX\r\nDAlLXZWavnrmNdIUe0Xb4P9zfzzdfzg2QivaBYsAb2NwP+NhUBs3IIOkQ9hB\r\nDD0FRaT6SiVqeXci/KUxcuqjhnF60uvnE0X5sE4nf6eWCTfU7RIEwB9tbt1I\r\nq5fTwRPA4cxpRZFdA2CWOuJyf2RyE6NGsfAlSPWvvXq8lvkXqWJk4TER2P75\r\nGq6Z35K9t6QAXcMYXNhxXF2W9sc0s47nepCU456tUXBK7W+wE522tllNaCds\r\n6lTXLLe+uGto6uFpyZmy0ydPyIefei/tgxWGPh0wYL/nlfrbqHQg5bSLhp32\r\nFmyaY1h9gcLAE5mwgF4YNxvX98tGf9Qb05Clx431S1UfNegH7jTyaHKNXDsR\r\nzb/QC5j6wL1O0YH5jwlYsMReKUrhJDiI/8n0Q6csqdovWFFKh1PxP6xYgzjr\r\nC91veWGqwvz0RKNC1YvYE/6bFYxxOVF6bdA=\r\n=3YJY\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_12.2.0-a95db206e7b5c12f4cd2bee94b2dddad507bd9c8_1669599534208_0.26984619125432774"},"_hasShrinkwrap":false},"13.0.0-f14ce0168502d49286dbaa912f815e774437029f":{"name":"@detachhead/ts-helpers","version":"13.0.0-f14ce0168502d49286dbaa912f815e774437029f","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"0.0.14-43959a8a9dd85b573b01bae9139c42b838bdc4dd","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.4.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^18.11.6","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^2.7.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^4.9.0-beta"},"gitHead":"f14ce0168502d49286dbaa912f815e774437029f","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript >=4.8. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@13.0.0-f14ce0168502d49286dbaa912f815e774437029f","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-belcJTmYd0mxTdqYJmgTurv1r4owE1xk4pAUJZX0xFnJD0J7Lu9VgGeOZUEAd0uBOeVnGhSa+F/F+LTlbFIeNw==","shasum":"c145bb162a67ea4f4bdde104bf115ff801e674da","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-13.0.0-f14ce0168502d49286dbaa912f815e774437029f.tgz","fileCount":83,"unpackedSize":382154,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAn+ZRsxiBDYqFUFAcQozwAQl/3TvdppNWrP0LjX8EPqAiEAidAnmBLjHRLMhjWy5E9KIrjn2HXRDIYL3talzsOLqcE="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjhBOmACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqWpw//XoGTwNzCK+lGFm9zjDh0uPiOBibcM6DUmiof/mafibHa5opb\r\n01NIJI4wE+uTwAMvtZShdoTRCbWRQxOP5cSQLqFUiUBfgYDbebcb8fsAlbuJ\r\nYEu7+xBV/oZkQqFUJIZqG5LIvFO7UTVIjIjQcKPJcWneMsZ/iIPAX5f4yst3\r\nbng7ELfqqZzY2Flh9YT+R+p4yJleGufUAwM9nKioH1ClPpHVte6WxZulp/E6\r\nxUDNc2OSvkJo1R6eP0xpTpeJDePVoBvzN5B/6jKmxRSjwenl4SEW46c0td11\r\njn9IgN3uOP+0sM6OgZYLT0/zFXCsdSw39gAly+h0v1I2rhzfbE7w7xj49SDL\r\nZ1Ss5KK8HPjT7IWLDnWFRCpjJQ5pn8hJvoGWjAoL2ta7xa83mqcTcLprne5J\r\nDLorcNJOct9QNY6y5UgbWbD4IMiRtHqonKNBALFN7Qca/UTTDcsCY92LQz7G\r\ngO9HDweHOP2jGz8zBTQilB/ZuFGWQgq7uj5Ni4M/BFNnCW3IjUV6JJyxCSgv\r\nxiu7vTVjJMYME3vV9icTjoCHmaiVeD2fGLXuCFp3t3mzQaSZUQS5zSfmGMhF\r\nfkah2MES8gJs+9p4Y9UxxLrQ/QDrJCtWHDGeUXb9EXWfvQurkDbub9M9D0Xs\r\no8Qmwjx1Rt9Jq+LzdxwQ4WG48dKEKjeCvI0=\r\n=lIrP\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_13.0.0-f14ce0168502d49286dbaa912f815e774437029f_1669600166217_0.6785726886400882"},"_hasShrinkwrap":false},"13.0.0":{"name":"@detachhead/ts-helpers","version":"13.0.0","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"0.0.14-43959a8a9dd85b573b01bae9139c42b838bdc4dd","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.4.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^18.11.6","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^2.7.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^4.9.0-beta"},"gitHead":"f14ce0168502d49286dbaa912f815e774437029f","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@13.0.0","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-Bo6O40lujxSNdYoAX6aERxirn3nfH124/8emJT10kJI/6ghOAUkecPSgpfh00I4dJAbzuapcnO8xxbJqRvZzvg==","shasum":"838c2c1a0f4d77749e70163c3c3af269037809bf","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-13.0.0.tgz","fileCount":83,"unpackedSize":382113,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDVHrwNvSxBrc6ur/FYQkeRO4oULbUS4dHJiITZmv8lwwIhAJ8/NdWiWdXUC1jfpnp+qle7FSzvuJJExPn93bo50go+"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjhBO/ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmptbA//d+HYE3XF1S8wsvhf9U983JfIR/Hol08qNZ8E6oHLczZSnAvo\r\n4B6N4Df3tfRTaBRmgexnJTaY3a84miO0rRyoV9Togu6/6v9/F3IyBOPyNCuS\r\n9LIaCTLFkvWDv5kv7KMxwSDkPWvHq5O3MjgdtsSCweeSR9jxkFEelkHk8pFK\r\nJI8RaUHk7IJSLwo/XPs3wqvxz0HbIVycEOIzwt+36+Pikn1ko+4vW+JZ5X80\r\nUjpUo13+9BAp1SEZq8C+aQTlvrUNO8yVpPv8FYnp70EAbBh7N/Es5r1sq/Ry\r\n8JP7GzCYN7GFGmt8nA+0u1xL7n2IEQFBkT/Rs3Z8X6Dn9XAUrHsdq+Ftv+vv\r\nxQ8Uemn04h8i8dJfSjxj42QbM+Xl/Qe/G/MT53d9ey5ze95jzNyyrUGHUsXF\r\nvjfoWovvXPMaCf/HXB1sSMl646nnEvpMHypvCRABbIuNmGtc0a1owDsXxOI8\r\nTTOdVGLs0EpwO4fPAkOmEvd1gpkAxmHuG5JTTV93sQ7+nPOeKAV/9bJnDwCS\r\nAPtLohP98FVtiWMuckfgTjsz3nMMDiXTmPO5Udee0f6Xw4cmKFNeLqd12Yb4\r\n20z5mqtJx2EtPsvQ7HZfA3DAsBPfsfWK9bZ5vY0BtTfSoPuKaEfUEL6lKCmZ\r\nnn5z5cBZhRgPw2Nj+bWYGCFd0iunnfm0SbA=\r\n=QTM7\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_13.0.0_1669600191601_0.8585933275229265"},"_hasShrinkwrap":false},"13.0.0-4ad7dd974bb075ce5a66a4bc3fd405afdd5e2c66":{"name":"@detachhead/ts-helpers","version":"13.0.0-4ad7dd974bb075ce5a66a4bc3fd405afdd5e2c66","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"0.0.14-43959a8a9dd85b573b01bae9139c42b838bdc4dd","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.4.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^18.11.6","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^2.7.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^4.9.0-beta"},"gitHead":"4ad7dd974bb075ce5a66a4bc3fd405afdd5e2c66","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript >=4.8. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@13.0.0-4ad7dd974bb075ce5a66a4bc3fd405afdd5e2c66","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-agi53btIxubx5Cawk3FDi5nBKiSPtO/qsgOv2dAUNZ7o2dxBF0BQr3aM+sUxOUt2syOEzpd5leDu6bcudn5Ekg==","shasum":"8f32c33f7556de896dc33e576acda6401febe230","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-13.0.0-4ad7dd974bb075ce5a66a4bc3fd405afdd5e2c66.tgz","fileCount":84,"unpackedSize":388421,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD8MTHp9m4pMWmZPXdN0QB0FSk2gtPOCrKCJFmeMy+vTgIhAKOtawbohA3Jmwo2u0kTPAqUn2kDr37kXN35R8sDdJgu"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjhrVNACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrXZg//YXwFkLseEfmYE77zhcEpj1AUeukLsMSLKsMB+Jatx/XepRpl\r\njG02UzCtMnuisrDBy6dfSdpeSQg/xPoCeP6hgyj7XtJLl1/z5Dj+KJq9Om7U\r\n3ranl2eS6gpIYox5qAuTf4XV16+mvKAkYjSrHpJsYWEvbmTYHEaZf8JBMsBS\r\nNkHaq1Sx5xaKOTMvERdA14PZ3/axUpmyMVJh3uAhypoHUtA1tqpefcuZEMdm\r\nBqnp8b8+evhPh7/cxjL8GYvpQbkZJ5NfjZ8cf+vBRTVQw/ERQWgJC9/nfeAa\r\nw1gAgzmEcr+sXU/NviY0L/r/7+pa+5+mNxSjAe+qa/GJSR0253B0m541E4jg\r\nIkDexjSf+LON4mZc5mv6Mfhvzi5lRhbIGdxChcS6r1GUsormf3R2exTdac92\r\n6bArvgDfHlohJBUYeGRGfd6Ko9SOqs9cEEc+/O4Lif9aODUajr+/04JtY7ly\r\nMWpLXN1/OpwBxCQDRbn38y6OK+7mHB2ppdtznBYP9mki/4RCNT1wHdvNhIqb\r\nvAISU99tzn4qGcE5wshHEk87wujx6BVkwr3M59RAeAFrmBcPPm4WHEus1N1h\r\nLl1sDogQeyXO2DKY53MdgDqEzxkyHoFNWPYPEJH2kAGSCZUxcgKL/U9yJ3V2\r\nKquRdx35Ddyvjq3dYlM4GScehbfnkymY3cg=\r\n=14OW\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_13.0.0-4ad7dd974bb075ce5a66a4bc3fd405afdd5e2c66_1669772621046_0.8187944398291831"},"_hasShrinkwrap":false},"13.0.0-3f293e59df7c8d66918cb395399e1b0108f58a8e":{"name":"@detachhead/ts-helpers","version":"13.0.0-3f293e59df7c8d66918cb395399e1b0108f58a8e","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"0.0.14-43959a8a9dd85b573b01bae9139c42b838bdc4dd","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.4.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^18.11.6","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^2.7.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^4.9.0-beta"},"gitHead":"3f293e59df7c8d66918cb395399e1b0108f58a8e","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript >=4.8. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@13.0.0-3f293e59df7c8d66918cb395399e1b0108f58a8e","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-E9aof4RiXYxM9GV0VNwI4fuNP7mjjajowO5razyQuEduWjldRcuC6k133HAgtqUA4k5PVy4/XgNS9167ZACW9g==","shasum":"f79f734d4fe5683c957d17ae668251695d81ce05","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-13.0.0-3f293e59df7c8d66918cb395399e1b0108f58a8e.tgz","fileCount":83,"unpackedSize":382709,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDxZqxcw9ioo181usR3Dq8IWXeycO8AzXyRDqWod/eSmAIhAINqWlfSw9IYdHqPlkjw2PGEwJBH1CSogvylZMbNHm43"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjiz/8ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmp76A/7B9JpukLv6rkLtrN4cNblTsD+gSOB1n4zEBb9fdfcAPPDmdDc\r\n3vJUva8LWWACcpNUI1G8VEfe3l7ip/18LSy6+LzzFhGtYxcT2H0TensDbFqM\r\nhvNqCRLVVl4O2H7Rz5fPNc2WfzQyvYdY1/T5fMZg19iZ9kTLu8tPKepZ0px1\r\nK8iStAuhskGsosI40fBQcGiCUFOz9453aSZ16bIWtfCxWmh4mTKjSjsbSIxB\r\nQvRkl1230slS7krOWE2lyp9D+ek6GGLcXvtmbm2xFfd7eS3D+siUzfgaozyq\r\ntmiKbAb7/u+HBdGapXs3SJlMOO4eopGPCHUF1REvw4v+/Kc8jMbbTsfj3g3L\r\npOJD1gQqACS0j1SifDPi98v04Gsv4/RrkTVZp3vQFbQd5X3tz9SiV5YgbFkY\r\ntC1E4JzV31jOzsKOqQ3rIGIDD5RR7BTR1J2UQjB9ygRlfyUa8NR5Q5zgIk3/\r\neezv8FNGp5cwNXfIlCthgbjb6c2c7xgvlyE4NoKcXwGHSyWlWvjK0SA2Jan8\r\npYPEsWxYwVE8svNvDxp3KtnuBTpOu7dIuJ2fm9lO6oYmBXzuR1yM0apso14Z\r\nXttXUlfFNIFoH7+x5gxp76WESaLYXVrh9/qbSj9aEIbE2wuspe9YerM2FFes\r\n5bZf42lB3/y8qS3fVRtjwVXflI0/Wbwvy0E=\r\n=pKLR\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_13.0.0-3f293e59df7c8d66918cb395399e1b0108f58a8e_1670070267835_0.3410430666589068"},"_hasShrinkwrap":false},"13.0.0-959e88790c72c030c8be73187e427917347a2f5d":{"name":"@detachhead/ts-helpers","version":"13.0.0-959e88790c72c030c8be73187e427917347a2f5d","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"0.0.14-43959a8a9dd85b573b01bae9139c42b838bdc4dd","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.4.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^18.11.6","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^2.7.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^5.0.0-dev.20221206"},"gitHead":"959e88790c72c030c8be73187e427917347a2f5d","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n## requirements\n\n### typescript\n\nthis package is designed for typescript >=4.8. you will probably have issues trying to use it with older versions, tho it will probably still work if you set `skipLibCheck` to `true` in your `tsconfig.json` (which isn't recommended)\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@13.0.0-959e88790c72c030c8be73187e427917347a2f5d","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-Gw/1iDXObUORORVELykgFl1zm4QM01rkX59ddWjj4Ap/v4xX7A/3+6z5DzD0xYoliEx9g2hPuhq8651LACU0mg==","shasum":"25b4d3a81706a5c8c7876aaaaf84e99dd2c38957","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-13.0.0-959e88790c72c030c8be73187e427917347a2f5d.tgz","fileCount":84,"unpackedSize":298564,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCLIewGusupCcc+mRn0u9Mf3a/K5pOnyHbr5KAITQGfPwIhAIti+4XZIvL1jVzsZ/q/My2SJRnziOc/VljR43i6h3kN"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjj/KtACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmow0Q//aKzs+yqIcnmxpyQi5iHtC0Nzf+b4Rq9AoBkSFP1eHwHBLnWA\r\nR09ZY7eCalWpCf5UHqpU2hqPEJlkzCqNl2QdJuVuyy6IXipiyy4+OLfQYBfC\r\n9cOirQNs+88IPX4AMX1OgbWFQOs0tdPQHiLel/tAHPaR3PtavGRWj9JFcO9C\r\nNwbP7Jd8FiOJSCfqpk0kYHOnIeJ0MvdXjaWRDCVjBbQQUGoPJcQ7Kdg7jrGN\r\nV9lkVuLKQ/m742scWZC57Ej6buR3+O3sYNnrzS0CTwcoE/2F8GiD7oPsEXK4\r\n/C74C7Hcwc/4xsdAwIXXOkjZ/Qtbj4RHiRbe6+EeSFg7lweeRkm9vlwMoEsi\r\nTL3CAYHIkXJOhDJ8vX7ZQ8//spwRyuO34guxuYrHyUGq/aN7qN9xAG9rnNnZ\r\nnfHr5Xnl0oA5U5H2WPKtk+otEQqnzQ3nQ2fNz+DrLcTXfDGmLvGjyGQxkawV\r\nhJtsF17Lt2Av4egaUeEIqnBx/rvZE9mmiaqq/vLfJN2v5AP6QaI2C76LPifp\r\nna11iJntzoi7hNGR3Hk7df122PwAtsL72U5aqu1EovsMJvqAWZS5FMcpmDng\r\nEUcCUWM8xM5XbLfQGBZtyPni2ynIuG3YsEQQaOXYuQnJOos1in4boIaqfpZb\r\n0DhJlnOAgxqDpqKlizhLGGrWgMcvn80HZ8U=\r\n=j+7U\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_13.0.0-959e88790c72c030c8be73187e427917347a2f5d_1670378156881_0.43259334175131814"},"_hasShrinkwrap":false},"13.0.0-4819829d0de6aeaf7d6d616aa823858eb78483f4":{"name":"@detachhead/ts-helpers","version":"13.0.0-4819829d0de6aeaf7d6d616aa823858eb78483f4","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"0.0.14-43959a8a9dd85b573b01bae9139c42b838bdc4dd","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.4.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^18.11.6","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^2.7.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^5.0.0-dev.20221206"},"gitHead":"4819829d0de6aeaf7d6d616aa823858eb78483f4","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n## requirements\n\n### typescript\n\nsince this package pushes the limits of the typescript compiler, i often update it to depend on unreleased\nversions of typescript for bug fixes and to ensure that upcoming releases won't break any of my wacky types.\ncurrently it depends on typescript >=5.0. you will probably encounter type errors and/or performance issues trying to\nuse it with older versions.\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@13.0.0-4819829d0de6aeaf7d6d616aa823858eb78483f4","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-ybQOx0WnVLpYmemdzd3OdNaRe0iqxvLXWl7dhTnM+CgnaPytveMjt7CSnsvdtGRlGrGp3hVrog2GebZPLOxJpQ==","shasum":"36d4511e7cf9abb63be0e9555c6b56b7c2d8a0f1","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-13.0.0-4819829d0de6aeaf7d6d616aa823858eb78483f4.tgz","fileCount":84,"unpackedSize":298693,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICOGznoiKFcJhW127EKyiY+AWUZEqlo2zAkIxH4mp93gAiEAgmwOCOvaDFFaIR57aZDS/oWHe8UJT5WXTZYOoq4C+kc="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjj/ZYACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmpp1A//Y1lVdrwQNIis+arnvxd8yAlHUbgJ/sU6YA7PjLDHteYTYF9g\r\niESThGGs4Ftpgncj1ehOCnVl4VSpPk3F0SdSyy3h6F9AhI4QehooUaLS4rct\r\n6eB9mgElWGHqgfsDUzu93R7YWueVARJrvrvyhnl9PqRvsKd1iH308/wEGkoc\r\nEmXnfMU9cAhWJeVRrLkh49wMdq6tWGjwP8zOeCnDkkzXRpVtgtbtoYPk1DLK\r\njXG0GcSKQsGxwTOOIk+E07CJCwx8wMiAI9Q7e7KPBF7uBqM9lzQ8kaxj8h13\r\n1PPjO7fDqgEx9Qk/2Qve0LcLSU2Q1UnHlYNBGUpXVFv8D7i5uPVV+cGOt1MO\r\nmGQVPVOYiMQ4TnUFUeYwhsybeDM/HywaBE4gaR+oJYoJsjKhn4UPZav5WWRY\r\nK8hkutEaMBTXEkcd7+tEDOB+MLeOU5CN9/bpfhI1iV3MM9W99Rr8xXDDdqB0\r\nckIM7uaqIrMY27FG4LWJHmpVYBJuO3LotEqY6s5NYWaeuI28Gm8ON9UojkBC\r\ntJD9Qm/gEkWhFCYdBxiZ3YCq3+JYl9DkwUuafAuU5ZOt/KFU/W8Zn6gyes4M\r\n0TfWdp4by1EHNQNr4tFR7337lRmamYxqnFS4+ZWhmjqvgw58lKMpF4GJX/N7\r\nF+y2mtKqDTFZxyNqWG6CO+GX/lF8wkeEHEU=\r\n=1Am2\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_13.0.0-4819829d0de6aeaf7d6d616aa823858eb78483f4_1670379096596_0.28012289205541796"},"_hasShrinkwrap":false},"13.0.0-41b0a938ca58fef10262a2e0c5fa9aa39178444c":{"name":"@detachhead/ts-helpers","version":"13.0.0-41b0a938ca58fef10262a2e0c5fa9aa39178444c","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"0.0.14-43959a8a9dd85b573b01bae9139c42b838bdc4dd","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.4.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^18.11.6","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^2.7.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^5.0.0-dev.20221206"},"gitHead":"41b0a938ca58fef10262a2e0c5fa9aa39178444c","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n## requirements\n\n### typescript\n\nsince this package pushes the limits of the typescript compiler, i often update it to depend on unreleased\nversions of typescript for bug fixes and to ensure that upcoming releases won't break any of my wacky types.\ncurrently it depends on typescript >=5.0. you will probably encounter type errors and/or performance issues trying to\nuse it with older versions.\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@13.0.0-41b0a938ca58fef10262a2e0c5fa9aa39178444c","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-qjMm3pLFlgsBN37GhL2FGdhBw/nVbJqUgbQCKmNQAX0+CcIhry+Xbp4bKrCfGpuJVYnyQN2xNDd0PcSYLQZJNg==","shasum":"1e72d17f11b97b7e6067a81e7b18d50387f2492a","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-13.0.0-41b0a938ca58fef10262a2e0c5fa9aa39178444c.tgz","fileCount":84,"unpackedSize":298493,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCHq8p9X8ZoE3j6A6NPxrDqz5lxUrsgy6dakm0hUePdoQIhAIe+E9yTGzM7oOzhngp4t1BhQ35ou/PH3lKlKYaC7hj+"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjkBgHACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoGJQ//U3kU/oSEJOBcCt7qxN5QCqnIlEPSohaQAks10ligMOtzgyvc\r\nzrBAhhpUeobx8Q3Eix1YVGuKouSI/uTUABTXiNcijWJ0UrZeahI423tKNYpW\r\ne7I3LyrGlGZ9sRWhhhr7rSHnB7YGNiNRtpWH6qyL5HV/ZvUba12SIwuOVI27\r\nlCzNhuQ3IMCIPiuUAdKWMYwYj6MZQn5M8H1BqCmhOjGk+EkoboIwbMnaZ8n9\r\nGDHBPnowD/AFye976LszIEJRYWhnn2GySb2DOQfQvyW3osFnoQREQFqBCnUM\r\nwdC4hUK0fyOio1/xlZN1QoR0wuJZ2oTAuv+A61TI9tAHI/c0GWqjakBUJXZI\r\npR5eXfLQDXlqKYrv7DLU5FSMGSvNX8M7Z3H/Bh7aitAzW7JVJEHBV7ghk+vw\r\ngPaqZjHmPRoP/Ed86b8XfoJHvYCz9RtilcvEHNOsWok+o4CZ8XO068RN/99v\r\nr4eRsn53/k+RrycWfrbDi5SV1j2/ZynrIHzqZcVGdvzWnFz13hXbfPjUvP07\r\nQqmPe4wmfjBA0Om1pI8yJPTbV1ES8PLKuLB8bFTbM8KpZHyoMcfn2es25lTM\r\nKf5tc/svl2MDh75VKb3bWByV4nQhA6qHe7YehPxOx72E+E4wj4+fO0DH7WSd\r\ne6u2qECq/BEakfHdNvCVxHaOWbpGyU7N2gA=\r\n=TCCE\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_13.0.0-41b0a938ca58fef10262a2e0c5fa9aa39178444c_1670387719060_0.8696328550978192"},"_hasShrinkwrap":false},"13.0.0-ef4535e573233fef972d2ee49dd08af407471121":{"name":"@detachhead/ts-helpers","version":"13.0.0-ef4535e573233fef972d2ee49dd08af407471121","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.21","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.4.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^18.11.6","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^2.7.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^5.0.0-dev.20221206"},"gitHead":"ef4535e573233fef972d2ee49dd08af407471121","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n## requirements\n\n### typescript\n\nsince this package pushes the limits of the typescript compiler, i often update it to depend on unreleased\nversions of typescript for bug fixes and to ensure that upcoming releases won't break any of my wacky types.\ncurrently it depends on typescript >=5.0. you will probably encounter type errors and/or performance issues trying to\nuse it with older versions.\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@13.0.0-ef4535e573233fef972d2ee49dd08af407471121","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-rBJc4p5NkXE1CDhiNB+56SD6MI9kbqOmEIxDcvNub2e8H52U9tR/JFS0Gg22ip2/uQ977GXNgqUcNQVOHkKU5w==","shasum":"1f7c0ec7deb7d9b04f9af4793a491674ef7ed376","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-13.0.0-ef4535e573233fef972d2ee49dd08af407471121.tgz","fileCount":84,"unpackedSize":298452,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICYa/rKD2Vp5W9U9uDL3GpFRkJeaKzcbRnsIiBwaS+hdAiBVFE6ZOvSz+uO3iKeyYkHzRj96WhYwNc3hCy/6jLb21Q=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjob62ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmo+0xAAg2bUa+NzgCxu5QkJrTkn3lcbv6ia1mgVtXuJZ1ilpAklY96c\r\nMVpyrYmqRDvHnEvaw1Fhn4Hqp+ITlg/V9gzTZmlbP2u8VjhpDInk7sdM3Me/\r\ncNd8VdUn9oYTtsHhnBWYt6DuIk9P6piS7VpSntBcSl27ZqlziLNW0/Um6jEk\r\nlNUsdKU+FKEn3i4ckD8dymUSlgcweTmZZ4aMh/3Cuj0MNUg1Z55bjH+v5vOT\r\n2RqUe9nbld3UVjOv1gINlZJv2aD5+qCdxTmlhlNTaESHzhfqPeGj1JXWamrt\r\nM01mbBXkNQHTzpY5RuIPMkDX7J0cIKvFa9Qkikky2RUBTEQPXmzgUnmMqi6V\r\n+Nbmt72JOsKwby311EyQ+/rn/AiR3XyQwTRwiXVVuNqaDNS2Clk+Q7S52YOs\r\nnshcxERtiIJVjbQ2Vkz0clUtrmD2YmFF0s/vWesVtE+B5AUa2GgVcADIJFNv\r\nPiyxf6kz/4PBMs5zbffFFaIHu4WnR0sQMpsC3k+8ltVVjKkqXp6LBl84ngsV\r\nkUO+QJi0WUUnBs2rEnVBK7aHvKMoFwbsM21riT97pDG+wlESAzj+lMNeIXsY\r\nFk5hMGB2q+QFAtwn91oEFxvCbCSYJaH7v8abMrs9oBC8vgtEYysggT/EWDXH\r\nWwQp8jPGnGddT1AdK/32U4E19OlopaxQzjY=\r\n=ihmc\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_13.0.0-ef4535e573233fef972d2ee49dd08af407471121_1671544502228_0.179379937792711"},"_hasShrinkwrap":false},"13.0.0-b361e7f32fadd302ebee585d366ee26593390ba9":{"name":"@detachhead/ts-helpers","version":"13.0.0-b361e7f32fadd302ebee585d366ee26593390ba9","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.21","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.4.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^18.11.6","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^2.7.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^5.0.0-dev.20221206"},"gitHead":"b361e7f32fadd302ebee585d366ee26593390ba9","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n## requirements\n\n### typescript\n\nsince this package pushes the limits of the typescript compiler, i often update it to depend on unreleased\nversions of typescript for bug fixes and to ensure that upcoming releases won't break any of my wacky types.\ncurrently it depends on typescript >=5.0. you will probably encounter type errors and/or performance issues trying to\nuse it with older versions.\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@13.0.0-b361e7f32fadd302ebee585d366ee26593390ba9","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-tUasXpjCqt2W3AbUNyOpuDzctED5E38gnEEid51Yr1jpiTedmyH/d7Xre/i9Jc7XbC0X2nS0VrKu+gvDnnyz7w==","shasum":"de84c96a84dcb3aec054bf3efdf7e802069a8579","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-13.0.0-b361e7f32fadd302ebee585d366ee26593390ba9.tgz","fileCount":84,"unpackedSize":298075,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICGWNZWBiTkSvJsiRw+v8mzSa/QSci0XLJvYzRZ7F+z3AiEA8FnQYrQIsBsPe/1f+Y9UWj+hKSRIKeSMN2O23dvE1IA="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjowmdACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpFBg//dJnPM1oh8+pWts0w3HZrrFhskXpBQGyx5azvdzMHOrQfER3d\r\nNNlClh+HMQVHLZQdN4JU5PuxHXY3zNEvUHznLgNC1Pe6HMye8tNI4DygNeNf\r\nCSRLKjiyVnUQFCx93Kk32lsltvHd6f9qItZ5d47g0+s4RwiqljfIj/yluckY\r\nBcdDU3YUCgum+yh5egynJhaFLYnWP8IVk3S1U0ZELTMZLw9b3lZCJgHiRX4l\r\nTTtvK7BV6wAelF8Zc+E5zWOVl80O0JFkVc081klpUqOX68p+69BpapV2n+8h\r\n1a9ULL9nherqdWqXZRR6a6NGG3Mr+UGp4x9vOtKR5AEhOgtU1EXOwrcjQWD4\r\nfEu3ZjRInhh+6n/QRJq3Geqb17+wv+bsIVc0YVLB6Qwi6uv1YsxXergCFg4C\r\nUElIqXHZ+GLjilkp5Te7UF+4NfQSIJNWAo8f0FOcuMvf4wRY8Mojwu9MoyIz\r\nDnkPEZdFePwwADwz1mpk3U/juTWpHhtyJR0La75NFJ1viNovmT9d7Y+9otHr\r\n2XN2j7gbLOtqcDUNc9iCIYwi+etAEM43d6Sy8iTwakyVq5QVvLcIcblH9s2W\r\noWnhaXHif/AUoI6hIvfj6mI+pmcP3NpMQGQf+UgHrLkD7c2hqXdx35LDJsiG\r\npu2M8zSlSU+1XIV2L7psP7F+YDKHyLJybOw=\r\n=yjTm\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_13.0.0-b361e7f32fadd302ebee585d366ee26593390ba9_1671629213034_0.5699375967846467"},"_hasShrinkwrap":false},"13.0.0-65aab520825a846cf9ba865e9f0916c260b670c1":{"name":"@detachhead/ts-helpers","version":"13.0.0-65aab520825a846cf9ba865e9f0916c260b670c1","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.21","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.4.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^18.11.6","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^2.7.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^5.0.0-dev.20221206"},"gitHead":"65aab520825a846cf9ba865e9f0916c260b670c1","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n## requirements\n\n### typescript\n\nsince this package pushes the limits of the typescript compiler, i often update it to depend on unreleased\nversions of typescript for bug fixes and to ensure that upcoming releases won't break any of my wacky types.\ncurrently it depends on typescript >=5.0. you will probably encounter type errors and/or performance issues trying to\nuse it with older versions.\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@13.0.0-65aab520825a846cf9ba865e9f0916c260b670c1","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-JW6LH/9v1IRz4GCBPlFb3O2WPgOqCn3xCN6LXL7bypO3wDXCa0Cwp9+7edcMzCYu3UQhneYWMCWNuk8AkV4eLA==","shasum":"1776fe0b202393a42406e5b30ee0a312ec5ff47b","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-13.0.0-65aab520825a846cf9ba865e9f0916c260b670c1.tgz","fileCount":84,"unpackedSize":298115,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHQzz0JcIq7MENwHXqwRmrdiySF5/qEE2gFiL0nkk4BBAiEA06YI1+BhPhb6NbnoFuDIgGVNatRWIuB299Bq59Vaml4="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjo6LmACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoUXQ/+LN8F9yiiOIqjbeO7aPvD2kACXVDNYiBcneXt/E0y0JAHLW8S\r\n7ftW21kCU8/h+/i1kikRgwcJy/1Me8YFV+cxnMj9faOb0r+gAktTX0oIg09f\r\nAID9rBNdRj5sYrqJaqmBDs/4CHgBe/GwUro2m34qDsUC/8w9Q246PBGo1kFD\r\nPLJtl2E53oqFtGJfsyYq40t6uGCQLg1tshMd0Ji6VROvsJsEZKAn9e0S6BfR\r\n4s/gmcLiNP7N45rQw1MdR2ViHHpYu9WBYjsEsXBxHLWAwC9Ng5KRuGhDLT97\r\nxa/lxORFa6xHy8Ei05uhZD5gjstXW8D6v5uQdLpZs+hmbHpXJ5zdv53kHtRS\r\nzRpgcFPJl/5u2Cxtk7ksv0+sbTiXJn3Nroq7Ul3iQ9PSloKhkYbrWyl8U6je\r\nE5pV2MQL2iXvaAWt0pU1aDBOJd6mr8NlrH/zobuybErYRxM4FXCvNs5ii6s1\r\ns+17FbGtPIK4oJUD36BXXvZ1Ud9S1v3rP1O+fNDqm7+d8aG0ghIyUsoAZk8Y\r\nadCSxdlUCA2yzxsrmN09b3dckZ3/6nz7/Lp4HNQCD9mCQ4QmILdy2ZZ5vPnz\r\n+ycLKZnBiNwFWynqKY7bQ2AE2kraJlShqj0NR+mm+jYIuZnRcQb14Z9t385c\r\npSvvaRqYNKn1ww46Aw2AYnn99Q98CBCHC3c=\r\n=nx98\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_13.0.0-65aab520825a846cf9ba865e9f0916c260b670c1_1671668454675_0.1437928127539061"},"_hasShrinkwrap":false},"13.0.0-26cf6b031ff2fca993cdd1a7c33827660a271e53":{"name":"@detachhead/ts-helpers","version":"13.0.0-26cf6b031ff2fca993cdd1a7c33827660a271e53","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.21","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.4.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^18.11.6","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^2.7.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^5.0.0-dev.20221206"},"gitHead":"26cf6b031ff2fca993cdd1a7c33827660a271e53","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n## requirements\n\n### typescript\n\nsince this package pushes the limits of the typescript compiler, i often update it to depend on unreleased\nversions of typescript for bug fixes and to ensure that upcoming releases won't break any of my wacky types.\ncurrently it depends on typescript >=5.0. you will probably encounter type errors and/or performance issues trying to\nuse it with older versions.\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@13.0.0-26cf6b031ff2fca993cdd1a7c33827660a271e53","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-BCOigY9ILa1q+7+XH4jrYlS8JHaTr/IIhYBR7NhL/3ho+TUrgZYkobJJPB966gvneCaIna9t+OypS8pXzBe3bA==","shasum":"42dfcee7ce73bcb69e617f61adb01d7e355868b6","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-13.0.0-26cf6b031ff2fca993cdd1a7c33827660a271e53.tgz","fileCount":84,"unpackedSize":297713,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCFvvIHCc02NWHlDyeDhrAYxr9jRtxWneVSaLP38Uqr4QIhAPJw4iIHZJpiLuZa97fBs4eo7y5Le0cVcEZwm3c+kSzx"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjo8nlACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmow/hAAlq59BisrE4oK2FG89fZqYdlCRPgjyzoSZaMNdoHAOGW+RViI\r\nGESMejnmn24IWoKkD7FdXBFuIqzB2pqNu/+2gcvipKmfFy3mIMXuh57mveSY\r\nZhH05JIkEAWrLKMKoUblExW2oF8T6AONgERdpOc4wAGTHxhZucCdhIiwejdC\r\nwdXEllU8TCzbxkK2IjbFPviJTQX94OksJq2FmNT3OgWURouwv1caG6AKbZ+v\r\nNPp6AU6PFmH4jdQaXFsG4bTDCr0R3HljW7bHGFrDCIYgil1VazXkC0zR/HtS\r\nJ6wnNbp4LCiE0oNYd2MQzcDlWYBNpdMCHWWjevGfZIJUUW85GESAY/bhFNyH\r\nObt+ZjKG0oMg9X64DUhfJs45Iu/n6dgZJpTNCB1yduTGu0AWA8IHoK1mTwnx\r\no8NIzRMJpMlF7Q8YUhBpWbA2IJqRTfTVQy2AoUh035c4JFH4XfbI7VLaus9D\r\nBE1SOQJbFkFvFiVLriQoent+7xVYXqT0sSuWebiYmuz+oXm5NcpcJ82McRa8\r\npq8w4hV9sU40FnF8kOJlfEK4Bfz15KtsUUXTh1N41VR2l3j+cO7pP34/wQp1\r\nlahXiTPxZKRwBwsj8hfeyYLtGfGOVhFza1w4n5SroWsGKuhIYIxf9Fjm7ktM\r\nZDQABM8NwtCSkFG4q0P5V4IRuXYMaUnd5H0=\r\n=zbon\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_13.0.0-26cf6b031ff2fca993cdd1a7c33827660a271e53_1671678436968_0.6444956202336529"},"_hasShrinkwrap":false},"13.0.0-f2dcf0f663d58cc56bc62a910d394c99188524ef":{"name":"@detachhead/ts-helpers","version":"13.0.0-f2dcf0f663d58cc56bc62a910d394c99188524ef","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.21","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.4.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^18.11.6","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^2.7.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^5.0.0-dev.20221206"},"gitHead":"f2dcf0f663d58cc56bc62a910d394c99188524ef","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n## requirements\n\n### typescript\n\nsince this package pushes the limits of the typescript compiler, i often update it to depend on unreleased\nversions of typescript for bug fixes and to ensure that upcoming releases won't break any of my wacky types.\ncurrently it depends on typescript >=5.0. you will probably encounter type errors and/or performance issues trying to\nuse it with older versions.\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@13.0.0-f2dcf0f663d58cc56bc62a910d394c99188524ef","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-N/9BQHAalwclkIOP7tk3vykdhLx3LWxJmtuET3sKbMPkZoxkLIcCpQ/55s1YiQhBK7dKJUy1BT9BET4nCuQDRw==","shasum":"5123df20f2e246b51e8ff6c404fcd254b0f1fbdc","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-13.0.0-f2dcf0f663d58cc56bc62a910d394c99188524ef.tgz","fileCount":84,"unpackedSize":297926,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEMCH1kbPEOhp9jr1wp70FmCVANW57+gBul1bZ22tdM9if4CICbqNK1UjJIW3OI1e5WFcGJ9groZLPMzs/WbNTP/Wyti"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjpRUiACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqXPRAAlsl5ya+F/FGco5kcdPTW18CEGzW7RQ57wZQ6g1b3lt/Dn6Gv\r\n1KwOQMkJZ8n0f3XOuj0KckxAUEO8X9V2KAcYy0PY7GXiiowEb1lDnhp78c1O\r\nNG7GOjx1MtoQQHme4RrJXfC4WmvOY5hZZ4B8GkiPjkIQnj0N2eUHDzPpFQrn\r\nfoyKAX++BWvrFPZm1mvADHNRBsrGMe9QPLfTujXiIgm2/BhvVhKZ4v9cHPVx\r\nj3wSqOOdmajp38uXi4s2q6N7G+Vs4mjdLZTNh+l37UpE5KKHVXR6MFhHI1yj\r\nzJsnxhARadjPCq524kLMlRePeBFPvrdCFQOsygD/ADsbFPnnDlE1kaB0xTMA\r\nV2aQEdixOgmZlGU/cu/uoybzi9PiJxVZ65g9nZXPuSHnvvkS7HdP/OcwMuVM\r\nw9/0DLvNI2U1zSwCdeCS+9W+sKdliFCJ7cN1rfHVPztJj14ggQCsjhTBIuVL\r\n6vicGTXnqxKmXayRZf0f7WllTimdMUqbRYojvWjyyzO/W97ME7GEPEy3xxLP\r\nwZpErCe4IXT4vo5cbzQ/1MPnC6Z29ekL+OaqiDX7udAVKzudkoJmNxr1q4hq\r\nt2DeieA2ICxmlsDcdCx2FQgX5AavutqSSLF8VHDIBN3wCx2nlgVo5ecTqjZJ\r\nuUbFVCipghgmIeHI8VbFumSTStGedfUq5jg=\r\n=kX9q\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_13.0.0-f2dcf0f663d58cc56bc62a910d394c99188524ef_1671763234580_0.07151446096199465"},"_hasShrinkwrap":false},"13.0.0-6121075e1f328afd52ccd0a8c6851870705f41e2":{"name":"@detachhead/ts-helpers","version":"13.0.0-6121075e1f328afd52ccd0a8c6851870705f41e2","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.21","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.4.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^18.11.6","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^2.7.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^5.0.0-dev.20221206"},"gitHead":"6121075e1f328afd52ccd0a8c6851870705f41e2","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n## requirements\n\n### typescript\n\nsince this package pushes the limits of the typescript compiler, i often update it to depend on unreleased\nversions of typescript for bug fixes and to ensure that upcoming releases won't break any of my wacky types.\ncurrently it depends on typescript >=5.0. you will probably encounter type errors and/or performance issues trying to\nuse it with older versions.\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@13.0.0-6121075e1f328afd52ccd0a8c6851870705f41e2","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-pkf6P0pFRHfRESp4n9qEF3u3EQBNl7hvBk2TR3ZkQCoA3B/ZTaIoFi6flJBkBagIkalCXK6TqLIFynJ9qO1VSg==","shasum":"c63f584e5a4467b1a0d232826840f366f3fda5ba","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-13.0.0-6121075e1f328afd52ccd0a8c6851870705f41e2.tgz","fileCount":84,"unpackedSize":300408,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCwlOGhNmQNjduWbO1n7dGD0Bonb6MZhfj5NYsUQFqO1gIhAM3vmv07fyHIMVAUsX7sgr0H0ooJmf/FP0mfK1ng6hKO"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjtRW/ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmp3kA/5AJpYrWMaBkuQpj/EMooRTYnJ6S7qbyZdw1tqjiAFrbYRJGe8\r\nRRpuYPI98EMfXJIOtsclgT/pBiAxOvXoQ52mPeUlNdvQWGTxi9hsFJTIgvnI\r\nYULjJF2PllAVYxphmL/PEjaF1+hglz2dqpWUVGWVfyNfQwt+EMypWWpK+oLS\r\nZ4Q/VprsywFSxuCszY5ZJLfCd/rV+Cvz54T6bnKYj1w8cuAmukcrLlDSKl4r\r\naRSb7VxwLXhOxvJHN+hbmuYnY/pSp7CtSgMZG+7y4flh9kSmeC8PUC+wOhQK\r\njPnGW9if9B9YfdV+y4NDYV+nw1rIaiiThmSR7BhPkWM0iI4mFG9LdN/6OihX\r\n5mPH/Tmu9oIwNru7UB/8Hzk5kz3nR8Z4WHL0dxPhq1V451kBDbmPOYe2mUS+\r\nWHhF2MslDTckWxLK2FXHds7IO8Xlvt5GzmqeEXRLkxtZkvMMCW87Jqyjuw7Y\r\nHUaH1TSPfpEMhHqrWrv1Ndc+kZuQDC2WEV2+HK7d0Qy7S3Ou6w5ksw/wjWev\r\n6VWWuvLcDBaTNjMdmaf5he6uZVmlxsqdgUdoXmCc6veRUYUcXSIvnKuU8KKR\r\nO5RvEzuUwGNZTqcLwmEyOdnRSHlmB5E5zGIXCHJvJDVbYNZ/cIUUibL+pBfx\r\n+XyxEwRFNS3stuKN1m1wVX/YXShbE8NmXFM=\r\n=lYvi\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_13.0.0-6121075e1f328afd52ccd0a8c6851870705f41e2_1672811967473_0.1740197160976753"},"_hasShrinkwrap":false},"13.0.0-ba2935db54da4d8424b204e25f0dd63e2ff2b7ba":{"name":"@detachhead/ts-helpers","version":"13.0.0-ba2935db54da4d8424b204e25f0dd63e2ff2b7ba","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.21","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.4.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^18.11.6","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^2.7.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^5.0.0-dev.20221206"},"gitHead":"ba2935db54da4d8424b204e25f0dd63e2ff2b7ba","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n## requirements\n\n### typescript\n\nsince this package pushes the limits of the typescript compiler, i often update it to depend on unreleased\nversions of typescript for bug fixes and to ensure that upcoming releases won't break any of my wacky types.\ncurrently it depends on typescript >=5.0. you will probably encounter type errors and/or performance issues trying to\nuse it with older versions.\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@13.0.0-ba2935db54da4d8424b204e25f0dd63e2ff2b7ba","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-+BjV9988GasG+94PKg1uAhoCCmSSxAlJPJywRcWg9HZM00U7zPzB87w0T6axI+YzaqSSLXcNqWJtgBYr3LMBAA==","shasum":"ea5877d767267f8df761b28422399b7d28549750","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-13.0.0-ba2935db54da4d8424b204e25f0dd63e2ff2b7ba.tgz","fileCount":84,"unpackedSize":300797,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDVAl9Blj7NEtcz6MPOD5z2g00qEEN39Q968AWvNY0JIAiAf0XJgRXrbrqePRaQ1/E1k7cVdkW2IMwFAnMOcsY5/wQ=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjtSDYACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrseA/+IPDeAXkSKTDMDvtn5enEG3NROJ1+TqrC8xq9E7+3aZewsGjE\r\nlZWLmyaTxn30L7PWt2or1d5xGl72C/U8K+Tgj8lSEHg6NVB+jUtopWDyMcHB\r\nYsiCNEwLC3/OYpsIsJv8n1lEPedi+MGU65g0rIEcqP6ZUr11rHBz49d+wS3U\r\niBv6hmjctIvRq9gmV6WWtxxczYd5WdM8Pj9SveaHKQUmRWBsWb9zIMMDxugw\r\nZoOjkxWNKhIU0gtoORozBxaVm6zkhBDS+dfyIEZ17Oi0yS75dHTGMN4rV0tV\r\nM0vTKSMuZkP7qcSjl7TCbdAfGfN0SKnzEF5akb1v6biZ37r9ts+fKLSL8DvP\r\nE6jWozmVIZUE28uAC15JwZ2VunAACy1BHtFVi+QugV4W4fejDPBVesJHxIAU\r\nuCa0p9bzkUerhpP2nqc0n98VQXA+9zexS2NJb6JyAaPp0gJi2Q0X2XrcCaLH\r\nEBtMV0HSN8rdEbuvl2SUaKJ3vueYDx5iP1xN74Y0qPjs01556kRPmD0NV1RS\r\nKwpIGMOQkZfS+cZqWMXUFc/9Fv9tGc/6MVyUjArZ6F9wf7//xJeqjmAdWwQo\r\nZ4L7MbGuX/RClYgYkjrRh7fjBHfKbctkepV5bYHfmzOyrTINw+8FHfEehc6t\r\nnOtO0Z8hu1V3HrpI6MxaSNBKs5jzSEFDN98=\r\n=EvxO\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_13.0.0-ba2935db54da4d8424b204e25f0dd63e2ff2b7ba_1672814808252_0.4247008115258921"},"_hasShrinkwrap":false},"14.0.0":{"name":"@detachhead/ts-helpers","version":"14.0.0","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.21","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.4.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^18.11.6","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^2.7.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^5.0.0-dev.20221206"},"gitHead":"bc8bae19d61667054d4c129cddc7c1b7cd0c9222","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@14.0.0","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-12EQqly/DUXqPPSdspo6k00hAuPK4ZCiQ6iGPEibpG7gVvrFLjr8kSNoO4IrmC9Vp0FvazYmHGhoivmT9roZrg==","shasum":"3554b302e8ae130cfd32508bb4ff5c7760872b68","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-14.0.0.tgz","fileCount":84,"unpackedSize":300756,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICE5o9xIQIlFtQ7EcmTlSOhEfta50POhpivqAX8sXDgCAiEA2ZJT448CZCfOLYpZN9wHG5p6pNgC/yzavvApNxzjBc0="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjtSozACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmokzQ//XKVMI+fYCDNDxeemzHZRLtpsQFNd6CjxP+Vv0AFORYRew3Yp\r\nDen1R4Ze/Dr102AAE2BI1YfJaltVd6gq+unR+qnozn9Necbq0kw48KU3oubP\r\nWGlQ0sDbKA5aSbQqT9l96GlEqWGWDOBU7HOAMUt3K6bNYdJszq869a7hy0sa\r\nf1xjdilC4tImPzaIlWnvj1z+mf6PdX/p9y+Aa9uFFAwrbA2+98TISc5TvIjV\r\n89MXt5yzbhN7rl/joYV0CYiqC6/S9bAhdGMawdPmEZww8/yCQ6sIRfpJVQfj\r\nqHtTOgkt7NEZqiPlUsOKIWzrkDCxKQGdYhIdB3u+bCZkhdsujIona1iji7kJ\r\nQLW2C/cfRsok4jG9bKHIviVrLEAKfrJoYKoWtkm9303tOyM3xOvAqUW0qx6B\r\nSjcYw8hr9s6E9Y8nknRbbQ/+Tbr4Qn+ewyOIbyBGcOG/UAfpLNOh8b7NYihz\r\nN5kLctKbnWhB6usDLHkndTKJi86kGC5UaHoJJbnSLgnFCKZMHd9RxNRRwtan\r\nCf/FmkZrMnOCkToQvAF5dC4IKod1Ltsm12Y9bIuyA+ojCz50nr3e5o9/6KPg\r\nuvM/rV8GzSPwMQcbkhK6ztcazisOwlPUHi4D67CnyD5aCb1dR1dfkrtPGQ7H\r\n3X4VFPCMo4uZbgbf0wc0bgL5elvKuvCVplo=\r\n=T6L0\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_14.0.0_1672817202886_0.012696309419820917"},"_hasShrinkwrap":false},"14.0.0-32e4e15c96e9a0c41fd01325262f79767e4e9ea5":{"name":"@detachhead/ts-helpers","version":"14.0.0-32e4e15c96e9a0c41fd01325262f79767e4e9ea5","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.21","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.4.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^18.11.6","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^2.7.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^5.0.0-dev.20221206"},"gitHead":"32e4e15c96e9a0c41fd01325262f79767e4e9ea5","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n## requirements\n\n### typescript\n\nsince this package pushes the limits of the typescript compiler, i often update it to depend on unreleased\nversions of typescript for bug fixes and to ensure that upcoming releases won't break any of my wacky types.\ncurrently it depends on typescript >=5.0. you will probably encounter type errors and/or performance issues trying to\nuse it with older versions.\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@14.0.0-32e4e15c96e9a0c41fd01325262f79767e4e9ea5","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-Btytn2o7l4LhKzrjOcUZ+OHGoxWPMU7nc1Q/i4nnSvAkmlr+I/JLEflWY3hoLBy7GltfZqtRTyqGLzgOSHWRig==","shasum":"0de342e8a2bdd4a697bc3e8dcfe2ec2b66f99323","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-14.0.0-32e4e15c96e9a0c41fd01325262f79767e4e9ea5.tgz","fileCount":84,"unpackedSize":303239,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDyHBdnC9lIh6eG7MhqigFLaqRLx2rWTR7XKo8kyYC9EAiEA65c7n6suDaFCL7ftHUYkmfjbn2ncWTShCqE23x7wsSU="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj9yDpACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpQaA/+NIAQiIDfhf9O3KFgbBjnFxQONc88nApe1umPtziW0Vz55+B+\r\noCIf08+zVMysmytjjI/4UwEG197UIdYbwd6afMTKiYHir4BIMkMCjgIeCRtm\r\nhh3AFB0xdio5aXjthXjF1xxHKPpvpcAJDs3xNgzRf+TNXNTWFWkkiaAyUKsg\r\nsnRDJk4/9JwylxxricYznT4ZRxLpEMEwqS6DQ7aXpk/B1q6LeHtQohQvPB61\r\nvN/4ari52iu66YyVCAGTSuOSUpsFJSApHTu8hv/iIZzwsXzl/gKBbGQuXn8R\r\nXD7VEwy7GlgcmXZ/jlJ/4mZoOH/PyPQTWQI6MF8BqAqOUDhbSII2VADXlMlo\r\nxvws+AN/vly4bG2F3dHOsQDI30euDw1apkVdpsEyV29ERFuL0r5QJ73NkLgG\r\nVnZazNAa05qzojSZHDZKFCD9FrwFEi+CwLQDWODdZhUGCU6iv7siZzF5wo3o\r\n1qE2TdMN4yC8jmf1X+G/x5nAz7r+MkfQszMiVcWxRpqxxjLdUJPDgOCHUihH\r\n0Zr6zFrRZDJQmPVdc2UGQoiXFPRthugOhivwNjuie6OTLwkCkiBBTvomvEkk\r\nZOG4ObcibIj2rLPtOFUzVD6h5zJUpWTl1/6cYUFsVcYu474O6taI9170np0+\r\nP7QFm7+cVnrJN2cINa26YMIrrUJpMqFJtxo=\r\n=QLZQ\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_14.0.0-32e4e15c96e9a0c41fd01325262f79767e4e9ea5_1677140201443_0.010420798463211645"},"_hasShrinkwrap":false},"14.0.0-d7c13353712f110870d105299eb04f444e9b0e34":{"name":"@detachhead/ts-helpers","version":"14.0.0-d7c13353712f110870d105299eb04f444e9b0e34","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.21","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.4.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^18.11.6","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^2.7.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^5.0.0-dev.20221206"},"gitHead":"d7c13353712f110870d105299eb04f444e9b0e34","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers/dist/functions/Number'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nimport { formatDate } from '@detachhead/ts-helpers/dist/functions/Date'\n\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nimport { exactly } from '@detachhead/ts-helpers/dist/functions/misc'\n\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nimport { Equals } from '@detachhead/ts-helpers/dist/types/misc'\n\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nimport { SafeVariance, ToArrowFunction } from '@detachhead/ts-helpers/dist/types/Function'\n\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\nimport { ToNonArrowFunction, UnsafeVariance } from '@detachhead/ts-helpers/dist/types/Function'\n\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n### casting functions\n\n```ts\nimport { narrow, narrowCast, unsafeNarrow } from '@detachhead/ts-helpers/dist/functions/misc'\n```\n\nthe `as` keyword doesn't always work exactly how you want. the `narrow`, `unsafeNarrow` and `narrowCast` functions can be used to cast variables in different ways\n\n|                         | modifies original variable's type | returns the value with the casted type | intersects original type with casted type | allows non-overlapping types |\n| ----------------------- | --------------------------------- | -------------------------------------- | ----------------------------------------- | ---------------------------- |\n| `as` keyword            |                                   | yes                                    |                                           |                              |\n| `narrow` function       | yes                               |                                        | yes                                       |\n| `unsafeNarrow` function | yes                               |                                        | yes                                       | yes                          |\n| `narrowCast` function   |                                   | yes                                    | yes                                       | yes                          |\n\n## requirements\n\n### typescript\n\nsince this package pushes the limits of the typescript compiler, i often update it to depend on unreleased\nversions of typescript for bug fixes and to ensure that upcoming releases won't break any of my wacky types.\ncurrently it depends on typescript >=5.0. you will probably encounter type errors and/or performance issues trying to\nuse it with older versions.\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@14.0.0-d7c13353712f110870d105299eb04f444e9b0e34","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-+4EGnkbAuT+z0hEjY4bqsRIeygP/3a5EmokMgQK16xtPjwPKX0MNmBDZ8cQDCBzzOV+q+zbpvLSfzdWGVz4ORQ==","shasum":"8a5b8125f15fa31a091f0efe6bab06365c33fe14","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-14.0.0-d7c13353712f110870d105299eb04f444e9b0e34.tgz","fileCount":84,"unpackedSize":305687,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCLYouTb0Wa3pcbGV9DV1RF4sTl1Cav6kK4Lf5ldzvz1AIgbsUPWFAx7PmTmypeqDq/D6hOXquD5uKPAWZshQnhwU0="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj+BOeACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpCOA//UmowE0bo+k193LKS0Vx31LUet8va7VGP6HySmuFLwSkJ8c1m\r\noKNThvpzzSKG/+jlf87AX4oh+K4L71FZX8wG/9ctSXvWrFwu2ycbkiaFWGyh\r\n2HVD5osGu+o5bhiQrbU/QbJeSUaVzhalsOe7UUJNpXdqC9lX7z2u/LwKIXd8\r\nsgYg6/L6K4pbh2MLwTPKDIF+rOvwH/1lk4UPNJkp0NFiFshOtFnSYi8ekhW8\r\ncT242UjZysWDqyaIzoxmZcqqDXyTkymigKXb8G6EfMeiNcse0NEYd2RWnyRZ\r\nBAZswcYzSSK1BJ5NTeIszhN9ND1uJan/aUtkxl3qToTbAybJ4mdR4kTt1Zpe\r\nD0xHMPKyChosnv7OciJAHR+0ouK2gN1vDcC4/E2uwPWJMWczQXGzrXmjUNFW\r\nNxbGv6xY66vpVjSGqzdvVAP2JbV3rRTNESt6FuHE7bC35AQgq8l2A/6gj+Kr\r\nHgDKIqxfqUE973jE+1jYJ/BTMum4bu2Vw1fPT8h4jvr+2JGtE2t1gsrPaNLx\r\nsaVs1b+Aj5bPH+KXwOVnYcpzNykZRGFyoYOXHk8FgGp8wc4fTGw83nHMVRux\r\nKpwzKhC6iMq9v+PWhCP5NsYO7eibe1nKplIcPROXy7WLvbyMQiC3UzN4aUz7\r\nRiS+s43tGc5NMPJWltqH3Gt8A7vqLiuKBIQ=\r\n=96VO\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_14.0.0-d7c13353712f110870d105299eb04f444e9b0e34_1677202334183_0.6635496549644577"},"_hasShrinkwrap":false},"14.0.0-32b3d6dc37bee793c99585218b18762a2f20ff7a":{"name":"@detachhead/ts-helpers","version":"14.0.0-32b3d6dc37bee793c99585218b18762a2f20ff7a","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.21","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.4.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^18.11.6","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^2.7.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^5.0.0-dev.20221206"},"gitHead":"32b3d6dc37bee793c99585218b18762a2f20ff7a","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers/dist/functions/Number'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nimport { formatDate } from '@detachhead/ts-helpers/dist/functions/Date'\n\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nimport { exactly } from '@detachhead/ts-helpers/dist/functions/misc'\n\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nimport { Equals } from '@detachhead/ts-helpers/dist/types/misc'\n\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nimport { SafeVariance, ToArrowFunction } from '@detachhead/ts-helpers/dist/types/Function'\n\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\nimport { ToNonArrowFunction, UnsafeVariance } from '@detachhead/ts-helpers/dist/types/Function'\n\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n### casting functions\n\n```ts\nimport { narrow, narrowCast, unsafeNarrow } from '@detachhead/ts-helpers/dist/functions/misc'\n```\n\nthe `as` keyword doesn't always work exactly how you want. the `narrow`, `unsafeNarrow` and `narrowCast` functions can be used to cast variables in different ways\n\n|                         | modifies original variable's type | returns the value with the casted type | intersects original type with casted type | allows non-overlapping types |\n| ----------------------- | --------------------------------- | -------------------------------------- | ----------------------------------------- | ---------------------------- |\n| `as` keyword            |                                   | yes                                    |                                           |                              |\n| `narrow` function       | yes                               |                                        | yes                                       |\n| `unsafeNarrow` function | yes                               |                                        | yes                                       | yes                          |\n| `narrowCast` function   |                                   | yes                                    | yes                                       | yes                          |\n\n## requirements\n\n### typescript\n\nsince this package pushes the limits of the typescript compiler, i often update it to depend on unreleased\nversions of typescript for bug fixes and to ensure that upcoming releases won't break any of my wacky types.\ncurrently it depends on typescript >=5.0. you will probably encounter type errors and/or performance issues trying to\nuse it with older versions.\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@14.0.0-32b3d6dc37bee793c99585218b18762a2f20ff7a","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-Hu+lyr3Ri6crwJvVXl2QYAMpLI5KeHdyl3lGawoMHIA1VwQ7hTNMwA2EAiZI8cVU+gRup3BJeHQk8T8LqKu3lw==","shasum":"25bb7e365f3382cfc3a98beb1d547b4fc19eb908","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-14.0.0-32b3d6dc37bee793c99585218b18762a2f20ff7a.tgz","fileCount":84,"unpackedSize":307092,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFf/yeI4+OMKs2v/34Ip1DyK8BqObPC+ZIDtoYgIS0apAiBq7Huwb4FgyEvA8RbdJpqUDj126P48ggnFbkbTxLemKQ=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj/Zm0ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmo34A//UBIM5RHm5zHCctGKYXeOteGBbpLyFXW+9WHySloYLXAMFr+r\r\n97pCEzZx7p5PawWLHRkQYePJVC5nZSV2haPFiaifMpbYZULJmIc8ZHXoAjek\r\nvGn7A6v9q5J9aqoAD7ByJPzJEIBusVNTV2I7zNaShjaITqGMrz/SCxIMtkQ0\r\nxJLFFEIcHk5homKOJplqxnGpqLG/7eie/I7AKb75+8aSLC8jk2iZPUzoPvFP\r\n7mzN0zJ+5uzfIwbFwPvoQ/U1oeRDYGOnEDU0yJKQ8VJ+QTh/IIsEDFb0W5tv\r\n6igEHu431l+5WG4J3utPQV2gRc1IDskOuCDS5DXCwaWAa+nKiNkMsys1BgmJ\r\nYUAEOcycXAVpOlB6sy7bJSHel2kz51JfINhILIy4KWWiNSRK0pzTKJgJSxeY\r\ntijelBVi5txln961GOz9fgcoh4d427r0zAR2o7rwnhDWW1mqwIJqRNNUO2E1\r\n7kcNLCJIJoedUJudzbG3CkUx55cRejG0MGZ3nsABlXiy/+BoD7d0Yee5T/kP\r\naxB6XCRX6GyQrLHC+DKQgiRYAoX2fsNmN++gJao1+4WZd4CwxoGQiZDgDkjg\r\n7gdowqP+JlePCIyzzxD9Sd6AjYW6aEpZD21sPGzIugwOzRwLivOFObSSMXfa\r\nzH35SjY+HTaosCm7svFwX9B5I+rwTo3QRrg=\r\n=rQrL\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_14.0.0-32b3d6dc37bee793c99585218b18762a2f20ff7a_1677564340655_0.033289449218919076"},"_hasShrinkwrap":false},"14.0.0-0b9ecb7a6f11ace7df212deb84eae3bbd93884e3":{"name":"@detachhead/ts-helpers","version":"14.0.0-0b9ecb7a6f11ace7df212deb84eae3bbd93884e3","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.21","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.4.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^18.11.6","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^2.7.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^5.0.0-dev.20221206"},"gitHead":"0b9ecb7a6f11ace7df212deb84eae3bbd93884e3","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers/dist/functions/Number'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nimport { formatDate } from '@detachhead/ts-helpers/dist/functions/Date'\n\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nimport { exactly } from '@detachhead/ts-helpers/dist/functions/misc'\n\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nimport { Equals } from '@detachhead/ts-helpers/dist/types/misc'\n\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nimport { SafeVariance, ToArrowFunction } from '@detachhead/ts-helpers/dist/types/Function'\n\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\nimport { ToNonArrowFunction, UnsafeVariance } from '@detachhead/ts-helpers/dist/types/Function'\n\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n### casting functions\n\n```ts\nimport { narrow, narrowCast, unsafeNarrow } from '@detachhead/ts-helpers/dist/functions/misc'\n```\n\nthe `as` keyword doesn't always work exactly how you want. the `narrow`, `unsafeNarrow` and `narrowCast` functions can be used to cast variables in different ways\n\n|                         | modifies original variable's type | returns the value with the casted type | intersects original type with casted type | allows non-overlapping types |\n| ----------------------- | --------------------------------- | -------------------------------------- | ----------------------------------------- | ---------------------------- |\n| `as` keyword            |                                   | yes                                    |                                           |                              |\n| `narrow` function       | yes                               |                                        | yes                                       |\n| `unsafeNarrow` function | yes                               |                                        | yes                                       | yes                          |\n| `narrowCast` function   |                                   | yes                                    | yes                                       | yes                          |\n\n## requirements\n\n### typescript\n\nsince this package pushes the limits of the typescript compiler, i often update it to depend on unreleased\nversions of typescript for bug fixes and to ensure that upcoming releases won't break any of my wacky types.\ncurrently it depends on typescript >=5.0. you will probably encounter type errors and/or performance issues trying to\nuse it with older versions.\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@14.0.0-0b9ecb7a6f11ace7df212deb84eae3bbd93884e3","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-veXrTddR3VKQ6XS/cyUxaH+Jh7n3v1si0WvC239eVJIftpy6eI5dLEi4adAyOL+X4st84ADT3RF4YK5uPzmA2w==","shasum":"242a47cbd5bea51f8573ee5a469d9805a81e953d","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-14.0.0-0b9ecb7a6f11ace7df212deb84eae3bbd93884e3.tgz","fileCount":84,"unpackedSize":307500,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCjqW3FVzE5aIMaH0lA5H4ro9SkK8wksAHNx6PgwaGmMgIgaD/dvgbvwC7y43RFvBVbCzZVD6aXnYRubvgBc4LXoPk="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj/Z1qACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoPkg//ctxUJHj+xSWl0kWojWPbSk4adGq/qiE5tke57c0LMXj6Qws4\r\nqyf5RQrVd8U1i2y4lWQNeN3ad08CFgMgCLeolzUlti3SX6O98sj3yuSCPtm6\r\nhBiQwYKokNn/cp8omNPjQ7HunFt14S/WIiIe06zqlqbic1bosKwQrL6/QEN0\r\n/KXPjS86fECbZwrmsq/cGwB6sO16Xq0NLThPmbbTncpVMvVD6auCh7sT20me\r\nG1dVioEzgkn752l87o0oCBFXY0eNuHAuCuaozX77A4e7YszX1PwJEEVKCZPI\r\nSiDOB2YGzF3Riz8ccqoZtX1Rcs49g2Y+F3kDJQd/+cD3MpwGUq0ApcN8dk0r\r\n8LX37aBP2xcFwXDKOVaYlcvc4sCFOuMZqRDWRPXKi595UyyImcwurU+k4mIZ\r\nedhZSU7j6h0LcFsgMDhDcqS75QD+Lpr1xY9JaABBJUHv8RgLq4uO3p6Vzk73\r\n5+m+RAfCq1OdH8peoKkr4sVjx7NUanDm0lDHjkc+AUrv6ZRf84cCmJb3CLuS\r\n4n+/efjsUdtkw/bC0tJo49/eCaROX2BXc0ylyPCHu45mlIZRqRJroLnra6n5\r\nWOHWj+7Y+Bc8zsOgV9/RmezXrITHgtI3i1COfxSlXfwOvHFrHXGB5hehwHkd\r\n3+L9VP1+mlj/6ukNJFDBQhVjkik/oRdfwvY=\r\n=0NpZ\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_14.0.0-0b9ecb7a6f11ace7df212deb84eae3bbd93884e3_1677565290263_0.4036632659886872"},"_hasShrinkwrap":false},"15.0.0":{"name":"@detachhead/ts-helpers","version":"15.0.0","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.21","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.4.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^18.11.6","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^2.7.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^5.0.0-dev.20221206"},"gitHead":"a1facbf96aa93bc4a1ffd72f08389d743da27818","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@15.0.0","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-EmxRHA7YFpoQi/MrgO/VRUUuuJY2FI+Mh4+5fuN67/2yEiCLkTnZVm3TLJqg0aG0BgNZfeSEmmtA7PDDLbMctw==","shasum":"bc73812b406c258e8c2219c8017726edf4c02205","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-15.0.0.tgz","fileCount":84,"unpackedSize":307459,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIB8OwICIIYuTFUkJeJ/yByWevYnkPapAdcmzaWSwMYBrAiEAiyD6/RX3XJ9/5ZNE+jI2YtEiEuIe/mePkK3rGV12R1Y="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj/aICACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqULQ//Towa7OHZiN/tGZw2VpU+dHkeCHQr6pvz+S3N+sfY9kSQfyWy\r\nFehWlhrZomvtFGqm1VMEHRZ+FwD5nx/y9VBlcNgGE45OQ5zlhXdfTNcH2Q6/\r\nDAU2gWKEi7wQHEaoMIcTfsDK14fF7IXgY96yPgNV3/tmXdv6mgH4ydCvnV6P\r\nbguQrdJP3gHgK7uZuWB5xIy+AAvud8yeakxuFbw1bEUyTtTpIgm5xbfkLkYy\r\nyaNYgJJFPC9jhvggbBL4elmYf2zAq3yNgK5s8CAqf7boEACohs5j2nQz5XeV\r\nuWa9s2qHlchsE0tTH3jOre3TxFNOh3Zltqyb9/yvc2SdGXoFDShm4WtG+LDO\r\n6nw/sev6oKFpLKvVY32E/k5XrZRZ1cRDKiwY+x85kV8naJE52lJ40iWOaHQP\r\ncQyvSpFnbl1VplQ0Ajmk5gVwSnEXvZ9zgbSThM9Lz5fruXfnNe74R0rOOiRA\r\nLkPABcnTrmu8eZJ/dUscfvUi23L6W/C4pW3g+BUOawrnwY/sVElEK7Hn/DdA\r\n3BRZqFJ5i/CHSwboAwnaAa3jpzL99GkEngM8LLtU/ibeutgHJjCKZDzv9QVD\r\nPLoSn987K8WEe4d9M3dDtOXgEbktij6wAtcde09lVGEPgQopkAaezhAbcBG1\r\nxmyMK/jr5p2suM6BrLYrEKhMX7RuRAi2/rA=\r\n=tJ1X\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_15.0.0_1677566466629_0.295599281798949"},"_hasShrinkwrap":false},"15.0.0-1300b17d0b7335eea6869a247427a45d246a03a6":{"name":"@detachhead/ts-helpers","version":"15.0.0-1300b17d0b7335eea6869a247427a45d246a03a6","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.21","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.4.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^18.11.6","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^2.7.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^5.0.0-dev.20221206"},"gitHead":"1300b17d0b7335eea6869a247427a45d246a03a6","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers/dist/functions/Number'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nimport { formatDate } from '@detachhead/ts-helpers/dist/functions/Date'\n\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nimport { exactly } from '@detachhead/ts-helpers/dist/functions/misc'\n\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nimport { Equals } from '@detachhead/ts-helpers/dist/types/misc'\n\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nimport { SafeVariance, ToArrowFunction } from '@detachhead/ts-helpers/dist/types/Function'\n\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\nimport { ToNonArrowFunction, UnsafeVariance } from '@detachhead/ts-helpers/dist/types/Function'\n\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n### casting functions\n\n```ts\nimport { narrow, narrowCast, unsafeNarrow } from '@detachhead/ts-helpers/dist/functions/misc'\n```\n\nthe `as` keyword doesn't always work exactly how you want. the `narrow`, `unsafeNarrow` and `narrowCast` functions can be used to cast variables in different ways\n\n|                         | modifies original variable's type | returns the value with the casted type | intersects original type with casted type | allows non-overlapping types |\n| ----------------------- | --------------------------------- | -------------------------------------- | ----------------------------------------- | ---------------------------- |\n| `as` keyword            |                                   | yes                                    |                                           |                              |\n| `narrow` function       | yes                               |                                        | yes                                       |\n| `unsafeNarrow` function | yes                               |                                        | yes                                       | yes                          |\n| `narrowCast` function   |                                   | yes                                    | yes                                       | yes                          |\n\n## requirements\n\n### typescript\n\nsince this package pushes the limits of the typescript compiler, i often update it to depend on unreleased\nversions of typescript for bug fixes and to ensure that upcoming releases won't break any of my wacky types.\ncurrently it depends on typescript >=5.0. you will probably encounter type errors and/or performance issues trying to\nuse it with older versions.\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@15.0.0-1300b17d0b7335eea6869a247427a45d246a03a6","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-SDZWDL+ievXlSf0jcfty5nNGN7uIcDrmd2Oj1AZ0CNcCY+9Z4KGcEXhlVAK0pH4AtosKjBMJX76KOXqB8Dylmw==","shasum":"0ac86e4d5125e1fe6595a2f07933866b69d91967","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-15.0.0-1300b17d0b7335eea6869a247427a45d246a03a6.tgz","fileCount":84,"unpackedSize":310768,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD+Z2G0uyCBDsXtdCfgEPoB2nyTnkekNi/4OdELUcjyCwIgSkPiDsLzkyMz5L7ubyX+0RvHwPAstpEhRSv59l5T4o8="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj//RoACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmp5Aw/+MgVtlvMULgDgcrRrVlQV1zbnDEkdfj5zJx27S+fwt+8iDoVj\r\nEboEQVdaViaYflllOOCXnU6Lc/+b8V2w3Syw0L1J/qAyCNP8ritv6X5RNFeJ\r\n6Q/O73/rDcmoLOUsgpM65drs+QeRzkhAcUXW/YwfHRta27Hb2FHKs1AWep2O\r\nCd3U9zSOnpD3woulQaA+1ar8dUl6S1kHgXU+tJw2oA+xmvfK8swja8CqGYxm\r\n1nhgnVg+aqGGSeR9GK8mikrzT+fWQWhrS0UxklSFaGMDjwKfnQ/d4FGEAAJS\r\nAQqofU4jStrSmcK1O8kJsQf1q2Ap9gGhwDOaNdGGX+9M7Q01B/wl9cTrO7Gh\r\nEWlBirl076psssUkcUsh+vKvVTNzpFkry1lFoVCsIMhdWrufwnvhG+wGp1h7\r\nwkGC3YS+rXnc/WJl0LAwLlEtlMhPw6w0pa8Ib6rE0rz1vsRTM3xVMLvojNps\r\nCmlfFEum7+S9ZdC7tdUhftyiKkWXLEXJeRll9LZjd4+pH5OfgyNJwmWnCfQK\r\n1mAziPXsbRre6Z39f10iDU34gjc5gPPNetONsHknRBpPpxFAFq2P3MjTxKIA\r\nucT3B4b9tFc+sT2rrjrW1kKl35dl0GmH/wjQAT2p3t2mFzWXZIouAI1Ra+oZ\r\nxuTnuh5zu2cuZwth9CoUg/IRzSbBLn/4W2w=\r\n=gAJY\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_15.0.0-1300b17d0b7335eea6869a247427a45d246a03a6_1677718632501_0.3526937396227061"},"_hasShrinkwrap":false},"15.0.0-a9929cb12aff2f07b33df3fcda975ce0d67b9523":{"name":"@detachhead/ts-helpers","version":"15.0.0-a9929cb12aff2f07b33df3fcda975ce0d67b9523","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.21","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.4.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^18.11.6","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^2.7.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^5.0.0-dev.20221206"},"gitHead":"a9929cb12aff2f07b33df3fcda975ce0d67b9523","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers/dist/functions/Number'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nimport { formatDate } from '@detachhead/ts-helpers/dist/functions/Date'\n\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nimport { exactly } from '@detachhead/ts-helpers/dist/functions/misc'\n\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nimport { Equals } from '@detachhead/ts-helpers/dist/types/misc'\n\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nimport { SafeVariance, ToArrowFunction } from '@detachhead/ts-helpers/dist/types/Function'\n\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\nimport { ToNonArrowFunction, UnsafeVariance } from '@detachhead/ts-helpers/dist/types/Function'\n\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n### casting functions\n\n```ts\nimport { narrow, narrowCast, unsafeNarrow } from '@detachhead/ts-helpers/dist/functions/misc'\n```\n\nthe `as` keyword doesn't always work exactly how you want. the `narrow`, `unsafeNarrow` and `narrowCast` functions can be used to cast variables in different ways\n\n|                         | modifies original variable's type | returns the value with the casted type | intersects original type with casted type | allows non-overlapping types |\n| ----------------------- | --------------------------------- | -------------------------------------- | ----------------------------------------- | ---------------------------- |\n| `as` keyword            |                                   | yes                                    |                                           |                              |\n| `narrow` function       | yes                               |                                        | yes                                       |\n| `unsafeNarrow` function | yes                               |                                        | yes                                       | yes                          |\n| `narrowCast` function   |                                   | yes                                    | yes                                       | yes                          |\n\n## requirements\n\n### typescript\n\nsince this package pushes the limits of the typescript compiler, i often update it to depend on unreleased\nversions of typescript for bug fixes and to ensure that upcoming releases won't break any of my wacky types.\ncurrently it depends on typescript >=5.0. you will probably encounter type errors and/or performance issues trying to\nuse it with older versions.\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@15.0.0-a9929cb12aff2f07b33df3fcda975ce0d67b9523","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-0bGjkIilhHNYaKXfvt5lhGBJP7ZEji3zREWQs7hGw4toQMfhD+crGCNltQGmA7cmot+joDcuXpCOwY2JFa6VtQ==","shasum":"bd040dc65665470beef8edfca84d5bb6eff17863","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-15.0.0-a9929cb12aff2f07b33df3fcda975ce0d67b9523.tgz","fileCount":84,"unpackedSize":310339,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDb2hhc8WkfDjkV1VPQDl55bxPT4r53uTXbEc/ZT+N0AAiAh6bZmJ+2MuIWiZ95wo7J50m8ICJjel/YHfF3FrMSuaw=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj//tzACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpUTBAAiZm8PfG6hL1MJgPlrogXMcBiTZRrpCEAsf2cBehAReAXi4eu\r\n/5/PVrd+FYvGRyewvpsqVO9DlDVPgGBj/d2yvXdxtlfSjU/CyceEe03wdwLS\r\nzVPvJx7T62cK9huqiwLy/tQCgprh8wef4h/3SfWWiZ5xtnsAfiCEARkPcOI2\r\n6B0y1Ufiu2+E1kyQNWI7DA/P5q0tXfdwKxBpOoFEK4+BVvozBqZaIm6uwto1\r\niy5Mc4zMOIvRL3DFvMCtggeCIj5DKFaQ+6huFP1yNXNv6PWvOhkROmP0UFoe\r\neTIlOGELFtUjglhDb7v1ROGdsW6bcpyssfS+MSlO5OVysyICIErY2IL68SGQ\r\n2jewW7X9DVwCzrJ+4VdgpP39vSbtcn4rF/TO1CCXtj4e/UYpxUQZiwXRG93W\r\nL2SeY8db5vGFtP3ykUpaNsMBB4UCyEvH+v5xJJF5eEA6AI79cvagZJnwpT5t\r\n6pVWQ36CFTVF0gtbGlyZYMLqgaboFAsKUloqv7Aoi08TE/rzCzNULUI2UXIL\r\nFhoHdj12DDkvOo/yY7fjKfHkGGfnQgdBR2I3wzEMFOPgquXLls3fjD7QzXFG\r\n0gyurtz9N4sfZ2BFSZIPMf6jb4bzivAESNQbORcB781UOfaaG52DKJJtwY+o\r\nY/T6mrRMla24SraupF0nXkqnvFTvq8bm0ik=\r\n=LU6v\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_15.0.0-a9929cb12aff2f07b33df3fcda975ce0d67b9523_1677720434791_0.5470935000729076"},"_hasShrinkwrap":false},"15.0.0-1f5417804ae8f007d0367fc24930921619702db4":{"name":"@detachhead/ts-helpers","version":"15.0.0-1f5417804ae8f007d0367fc24930921619702db4","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^0.0.24","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.4.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^18.11.6","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^2.7.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^5.0.0-dev.20221206"},"gitHead":"1f5417804ae8f007d0367fc24930921619702db4","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers/dist/functions/Number'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nimport { formatDate } from '@detachhead/ts-helpers/dist/functions/Date'\n\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nimport { exactly } from '@detachhead/ts-helpers/dist/functions/misc'\n\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nimport { Equals } from '@detachhead/ts-helpers/dist/types/misc'\n\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nimport { SafeVariance, ToArrowFunction } from '@detachhead/ts-helpers/dist/types/Function'\n\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\nimport { ToNonArrowFunction, UnsafeVariance } from '@detachhead/ts-helpers/dist/types/Function'\n\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n### casting functions\n\n```ts\nimport { narrow, narrowCast, unsafeNarrow } from '@detachhead/ts-helpers/dist/functions/misc'\n```\n\nthe `as` keyword doesn't always work exactly how you want. the `narrow`, `unsafeNarrow` and `narrowCast` functions can be used to cast variables in different ways\n\n|                         | modifies original variable's type | returns the value with the casted type | intersects original type with casted type | allows non-overlapping types |\n| ----------------------- | --------------------------------- | -------------------------------------- | ----------------------------------------- | ---------------------------- |\n| `as` keyword            |                                   | yes                                    |                                           |                              |\n| `narrow` function       | yes                               |                                        | yes                                       |\n| `unsafeNarrow` function | yes                               |                                        | yes                                       | yes                          |\n| `narrowCast` function   |                                   | yes                                    | yes                                       | yes                          |\n\n## requirements\n\n### typescript\n\nsince this package pushes the limits of the typescript compiler, i often update it to depend on unreleased\nversions of typescript for bug fixes and to ensure that upcoming releases won't break any of my wacky types.\ncurrently it depends on typescript >=5.0. you will probably encounter type errors and/or performance issues trying to\nuse it with older versions.\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@15.0.0-1f5417804ae8f007d0367fc24930921619702db4","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-DoHac1KzMXbyFC5byNV0uA1E0D64mVuTHx9rFZfT4vx4Z0UzTvbcl5IHkmYVLYzhhca5eomL3ZtIH3WCCxBRRA==","shasum":"34a260ae0926e8a1c96e143932970023735a4634","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-15.0.0-1f5417804ae8f007d0367fc24930921619702db4.tgz","fileCount":84,"unpackedSize":308009,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD9o/qELA93mdfQ8qJUIIeKrld3C4mDAgJs486E6uSiOAIgW/44j+BkRmYsuqHskSIoj4ngdVbEicxOOOaVHSiciQc="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkCLMLACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmp4zQ/9FsmqgtTjKSZKZg3P4mg4j8/jYDzRyqr64J4Jexxe619S+QKt\r\nW6hbVev7pyiPb/XMLdY0RfAaxfI1z5le7dVzBzTrLC3a4fGnuY50WHbE0BG+\r\nshl/JT6JAt9sBUryN0UKOUVqSRaabF/+37CkOFvuV5Ef3CchjY/lvxeSg7ff\r\nWcriK4NlM/nvk0raBnGKvaZA/HitE+4LszAhsyte6VzSiTbrwv0QvLHXsj8k\r\n7X/ULNdTdMGRVP5w6m2NdyT1j4zAtYS9pGkxSHogSqefq7arwZFAutJfZ5Gv\r\nmGcMyILHGXjfmehW2JMCoweUSkY4rlTA6BH5hPwq4XkSEXrcRq9ol4cxbu4K\r\nugGVJQc1VKVaKrWHvX9/7hoIBJk2cwxic/5usy55pAhDqkiABpWPcYog2E7b\r\nelkidBVRJdSX+dw38cBNI4K1x/2nx1zM2TME10mNdvNr2tf1oxi7fT484/p9\r\nZGtTYStQdJpVsDKzLTTZ4Fg2FvRBO8klh1GFY80uKD/5CCkVYgiS/hXeOpTs\r\narPgAY+JdruogGKqqUza/cT/gxwc3PCROjcwi+8DMt/py4sWWLZ/aMNN/Xt9\r\n6RS3FNzkpMPXbZbNv+C+BAUXoVL0HAuMDxEPYD3cBjtaF82Q1S9jxivU4N3s\r\n+3kdkKyfPEcapDgFf1lWXUZW2OHeoY8ljR0=\r\n=udD0\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_15.0.0-1f5417804ae8f007d0367fc24930921619702db4_1678291723531_0.3076865536500175"},"_hasShrinkwrap":false},"15.0.0-17b9c57658029a3ffb7e1ede97521cae1d7dcd2f":{"name":"@detachhead/ts-helpers","version":"15.0.0-17b9c57658029a3ffb7e1ede97521cae1d7dcd2f","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^1","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.4.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^18.11.6","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^2.7.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^5.0.0-dev.20221206"},"gitHead":"17b9c57658029a3ffb7e1ede97521cae1d7dcd2f","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers/dist/functions/Number'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nimport { formatDate } from '@detachhead/ts-helpers/dist/functions/Date'\n\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nimport { exactly } from '@detachhead/ts-helpers/dist/functions/misc'\n\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nimport { Equals } from '@detachhead/ts-helpers/dist/types/misc'\n\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nimport { SafeVariance, ToArrowFunction } from '@detachhead/ts-helpers/dist/types/Function'\n\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\nimport { ToNonArrowFunction, UnsafeVariance } from '@detachhead/ts-helpers/dist/types/Function'\n\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n### casting functions\n\n```ts\nimport { narrow, narrowCast, unsafeNarrow } from '@detachhead/ts-helpers/dist/functions/misc'\n```\n\nthe `as` keyword doesn't always work exactly how you want. the `narrow`, `unsafeNarrow` and `narrowCast` functions can be used to cast variables in different ways\n\n|                         | modifies original variable's type | returns the value with the casted type | intersects original type with casted type | allows non-overlapping types |\n| ----------------------- | --------------------------------- | -------------------------------------- | ----------------------------------------- | ---------------------------- |\n| `as` keyword            |                                   | yes                                    |                                           |                              |\n| `narrow` function       | yes                               |                                        | yes                                       |\n| `unsafeNarrow` function | yes                               |                                        | yes                                       | yes                          |\n| `narrowCast` function   |                                   | yes                                    | yes                                       | yes                          |\n\n## requirements\n\n### typescript\n\nsince this package pushes the limits of the typescript compiler, i often update it to depend on unreleased\nversions of typescript for bug fixes and to ensure that upcoming releases won't break any of my wacky types.\ncurrently it depends on typescript >=5.0. you will probably encounter type errors and/or performance issues trying to\nuse it with older versions.\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@15.0.0-17b9c57658029a3ffb7e1ede97521cae1d7dcd2f","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-R/K0iYN+7XIL8kj43GlsTrfh/n8gCsfbhTUppfxB3z9/dJup0EKuQvltQRtsFAIJ89LYVLGkdpWDTaLZ5Bokvw==","shasum":"bf6d5bc597f6532d361aaadda0253c3e7d5fce22","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-15.0.0-17b9c57658029a3ffb7e1ede97521cae1d7dcd2f.tgz","fileCount":84,"unpackedSize":309336,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGZWnl6Z1Ar1hlPQH9rpe/isp3+Q2/bCpkI3eLkSTHbGAiBzxWNmhlpEJYiIjM4VPqGnIUkJYGNd9FN9Mha7/Lieng=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkD8grACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpIng/+KaVN2kDTRrk3IE4zfx5EunMt9TW83D72KHK4rpbiyZy67WIL\r\nGZlOHi/PP9CYKXQVVX8Vov77daiYywIb455dA9kcShnkOMt7OE93O8p1jhmb\r\nQS95pxs6QRD92Jo6a6R9wLtCVY5ZPvUPXWVJ9l8T/nueF/ZSYaNTJXrOipD9\r\nGAP6rE8SFFfDaf5j/XMtwLSGXoc7j69glEIZjze8FVTGE1kQbxDqsMBntPXx\r\nfbAzbf0ca0yK5W/T6XSYjIY4L+hgF3lDpfvbbX1ky2Edn+l8cg52gEywx8me\r\nYZrU5Ph2UA6zrTe3I/kgevIRmIYMHKEMH4ncqP4py4SFli9fG6YduJuIMCpP\r\ngvO7B0muyJ39OB8t9MSf1XRWRwNNUsw0BVFubnxtRcQi20t6868G4NCjsPCK\r\no5S0w/MbCqlN20d4OjH5cl4WQAZgs9REjrN3PQ34S5mONJjH8SBQaH47bdNE\r\n/tk1mgbMhAu0PFz8imEMDkAl5n/FDBPSZiQcoaa8e9z4E7wjD6C0rE6b14XA\r\nf2fFJbCb5FU0gthLNPDzSptmRQYp/MSCaV5iijwO4l/z9sAlV9pKSu7vYKJu\r\n8SwsewAX6yp/978neGpD+4zTmZm9lNZ5Ii4rYITxnBi1cAq90ZJ1FO7EE8/m\r\n/bBdi0x4zEo+OhAeRVuIdQfkFk3OghnT9do=\r\n=Kgpn\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_15.0.0-17b9c57658029a3ffb7e1ede97521cae1d7dcd2f_1678755882966_0.0893164473826491"},"_hasShrinkwrap":false},"15.0.0-74de36b3eecec33aaecc20f62500b755e244ab81":{"name":"@detachhead/ts-helpers","version":"15.0.0-74de36b3eecec33aaecc20f62500b755e244ab81","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^1","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.4.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^18.11.6","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^2.7.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^5.0.0-dev.20221206"},"gitHead":"74de36b3eecec33aaecc20f62500b755e244ab81","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers/dist/functions/Number'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nimport { formatDate } from '@detachhead/ts-helpers/dist/functions/Date'\n\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nimport { exactly } from '@detachhead/ts-helpers/dist/functions/misc'\n\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nimport { Equals } from '@detachhead/ts-helpers/dist/types/misc'\n\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nimport { SafeVariance, ToArrowFunction } from '@detachhead/ts-helpers/dist/types/Function'\n\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\nimport { ToNonArrowFunction, UnsafeVariance } from '@detachhead/ts-helpers/dist/types/Function'\n\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n### casting functions\n\n```ts\nimport { narrow, narrowCast, unsafeNarrow } from '@detachhead/ts-helpers/dist/functions/misc'\n```\n\nthe `as` keyword doesn't always work exactly how you want. the `narrow`, `unsafeNarrow` and `narrowCast` functions can be used to cast variables in different ways\n\n|                         | modifies original variable's type | returns the value with the casted type | intersects original type with casted type | allows non-overlapping types |\n| ----------------------- | --------------------------------- | -------------------------------------- | ----------------------------------------- | ---------------------------- |\n| `as` keyword            |                                   | yes                                    |                                           |                              |\n| `narrow` function       | yes                               |                                        | yes                                       |\n| `unsafeNarrow` function | yes                               |                                        | yes                                       | yes                          |\n| `narrowCast` function   |                                   | yes                                    | yes                                       | yes                          |\n\n## requirements\n\n### typescript\n\nsince this package pushes the limits of the typescript compiler, i often update it to depend on unreleased\nversions of typescript for bug fixes and to ensure that upcoming releases won't break any of my wacky types.\ncurrently it depends on typescript >=5.0. you will probably encounter type errors and/or performance issues trying to\nuse it with older versions.\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@15.0.0-74de36b3eecec33aaecc20f62500b755e244ab81","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-XCYunOrKF2y3Pm0fHgZdzRDr04+O06nhw+nl2Czk3EJlV51/6GIAYwn+Ek7XllHlbi7oxvstc1q/dCHubv33hw==","shasum":"73bea1b01cbb744274fc6a7dd695dfbcd155e5dc","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-15.0.0-74de36b3eecec33aaecc20f62500b755e244ab81.tgz","fileCount":84,"unpackedSize":309653,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICeeLinqFUXOKx+7nRjkUzIHgiKRh//bKgkFsuKJoP0DAiEAksScYbbL/gGCs262K4ysccTBck63jagDw9GywO0DSzI="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkD9A0ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmp+Uw/+LV1jQzYY1YvEB3HXNptFXLO9MGew4rvgr3tsijQ2TpDLSnkQ\r\n/t5nu3Qj6lNEnyrY7RgLp9y2qdspP2JOjIjqA/N/SitA8Tl9cdi9tv2XVUZm\r\nhQXbP7LRBWdt4WWBvyvFkvyxzODxKzEu+fAwfIUuP0UAkuEryiT7l1QVXJIR\r\n8JcxDyRPn11PGvwdhuNzXorQu5uFbb449gn3zft+uWet7Yu1gHR6JZsVMFSZ\r\nN2Yn4oyfmx3ABU5N3jGw8fy+L7JqpAb+6US6NKdajrxsfGsV05Dl6INZ1GRc\r\nr+JOXgjixkr5P7HqtUeUqe/qY4x9s+sk8aW39BYd9fg7QLu8hyizaVShCIV0\r\n2rEBF1iHbzmWMOId1UyjddvMCMGUQhrASU9Z/QGY7RtC2GZyjuGNSz6q43Gx\r\nJeAYnyBo7ARtAgPGKhJC+8FTu7QpX3GoEmJAZEdaaGHq3BK4XbYOjROeK86M\r\no1STuVCQnxqPNsVl8SiAhhsk2IiVeByKwQEU4/8RXVyTQfX2CVgPnN396Agb\r\nq35AbljzQhzvt+ZMNqVtjRjZQffmyigyFE0106RFTHNEQ5jncIvwbSog8C6g\r\nTS/XDI3pNM5yqo8A6cbxexzXBP1U4rY11iqLcxIrcjK7JRwFj0LlANH44BZn\r\nH9CVYu5XcPW1xGJxCY3cpk84wUNCuZmlkW8=\r\n=smcS\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_15.0.0-74de36b3eecec33aaecc20f62500b755e244ab81_1678757940692_0.011568594447731284"},"_hasShrinkwrap":false},"15.0.0-6eb381e6752111ba8c5610df867915bbecd7880f":{"name":"@detachhead/ts-helpers","version":"15.0.0-6eb381e6752111ba8c5610df867915bbecd7880f","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^1","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.4.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^18.11.6","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^2.7.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^5.0.0-dev.20221206"},"gitHead":"6eb381e6752111ba8c5610df867915bbecd7880f","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers/dist/functions/Number'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nimport { formatDate } from '@detachhead/ts-helpers/dist/functions/Date'\n\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nimport { exactly } from '@detachhead/ts-helpers/dist/functions/misc'\n\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nimport { Equals } from '@detachhead/ts-helpers/dist/types/misc'\n\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nimport { SafeVariance, ToArrowFunction } from '@detachhead/ts-helpers/dist/types/Function'\n\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\nimport { ToNonArrowFunction, UnsafeVariance } from '@detachhead/ts-helpers/dist/types/Function'\n\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n### casting functions\n\n```ts\nimport { narrow, narrowCast, unsafeNarrow } from '@detachhead/ts-helpers/dist/functions/misc'\n```\n\nthe `as` keyword doesn't always work exactly how you want. the `narrow`, `unsafeNarrow` and `narrowCast` functions can be used to cast variables in different ways\n\n|                         | modifies original variable's type | returns the value with the casted type | intersects original type with casted type | allows non-overlapping types |\n| ----------------------- | --------------------------------- | -------------------------------------- | ----------------------------------------- | ---------------------------- |\n| `as` keyword            |                                   | yes                                    |                                           |                              |\n| `narrow` function       | yes                               |                                        | yes                                       |\n| `unsafeNarrow` function | yes                               |                                        | yes                                       | yes                          |\n| `narrowCast` function   |                                   | yes                                    | yes                                       | yes                          |\n\n## requirements\n\n### typescript\n\nsince this package pushes the limits of the typescript compiler, i often update it to depend on unreleased\nversions of typescript for bug fixes and to ensure that upcoming releases won't break any of my wacky types.\ncurrently it depends on typescript >=5.0. you will probably encounter type errors and/or performance issues trying to\nuse it with older versions.\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@15.0.0-6eb381e6752111ba8c5610df867915bbecd7880f","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-vMXx7FagHIUHOhNG7pPxx0Ngk7q01tgDwh+xftH+FGiANXdxjpT8SO8i8CqYSCAKTgvdOgWTrzlLxCnJKa/jBw==","shasum":"8737e0546d0b135cc4c1e5946608fd6fa8ffda55","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-15.0.0-6eb381e6752111ba8c5610df867915bbecd7880f.tgz","fileCount":84,"unpackedSize":312492,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCZMrl4Rhj307a5MduOVQynUQkQOlpuBcKwfHIa36INqgIhAK90u6vmaenyc1DPXixoOCU7l8Gl2OffjRwa1GDXKYzd"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkD+5+ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmpcog/5AWba0KN9GsKpSvYxXxop/sUHjXY/NVLXAFpnTkRhdTmsK/nv\r\nbbuABfC/FUxJB+8I4TEpoN9EYSe6ILeCAqIs4MEBgjFNTj4ZOBiQEF0ECKNY\r\nnpg7hHLHlmlzw3qRU7+wMxLOC+UbALbhJnktFFJpgJsFr+z5NuR1AlekBfVo\r\n+P8rTNuR4HqnPKo4rfCtplKaGXP6hOGTaqYnpjKit7Qs6Ya+srpw178rr2/u\r\nvF97Vj6OYPavWSTWcARxo7uqii7JXhbDxlzEFDQTAR+R0WJuMqI3xu0FxTO7\r\nfw63ceUsvE/BHKlYRus0qJylcpM85lcNUA5rWCaMt9a2KXp3AVpkyj9pGIB9\r\nb/jptWVKIMDDGPwzPkYshvcYd1ub3RyzqW5ZvTZo7fHcDgaev+bKjWO0V4tt\r\nWyQezLo68pzyGRnZlCzCSONKKJ79THw8fL46/K4KUQVUmGyPokpgmXy/vgup\r\nPMFO0nzxG55bDjj8z8MeL7zgaIGvuwpZojWcGFNjaBoAuxKTmWW9xVhMHNS8\r\nwSkuQJjQvr9gTGIA2iCSNinfxYbMQbhip92KvCtg3VP2p0Lm6TiRMB5nZh7r\r\nMMm8bh3aQosSlMIzcEwXTRWVbfN3xz3rnXCSgGJ/f5cIkECS/elDos+M8n8l\r\nkhdJxERUhaHUpU/vnzUVfSWQuC3ENdQaBws=\r\n=THum\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_15.0.0-6eb381e6752111ba8c5610df867915bbecd7880f_1678765694134_0.7897688391207232"},"_hasShrinkwrap":false},"15.1.0":{"name":"@detachhead/ts-helpers","version":"15.1.0","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^1","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.4.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^18.11.6","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^2.7.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^5.0.0-dev.20221206"},"gitHead":"73ab5c802e0813b5f94f8f7530a67af31c9d5112","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@15.1.0","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-t7G5EdFFI7V8oe/8x5js98ZXDlxFppunIbUYvPNk0SlHMZSipS/rn7RhIFMhE2PIugWqIdqA3IwZ8B+ofYHmyg==","shasum":"0d626c0d275d4503a03e102eb253f394bf604637","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-15.1.0.tgz","fileCount":84,"unpackedSize":312451,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCVdS1GH827cNwHrF3o5DXEJ7EHYCMMu90lkSYov17cGQIgHC+Cls6M5HT1V65CQYB8opc2mVW3YsjMsnOj5iP4L54="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkD/jLACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmrwyg/8CtWBCILIObHBCGohMC5ExErBqUL36jebucdKkpNwuYT2iF1O\r\nKxxC1wFWMky4fgintRek5By2orNjFNEsCxDKllV6QulU7u8ilB4gD9QkSkaf\r\n9YBQ8zyHbqv3i1NBxiB9lepJu3c0BmeHSLNJv7XMo8v7TP1d/jYcbZr5yIOn\r\nHQqHp3ANPBEkQWgg7LB5LtSubXgoKhMWFeLV6hxm0iF5NLgodafyELHnZq7g\r\nCgnTh3QnseHzXAAjB09n0Ll501BWRWGvM2OZzOumBuRFmTc/etyosGlMKili\r\n2ZnXrzISUACGskc+Arn5LD8HisfdoMO1oIOUB4QDzuZWjT8Es8r2RZqLzPuW\r\nNqxHvlfY3NO1OJYqNLGbzeICoZGNU6awJIs2qBnjSDAvZuIzkbmBr4A++nx9\r\n2bXWnEUC2OIJoN83Csd1Gptn1xfENDkZIRB4Ze2Xj6Le7/K6UZDkIviJtse2\r\n0V43R6sI6duIV8BIoaKLPeJEV/KzzHN9b+sC4jzrzNqaOELZRfIrB1Lukqef\r\nzm2+OBaRbkjipviJfaDASwqYpIbTcSjnfOjUR38bKkdHBD6kzHCUvdwxGhyT\r\n4RjsKBhcfzFCPYHg5urJU/meerpSCtx0wGrUBUGcbZmZFdzU2TRSO0TgDOh5\r\ncCIBvRU2HAGctx9gNmXzPdu5J72cAVmcZKg=\r\n=m2pN\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_15.1.0_1678768331486_0.9957764013057784"},"_hasShrinkwrap":false},"15.1.0-66fa4164ac9dcc122a8a4c7385fbb19727a139d0":{"name":"@detachhead/ts-helpers","version":"15.1.0-66fa4164ac9dcc122a8a4c7385fbb19727a139d0","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^1","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.4.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^18.11.6","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^2.7.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^5.0.0-dev.20221206"},"gitHead":"66fa4164ac9dcc122a8a4c7385fbb19727a139d0","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers/dist/functions/Number'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nimport { formatDate } from '@detachhead/ts-helpers/dist/functions/Date'\n\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nimport { exactly } from '@detachhead/ts-helpers/dist/functions/misc'\n\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nimport { Equals } from '@detachhead/ts-helpers/dist/types/misc'\n\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nimport { SafeVariance, ToArrowFunction } from '@detachhead/ts-helpers/dist/types/Function'\n\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\nimport { ToNonArrowFunction, UnsafeVariance } from '@detachhead/ts-helpers/dist/types/Function'\n\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n### casting functions\n\n```ts\nimport { narrow, narrowCast, unsafeNarrow } from '@detachhead/ts-helpers/dist/functions/misc'\n```\n\nthe `as` keyword doesn't always work exactly how you want. the `narrow`, `unsafeNarrow` and `narrowCast` functions can be used to cast variables in different ways\n\n|                         | modifies original variable's type | returns the value with the casted type | intersects original type with casted type | allows non-overlapping types |\n| ----------------------- | --------------------------------- | -------------------------------------- | ----------------------------------------- | ---------------------------- |\n| `as` keyword            |                                   | yes                                    |                                           |                              |\n| `narrow` function       | yes                               |                                        | yes                                       |\n| `unsafeNarrow` function | yes                               |                                        | yes                                       | yes                          |\n| `narrowCast` function   |                                   | yes                                    | yes                                       | yes                          |\n\n## requirements\n\n### typescript\n\nsince this package pushes the limits of the typescript compiler, i often update it to depend on unreleased\nversions of typescript for bug fixes and to ensure that upcoming releases won't break any of my wacky types.\ncurrently it depends on typescript >=5.0. you will probably encounter type errors and/or performance issues trying to\nuse it with older versions.\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@15.1.0-66fa4164ac9dcc122a8a4c7385fbb19727a139d0","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-sngRxPM2ui9TCCcNIIpUviq3Ny0hLMLgwKAa1cwXcXcPmhmTdQrFq6yK/gnRSpDFv1dTdXUSdJlv3qVAxbWgeA==","shasum":"e6008a9b0a8285ff01431239625bb2bff9bded84","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-15.1.0-66fa4164ac9dcc122a8a4c7385fbb19727a139d0.tgz","fileCount":84,"unpackedSize":313242,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCq+qT7I2KO7smlwqB6oh+YEPbCTFJHx+1LXzZJX3mFrQIhAOLqO0ailAIpSPpbIx+yhNDiAN4J2xAZ/5XF67BX5/hG"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkEpCmACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqaoRAAiErRvh/gx8k1xOxAlp64Lvds03l5ZH693p9DuA2u+YRZxOkE\r\n5GbYBq4vyAMmZoC1mm1xnNWeUKe4E2OSiv6oO5Yr4jOpiKVEbpDCwfOduGgM\r\nnv5mK6tP2XIfvZnd7w//jFy+FanpZgmIF7ApcjVceoMgLctZnkmqencDpu3v\r\n1ODxRfxc25Np96ZVbxk3v6+6DvPF+AMdLziZnuSTlGAJ6uypVCVJUb+V00gj\r\n81g17Caa+GZXf9dlge1eKA2/5rirIsGiy6wuVTldxUEu0n/8gPqlpQXjBE3E\r\npwETDZTTc7Qc5jif2ChEt9kTKXMNi17l7DTJL2Hsa2bAOTe5TbywYWbtpvCn\r\nSkQV6WrljB+JWhwFRl6gWZjk32kTWgKuiqmjSixnkxBo3Oaqr+deu6z65Awo\r\n40Zuml2bQPq9njSn50O5pe9f5D9B9PcHfkDX/bzYCRr4Lf458ihcn1XWbNW2\r\nZ0BShZ2YgYKvLEFnn/3ZlRSPS2nfdcTkTJ4j2q/Rox1oIV6AY5fpkgFeqmo6\r\nS+hrpjIuwEHMKJJrfwL4xp0Rlr2HRBb1Rrm+uezokQVWQqgPGdBImmAKzzyF\r\nQPMDxSIu6wwiaFT7afF9UNbfy4ABHRvWAEvik0UGnnxRhW/f+PJZrlSJiFel\r\nN2XPQLL45NCVmrT7PE1dDsD+efRJC+oY67Y=\r\n=Fxz0\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_15.1.0-66fa4164ac9dcc122a8a4c7385fbb19727a139d0_1678938277853_0.5063114849915975"},"_hasShrinkwrap":false},"15.1.0-214b3ecd8ab4a743329b51b475171060ef0fca87":{"name":"@detachhead/ts-helpers","version":"15.1.0-214b3ecd8ab4a743329b51b475171060ef0fca87","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^1","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.4.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^18.11.6","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^2.7.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^5.0.0-dev.20221206"},"gitHead":"214b3ecd8ab4a743329b51b475171060ef0fca87","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers/dist/functions/Number'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nimport { formatDate } from '@detachhead/ts-helpers/dist/functions/Date'\n\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nimport { exactly } from '@detachhead/ts-helpers/dist/functions/misc'\n\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nimport { Equals } from '@detachhead/ts-helpers/dist/types/misc'\n\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nimport { SafeVariance, ToArrowFunction } from '@detachhead/ts-helpers/dist/types/Function'\n\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\nimport { ToNonArrowFunction, UnsafeVariance } from '@detachhead/ts-helpers/dist/types/Function'\n\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n### casting functions\n\n```ts\nimport { narrow, narrowCast, unsafeNarrow } from '@detachhead/ts-helpers/dist/functions/misc'\n```\n\nthe `as` keyword doesn't always work exactly how you want. the `narrow`, `unsafeNarrow` and `narrowCast` functions can be used to cast variables in different ways\n\n|                         | modifies original variable's type | returns the value with the casted type | intersects original type with casted type | allows non-overlapping types |\n| ----------------------- | --------------------------------- | -------------------------------------- | ----------------------------------------- | ---------------------------- |\n| `as` keyword            |                                   | yes                                    |                                           |                              |\n| `narrow` function       | yes                               |                                        | yes                                       |\n| `unsafeNarrow` function | yes                               |                                        | yes                                       | yes                          |\n| `narrowCast` function   |                                   | yes                                    | yes                                       | yes                          |\n\n## requirements\n\n### typescript\n\nsince this package pushes the limits of the typescript compiler, i often update it to depend on unreleased\nversions of typescript for bug fixes and to ensure that upcoming releases won't break any of my wacky types.\ncurrently it depends on typescript >=5.0. you will probably encounter type errors and/or performance issues trying to\nuse it with older versions.\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@15.1.0-214b3ecd8ab4a743329b51b475171060ef0fca87","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-Fo7UwPVeCm8Mi66/xe75nXpgWdEDMECocSU9dmG0KgzO/3A8ySJzCsUfK5QCraPBQTqEhJ6A99vjvV2HlFnWrA==","shasum":"d9dd4bd55ff954147347b8f2841cf6a86c55d14c","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-15.1.0-214b3ecd8ab4a743329b51b475171060ef0fca87.tgz","fileCount":84,"unpackedSize":322512,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHBhOf6peEh4ncahd4HqGDpQMFa3go+MC8roy1X3FQOuAiEAppdMwf245qQtIdY0nP3G8DpByviZuNsv3vnOAsxIlvs="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkE/NbACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrB5A/5Acy3xCmExJEmf5F4ZKlwjVx4+hQfeIRV/aumOgUoS7uG1+dt\r\nnOVq+j2R8czBks7nRjwA6mKdU6yS8FOyKyQQ8rvbUXxNQV/jUOvKzXsC4/gc\r\nHPO++mfFuIcgOHe6mhq/qcgtrAtAcyHzsF+7vEGyuuzUy+SPYv9J3Dpp+jjZ\r\n04vWZwxmgTu0hOuLeb01IZmJavCpbnbfuvackl1+GIU5et80m2NuIsO4mPiE\r\nnavdzwiTRhWtws3YKa/B0DPCV08bvoIS6VtmineWddF58YtkI2EeOBm/G3Af\r\nBsz3s24QWsIihgY1sD0b0vuHAzzZ1SyXuDKd6yC/eqTV/tMqz3AlrB61Jse3\r\nHkjoElXiVfQc3hIKJ8SQmOp0csMyOtRGvCsO85+BTWKrFGbAulFgtUEMUOEM\r\njw77LKt1qbL8iDa1HUSgxRqUWLt0yUIbmeuxK9TqqtSXk9Nq0/oayfIf/1eH\r\nOFL9IMnOyv+r59xaGi8KiJwyNe72H/00xdg+LLXGt3kYPGemSWxHSF2khXjy\r\nosc/kpTZk2jiVcCAIg0Vy1LZ8CnceTZOsNMCWtsiZvVuLBgRALOgRa7zwrgs\r\nwLLvQjE4sUwHggrbTiwwD2N5QykgNUh0hBfG4J7DhsUNI4FgX9NXZDEq6cGS\r\n0CiuvuhpTP3wv9iRq8pnMVpMaxPs3+q372M=\r\n=+DD1\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_15.1.0-214b3ecd8ab4a743329b51b475171060ef0fca87_1679029083546_0.033870497981977055"},"_hasShrinkwrap":false},"15.1.0-1861d65fb22a1bc4823563aa11e668bd432904fe":{"name":"@detachhead/ts-helpers","version":"15.1.0-1861d65fb22a1bc4823563aa11e668bd432904fe","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^1","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.4.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^18.11.6","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^2.7.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^5.0.0-dev.20221206"},"gitHead":"1861d65fb22a1bc4823563aa11e668bd432904fe","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers/dist/functions/Number'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nimport { formatDate } from '@detachhead/ts-helpers/dist/functions/Date'\n\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nimport { exactly } from '@detachhead/ts-helpers/dist/functions/misc'\n\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nimport { Equals } from '@detachhead/ts-helpers/dist/types/misc'\n\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nimport { SafeVariance, ToArrowFunction } from '@detachhead/ts-helpers/dist/types/Function'\n\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\nimport { ToNonArrowFunction, UnsafeVariance } from '@detachhead/ts-helpers/dist/types/Function'\n\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n### casting functions\n\n```ts\nimport { narrow, narrowCast, unsafeNarrow } from '@detachhead/ts-helpers/dist/functions/misc'\n```\n\nthe `as` keyword doesn't always work exactly how you want. the `narrow`, `unsafeNarrow` and `narrowCast` functions can be used to cast variables in different ways\n\n|                         | modifies original variable's type | returns the value with the casted type | intersects original type with casted type | allows non-overlapping types |\n| ----------------------- | --------------------------------- | -------------------------------------- | ----------------------------------------- | ---------------------------- |\n| `as` keyword            |                                   | yes                                    |                                           |                              |\n| `narrow` function       | yes                               |                                        | yes                                       |\n| `unsafeNarrow` function | yes                               |                                        | yes                                       | yes                          |\n| `narrowCast` function   |                                   | yes                                    | yes                                       | yes                          |\n\n## requirements\n\n### typescript\n\nsince this package pushes the limits of the typescript compiler, i often update it to depend on unreleased\nversions of typescript for bug fixes and to ensure that upcoming releases won't break any of my wacky types.\ncurrently it depends on typescript >=5.0. you will probably encounter type errors and/or performance issues trying to\nuse it with older versions.\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@15.1.0-1861d65fb22a1bc4823563aa11e668bd432904fe","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-/OMYH87EX/yp9IwM4IoGleKGcX+MXmMlhqMN0T30GZYmBMVsaU0iBVCajmanPEvuHbb1RIp3RphKCbXrTkSHZw==","shasum":"8063fb9d198c07d35b6363298be90ccd9c0f206a","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-15.1.0-1861d65fb22a1bc4823563aa11e668bd432904fe.tgz","fileCount":84,"unpackedSize":322673,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC4YOGg3Fvroc4orhVjUfc8vKwWVrNiyfAAyK6nYC3jqwIgZHvctB/ffaO6XCCtvrYuRfsEmeZq6HbtoSrdlLZyjaA="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkFAoYACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqhyhAAo0Qfyn4ThzgF7HmMgC1W3F7kRC8jpXwjjmy3CHiIWUZNv+MQ\r\nCaYuPJZTcnx7etKdSgHbbxEBACCquh3uAaqrP3rXLbeZuK6ZD6+605vRR4d3\r\nKgG96oUR7AkbUrjbSEYDDi89L2vW69Y4pXs6GNtWN1pJCpE2R+XBr+bpjde4\r\n175x0JxB9rcEuwDtKPV2XYjxqKvmJ9jmqiyi/A6sQ277Jto/yRyX9G0888Fu\r\ncfp+smn9/j518zF3moM13voufTZbx/raK8LJzr27Tz/RGi/l05Rwf9nl5fCW\r\nHeHBOc+96rumA7fP/mgRPRcmT3pZLRXTsRlDEMBJMj9X/zNgEmg8P2oBKyg7\r\nKr2szCH5TkOF6tHthPp/vTJai/zHLK27eU0q7AkdhW3ZwQpW7PDsivlDhKij\r\nLhK10/FMGc23m8ZgzL19jYIOJkhko3aql1R7zX0xlN1KmPqx/zoveDgG64LK\r\nBZH5OmZGZzIjOghxoHDTi4O36Sn90nyuBGTjv01Rj0plAw/H7Ie83eRA/1ES\r\n3aMl2il7NODIQq5696HsUwLg/Wsj8nVX6D8NfTIJMGfzaf1EViNhwXzdx3YM\r\nyHkmkS3CnEB0eXT5YszjvLO5wArran/HGAtSrNUgTebS+LDYnY2r+6h9vRr5\r\npqU71fB6wmFOi9Lk04OW5xJ4UT14n7BHJOA=\r\n=2+7J\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_15.1.0-1861d65fb22a1bc4823563aa11e668bd432904fe_1679034904004_0.20945248127894667"},"_hasShrinkwrap":false},"15.1.0-9fa07de4ff4f3a081cb75e6a8182b09eb3f45f35":{"name":"@detachhead/ts-helpers","version":"15.1.0-9fa07de4ff4f3a081cb75e6a8182b09eb3f45f35","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^1","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.4.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^18.11.6","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^2.7.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^5.0.0-dev.20221206"},"gitHead":"9fa07de4ff4f3a081cb75e6a8182b09eb3f45f35","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers/dist/functions/Number'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nimport { formatDate } from '@detachhead/ts-helpers/dist/functions/Date'\n\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nimport { exactly } from '@detachhead/ts-helpers/dist/functions/misc'\n\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nimport { Equals } from '@detachhead/ts-helpers/dist/types/misc'\n\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nimport { SafeVariance, ToArrowFunction } from '@detachhead/ts-helpers/dist/types/Function'\n\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\nimport { ToNonArrowFunction, UnsafeVariance } from '@detachhead/ts-helpers/dist/types/Function'\n\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n### casting functions\n\n```ts\nimport { narrow, narrowCast, unsafeNarrow } from '@detachhead/ts-helpers/dist/functions/misc'\n```\n\nthe `as` keyword doesn't always work exactly how you want. the `narrow`, `unsafeNarrow` and `narrowCast` functions can be used to cast variables in different ways\n\n|                         | modifies original variable's type | returns the value with the casted type | intersects original type with casted type | allows non-overlapping types |\n| ----------------------- | --------------------------------- | -------------------------------------- | ----------------------------------------- | ---------------------------- |\n| `as` keyword            |                                   | yes                                    |                                           |                              |\n| `narrow` function       | yes                               |                                        | yes                                       |\n| `unsafeNarrow` function | yes                               |                                        | yes                                       | yes                          |\n| `narrowCast` function   |                                   | yes                                    | yes                                       | yes                          |\n\n## requirements\n\n### typescript\n\nsince this package pushes the limits of the typescript compiler, i often update it to depend on unreleased\nversions of typescript for bug fixes and to ensure that upcoming releases won't break any of my wacky types.\ncurrently it depends on typescript >=5.0. you will probably encounter type errors and/or performance issues trying to\nuse it with older versions.\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@15.1.0-9fa07de4ff4f3a081cb75e6a8182b09eb3f45f35","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-faMfGtQiUAA3p83a3JLN3R+F2zXadVmgFWuPAoIJQANBY6dsxngLc+cMHBfNqxfNckdEsoutMOopBX42FjTTgw==","shasum":"c0ff556414ffe3db93b5773badda352944b04aae","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-15.1.0-9fa07de4ff4f3a081cb75e6a8182b09eb3f45f35.tgz","fileCount":90,"unpackedSize":323312,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIF0to5k+eFKHvjaJiimel9XL/eIk0cJHWJB3kEXFa2u9AiAZqlOfH3xlsmRDRCpWkAex5UpCmT09c06oUU710DCCXw=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkGPoOACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrOsA/7B/FpUf+nyIq+L9krKzAAK137vLA3jPT2rffFC280xquabvG1\r\npZoDH0n2S4KCZBW/8SbxWJbyWbGfxoufIFdEFZj5RmJlVvQZRhg4aATnx3yS\r\nNDRdDyjZRTRPmWFN4LB+MBDBeAQGh8IORMiR4zg9+Dt90K+nSG8K1a0yycZm\r\nDYOafRtY+jBpxidnd0WxBU7gcpDwpPgBMxs1VtXaMku9bldwuhpG3W0kTatd\r\nVO8J0+XkbRhlXve0QhFQLFOVTLCC/R7dVI5O3Qq2n+xrbnRHXDLXVdUomjQT\r\nomglVegPC/6V4I9XAZqM9Oxx8Mw7VHzxFJq+mZh943PJNvLzfE9XgLum2koj\r\n1xpwc4KXmnzD5SzXFoKZxYVXZlZOdeb0gcZ5aAwKxYrc6wci/3YRQs18SpC2\r\nQJ4oGNd2rLEAzG4qbwKwb5Zqs8nqIUfX6NRLBSIiF/ZSBs/yDWkSr1hcHShZ\r\nAYfo8avG3gdRQZz2PJhNoJS+C8pMuIyhzK9UXuaSq3vmiWmWlzKSNAKPdsor\r\noSsDqd612nzGaCLZbfSnElpSTSDauj3Vbdzj9S3ogNkHvD4WayZEy07sHm2Y\r\n847FfLRnVOOudILep5G0aQcc7hwZl2zsUBm6cE/ZO0zB9+fdyA2LpHsqsBSl\r\nhJ0kx8rTPK3PdE5eE5eC260G1EdBnpRR/sg=\r\n=vYnH\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_15.1.0-9fa07de4ff4f3a081cb75e6a8182b09eb3f45f35_1679358478220_0.7729009399005848"},"_hasShrinkwrap":false},"16.0.0":{"name":"@detachhead/ts-helpers","version":"16.0.0","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^1","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.4.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^18.11.6","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^2.7.1","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^5.0.0-dev.20221206"},"gitHead":"2ef3bb9aca56e66a759d11772c399981d659e012","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@16.0.0","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-8Iy8yjf0VZhiFguSYexISwBFHWbC8iCV6jZri4WufUx+l3JUJkBHjsbrzZsuMpt6Wh+f7U6DtAZHO3DUPiF5bg==","shasum":"5d9fb41e6770b56c09f066d2779820cd93db4573","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-16.0.0.tgz","fileCount":90,"unpackedSize":323271,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEg4rATVzDqo7KTK//ks9MgDmqEiUxwysSh1DYzh9xl+AiB7Qj0O4w1T58QqepfIGy2YSEtCbnv3d16Oux50Numsgw=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkGPuIACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqrHQ/+J2Z234QApyLIsQWlmMp0GqJRizo/rk3yuEBdvtg4dErlJjCL\r\nYIIcs0ZCRZi5L37jbMyS5E1R2E2hBqLO+RBCUpnfYi1JpolzT0JyCjvWXSFq\r\nJq432WWS9eV2YRPhJTXLgTYOvujUXM1X53jQs+Cbo+Rv79KX8P8wi31FJFo1\r\n5/8Qop88CT0+3kRvL0udCA0yKf+ypuvQrv4a/PAfx7dX6ztwtnyJqBFoP+VU\r\n9zks42sKuVKmpElYnpeKs0dqOSImhaIFAj+jiYKnThjplQe8z6lPtouiuIkH\r\nagkrGdpkG/0ZMfd09X3mggft6YMycae04Hr8SrqjVo9ylifTjyRl6ZRX6Teb\r\n7MwZiqifGfMBhh6acistXRS9FRc2dNezSOercg1SsWWq/2d6jOpvuaZ30zYo\r\nNXO+HVu2cMwupaDK12YAZgVDX8hjS8rb0AdbFt8NhPKaKxwGSVz/2s6sd9r7\r\njgBQSB3zAC1TLNXPORi5DIX14iVV3Ap3fceEhWXbX/SLzPTUNMAIAzs6Uw5W\r\nwYOe3bFvJmMRX2pvbkJUTQaqOk9Dz0v+pWT9T2qEGrvyKEmMbT3JkLZfvEzK\r\nEn9Tly83ZRz7s2Vr/0+br2jZ1jJVGK/Zt5+cFex7p7FfqvXrNUgNe5ALL9wE\r\nN0cE4P7LEmhD8EFasscO6eJdOTKZQxFVHTk=\r\n=VhDO\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_16.0.0_1679358856719_0.8077979597127674"},"_hasShrinkwrap":false},"16.0.0-6a77cd5f68c3f2cb170e27bd507abeaebcd2efc4":{"name":"@detachhead/ts-helpers","version":"16.0.0-6a77cd5f68c3f2cb170e27bd507abeaebcd2efc4","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^1","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.4.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^18.11.6","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^2.8.7","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^5.0.0-dev.20221206"},"//":"https://github.com/trivago/prettier-plugin-sort-imports/issues/204#issuecomment-1431287240","overrides":{"@trivago/prettier-plugin-sort-imports":{"@babel/core":"7.20.12","@babel/parser":"7.20.15","@babel/traverse":"7.20.13"}},"gitHead":"6a77cd5f68c3f2cb170e27bd507abeaebcd2efc4","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers/dist/functions/Number'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nimport { formatDate } from '@detachhead/ts-helpers/dist/functions/Date'\n\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nimport { exactly } from '@detachhead/ts-helpers/dist/functions/misc'\n\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nimport { Equals } from '@detachhead/ts-helpers/dist/types/misc'\n\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nimport { SafeVariance, ToArrowFunction } from '@detachhead/ts-helpers/dist/types/Function'\n\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\nimport { ToNonArrowFunction, UnsafeVariance } from '@detachhead/ts-helpers/dist/types/Function'\n\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n### casting functions\n\n```ts\nimport { narrow, narrowCast, unsafeNarrow } from '@detachhead/ts-helpers/dist/functions/misc'\n```\n\nthe `as` keyword doesn't always work exactly how you want. the `narrow`, `unsafeNarrow` and `narrowCast` functions can be used to cast variables in different ways\n\n|                         | modifies original variable's type | returns the value with the casted type | intersects original type with casted type | allows non-overlapping types |\n| ----------------------- | --------------------------------- | -------------------------------------- | ----------------------------------------- | ---------------------------- |\n| `as` keyword            |                                   | yes                                    |                                           |                              |\n| `narrow` function       | yes                               |                                        | yes                                       |\n| `unsafeNarrow` function | yes                               |                                        | yes                                       | yes                          |\n| `narrowCast` function   |                                   | yes                                    | yes                                       | yes                          |\n\n## requirements\n\n### typescript\n\nsince this package pushes the limits of the typescript compiler, i often update it to depend on unreleased\nversions of typescript for bug fixes and to ensure that upcoming releases won't break any of my wacky types.\ncurrently it depends on typescript >=5.0. you will probably encounter type errors and/or performance issues trying to\nuse it with older versions.\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@16.0.0-6a77cd5f68c3f2cb170e27bd507abeaebcd2efc4","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-19vjHOMmAuRpuTE/UyigeCVPXt2QVaVOWjMMQWfGVTcd/OCpzyPBXj//eLtxCKFAzpT/L1mvYK1T29BgDvzKzQ==","shasum":"f2a02689261658d269aac803fa0848986fcdae41","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-16.0.0-6a77cd5f68c3f2cb170e27bd507abeaebcd2efc4.tgz","fileCount":90,"unpackedSize":333398,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCepyJgeJLfITY4NQ2CYMAfOSfbYNzNe9gczembt9cXTQIgHZtANpWorPqjywEBzttLs1vnj4WoamOQUubFuYMF5xg="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkOJ+LACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqQuQ/8Di39AGdXGUJUQSGtVswtahtOMY00V6tKITBNaTmMBlEV+RAN\r\nio9M6i7SptJHL79H6PoNbhGGAROlkyEzajS/PjXiw3Mmjh71emRwuOEDag5i\r\nQOF3jIFrBZuG1EN850gWv8oJwMPF0HWgBVnZ4onFo/P0oxw5MZrNuebOp3Xg\r\n8VSbbIOG5p/WeMs3SQSY5nRqAwbF2daq6y23/bd7QCKAOykX14Upvks6hhIh\r\nxRcwtakpsV5K3ExqzjgGUnVQcPbTgmA/ahAHqro3qvW7Uw5bN5LiTW+CpcFO\r\nJ12adHIPXRFc56Kb33K7z6smtOpaFS5OkPa3iJmzO9a9kk52YP/auHVuTKwS\r\nxDU2tHTbqo4CILcOCDZxrGqy1WIcbJP0sV1efVM+aRavcy7dI5rXQvRLokGd\r\nS46YWO4ZCp+O8+TFnS7EETfpwpw3fu+HtAOFwAgLKfzmpRJu1/OqbpOmU1Mj\r\nCERM6ED8TFAIHIYQ7z8fJMWTpcKVx8n/5KirY2OtWcchJ70WU88rtS2THoqN\r\ne7KOJDAKDEjSp2WvaNdCanBkM3+QMQYdjBHOU2Pg+Sj1v+jIdPYxzBuCUeJJ\r\nb7SCAgclUvylRB2pXSvWaCZqGqRgfDILbD0wbjhhPyE5qOfsEqY+g3kygsuT\r\n76vAJHEaRMqqiBQrL3DYrS1Hmy+uC4MiWtQ=\r\n=Yk0k\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_16.0.0-6a77cd5f68c3f2cb170e27bd507abeaebcd2efc4_1681432458967_0.2491305227964149"},"_hasShrinkwrap":false},"16.0.0-b71e5328fd77260ad5671c5a71565b160e2051d5":{"name":"@detachhead/ts-helpers","version":"16.0.0-b71e5328fd77260ad5671c5a71565b160e2051d5","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^1","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.4.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^18.11.6","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^2.8.7","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^5.0.0-dev.20221206"},"//":"https://github.com/trivago/prettier-plugin-sort-imports/issues/204#issuecomment-1431287240","overrides":{"@trivago/prettier-plugin-sort-imports":{"@babel/core":"7.20.12","@babel/parser":"7.20.15","@babel/traverse":"7.20.13"}},"gitHead":"b71e5328fd77260ad5671c5a71565b160e2051d5","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers/dist/functions/Number'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nimport { formatDate } from '@detachhead/ts-helpers/dist/functions/Date'\n\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nimport { exactly } from '@detachhead/ts-helpers/dist/functions/misc'\n\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nimport { Equals } from '@detachhead/ts-helpers/dist/types/misc'\n\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nimport { SafeVariance, ToArrowFunction } from '@detachhead/ts-helpers/dist/types/Function'\n\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\nimport { ToNonArrowFunction, UnsafeVariance } from '@detachhead/ts-helpers/dist/types/Function'\n\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n### casting functions\n\n```ts\nimport { narrow, narrowCast, unsafeNarrow } from '@detachhead/ts-helpers/dist/functions/misc'\n```\n\nthe `as` keyword doesn't always work exactly how you want. the `narrow`, `unsafeNarrow` and `narrowCast` functions can be used to cast variables in different ways\n\n|                         | modifies original variable's type | returns the value with the casted type | intersects original type with casted type | allows non-overlapping types |\n| ----------------------- | --------------------------------- | -------------------------------------- | ----------------------------------------- | ---------------------------- |\n| `as` keyword            |                                   | yes                                    |                                           |                              |\n| `narrow` function       | yes                               |                                        | yes                                       |\n| `unsafeNarrow` function | yes                               |                                        | yes                                       | yes                          |\n| `narrowCast` function   |                                   | yes                                    | yes                                       | yes                          |\n\n## requirements\n\n### typescript\n\nsince this package pushes the limits of the typescript compiler, i often update it to depend on unreleased\nversions of typescript for bug fixes and to ensure that upcoming releases won't break any of my wacky types.\ncurrently it depends on typescript >=5.0. you will probably encounter type errors and/or performance issues trying to\nuse it with older versions.\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@16.0.0-b71e5328fd77260ad5671c5a71565b160e2051d5","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-Fx5C4LMmYAbwE7RwKOjxOpytVve3hIrEro66Kq3iFvHEstKx8xq/cZ4GfY7RhUmarTT0eu+SK3K3vst/qg0ysw==","shasum":"eefb4f115536f37f47bd2900bed42a8824b4a8f6","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-16.0.0-b71e5328fd77260ad5671c5a71565b160e2051d5.tgz","fileCount":90,"unpackedSize":333399,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICTBF1OX8jgkmen3X8AnISs2y71XY69okhabTMkeqQWMAiB0IA6YhX3SRbjpljRKkXjaxTJ/cH53a+aMb83dgodxwQ=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkOKEkACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmq+PQ//cWQawYgvmZSw6PINThv0LrSPDPsMsaDpfqDh56HE2yD5Zzse\r\nUv5OtbxxYIvC+WLWLIoED3nu6DybkpKwFFwF66wyijXlXM3+OFvH4503vfpf\r\nrjEOBFhAc6Fsvxp3wAVZb3pca7NWmoocLPhtVjQ4qgFYHREbKbc/HpMuMz5q\r\nNLLXn1Oy5Oiyh7g0OtS56INw1x6zBcXcyn3sHAUGHgNo7wCh7KcRcQKZXmcK\r\nEyFLvheBB6SNjbZa13gkTXhv+gP8Y5ohQd70whH/jjsKZzLS+9iOvwdSMhIW\r\n02uD8qaSct8wGLrxeE0WkKFvQDS/UjZquNDZP8rpJNXLJXNEn0zj7n9CDzZs\r\nK5/CzMwbcc8nbciA6e8zWydaL5i4XM/nLRdgFRqpujtTlKF4W0uh58CY1TUm\r\nUn5xIgsDfyznhXuqsSas+9hx0ig1qG3xwtehRtCPiWcN9D6tJ/FUxguIFZIh\r\nv3mlEfxQBYR10tqZ+FQpAz2hCNNMvYTZyMlufNMneLdrbWSXgmVmcyNnZaIh\r\nD/LDFrt0iZxjtogP6CgM8RusKRhk6xzPSlqnY0IpWVuMOyOc4JhCVfiLIOpu\r\nitIca9dvlqnI8gu6/5iT18/kQfOiQ2mHVDAH7/qySQjMGv4Os8t2zQlgICTp\r\nSbEYV3pD2SRt41NYQsed0jHfMJgIEO467Wk=\r\n=3IcX\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_16.0.0-b71e5328fd77260ad5671c5a71565b160e2051d5_1681432868480_0.058185430772408564"},"_hasShrinkwrap":false},"16.1.0":{"name":"@detachhead/ts-helpers","version":"16.1.0","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^1","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.4.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^26.0.20","@types/node":"^18.11.6","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^2.8.7","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","typed-nodejs-assert":"^1.1.0","typescript":"^5.0.0-dev.20221206"},"//":"https://github.com/trivago/prettier-plugin-sort-imports/issues/204#issuecomment-1431287240","overrides":{"@trivago/prettier-plugin-sort-imports":{"@babel/core":"7.20.12","@babel/parser":"7.20.15","@babel/traverse":"7.20.13"}},"gitHead":"011d143c5d4c07eb5451cdf074adddeb341a83f4","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@16.1.0","_nodeVersion":"15.4.0","_npmVersion":"7.0.15","dist":{"integrity":"sha512-vQW/3niDnOdyAOvo34ZswPsEdXRGZvFQkYnSGN10ZQU/Z0FZyixtz/GhGN65q0HKAzdx4g92ptMaRSdBtSra5w==","shasum":"0736ae692a7bee571b5abd63ff88970d3e6a02fb","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-16.1.0.tgz","fileCount":90,"unpackedSize":333342,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDcLv0h4ZRVlszo19yyKxbwp3DYwMRdem5TNxSsfrJDOgIgUlrrHFglXlTzphvV2PnFc644fF4X6Eatvy1GKW5LCho="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkOKzaACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoFYA//cWilD0HUFZisWA9QsSJzsE8xuARp7Zq3Pv6FRGH5fJgvcXRJ\r\nMvlUH1wO/wfyfxSsNjsVs5jDO0iiJrKUffBBSmNGGMSXIFM+yfKMdRlYquN2\r\nv+yp9OvuX0xVZU14rjF+wRWn8XrVRx5JYefWK3ZaT8edAVFOIs8H9Qi1WDpN\r\nJaE187GstT+y0Ljotu3QTxN2PvE7Q93N1Dkpr3Js68Irsh1raCGEjg7ZT5Xb\r\nvosvi5unfQZf48cIOORsdcBMbjnjlTlUs05FBiNEN/kMKTVgfZvB1+b1fM59\r\nHxphYb7foG1o27Rk/4hgCYQTfMEEQloWowIzkNec2lTFbEPxSNrlRmDTHtNs\r\nlVdHEAgUOj/3aIgaRO0zti6LRkyY2fWMu2ao/tPKM9i9CLpcGYFBWbXqwpKK\r\nlTm6AGIiJOwn/wJZouLUBdCT14yG+aK6YoIwI1eUZMk/Txm4yxoSjV0XbHfn\r\nElY6bUE7S8GdtCejovbDr902JNkGunDP4S4w15u58trQoonrHzZO3tfgy2/M\r\nP2bZVAJhMoPzzbz2nJPIJVib8k+cgvkjUyby7U1d0dTYg7tE/nv2p21t6uJe\r\nNQb35iu8nG3j8TfH90Ool78CJ3gv3IpL/OvlCPVsvval2a8eRLxeoiXm1p+4\r\ng1lb56EAhKlPHB6zoDfmviUzbZm8Dwgw1dk=\r\n=hZWb\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_16.1.0_1681435865939_0.801915416592387"},"_hasShrinkwrap":false},"16.1.0-7e1af721833092e45eaf391a44e7b11f2c0d0d49":{"name":"@detachhead/ts-helpers","version":"16.1.0-7e1af721833092e45eaf391a44e7b11f2c0d0d49","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^1.2.2","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.4.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^27.5.1","@types/node":"^18.11.6","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^2.8.8","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","ts-spec":"^1.4.6","typed-nodejs-assert":"^1.1.0","typescript":"^5.0.0"},"//":"https://github.com/trivago/prettier-plugin-sort-imports/issues/204#issuecomment-1431287240","overrides":{"@trivago/prettier-plugin-sort-imports":{"@babel/core":"^7.21.8","@babel/parser":"^7.21.8","@babel/traverse":"^7.21.5"}},"engines":{"node":">=16.6.0"},"gitHead":"7e1af721833092e45eaf391a44e7b11f2c0d0d49","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers/dist/functions/Number'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nimport { formatDate } from '@detachhead/ts-helpers/dist/functions/Date'\n\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nimport { exactly } from '@detachhead/ts-helpers/dist/functions/misc'\n\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nimport { Equals } from '@detachhead/ts-helpers/dist/types/misc'\n\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nimport { SafeVariance, ToArrowFunction } from '@detachhead/ts-helpers/dist/types/Function'\n\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\nimport { ToNonArrowFunction, UnsafeVariance } from '@detachhead/ts-helpers/dist/types/Function'\n\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n### casting functions\n\n```ts\nimport { narrow, narrowCast, unsafeNarrow } from '@detachhead/ts-helpers/dist/functions/misc'\n```\n\nthe `as` keyword doesn't always work exactly how you want. the `narrow`, `unsafeNarrow` and `narrowCast` functions can be used to cast variables in different ways\n\n|                         | modifies original variable's type | returns the value with the casted type | intersects original type with casted type | allows non-overlapping types |\n| ----------------------- | --------------------------------- | -------------------------------------- | ----------------------------------------- | ---------------------------- |\n| `as` keyword            |                                   | yes                                    |                                           |                              |\n| `narrow` function       | yes                               |                                        | yes                                       |\n| `unsafeNarrow` function | yes                               |                                        | yes                                       | yes                          |\n| `narrowCast` function   |                                   | yes                                    | yes                                       | yes                          |\n\n## requirements\n\n### typescript\n\nsince this package pushes the limits of the typescript compiler, i often update it to depend on unreleased\nversions of typescript for bug fixes and to ensure that upcoming releases won't break any of my wacky types.\ncurrently it depends on typescript >=5.0. you will probably encounter type errors and/or performance issues trying to\nuse it with older versions.\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@16.1.0-7e1af721833092e45eaf391a44e7b11f2c0d0d49","_nodeVersion":"19.7.0","_npmVersion":"9.5.0","dist":{"integrity":"sha512-4kKoPFMU1an2Oe1y7PDL1OsvQIlz7EWQ4ipIuUU2PTP9XflSVnMwD6E/nHgNjETDvetuV0itx3wFjU30YeR3KQ==","shasum":"99feb52d76e0e73791ee0badf36e523a91f24460","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-16.1.0-7e1af721833092e45eaf391a44e7b11f2c0d0d49.tgz","fileCount":90,"unpackedSize":331849,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD8rbAKU7WeiFyGG6qaY8neh1y4ouctzLe8n5Hmwz4nIwIhAOOJxF+3untesaCkJ11uHJnrSjBhpZka1uJqwq/dBFUi"}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_16.1.0-7e1af721833092e45eaf391a44e7b11f2c0d0d49_1684070449063_0.9008285959404381"},"_hasShrinkwrap":false},"16.1.0-73a21f951742d13a89071ee41853fa17e5089e8a":{"name":"@detachhead/ts-helpers","version":"16.1.0-73a21f951742d13a89071ee41853fa17e5089e8a","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^1.2.2","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.4.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^27.5.1","@types/node":"^18.11.6","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^2.8.8","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","ts-spec":"^1.4.6","typed-nodejs-assert":"^1.1.0","typescript":"^5.0.0"},"//":"https://github.com/trivago/prettier-plugin-sort-imports/issues/204#issuecomment-1431287240","overrides":{"@trivago/prettier-plugin-sort-imports":{"@babel/core":"^7.21.8","@babel/parser":"^7.21.8","@babel/traverse":"^7.21.5"}},"engines":{"node":">=16.6.0"},"gitHead":"73a21f951742d13a89071ee41853fa17e5089e8a","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers/dist/functions/Number'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nimport { formatDate } from '@detachhead/ts-helpers/dist/functions/Date'\n\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nimport { exactly } from '@detachhead/ts-helpers/dist/functions/misc'\n\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nimport { Equals } from '@detachhead/ts-helpers/dist/types/misc'\n\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nimport { SafeVariance, ToArrowFunction } from '@detachhead/ts-helpers/dist/types/Function'\n\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\nimport { ToNonArrowFunction, UnsafeVariance } from '@detachhead/ts-helpers/dist/types/Function'\n\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n### casting functions\n\n```ts\nimport { narrow, narrowCast, unsafeNarrow } from '@detachhead/ts-helpers/dist/functions/misc'\n```\n\nthe `as` keyword doesn't always work exactly how you want. the `narrow`, `unsafeNarrow` and `narrowCast` functions can be used to cast variables in different ways\n\n|                         | modifies original variable's type | returns the value with the casted type | intersects original type with casted type | allows non-overlapping types |\n| ----------------------- | --------------------------------- | -------------------------------------- | ----------------------------------------- | ---------------------------- |\n| `as` keyword            |                                   | yes                                    |                                           |                              |\n| `narrow` function       | yes                               |                                        | yes                                       |\n| `unsafeNarrow` function | yes                               |                                        | yes                                       | yes                          |\n| `narrowCast` function   |                                   | yes                                    | yes                                       | yes                          |\n\n## requirements\n\n### typescript\n\nsince this package pushes the limits of the typescript compiler, i often update it to depend on unreleased\nversions of typescript for bug fixes and to ensure that upcoming releases won't break any of my wacky types.\ncurrently it depends on typescript >=5.0. you will probably encounter type errors and/or performance issues trying to\nuse it with older versions.\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@16.1.0-73a21f951742d13a89071ee41853fa17e5089e8a","_nodeVersion":"19.7.0","_npmVersion":"9.5.0","dist":{"integrity":"sha512-cx2xrUMJbxOD/Xr6f7davVeMCvLvfDh0H55pr4/qWQIvRmC55HAP1iM8MoRFrarO0X4Aew3GStixrrBYHNn7sw==","shasum":"39d91f6e604a527c9c1073fab35f154f8c378b92","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-16.1.0-73a21f951742d13a89071ee41853fa17e5089e8a.tgz","fileCount":90,"unpackedSize":333375,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFFjJXaUijkYFODgUPg4gHhr7HEX3dZAa9xcVrYP5iJFAiAkr6Llbb+dJvJw2EA3Ovj8T4CB/C0SgPNXy3qc6D9OFQ=="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_16.1.0-73a21f951742d13a89071ee41853fa17e5089e8a_1689855773497_0.7594917929904641"},"_hasShrinkwrap":false},"16.1.0-7bb5b906b0173c4daf00be8c87bff69239bfb497":{"name":"@detachhead/ts-helpers","version":"16.1.0-7bb5b906b0173c4daf00be8c87bff69239bfb497","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.167","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^1.2.2","@jest/types":"^27.2.5","@trivago/prettier-plugin-sort-imports":"^3.4.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.5","@types/jest":"^27.5.1","@types/node":"^18.11.6","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^27.5.1","power-assert":"^1.6.1","prettier":"^2.8.8","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^27.1.4","ts-node":"^10.7.0","ts-spec":"^1.4.6","typed-nodejs-assert":"^1.1.0","typescript":"^5.0.0"},"//":"https://github.com/trivago/prettier-plugin-sort-imports/issues/204#issuecomment-1431287240","overrides":{"@trivago/prettier-plugin-sort-imports":{"@babel/core":"^7.21.8","@babel/parser":"^7.21.8","@babel/traverse":"^7.21.5"}},"engines":{"node":">=16.6.0"},"gitHead":"7bb5b906b0173c4daf00be8c87bff69239bfb497","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers/dist/functions/Number'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nimport { formatDate } from '@detachhead/ts-helpers/dist/functions/Date'\n\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nimport { exactly } from '@detachhead/ts-helpers/dist/functions/misc'\n\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nimport { Equals } from '@detachhead/ts-helpers/dist/types/misc'\n\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nimport { SafeVariance, ToArrowFunction } from '@detachhead/ts-helpers/dist/types/Function'\n\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\nimport { ToNonArrowFunction, UnsafeVariance } from '@detachhead/ts-helpers/dist/types/Function'\n\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n### casting functions\n\n```ts\nimport { narrow, narrowCast, unsafeNarrow } from '@detachhead/ts-helpers/dist/functions/misc'\n```\n\nthe `as` keyword doesn't always work exactly how you want. the `narrow`, `unsafeNarrow` and `narrowCast` functions can be used to cast variables in different ways\n\n|                         | modifies original variable's type | returns the value with the casted type | intersects original type with casted type | allows non-overlapping types |\n| ----------------------- | --------------------------------- | -------------------------------------- | ----------------------------------------- | ---------------------------- |\n| `as` keyword            |                                   | yes                                    |                                           |                              |\n| `narrow` function       | yes                               |                                        | yes                                       |\n| `unsafeNarrow` function | yes                               |                                        | yes                                       | yes                          |\n| `narrowCast` function   |                                   | yes                                    | yes                                       | yes                          |\n\n## requirements\n\n### typescript\n\nsince this package pushes the limits of the typescript compiler, i often update it to depend on unreleased\nversions of typescript for bug fixes and to ensure that upcoming releases won't break any of my wacky types.\ncurrently it depends on typescript >=5.0. you will probably encounter type errors and/or performance issues trying to\nuse it with older versions.\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@16.1.0-7bb5b906b0173c4daf00be8c87bff69239bfb497","_nodeVersion":"19.7.0","_npmVersion":"9.5.0","dist":{"integrity":"sha512-jCv/qF0i5jm+udCzLKmgT0mjYh/+rLNjEIbU2YgFJYPu/M1/83+M0CB88P9w65+giTbuGjuegfpgtIq26GM7uA==","shasum":"1255d8ab5fcb398bcde28a5090b153efa649a6d1","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-16.1.0-7bb5b906b0173c4daf00be8c87bff69239bfb497.tgz","fileCount":90,"unpackedSize":333375,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD11Yenn5hlDzuhFWFC1RfBu8U6u5h0/8ePNuZE/3YD0gIgF+yOS2PNpzIodXb8ULJZEr1fHADGx7wjfUwNOBZYf38="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_16.1.0-7bb5b906b0173c4daf00be8c87bff69239bfb497_1690101216086_0.9012810855291631"},"_hasShrinkwrap":false},"16.1.0-064bd6e36fa1652dd72ff70f5ea2228eb7d08924":{"name":"@detachhead/ts-helpers","version":"16.1.0-064bd6e36fa1652dd72ff70f5ea2228eb7d08924","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.195","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^1.2.2","@jest/types":"^29.6.1","@trivago/prettier-plugin-sort-imports":"^3.4.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.6","@types/jest":"^29.5.3","@types/node":"^20","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^29.6.1","power-assert":"^1.6.1","prettier":"^2.8.8","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^29.1.1","ts-node":"^10.9.1","typed-nodejs-assert":"^1.1.0","typescript":"^5.2.0-beta"},"//":"https://github.com/trivago/prettier-plugin-sort-imports/issues/204#issuecomment-1431287240","overrides":{"@trivago/prettier-plugin-sort-imports":{"@babel/core":"^7.21.8","@babel/parser":"^7.21.8","@babel/traverse":"^7.21.5"},"typescript":"$typescript"},"engines":{"node":">=16.6.0"},"gitHead":"064bd6e36fa1652dd72ff70f5ea2228eb7d08924","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers/dist/functions/Number'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nimport { formatDate } from '@detachhead/ts-helpers/dist/functions/Date'\n\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nimport { exactly } from '@detachhead/ts-helpers/dist/functions/misc'\n\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nimport { Equals } from '@detachhead/ts-helpers/dist/types/misc'\n\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nimport { SafeVariance, ToArrowFunction } from '@detachhead/ts-helpers/dist/types/Function'\n\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\nimport { ToNonArrowFunction, UnsafeVariance } from '@detachhead/ts-helpers/dist/types/Function'\n\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n### casting functions\n\n```ts\nimport { narrow, narrowCast, unsafeNarrow } from '@detachhead/ts-helpers/dist/functions/misc'\n```\n\nthe `as` keyword doesn't always work exactly how you want. the `narrow`, `unsafeNarrow` and `narrowCast` functions can be used to cast variables in different ways\n\n|                         | modifies original variable's type | returns the value with the casted type | intersects original type with casted type | allows non-overlapping types |\n| ----------------------- | --------------------------------- | -------------------------------------- | ----------------------------------------- | ---------------------------- |\n| `as` keyword            |                                   | yes                                    |                                           |                              |\n| `narrow` function       | yes                               |                                        | yes                                       |\n| `unsafeNarrow` function | yes                               |                                        | yes                                       | yes                          |\n| `narrowCast` function   |                                   | yes                                    | yes                                       | yes                          |\n\n## requirements\n\n### typescript\n\nsince this package pushes the limits of the typescript compiler, i often update it to depend on unreleased\nversions of typescript for bug fixes and to ensure that upcoming releases won't break any of my wacky types.\ncurrently it depends on typescript >=5.0. you will probably encounter type errors and/or performance issues trying to\nuse it with older versions.\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@16.1.0-064bd6e36fa1652dd72ff70f5ea2228eb7d08924","_nodeVersion":"19.7.0","_npmVersion":"9.5.0","dist":{"integrity":"sha512-aLIyTT37AuNLIO1eI35vpdP70Y97UF0y++ALS/WDb3+YqOHgpjMCHedtnrM8EX3fYh9XthvEGYxSgeWihkqtTw==","shasum":"90dfab4a2eb56ec8d083e05807ec5f0e5777ef6b","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-16.1.0-064bd6e36fa1652dd72ff70f5ea2228eb7d08924.tgz","fileCount":90,"unpackedSize":333568,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDO5950QW2Lm4e8EXarKyOYdqs8RPa/bojt/6P6he/DNgIhAOpDhweBuRAR7U2d8Pb16/fBCfkI0wEKhje5iFUliUrS"}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_16.1.0-064bd6e36fa1652dd72ff70f5ea2228eb7d08924_1690199547203_0.32223057811632017"},"_hasShrinkwrap":false},"16.1.0-f64e5159dba50b1b14d5e79bcbd36ef96ff3ce67":{"name":"@detachhead/ts-helpers","version":"16.1.0-f64e5159dba50b1b14d5e79bcbd36ef96ff3ce67","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.195","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^1.2.2","@jest/types":"^29.6.1","@trivago/prettier-plugin-sort-imports":"^3.4.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.6","@types/jest":"^29.5.3","@types/node":"^20","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^29.6.1","power-assert":"^1.6.1","prettier":"^2.8.8","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^29.1.1","ts-node":"^10.9.1","typed-nodejs-assert":"^1.1.0","typescript":"^5.2.0-beta"},"//":"https://github.com/trivago/prettier-plugin-sort-imports/issues/204#issuecomment-1431287240","overrides":{"@trivago/prettier-plugin-sort-imports":{"@babel/core":"^7.21.8","@babel/parser":"^7.21.8","@babel/traverse":"^7.21.5"},"typescript":"$typescript"},"engines":{"node":">=16.6.0"},"readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers/dist/functions/Number'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nimport { formatDate } from '@detachhead/ts-helpers/dist/functions/Date'\n\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nimport { exactly } from '@detachhead/ts-helpers/dist/functions/misc'\n\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nimport { Equals } from '@detachhead/ts-helpers/dist/types/misc'\n\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nimport { SafeVariance, ToArrowFunction } from '@detachhead/ts-helpers/dist/types/Function'\n\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\nimport { ToNonArrowFunction, UnsafeVariance } from '@detachhead/ts-helpers/dist/types/Function'\n\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n### casting functions\n\n```ts\nimport { narrow, narrowCast, unsafeNarrow } from '@detachhead/ts-helpers/dist/functions/misc'\n```\n\nthe `as` keyword doesn't always work exactly how you want. the `narrow`, `unsafeNarrow` and `narrowCast` functions can be used to cast variables in different ways\n\n|                         | modifies original variable's type | returns the value with the casted type | intersects original type with casted type | allows non-overlapping types |\n| ----------------------- | --------------------------------- | -------------------------------------- | ----------------------------------------- | ---------------------------- |\n| `as` keyword            |                                   | yes                                    |                                           |                              |\n| `narrow` function       | yes                               |                                        | yes                                       |\n| `unsafeNarrow` function | yes                               |                                        | yes                                       | yes                          |\n| `narrowCast` function   |                                   | yes                                    | yes                                       | yes                          |\n\n## requirements\n\n### typescript\n\nsince this package pushes the limits of the typescript compiler, i often update it to depend on unreleased\nversions of typescript for bug fixes and to ensure that upcoming releases won't break any of my wacky types.\ncurrently it depends on typescript >=5.0. you will probably encounter type errors and/or performance issues trying to\nuse it with older versions.\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","gitHead":"f64e5159dba50b1b14d5e79bcbd36ef96ff3ce67","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@16.1.0-f64e5159dba50b1b14d5e79bcbd36ef96ff3ce67","_nodeVersion":"20.4.0","_npmVersion":"9.7.2","dist":{"integrity":"sha512-dsoMJ4Brgvg8OoLfVUdG4+NcMqQtE5SRUcfOPQd/yM8Fky9rW6fPpqhdjbkfdN9+WRL4t4X5xUZ6QW3R0hYM5A==","shasum":"58a566f4f4756351d396566517c3d663be8e2e4f","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-16.1.0-f64e5159dba50b1b14d5e79bcbd36ef96ff3ce67.tgz","fileCount":90,"unpackedSize":334048,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAnoLzu2d9qWXr4acRkAOD/afEWG1LmrY3AiGpgo06e5AiBGo2rOlpH6B4UOd0R2DhlihAjJgULRzNJbcP5ovEEE5g=="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_16.1.0-f64e5159dba50b1b14d5e79bcbd36ef96ff3ce67_1690200295589_0.846067278059059"},"_hasShrinkwrap":false},"16.1.0-2467287e1c6ba90ad367c35fbdea72696b04d827":{"name":"@detachhead/ts-helpers","version":"16.1.0-2467287e1c6ba90ad367c35fbdea72696b04d827","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.195","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^1.2.2","@jest/types":"^29.6.1","@trivago/prettier-plugin-sort-imports":"^3.4.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.6","@types/jest":"^29.5.3","@types/node":"^20","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^29.6.1","power-assert":"^1.6.1","prettier":"^2.8.8","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^29.1.1","ts-node":"^10.9.1","typed-nodejs-assert":"^1.1.0","typescript":"^5.2.0-beta"},"//":"https://github.com/trivago/prettier-plugin-sort-imports/issues/204#issuecomment-1431287240","overrides":{"@trivago/prettier-plugin-sort-imports":{"@babel/core":"^7.21.8","@babel/parser":"^7.21.8","@babel/traverse":"^7.21.5"},"typescript":"$typescript"},"engines":{"node":">=16.6.0"},"readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers/dist/functions/Number'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nimport { formatDate } from '@detachhead/ts-helpers/dist/functions/Date'\n\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nimport { exactly } from '@detachhead/ts-helpers/dist/functions/misc'\n\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nimport { Equals } from '@detachhead/ts-helpers/dist/types/misc'\n\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nimport { SafeVariance, ToArrowFunction } from '@detachhead/ts-helpers/dist/types/Function'\n\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\nimport { ToNonArrowFunction, UnsafeVariance } from '@detachhead/ts-helpers/dist/types/Function'\n\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n### casting functions\n\n```ts\nimport { narrow, narrowCast, unsafeNarrow } from '@detachhead/ts-helpers/dist/functions/misc'\n```\n\nthe `as` keyword doesn't always work exactly how you want. the `narrow`, `unsafeNarrow` and `narrowCast` functions can be used to cast variables in different ways\n\n|                         | modifies original variable's type | returns the value with the casted type | intersects original type with casted type | allows non-overlapping types |\n| ----------------------- | --------------------------------- | -------------------------------------- | ----------------------------------------- | ---------------------------- |\n| `as` keyword            |                                   | yes                                    |                                           |                              |\n| `narrow` function       | yes                               |                                        | yes                                       |\n| `unsafeNarrow` function | yes                               |                                        | yes                                       | yes                          |\n| `narrowCast` function   |                                   | yes                                    | yes                                       | yes                          |\n\n## requirements\n\n### typescript\n\nsince this package pushes the limits of the typescript compiler, i often update it to depend on unreleased\nversions of typescript for bug fixes and to ensure that upcoming releases won't break any of my wacky types.\ncurrently it depends on typescript >=5.0. you will probably encounter type errors and/or performance issues trying to\nuse it with older versions.\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","gitHead":"2467287e1c6ba90ad367c35fbdea72696b04d827","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@16.1.0-2467287e1c6ba90ad367c35fbdea72696b04d827","_nodeVersion":"20.4.0","_npmVersion":"9.7.2","dist":{"integrity":"sha512-T7TS7Ra3QV3DT/w4ux8rlm626EyvSynAKE9CqE6NLgWDqCguH+LwJvFpW3D/BxDjbFIepTYJJaz+IKmiEKsaUg==","shasum":"284df36297284d89490dfd8bfbfd881ca2ef5124","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-16.1.0-2467287e1c6ba90ad367c35fbdea72696b04d827.tgz","fileCount":90,"unpackedSize":338084,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDRESm2qjKPYfUN4ctp6kAqEcPWF4n7+aqPHJS+Ov5VnwIhAO50OWzudANI1Hdoy0/l+8JmvxP5zzBLOlRnmGmGNB4L"}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_16.1.0-2467287e1c6ba90ad367c35fbdea72696b04d827_1690205602612_0.7227007141878314"},"_hasShrinkwrap":false},"16.1.0-4d936d7f443b76961f9cc384ab5fa4cabe73bf9d":{"name":"@detachhead/ts-helpers","version":"16.1.0-4d936d7f443b76961f9cc384ab5fa4cabe73bf9d","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.195","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^1.2.2","@jest/types":"^29.6.1","@trivago/prettier-plugin-sort-imports":"^3.4.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.6","@types/jest":"^29.5.3","@types/node":"^20","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^29.6.1","power-assert":"^1.6.1","prettier":"^2.8.8","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^29.1.1","ts-node":"^10.9.1","typed-nodejs-assert":"^1.1.0","typescript":"^5.2.0-beta"},"//":"https://github.com/trivago/prettier-plugin-sort-imports/issues/204#issuecomment-1431287240","overrides":{"@trivago/prettier-plugin-sort-imports":{"@babel/core":"^7.21.8","@babel/parser":"^7.21.8","@babel/traverse":"^7.21.5"},"typescript":"$typescript"},"engines":{"node":">=16.6.0"},"readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers/dist/functions/Number'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nimport { formatDate } from '@detachhead/ts-helpers/dist/functions/Date'\n\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nimport { exactly } from '@detachhead/ts-helpers/dist/functions/misc'\n\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nimport { Equals } from '@detachhead/ts-helpers/dist/types/misc'\n\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nimport { SafeVariance, ToArrowFunction } from '@detachhead/ts-helpers/dist/types/Function'\n\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\nimport { ToNonArrowFunction, UnsafeVariance } from '@detachhead/ts-helpers/dist/types/Function'\n\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n### casting functions\n\n```ts\nimport { narrow, narrowCast, unsafeNarrow } from '@detachhead/ts-helpers/dist/functions/misc'\n```\n\nthe `as` keyword doesn't always work exactly how you want. the `narrow`, `unsafeNarrow` and `narrowCast` functions can be used to cast variables in different ways\n\n|                         | modifies original variable's type | returns the value with the casted type | intersects original type with casted type | allows non-overlapping types |\n| ----------------------- | --------------------------------- | -------------------------------------- | ----------------------------------------- | ---------------------------- |\n| `as` keyword            |                                   | yes                                    |                                           |                              |\n| `narrow` function       | yes                               |                                        | yes                                       |\n| `unsafeNarrow` function | yes                               |                                        | yes                                       | yes                          |\n| `narrowCast` function   |                                   | yes                                    | yes                                       | yes                          |\n\n## requirements\n\n### typescript\n\nsince this package pushes the limits of the typescript compiler, i often update it to depend on unreleased\nversions of typescript for bug fixes and to ensure that upcoming releases won't break any of my wacky types.\ncurrently it depends on typescript >=5.0. you will probably encounter type errors and/or performance issues trying to\nuse it with older versions.\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","gitHead":"4d936d7f443b76961f9cc384ab5fa4cabe73bf9d","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@16.1.0-4d936d7f443b76961f9cc384ab5fa4cabe73bf9d","_nodeVersion":"20.4.0","_npmVersion":"9.7.2","dist":{"integrity":"sha512-dbscbCqS5OSLyaCxlHnhi9d67r09f2ZzqyFQBC2tleRvrfVu5dM15SBDo2B2v0Iub63AJilJ6FqCkfelzvpWXA==","shasum":"0abeafcc7ad076c384a563a3fd70e44a556863fa","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-16.1.0-4d936d7f443b76961f9cc384ab5fa4cabe73bf9d.tgz","fileCount":90,"unpackedSize":338232,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQClduu0pl37KEYSe1dUEvxIkl0fjFuYlbT9bPE3A0DvUwIhAI5Q3CF0xNLiK6ZfGWVD+XSHlZ8LM3FVF9By5Rpw7/8R"}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_16.1.0-4d936d7f443b76961f9cc384ab5fa4cabe73bf9d_1690205903934_0.2607223493381787"},"_hasShrinkwrap":false},"16.1.0-8075f1b69fcb8e43f9190d228d110fd30d45f9fc":{"name":"@detachhead/ts-helpers","version":"16.1.0-8075f1b69fcb8e43f9190d228d110fd30d45f9fc","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.195","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^1.2.2","@jest/types":"^29.6.1","@trivago/prettier-plugin-sort-imports":"^3.4.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.6","@types/jest":"^29.5.3","@types/node":"^20","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^29.6.1","power-assert":"^1.6.1","prettier":"^2.8.8","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^29.1.1","ts-node":"^10.9.1","typed-nodejs-assert":"^1.1.0","typescript":"^5.2.2"},"//":"https://github.com/trivago/prettier-plugin-sort-imports/issues/204#issuecomment-1431287240","overrides":{"@trivago/prettier-plugin-sort-imports":{"@babel/core":"^7.21.8","@babel/parser":"^7.21.8","@babel/traverse":"^7.21.5"},"typescript":"$typescript"},"engines":{"node":">=16.6.0"},"readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers/dist/functions/Number'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nimport { formatDate } from '@detachhead/ts-helpers/dist/functions/Date'\n\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nimport { exactly } from '@detachhead/ts-helpers/dist/functions/misc'\n\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nimport { Equals } from '@detachhead/ts-helpers/dist/types/misc'\n\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nimport { SafeVariance, ToArrowFunction } from '@detachhead/ts-helpers/dist/types/Function'\n\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\nimport { ToNonArrowFunction, UnsafeVariance } from '@detachhead/ts-helpers/dist/types/Function'\n\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n### casting functions\n\n```ts\nimport { narrow, narrowCast, unsafeNarrow } from '@detachhead/ts-helpers/dist/functions/misc'\n```\n\nthe `as` keyword doesn't always work exactly how you want. the `narrow`, `unsafeNarrow` and `narrowCast` functions can be used to cast variables in different ways\n\n|                         | modifies original variable's type | returns the value with the casted type | intersects original type with casted type | allows non-overlapping types |\n| ----------------------- | --------------------------------- | -------------------------------------- | ----------------------------------------- | ---------------------------- |\n| `as` keyword            |                                   | yes                                    |                                           |                              |\n| `narrow` function       | yes                               |                                        | yes                                       |\n| `unsafeNarrow` function | yes                               |                                        | yes                                       | yes                          |\n| `narrowCast` function   |                                   | yes                                    | yes                                       | yes                          |\n\n## requirements\n\n### typescript\n\nsince this package pushes the limits of the typescript compiler, i often update it to depend on unreleased\nversions of typescript for bug fixes and to ensure that upcoming releases won't break any of my wacky types.\ncurrently it depends on typescript >=5.0. you will probably encounter type errors and/or performance issues trying to\nuse it with older versions.\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","gitHead":"8075f1b69fcb8e43f9190d228d110fd30d45f9fc","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@16.1.0-8075f1b69fcb8e43f9190d228d110fd30d45f9fc","_nodeVersion":"20.4.0","_npmVersion":"9.7.2","dist":{"integrity":"sha512-1mFJuWlnhakSVtH++z11hGyiyb71XFG/ayM4UVePD/skYahqo0Ctx2IOZ7OGHLut5OX6qRe7uYkKkVkShR/9zw==","shasum":"c214a06637441cf02777cdf96129af2a53eeb78d","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-16.1.0-8075f1b69fcb8e43f9190d228d110fd30d45f9fc.tgz","fileCount":90,"unpackedSize":338263,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBFw9WfYfTr+ELUlwcbE15r8GkpoLtlLbyqZme2zoa0SAiAMN8gsAL9/eLSEU3xjCAYHw6Kxk1w+MpjNzrNcN8pxcg=="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_16.1.0-8075f1b69fcb8e43f9190d228d110fd30d45f9fc_1695113468889_0.6830308511686594"},"_hasShrinkwrap":false},"16.2.0":{"name":"@detachhead/ts-helpers","version":"16.2.0","main":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"test":"jest --detectOpenHandles","lint:check":"eslint .","lint:fix":"npm run lint:check -- --fix","format:check":"prettier --check .","format:fix":"prettier --write .","build":"rimraf ./dist && tsc -p src/tsconfig.json","typecheck:config-files":"tsc -p tsconfig.json","build-and-lib-check":"npm run build && tsc -p tsconfig.lib-check.json","check":"npm run typecheck:config-files && npm run build-and-lib-check && npm run lint:check && npm run format:check && npm run test","bump":"npm version"},"keywords":[],"author":{"name":"detachhead"},"license":"ISC","description":"various typescript helper functions and utility types","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"dependencies":{"@types/lodash":"4.14.195","date-fns":"2.21.1","is-ci":"2.0.0","lodash":"^4.17.21","ordinal":"1.0.3","throw-expression":"1.0.2","ts-is-present":"1.2.1","ts-toolbelt":"9.6.0","tsdef":"0.0.14","utility-types":"3.10.0"},"devDependencies":{"@detachhead/eslint-config":"^1.2.2","@jest/types":"^29.6.1","@trivago/prettier-plugin-sort-imports":"^3.4.0","@types/assert":"^1.5.6","@types/eslint":"^8.4.6","@types/jest":"^29.5.3","@types/node":"^20","@types/power-assert":"^1.5.3","babel-preset-power-assert":"^3.0.0","espower-typescript":"^9.0.2","jest":"^29.6.1","power-assert":"^1.6.1","prettier":"^2.8.8","rimraf":"^3.0.2","source-map-support":"^0.5.19","ts-jest":"^29.1.1","ts-node":"^10.9.1","typed-nodejs-assert":"^1.1.0","typescript":"^5.2.2"},"//":"https://github.com/trivago/prettier-plugin-sort-imports/issues/204#issuecomment-1431287240","overrides":{"@trivago/prettier-plugin-sort-imports":{"@babel/core":"^7.21.8","@babel/parser":"^7.21.8","@babel/traverse":"^7.21.5"},"typescript":"$typescript"},"engines":{"node":">=16.6.0"},"gitHead":"699544543b46f6015b59b9c541be79545de472d3","bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"},"homepage":"https://github.com/DetachHead/ts-helpers#readme","_id":"@detachhead/ts-helpers@16.2.0","_nodeVersion":"20.4.0","_npmVersion":"9.7.2","dist":{"integrity":"sha512-1kwJ1AgXWK9goECjtyRh6SMVf7YYkMt0yvUccxqo7qpDRYs3uDC0ot5MhIbDTbhyoQQio3wTTmA2m5ijdUehdA==","shasum":"b07b5f32ab1bbaf0a58da0d1852af4d3b2533a71","tarball":"https://registry.npmjs.org/@detachhead/ts-helpers/-/ts-helpers-16.2.0.tgz","fileCount":90,"unpackedSize":338222,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAdW3+Y2PshEfM1qSUb6hfKlXHzpfTUx0Mo3BcDVZGjHAiEA8st0nkIkOeT1LGouLVadFim8vO0WAEIk5Al+zICojpE="}]},"_npmUser":{"name":"detachhead","email":"detachhead@gmail.com"},"directories":{},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-helpers_16.2.0_1695114160062_0.6042836411535373"},"_hasShrinkwrap":false}},"time":{"created":"2021-01-12T15:40:58.264Z","1.0.0":"2021-01-12T15:40:58.502Z","modified":"2023-09-19T09:02:40.418Z","1.0.1":"2021-01-12T15:55:45.698Z","1.0.2":"2021-01-12T16:00:55.344Z","1.1.0":"2021-01-12T17:04:14.446Z","2.0.0":"2021-01-24T13:08:10.407Z","2.1.0":"2021-01-24T14:30:01.881Z","2.2.0":"2021-01-25T16:26:35.376Z","3.0.0":"2021-02-13T17:29:43.701Z","3.0.1":"2021-02-13T17:56:02.662Z","3.1.0":"2021-02-16T12:19:11.062Z","3.2.0":"2021-02-25T11:14:59.030Z","3.3.0":"2021-03-03T10:37:39.488Z","3.4.0":"2021-03-05T09:27:37.535Z","4.0.0":"2021-03-08T12:12:43.856Z","5.0.0":"2021-03-23T13:36:23.952Z","6.0.0":"2021-03-28T08:50:19.132Z","6.1.0":"2021-03-28T09:11:14.528Z","6.2.0":"2021-03-29T00:49:37.480Z","6.3.0":"2021-04-06T12:02:57.723Z","6.4.0":"2021-04-19T19:42:15.384Z","7.0.0":"2021-04-24T10:12:51.801Z","7.0.0-test":"2021-04-24T10:40:46.407Z","7.0.1":"2021-04-24T10:49:12.863Z","6.4.0-test":"2021-04-24T11:09:29.187Z","6.4.0-test2":"2021-04-24T11:31:30.773Z","7.0.0-test3":"2021-04-24T11:35:41.139Z","7.0.0-test4":"2021-04-24T11:42:07.260Z","7.0.0-7bf82ae5e8cf9edf82bd05fec5aea7690efe2e50":"2021-04-24T15:35:38.497Z","7.0.0-e96cffe946bc645a061a0504664607b46063374d":"2021-04-24T15:43:49.856Z","7.0.0-56fddd9273c70b028585f63a2ec0e9f01ff9902b":"2021-04-24T15:51:20.846Z","7.0.1-d53cd47ab3e47f4d850a4a4d1808372d8cd5c196":"2021-04-24T16:25:21.966Z","7.0.1-5ad39f676f8d28536316255a3b248b6aff931450":"2021-04-25T12:26:22.408Z","7.0.1-1d3a8f7c897d4d9a22e1e7bf61116504809d8ca1":"2021-04-25T12:36:46.659Z","7.0.1-10cff7ecce9c20dbd7398dd426ad2c39ce4bc866":"2021-04-25T12:40:56.460Z","7.0.1-57f39b191556f9992d5909b36025526588252c61":"2021-04-25T12:55:52.704Z","7.0.0-38be65f531b05ac601780ce711717449e038c856":"2021-04-28T11:39:59.939Z","7.0.0-b3dc70bcb221c7a3a831492da2c7763deeae95bf":"2021-05-31T11:10:04.597Z","7.0.0-e528e8c7edfc4b16e7aaf3f7f00ec2efa03991b6":"2021-06-16T11:59:59.429Z","7.0.0-7340d9ddedf3534eabaee09621780c6d3a71eeff":"2021-07-03T08:47:29.715Z","7.0.0-2a850824a7432eced04a89875f0dd0c5eee8fa0d":"2021-07-03T08:52:41.227Z","7.0.0-d21e889d602ab3ed8bd643999cafeaf1c8d04fd1":"2021-07-03T08:54:01.748Z","7.0.0-f45cfb04909f3065f245703b2f6be57a0a03e802":"2021-07-03T14:20:58.347Z","8.0.0-5c375b6c6397c32ed6134bed531ff51d7e9761f8":"2021-07-27T17:45:16.656Z","8.0.0-76d17fd608922ef08d5fb5f8799d0cf7d227143d":"2021-07-27T17:58:13.499Z","8.0.0":"2021-08-01T00:22:50.599Z","8.0.0-eaf2f20205261f4441d091c2a48987ee10ad8739":"2021-08-02T10:40:10.911Z","8.0.0-3c779a35b80fa320acf35da8d051e77e30d80599":"2021-08-02T11:19:15.081Z","8.0.0-fc6c8b8b5bd674e70d1cb6dec7c0ad6bfa50a820":"2021-08-02T11:23:47.580Z","8.0.0-3c0f47a679dbdd208a68d26246f7726807d687f8":"2021-08-02T17:14:34.494Z","8.0.0-dev":"2021-08-03T08:19:18.373Z","8.0.0-15cceecd6478e5898952bd5aaef82873d20d70cb":"2021-08-03T09:16:11.647Z","8.1.0-91466570db6f80cef9c7d772ea3c879182473daa":"2021-08-03T09:17:35.847Z","8.1.0":"2021-08-03T09:19:30.315Z","8.1.0-e0eb961072454184d60b0860062257e1c8efae76":"2021-08-03T10:03:55.180Z","8.1.0-7ddf86ba80b21b05b2efbc62e236174d149954f1":"2021-08-03T11:01:09.363Z","8.1.0-7746764a4a5ed4a83c1861e73332e69fa1d27df6":"2021-08-03T11:32:29.717Z","8.1.0-dev":"2021-08-03T11:34:45.743Z","8.1.0-0f21095850ed63c2648ef39d07b0ce5c07b84a82":"2021-08-03T11:58:11.422Z","8.1.0-58ced0930338a92a3267df7aeedb7c1c35e71d75":"2021-08-03T12:05:16.160Z","8.1.1":"2021-08-03T12:48:25.689Z","8.1.1-0bac80661d986c3a2799e0895507faafaf6eb896":"2021-08-03T14:17:34.241Z","8.1.2":"2021-08-03T14:48:51.301Z","8.1.2-f7e8288fdce5a2d52e5f11a7c622265077378884":"2021-08-08T14:27:53.139Z","8.1.2-899150a28560b19758de53a7173fad07b351eed1":"2021-08-31T09:49:29.514Z","8.1.2-ea2cc954da9fd7c42347a575743e9b9f1058856e":"2021-09-28T04:31:45.753Z","8.1.2-f554824d42fc6d96d157f8a8f3d4fcd94761a337":"2021-09-29T09:45:52.457Z","8.1.2-ed4eeb021944556e05bec24ff3e8da42032a01ca":"2021-09-29T09:50:04.143Z","8.1.2-3bfe9bf6557cfad21438dc32db5f6df2fd59afe2":"2021-09-29T10:44:14.794Z","8.1.2-aff579af3ede45bda7fac3d0822d8d30a42654ce":"2021-09-30T01:46:26.885Z","8.1.2-8dd5c95cbc509110a48e199f6dbb2c726c256d9a":"2021-09-30T10:34:16.037Z","8.1.2-cb0871e586ffba387be818781f7bbd3150e08cf4":"2021-09-30T10:42:49.433Z","8.1.2-8d67c3a8038d76b7981fd6f6bd6b926c1c1b22c7":"2021-09-30T10:45:46.681Z","8.2.0-f46604613b8263b1e1af8a490c46dfa11b935c37":"2021-09-30T10:48:22.010Z","8.2.0":"2021-09-30T10:51:07.269Z","8.2.0-eb282bb60205e4b29d53b30f347192afd5391056":"2021-10-01T03:04:31.925Z","8.2.0-52d3faa3e233894cdaf00858e287a51c82f3fa3c":"2021-10-04T08:49:34.742Z","8.2.0-11b48ceb3d76a4b6c955ad327b9878ed241f2ba9":"2021-10-04T08:53:50.060Z","8.2.0-59c1b79e4a893815e33d68ab21d1fd5dbaea8337":"2021-10-04T09:08:29.157Z","8.2.0-7196c6856372587dd5c3a7fa47bb2ee06b38ee68":"2021-10-04T13:33:21.635Z","8.2.0-55c37563b1e93119efced6851248a8b9090d2443":"2021-10-04T15:08:30.101Z","8.2.0-6a10da8d339e902596396e52e2fb7f0071b82f16":"2021-10-10T13:40:15.089Z","8.2.0-55c4a8f39c9a92fdc325b20cf52858019b418173":"2021-10-10T15:06:07.530Z","8.2.0-d8ebcd4f9782b60ca9fbd935b711a8ce67e3d7fa":"2021-10-10T22:21:16.476Z","8.2.0-2338189488360f923a401bc06db26626e0b8607e":"2021-10-11T03:55:56.303Z","8.2.0-21a2079c5fa694b9782f33d9fa7b7c3e1880ce49":"2021-10-11T13:39:37.565Z","8.2.0-11609dadca6957eaea883f6c54b52733357731e7":"2021-10-11T13:46:47.336Z","8.2.0-09fe190ff602d48aa3876acbec40bae12b7799fe":"2021-10-11T14:28:04.127Z","8.2.0-146ccc3eac581bc83bb5af99a3bb28a353116144":"2021-10-12T06:09:44.048Z","8.2.0-4f0d52eefc438907e945059f0c3294ede493c034":"2021-10-12T06:12:39.321Z","8.2.0-4eb4d3571408fc46f754ecf3383fb03e6062d235":"2021-10-12T14:46:32.856Z","8.2.0-fde9f2eede1001a9ebcc6f41364296d59872b2ea":"2021-10-12T15:53:33.304Z","9.0.0-9b4a478c3a63affa1f7f29aeabc2e5f76583ddfc":"2021-10-12T16:13:41.269Z","9.0.0-98e7f1fb467ec3c8704a197482b3548cf96e88a6":"2021-10-12T22:44:33.896Z","9.0.0":"2021-10-13T02:28:50.466Z","9.0.0-23ada89220af6ee65456fa5dd9b8ac5ec8b1ae53":"2021-10-13T08:28:57.419Z","9.0.0-fcd3c5481300abf5038f675ae092b8f641f0f52b":"2021-10-13T08:34:02.743Z","9.0.0-8b2927ca0f4c1d3ce92022dd7bfb67ee006f4fe4":"2021-10-14T04:07:06.235Z","9.0.0-0d6735c98d3160c67b13828ef4550d4f8b1f45b0":"2021-10-14T05:41:57.132Z","9.0.0-da1d6326a81a14fb2622e4828de865ce238cf92b":"2021-10-14T15:10:56.257Z","9.0.0-dc727ef00d1e00d86a6c60017465a01073bae7ac":"2021-10-14T15:18:50.818Z","9.0.0-89222eda972350690624dc5f5f8c7c4cfd439c3b":"2021-10-14T15:28:27.667Z","9.0.0-4db5a47c2fc9d64c65b725f2eb3c03b5aefc6475":"2021-10-15T01:02:04.311Z","9.0.0-f94c208201b0881e2e2c08fe501d8acb59bb7301":"2021-10-15T03:34:17.724Z","9.0.0-9602327dec6aee67fa7a22249f518c24ae88878b":"2021-10-15T03:35:36.017Z","9.0.0-c0eb663b032c342b194bdd1cd1e3143a0990e9af":"2021-10-17T03:40:00.968Z","9.0.0-d8f1473bb11f9f3cb6c6b5205038d6d06206e9d6":"2021-10-17T03:53:00.862Z","9.0.0-fd883d6c832fe5906af34e94ec4be8a50d4aa3d1":"2021-10-17T03:56:49.409Z","9.0.0-ad0067ba54b5c7560339216705abfdc86f4f109a":"2021-10-17T04:00:05.331Z","9.0.0-9e5f4c025732d4b26a592f18bf55b0ca27878536":"2021-10-17T14:18:19.137Z","9.0.0-c874b695e8ad2534f4daea0987f07f1c70282503":"2021-10-18T08:10:36.703Z","10.0.0-83d2b0f70ed41ec8273501b3a2c3fb547cda4cea":"2021-10-18T10:52:36.162Z","9.0.0-729f310f5608acf01a487071191509cb32dd555e":"2021-10-18T11:17:56.961Z","10.0.0-9cf68674a0a192c65e4f0d6fafd80caa9285f1eb":"2021-10-18T11:21:30.221Z","10.0.0-9dd54755d2b76651ae644bdbda7204f2191321e7":"2021-10-18T11:31:47.565Z","10.0.0-e439b680a400b0dfc77a9f380c5a1e12695915fb":"2021-10-18T12:12:25.131Z","10.0.0-234db3b4b4bb683d55c13d819f3abb94dd9d6cc3":"2021-10-18T12:21:35.488Z","10.0.0-26175c52de298661f5b33f38025268e2785bd641":"2021-10-18T12:29:55.404Z","10.0.0-9edc3bd098e232a01c5e2a6a107c2890db73aa55":"2021-10-18T14:32:17.556Z","10.0.0":"2021-10-18T14:40:46.310Z","10.0.0-12efa73e3504fdefa1d71a511819ed0e3b1cb6e7":"2021-10-27T02:42:13.567Z","10.0.0-22ac6e836c99bdf344671e401f9d60749c416809":"2021-10-27T03:27:30.464Z","10.0.0-412c64d040327c7f4df7680dd409f1a3fd771e2b":"2021-11-21T06:21:43.113Z","10.0.0-8bf569e50aadc156b87540fc6df9df04163d0788":"2021-11-21T06:38:09.221Z","10.0.0-e1cf04756fcae368b6d993af342822e000008587":"2021-11-21T13:40:30.168Z","10.0.0-d61e00f6a8a82e6395a716a8d41e98a407f27028":"2021-11-22T23:44:48.786Z","10.0.0-fa181fb376601bf0f3e0e16c3446b5661aa0bc43":"2021-11-23T00:30:01.699Z","10.0.0-33601ff5a33f3339b12ee231878af3913f1cf3a5":"2022-01-24T00:57:59.317Z","10.0.0-1fc2d938ad21e56e82ba21e25a8ae821ad9f6424":"2022-01-24T01:48:12.647Z","10.0.0-7a3c319a8e83032f4869d721744829b80c53e10b":"2022-01-28T00:15:55.351Z","10.0.0-9e128422305d65cbd9cf50254ef2d994582ff216":"2022-01-28T01:48:23.136Z","10.0.0-10f63434d1bd72c8d86a912a3595348f5bbf88f4":"2022-01-28T04:59:29.609Z","10.0.0-51ed9a74b1a0098157ac9ad7f898d4191cafbb92":"2022-01-28T06:57:31.618Z","10.0.0-f1b2c9d4466923613fcb7215b058064f25b79905":"2022-01-28T08:03:20.845Z","10.0.0-43f7d8067c85d9939d4cb88d688f4cbbb06c9ad8":"2022-02-01T07:53:17.844Z","10.0.0-7f5767d7af52e84e3f78f34b4e3339fd1b666982":"2022-02-01T11:45:16.759Z","10.0.0-aa3e476b4e3a6ec1696942d0c4419c8881344531":"2022-02-02T03:59:05.745Z","10.0.0-16153cb1c8f6d906b3fd3b2d4a834e25a8ec2053":"2022-02-02T04:34:37.544Z","10.0.0-bda05592857ac5f431028aa0b172028a954eb5ab":"2022-02-02T08:05:27.663Z","10.0.0-a2b9a4fee69be4a45ba0d5b5023eebabe784ee9a":"2022-04-09T11:30:45.513Z","10.0.0-fd264d0567c6c054705a87077e0973c0f504596c":"2022-04-09T14:41:14.703Z","10.0.0-c22d30e85e9716d9d89a0e9dac2dd96258bcbb28":"2022-04-09T15:07:23.013Z","10.0.0-013c49e4557b9ed83fec311ee209fcae92016cb0":"2022-04-09T15:41:48.187Z","10.0.0-7c4c0d416966411080f54f86f316b0de4c6d6409":"2022-04-09T15:50:00.507Z","11.0.0":"2022-04-19T06:05:57.758Z","11.0.0-8fc0e2f92e5d812b9da8773d0cd3fe0aac78da92":"2022-04-19T06:06:19.406Z","11.0.0-08a8238f722ea4639b7e0ce62cd6ab62047823c5":"2022-04-19T11:40:44.023Z","11.1.0-a04614eccede7c863a4c5eeeaf845d2849a446c2":"2022-04-19T11:46:30.792Z","11.1.0":"2022-04-19T11:49:15.670Z","11.1.0-349780eb8075f51c0662e5c9671338772df4cebc":"2022-06-24T01:49:52.559Z","11.1.0-76d21e9573fed569d76bed953b7d13b810e23d0f":"2022-06-25T13:47:20.007Z","11.1.0-6d1cd4d0bbf9ce3ce5013a29d615ff9ebca9baf6":"2022-06-25T15:17:18.588Z","11.2.0-55ee8574cdae688cdf615e73d40b232332b76cd9":"2022-06-25T15:32:47.583Z","11.2.0":"2022-06-25T15:38:52.473Z","11.2.0-998e54e1591c6b1436b433ad596791eab9a98ca8":"2022-07-16T08:01:00.505Z","11.2.0-b13c5a915aed60b127bcb3051d5a592810a7ca7c":"2022-07-16T08:08:33.357Z","11.2.0-bf142628b69f9107169a5b307fc7910281209636":"2022-07-21T09:59:28.450Z","11.2.0-8c7bf2285afb89daaa272d0bd6dd2a18c35b156d":"2022-07-21T10:31:08.337Z","11.2.0-1990231fdda53fedb9f5fa9af39550b6a9215249":"2022-07-23T10:28:30.068Z","11.2.0-2d6aa49a198ad82bbb89c7f622eecc5c928ff305":"2022-07-23T12:23:28.811Z","11.2.0-af91a69fa0f8e70750deb5b87714ef8659869aa7":"2022-07-23T12:43:13.601Z","11.2.0-75a96db8abf9a19e9b1edabafbdbb28611137b10":"2022-07-23T13:04:02.640Z","11.2.0-90ac5e7a256c9212870a9e2c95b938871556d84b":"2022-07-24T12:21:04.405Z","11.2.0-1059c400260abfe58b651a0922ebcb50c5cb3812":"2022-07-24T12:38:15.531Z","12.0.0-6680ab03742414b74c7322db49ecc94061ef7bec":"2022-07-24T12:46:26.358Z","12.0.0":"2022-07-24T12:48:12.577Z","12.0.0-9d12d6f8920566ac4d9481d15d1dbc9669d39b90":"2022-07-25T11:36:17.148Z","12.0.0-3f5b78f95224c63e37310e7eb736fcb94af8cc39":"2022-08-19T05:04:25.249Z","12.1.0-ce8821800ef9863bb2a7616a35df870866aee880":"2022-09-05T01:53:44.501Z","12.1.0":"2022-09-05T01:59:41.133Z","12.1.0-e3ed006927b98f306d52e363fc2e06c9720a9caa":"2022-09-05T02:54:36.504Z","12.1.1-981d780df2ee0046595feab23007403afe38b258":"2022-09-05T02:56:37.086Z","12.1.1":"2022-09-05T03:03:28.185Z","12.1.1-8e0cdeffc5156f6718119c52ae5224ed36822562":"2022-09-12T09:59:45.423Z","12.1.1-86512c3d5a4b1511f5c4304f1b9c75593c822322":"2022-09-13T06:52:27.305Z","12.2.0":"2022-09-13T07:11:53.261Z","12.2.0-21e7f082b424b3599de6886dd19c33174bd85428":"2022-09-27T23:43:21.489Z","12.2.0-e8fe993df2b38c52e45274bb557114ab01b6542e":"2022-10-21T03:40:37.982Z","12.2.0-4a6d093441dbc3826c84b3aca3d4e72f0975b09e":"2022-10-21T04:13:42.894Z","12.2.0-48682ec3fad0800019a639c63ae75af701b1bc38":"2022-10-26T14:11:44.660Z","12.2.0-d20a203a26f67ced14848cb153645f3ae7962aef":"2022-10-26T14:17:14.497Z","12.2.0-4212bc7ec14e1f105031a3c94479089faa7f61c5":"2022-10-26T14:55:44.197Z","12.2.0-1747a9f032c3e299fc5c3d7ebdd6487476583b3f":"2022-11-03T05:49:27.710Z","12.2.0-ea9c0219597acfd5a80422f61a24d3b42e0a6014":"2022-11-03T05:56:46.361Z","12.2.0-ec487ad211b6d8fbea808d084b6b24544d029556":"2022-11-07T11:23:53.774Z","12.2.0-1dd1f4d2be163501e6227de74cfe229bd71a4a84":"2022-11-24T06:21:58.014Z","12.2.0-28289c8f5170256e66f123969dfef56bca801524":"2022-11-25T03:23:26.811Z","12.2.0-be99caa70295068607721d47c2105b82f60f6884":"2022-11-25T06:33:51.384Z","12.2.0-b4a523694792629511bbe65c79fd32cc34509d3d":"2022-11-28T01:18:48.235Z","12.2.0-a95db206e7b5c12f4cd2bee94b2dddad507bd9c8":"2022-11-28T01:38:54.354Z","13.0.0-f14ce0168502d49286dbaa912f815e774437029f":"2022-11-28T01:49:26.387Z","13.0.0":"2022-11-28T01:49:51.838Z","13.0.0-4ad7dd974bb075ce5a66a4bc3fd405afdd5e2c66":"2022-11-30T01:43:41.247Z","13.0.0-3f293e59df7c8d66918cb395399e1b0108f58a8e":"2022-12-03T12:24:28.013Z","13.0.0-959e88790c72c030c8be73187e427917347a2f5d":"2022-12-07T01:55:57.061Z","13.0.0-4819829d0de6aeaf7d6d616aa823858eb78483f4":"2022-12-07T02:11:36.843Z","13.0.0-41b0a938ca58fef10262a2e0c5fa9aa39178444c":"2022-12-07T04:35:19.313Z","13.0.0-ef4535e573233fef972d2ee49dd08af407471121":"2022-12-20T13:55:02.505Z","13.0.0-b361e7f32fadd302ebee585d366ee26593390ba9":"2022-12-21T13:26:53.193Z","13.0.0-65aab520825a846cf9ba865e9f0916c260b670c1":"2022-12-22T00:20:54.926Z","13.0.0-26cf6b031ff2fca993cdd1a7c33827660a271e53":"2022-12-22T03:07:17.204Z","13.0.0-f2dcf0f663d58cc56bc62a910d394c99188524ef":"2022-12-23T02:40:34.773Z","13.0.0-6121075e1f328afd52ccd0a8c6851870705f41e2":"2023-01-04T05:59:27.627Z","13.0.0-ba2935db54da4d8424b204e25f0dd63e2ff2b7ba":"2023-01-04T06:46:48.445Z","14.0.0":"2023-01-04T07:26:43.050Z","14.0.0-32e4e15c96e9a0c41fd01325262f79767e4e9ea5":"2023-02-23T08:16:41.584Z","14.0.0-d7c13353712f110870d105299eb04f444e9b0e34":"2023-02-24T01:32:14.370Z","14.0.0-32b3d6dc37bee793c99585218b18762a2f20ff7a":"2023-02-28T06:05:40.831Z","14.0.0-0b9ecb7a6f11ace7df212deb84eae3bbd93884e3":"2023-02-28T06:21:30.470Z","15.0.0":"2023-02-28T06:41:06.834Z","15.0.0-1300b17d0b7335eea6869a247427a45d246a03a6":"2023-03-02T00:57:12.657Z","15.0.0-a9929cb12aff2f07b33df3fcda975ce0d67b9523":"2023-03-02T01:27:14.981Z","15.0.0-1f5417804ae8f007d0367fc24930921619702db4":"2023-03-08T16:08:43.693Z","15.0.0-17b9c57658029a3ffb7e1ede97521cae1d7dcd2f":"2023-03-14T01:04:43.222Z","15.0.0-74de36b3eecec33aaecc20f62500b755e244ab81":"2023-03-14T01:39:00.880Z","15.0.0-6eb381e6752111ba8c5610df867915bbecd7880f":"2023-03-14T03:48:14.344Z","15.1.0":"2023-03-14T04:32:11.652Z","15.1.0-66fa4164ac9dcc122a8a4c7385fbb19727a139d0":"2023-03-16T03:44:38.013Z","15.1.0-214b3ecd8ab4a743329b51b475171060ef0fca87":"2023-03-17T04:58:03.675Z","15.1.0-1861d65fb22a1bc4823563aa11e668bd432904fe":"2023-03-17T06:35:04.232Z","15.1.0-9fa07de4ff4f3a081cb75e6a8182b09eb3f45f35":"2023-03-21T00:27:58.409Z","16.0.0":"2023-03-21T00:34:16.893Z","16.0.0-6a77cd5f68c3f2cb170e27bd507abeaebcd2efc4":"2023-04-14T00:34:19.227Z","16.0.0-b71e5328fd77260ad5671c5a71565b160e2051d5":"2023-04-14T00:41:08.696Z","16.1.0":"2023-04-14T01:31:06.147Z","16.1.0-7e1af721833092e45eaf391a44e7b11f2c0d0d49":"2023-05-14T13:20:49.279Z","16.1.0-73a21f951742d13a89071ee41853fa17e5089e8a":"2023-07-20T12:22:53.734Z","16.1.0-7bb5b906b0173c4daf00be8c87bff69239bfb497":"2023-07-23T08:33:36.301Z","16.1.0-064bd6e36fa1652dd72ff70f5ea2228eb7d08924":"2023-07-24T11:52:27.380Z","16.1.0-f64e5159dba50b1b14d5e79bcbd36ef96ff3ce67":"2023-07-24T12:04:55.762Z","16.1.0-2467287e1c6ba90ad367c35fbdea72696b04d827":"2023-07-24T13:33:22.788Z","16.1.0-4d936d7f443b76961f9cc384ab5fa4cabe73bf9d":"2023-07-24T13:38:24.163Z","16.1.0-8075f1b69fcb8e43f9190d228d110fd30d45f9fc":"2023-09-19T08:51:09.092Z","16.2.0":"2023-09-19T09:02:40.253Z"},"maintainers":[{"name":"detachhead","email":"detachhead@gmail.com"}],"description":"various typescript helper functions and utility types","keywords":[],"author":{"name":"detachhead"},"license":"ISC","readme":"# ts-helpers\n\nvarious typescript helper functions and utility types\n\n[![npm](https://img.shields.io/npm/v/@detachhead/ts-helpers)](https://npmjs.org/@detachhead/ts-helpers)\n\n## features\n\n### value tracking\n\nthis library includes many helper types and functions such as `add`, `subtract`, and `substring` which allow the values\nto be known at compile time\n\n![asdf](./readme%20pics/functions.gif)\n\n### `noUncheckedIndexedAccess` support\n\nthe `noUncheckedIndexedAccess` compiler flag is epic, but there's room for improvement. for example, the following\nissue:\n\n```ts\nif (foo.length > 2) {\n    const bar: string = foo[1] //error: string | undefined not assignable to string\n}\n```\n\ncan be solved with `lengthGreaterThan`\n\n```ts\nimport { lengthGreaterThan } from '@detachhead/ts-helpers/dist/functions/Number'\n\nif (lengthGreaterThan(foo, 2)) {\n    const bar: string = foo[1] //no error, foo is casted to [string, string]\n}\n```\n\nthere's also `lengthLessThan`, `lengthGreaterOrEqual`, etc.\n\nmost of the array functions in this library keep track of the length, mostly thanks\nto [this `TupleOf` utility type](https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787)\n\n### date formatter type\n\nthis library contains a helper type and function for formatting dates using\nthe [`date-fns`](https://date-fns.org/v2.21.1/docs/format) format.\n\n```ts\nimport { formatDate } from '@detachhead/ts-helpers/dist/functions/Date'\n\nconst date = formatDate(new Date(), 'dd-MM-yyyy')\n\nassert(date === '01/01/2021') //compile error, wrong date format\n```\n\nyou can use any date format that `date-fns` accepts, and the `FormatDate` utility type will generate a template literal\ntype to match your desired date format.\n\n### Type Testing\n\nWith the `exactly` function you can test if types or values are an exact match to a type\n\n```ts\nimport { exactly } from '@detachhead/ts-helpers/dist/functions/misc'\n\nconst a: 1 | 2 = 1\n//values (also does a runtime assertion on the values)\nexactly(1 as number, a) // error as `1 | 2` is not an exact match of `number`\nexactly(1 as number, a as number) // no error\nexactly(1 as 1 | 2, a) // no error\n\n// mixed\nexactly<number>()(a) // error as `1 | 2` is not an exact match of `number`\nexactly<number>()(a as number) // no error\nexactly<1 | 2>()(a) // no error\n\n// types\ntype Foo = 1 | 2\nexactly<1, Foo>() // error as `1 | 2` is not an exact match of `1`\nexactly<1 | 2, Foo>() // no error\n```\n\nThe `Equals` type allows you to check if two types are equal at the type level\n\n```ts\nimport { Equals } from '@detachhead/ts-helpers/dist/types/misc'\n\ntype Foo = Equals<number, 1 | 2> // false\ntype Bar = Equals<any, 10> // false\ntype Baz = Equals<unknown, never> // false\n```\n\n### variance modifier types\n\nwhen using the old method syntax, typescript does not check the variance on assignment:\n\n```ts\ndeclare class A<T> {\n    set(value: T): void\n    get(): T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a\n\nb.set('')\na.get() // typescript thinks this is a number but it's actually a string\n```\n\nfor more information about how variance works, see [this PR](https://github.com/microsoft/TypeScript/pull/18654). the TL;DR is basically that arrow functions are checked more strictly than the old method syntax (for backwards compatibility reasons). this means you should be using arrow functions where possible.\n\n```ts\ndeclare class A<T> {\n    set: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: A<unknown> = a // error: Type 'A<number>' is not assignable to type 'A<unknown>'\n```\n\nunfortunately however, arrow functions can't always be used. sometimes you need to use methods instead if, for example, you need to access `super` from a subclass:\n\n```ts\nclass B extends A<number> {\n    get = () => super.get() // runtime error, arrow functions can't access super\n}\n```\n\nthis is where variance modifiers come in\n\n#### `SafeVariance` / `ToArrowFunction`\n\nyou can use `SafeVariance<A>` to enable strict variance checking on a class that has methods in it. or if for whatever reason you need to convert an individual function type to an arrow function type, you can use `ToArrowFunction<A['get']>`\n\n```ts\nimport { SafeVariance, ToArrowFunction } from '@detachhead/ts-helpers/dist/types/Function'\n\nclass B<T> extends A<T> {\n    override get() {\n        return super.get()\n    }\n}\n\nconst a = new B<number>()\n\nconst b: SafeVariance<A<unknown>> = a // error\n```\n\n#### `UnsafeVariance` / `ToNonArrowFunction`\n\nvariance is only an issue when you're dealing with classes that have mutable state. if your type is immutable, you may want to disable variance checking without having to convert your shiny new arrow functions into cringe old methods.\n\nto do this, simply use `UnsafeVariance<A>` on your class, or `ToNonArrowFunction<A['set']>` to convert a function type:\n\n```ts\nimport { ToNonArrowFunction, UnsafeVariance } from '@detachhead/ts-helpers/dist/types/Function'\n\ndeclare class A<T> {\n    doSomethingElseThatTotallyDoesntChangeTheValue: (value: T) => void\n    get: () => T\n}\n\nconst a = new A<number>()\n\nconst b: UnsafeVariance<A<unknown>> = a // no error\n```\n\n#### drawbacks\n\n-   these modifier types can currently only be used at the use site, meaning you have to remember to use them on all usages of your types. see these issues:\n    -   [functions](https://github.com/DetachHead/ts-helpers/issues/162)\n    -   [classes](https://github.com/DetachHead/ts-helpers/issues/184)\n-   probably doesn't work properly with more complicated types. if you encounter anything like that, [raise an issue](https://github.com/DetachHead/ts-helpers/issues/new/choose)\n-   [private methods don't work properly with `UnsafeVariance`](https://github.com/DetachHead/ts-helpers/issues/160)\n\nit goes without saying that these modifiers _do not_ change the runtime behavior of a function. an arrow function is still an arrow function regardless of whether you use the `ToNonArrowFunction` type on it.\n\n### casting functions\n\n```ts\nimport { narrow, narrowCast, unsafeNarrow } from '@detachhead/ts-helpers/dist/functions/misc'\n```\n\nthe `as` keyword doesn't always work exactly how you want. the `narrow`, `unsafeNarrow` and `narrowCast` functions can be used to cast variables in different ways\n\n|                         | modifies original variable's type | returns the value with the casted type | intersects original type with casted type | allows non-overlapping types |\n| ----------------------- | --------------------------------- | -------------------------------------- | ----------------------------------------- | ---------------------------- |\n| `as` keyword            |                                   | yes                                    |                                           |                              |\n| `narrow` function       | yes                               |                                        | yes                                       |\n| `unsafeNarrow` function | yes                               |                                        | yes                                       | yes                          |\n| `narrowCast` function   |                                   | yes                                    | yes                                       | yes                          |\n\n## requirements\n\n### typescript\n\nsince this package pushes the limits of the typescript compiler, i often update it to depend on unreleased\nversions of typescript for bug fixes and to ensure that upcoming releases won't break any of my wacky types.\ncurrently it depends on typescript >=5.0. you will probably encounter type errors and/or performance issues trying to\nuse it with older versions.\n\n### runtime\n\nas long as it supports es2021 you should be good. tested on:\n\n-   nodejs >=15\n-   browsers (chrome >=85)\n-   deno (using esm.sh - eg. `import { exactly } from 'http://esm.sh/@detachhead/ts-helpers/dist/utilityFunctions/misc'`)\n","readmeFilename":"readme.md","homepage":"https://github.com/DetachHead/ts-helpers#readme","repository":{"type":"git","url":"git+https://github.com/DetachHead/ts-helpers.git"},"bugs":{"url":"https://github.com/DetachHead/ts-helpers/issues"}}