{"_id":"handy-types","_rev":"9-bb438f8ea1701812cc3c09a190e17b36","name":"handy-types","dist-tags":{"latest":"2.1.0"},"versions":{"1.0.0":{"name":"handy-types","version":"1.0.0","description":"A collection of small utility functions to check valiable types","keywords":["types","validator","type-checker","type alias"],"author":{"name":"Sifat Hossain","email":"hsifat@protonmail.com"},"repository":{"type":"git","url":"git+https://github.com/h-sifat/handy-types.git"},"bugs":{"url":"https://github.com/h-sifat/handy-types/issues"},"homepage":"https://github.com/h-sifat/handy-types#readme","license":"MIT","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"testCov":"jest --coverage","prepublishOnly":"tsc","prepack":"tsc","test":"jest --watch"},"devDependencies":{"@types/jest":"^27.0.2","jest":"^27.2.5","ts-jest":"^27.0.5","typescript":"^4.4.3"},"gitHead":"e6bfdf3dbd444d3510bffd4c13fcad27a03b1865","_id":"handy-types@1.0.0","_nodeVersion":"14.17.1","_npmVersion":"7.23.0","dist":{"integrity":"sha512-7uXNs5M6k5rtzX55hVFaDQEEW9s324dm4Lws43vpMA6GGVB0n+rk3bdzxwnknZBNqn0oYAgdTOjcqE5LEvGkeQ==","shasum":"1959b6d706fb9ca60a966dc71dcb372e4054dc32","tarball":"https://registry.npmjs.org/handy-types/-/handy-types-1.0.0.tgz","fileCount":5,"unpackedSize":12849,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDSzL14bB1sg/CM+6t3kn1Ai6LmrKhfyuPuSuaJaZDaRAiEAhdjj4AIX0qssqmJyCZSFICaAeG7E7FR737vJMP76cuk="}]},"_npmUser":{"name":"h_sifat","email":"hsifat@protonmail.com"},"directories":{},"maintainers":[{"name":"h_sifat","email":"hsifat@protonmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/handy-types_1.0.0_1633718157824_0.7663676962337855"},"_hasShrinkwrap":false},"1.0.1":{"name":"handy-types","version":"1.0.1","description":"A collection of small utility functions to check variable types","keywords":["types","validator","type-checker","type alias"],"author":{"name":"Sifat Hossain","email":"hsifat@protonmail.com"},"repository":{"type":"git","url":"git+https://github.com/h-sifat/handy-types.git"},"bugs":{"url":"https://github.com/h-sifat/handy-types/issues"},"homepage":"https://github.com/h-sifat/handy-types#readme","license":"MIT","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"testCov":"jest --coverage","prepublishOnly":"tsc","prepack":"tsc","test":"jest --watch"},"devDependencies":{"@types/jest":"^27.0.2","jest":"^27.2.5","ts-jest":"^27.0.5","typescript":"^4.4.3"},"gitHead":"ff2290f728509d96ea98c9f9c1c9366069f4271e","_id":"handy-types@1.0.1","_nodeVersion":"14.17.1","_npmVersion":"7.23.0","dist":{"integrity":"sha512-aRmD3PFn79OWzAko/fiZhHLUoXNFeplOqPnJ+N9+6ja9XYB5kvCpqKaHOE5KKaxa0m8odedTDRFQj6KKIlZeSw==","shasum":"bedfa6980de14637ecb67723a8321f5bfd5f712c","tarball":"https://registry.npmjs.org/handy-types/-/handy-types-1.0.1.tgz","fileCount":5,"unpackedSize":12849,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIA8kkX+72lkVnzDLEhISGFkIoCdseoIMDw4T168JjIRQAiEAxkGwrRJrfk8B/dZDU9q8Xt6Y99GqMx8Rx+9GsJS4Epw="}]},"_npmUser":{"name":"h_sifat","email":"hsifat@protonmail.com"},"directories":{},"maintainers":[{"name":"h_sifat","email":"hsifat@protonmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/handy-types_1.0.1_1633719382003_0.44454466669700454"},"_hasShrinkwrap":false},"1.1.0":{"name":"handy-types","version":"1.1.0","description":"A collection of small utility functions to check variable types","keywords":["types","validator","type-checker","type alias"],"author":{"name":"Sifat Hossain","email":"hsifat@protonmail.com"},"repository":{"type":"git","url":"git+https://github.com/h-sifat/handy-types.git"},"bugs":{"url":"https://github.com/h-sifat/handy-types/issues"},"homepage":"https://github.com/h-sifat/handy-types#readme","license":"MIT","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"testCov":"jest --coverage","prepublishOnly":"tsc","prepack":"tsc","test":"jest --watch"},"devDependencies":{"@types/jest":"^27.0.2","jest":"^27.2.5","ts-jest":"^27.0.5","typescript":"^4.4.3"},"gitHead":"ef8f1524226d31f65a43e8888a026fd2ee270c8f","_id":"handy-types@1.1.0","_nodeVersion":"14.17.1","_npmVersion":"7.23.0","dist":{"integrity":"sha512-cMEDLxeNgA0wOxYXkpdi7XYeRhNUVyZS6ytp6scSQv9BB3TlcUIgH8Outp08pNs9ogfq3PhyrNDXnp0UTYaCng==","shasum":"b2559f3fc066635376484ac090daa74fbb073615","tarball":"https://registry.npmjs.org/handy-types/-/handy-types-1.1.0.tgz","fileCount":5,"unpackedSize":14455,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFN/tEuWXmRkup50zLsdUAW11kLHW+o7iO7BSFlFoVM0AiEA7jYhdsoQT+1ckzl7zvL1SI/UFyD3PAfYWQP6RkS/3nA="}]},"_npmUser":{"name":"h_sifat","email":"hsifat@protonmail.com"},"directories":{},"maintainers":[{"name":"h_sifat","email":"hsifat@protonmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/handy-types_1.1.0_1633969462489_0.7999417336631576"},"_hasShrinkwrap":false},"1.2.0":{"name":"handy-types","version":"1.2.0","description":"A collection of small utility functions to check variable types","keywords":["types","validator","type-checker","type alias"],"author":{"name":"Sifat Hossain","email":"hsifat@protonmail.com"},"repository":{"type":"git","url":"git+https://github.com/h-sifat/handy-types.git"},"bugs":{"url":"https://github.com/h-sifat/handy-types/issues"},"homepage":"https://github.com/h-sifat/handy-types#readme","license":"MIT","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"test:coverage":"jest --coverage","prepublishOnly":"npm test && tsc","prepack":"tsc","test":"jest","test:watch":"jest --watch"},"devDependencies":{"@types/jest":"^27.0.2","jest":"^27.2.5","ts-jest":"^27.0.5","typescript":"^4.4.3"},"gitHead":"144ba760824f569b753d87a2fc5868818afd0666","_id":"handy-types@1.2.0","_nodeVersion":"14.17.1","_npmVersion":"8.1.1","dist":{"integrity":"sha512-VBqmxui2jtdUjbs+RHd22qN80k5ROTYSt3U9aaZW0ASc2ergBlCR3Mg0PgGZ4FpzPZGmH+8PBfVnDBBhruUZUA==","shasum":"d4e7a27dd8ee013f093856baa5c8feff010b3356","tarball":"https://registry.npmjs.org/handy-types/-/handy-types-1.2.0.tgz","fileCount":5,"unpackedSize":15094,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICJIEVE/NCbuMNPQhClITlRWr6OSArAVT/jfnwKVF1cQAiEAwJhgHHQZRn2ZoOKn9wUeFCllTRKMfIorfzJBfICHJDs="}]},"_npmUser":{"name":"h_sifat","email":"hsifat@protonmail.com"},"directories":{},"maintainers":[{"name":"h_sifat","email":"hsifat@protonmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/handy-types_1.2.0_1635563416417_0.02385811926743986"},"_hasShrinkwrap":false},"1.3.0":{"name":"handy-types","version":"1.3.0","description":"A collection of small utility functions to check variable types","keywords":["types","validator","type-checker","type alias"],"author":{"name":"Sifat Hossain","email":"hsifat@protonmail.com"},"repository":{"type":"git","url":"git+https://github.com/h-sifat/handy-types.git"},"bugs":{"url":"https://github.com/h-sifat/handy-types/issues"},"homepage":"https://github.com/h-sifat/handy-types#readme","license":"MIT","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"test:coverage":"jest --coverage","prepublishOnly":"npm test && tsc","prepack":"tsc","test":"jest","test:watch":"jest --watch"},"devDependencies":{"@types/jest":"^27.0.2","jest":"^27.2.5","ts-jest":"^27.0.5","typescript":"^4.4.3"},"gitHead":"49e492ad8ac88f748a1b8f56ee0a7e747ea2a8e3","_id":"handy-types@1.3.0","_nodeVersion":"14.17.1","_npmVersion":"8.1.1","dist":{"integrity":"sha512-apOjND8iZzKXXaUkLsDj6VlQdOqH2SnOvBc0QEyrZjFVtUxPO4fmZIzdsVCxCAEthZWRqEBcdhYhAmnRBQl96w==","shasum":"f030b209e2d4f3aa6188e354591d1e5cc72771de","tarball":"https://registry.npmjs.org/handy-types/-/handy-types-1.3.0.tgz","fileCount":5,"unpackedSize":15298,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCUN7/ZqWNC7YOgMOJQFeWmw9sC0Q9jMhVsM+9yahQ70wIhAMjBj72rePHECcMpV8G6kVhtCY86u1NwOjwCJGqOARLu"}]},"_npmUser":{"name":"h_sifat","email":"hsifat@protonmail.com"},"directories":{},"maintainers":[{"name":"h_sifat","email":"hsifat@protonmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/handy-types_1.3.0_1636382621151_0.4730463739958115"},"_hasShrinkwrap":false},"1.4.0":{"name":"handy-types","version":"1.4.0","description":"A collection of small utility functions to check variable types","keywords":["types","validator","type-checker","type alias"],"author":{"name":"Sifat Hossain","email":"hsifat@protonmail.com"},"repository":{"type":"git","url":"git+https://github.com/h-sifat/handy-types.git"},"bugs":{"url":"https://github.com/h-sifat/handy-types/issues"},"homepage":"https://github.com/h-sifat/handy-types#readme","license":"MIT","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"test:coverage":"jest --coverage","prepublishOnly":"npm test && tsc","prepack":"tsc","test":"jest","test:watch":"jest --watch"},"devDependencies":{"@types/jest":"^27.0.2","jest":"^27.2.5","ts-jest":"^27.0.5","typescript":"^4.4.3"},"gitHead":"37728249d27a450800a90359d13a5ddf14e52429","_id":"handy-types@1.4.0","_nodeVersion":"14.17.1","_npmVersion":"8.1.1","dist":{"integrity":"sha512-gdMu8ZceLRALZb0Gtl1JY0T2vhKSIs/VW1/56C4IsLJkQi9SKvxPqQ08QU2qcD5zl4B3f6a8UCIZwJ9CYbLlUg==","shasum":"d339029562af5c3923da1754abfed8d8ac47ec8c","tarball":"https://registry.npmjs.org/handy-types/-/handy-types-1.4.0.tgz","fileCount":5,"unpackedSize":17344,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh2tAcCRA9TVsSAnZWagAAZtoP/RglVfqAsnxcORcWCH71\nkZ///NYVhgDx/bMMQtvXXVs99u4PoaxaKksCRVIuJRmtJhQRGS0/Ft+504Gn\nl5WbOhVg6j5gQtnmat1MkIL0M5GPZg/b9VS3gwffUvfimozAQfljhgAR5Y7b\ny1aTiy2tRNN1Wy0L8bFgBaMbhNPhK/YEe8XDVC+2zISPVE4Jq9JgCbsCVg/A\n84SHgxjtQKUPm8D9wbI8N+iMFlwFBY8T599u9mxgylTSHu912S8dtwH+7UI7\nI25pKZo57Lpbd8KeHSB0suDwo93bBSExi5BnD8agSuzVATMLi2Qwhtwmwlpu\nNCevr2EyIfcw5+H6N0yLZN/NZhefPIocs4sQuQXpsJLiaLTl1OlgkD6CKWrf\nQkh9kAoJzSaEvrO5X3TMl22BmsAqkP9XPLLquh1zJ6XV1/B2Fem8DSUwjdEx\ncJCyFVIYFs0ce/y7X+R00zZlrTn5QSVmF2zoNUzWBU3ngiSpRjJLXlnEebMD\n23SV7lMNtxW2L2luuJPHFQFoQ1fctEbdQ0SMpr6pl1RBHgpM5EIxt+thqF1n\n7IB3bgq4bGUpuel0hJQHEg3UHRkglpgxg7EobRM2C6KsS9GpwPAxwm2cpu/I\nu2CvSn1cop6Eak3fTOsORh7B0WWJU/nnaQ17M92voMd69xPAnxqQXtOrrjOv\nsI1m\r\n=3FGA\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCo7Mk247fc9pwsSDdyBmMjVeSunWUtog5KncO0Ma2PlQIhANrGS7VBEPTzmkhIuFCM8FEwX+cRb/3YNDImrRb6TjXZ"}]},"_npmUser":{"name":"h_sifat","email":"hsifat@protonmail.com"},"directories":{},"maintainers":[{"name":"h_sifat","email":"hsifat@protonmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/handy-types_1.4.0_1636614173896_0.5018744030173001"},"_hasShrinkwrap":false},"2.0.0":{"name":"handy-types","version":"2.0.0","description":"A collection of small utility functions to check variable types","keywords":["types","validator","type-checker","type alias"],"author":{"name":"Sifat Hossain","email":"hsifat@protonmail.com"},"repository":{"type":"git","url":"git+https://github.com/h-sifat/handy-types.git"},"bugs":{"url":"https://github.com/h-sifat/handy-types/issues"},"homepage":"https://github.com/h-sifat/handy-types#readme","license":"MIT","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"test":"jest","test:watch":"jest --watch","test:coverage":"jest --coverage","build":"webpack","prebuild":"npm test","prepublishOnly":"npm run build"},"devDependencies":{"@types/jest":"^27.5.2","jest":"^27.2.5","ts-jest":"^27.0.5","ts-loader":"^9.3.1","typescript":"^4.4.3","webpack":"^5.74.0","webpack-cli":"^4.10.0"},"gitHead":"300c23d25d05bdb7d96fb5c550513ae834359a82","_id":"handy-types@2.0.0","_nodeVersion":"16.16.0","_npmVersion":"8.11.0","dist":{"integrity":"sha512-WD637KV+xlRORHjEuJGwDPd8TNfnAjaVnJp+hWzqF0ukZaK9gV/xoCbwqXzKgFzxO00uAJX+PZK/zSP0Ikx/cA==","shasum":"02d36aab1fbc1a5b62e83ab9f7ad37c2daf67406","tarball":"https://registry.npmjs.org/handy-types/-/handy-types-2.0.0.tgz","fileCount":11,"unpackedSize":31723,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCID85OXSmirtsmZ+lsF1t5sT7jl3KG7OdkNElqrQPvtiAAiB4K+w4I3IwhFxRGCPw9s2agS7PwLlfBc9VMdkQbbyTpw=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjA5hAACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpZ7Q//cZ58f+eQHLOJnP5we5dOYFjqHFejpAvhGqeYYkLWMtVnnb8J\r\n/X4MlHSoHzuFZdN/8jhSNchfemHrt+ocwec3tpWE8A8ecYVwAGRBGAw4w6MP\r\n+knHHLYipL19ztiulwF5Di6iD7lZ3vYSrepIv4CnODdlMZTepLsz0oKjLhtT\r\nzYOeUoTOQiFdlS0aDnx2vDD5o/H0B8bI1/XdsegW/9avM/cB+nGA41Ss7Auh\r\ngAmNckW7pgkCAusH9hqXyl1FVWk7fLJy6z9Mug/oryuZyzxRwoJXIqC3cM84\r\ntGXpL+3qhzdo+F8u4pLZX58iEpRXGJEfaRtY0ZKLA8n6Z66ZhdfhoJY8f6gg\r\n95xsGO23pBtZO9/ArAxh24rXFiVHeEQbJQsWZmd1pteG3Id/p+af/jmHqjvr\r\nJYNMA9vTFrMEgWdIAuG2iisMIyI4E5ScIkZKRvagqSemQ1nGRXYNs8oxNSKE\r\nUFV52AtvBW3+OT8PCy15q44hS0EonTJJ7uEr4UaDw3LI0QFdh42xPCoJS+OT\r\nxo3HCICrEMFD6uHfJamFOpmRxtnlbYmpyPb5deI+ZKGyv7d1bizeGxFHQhMX\r\nPfC07LUQkhBqlHz/i+9u/IJ7JZf1qPjm+3F6z+cw+RwmkNBFwlHekE8aHRuw\r\n4ImsQTpG8635BxXKfIviymbKKMZJQqXs8ro=\r\n=NTwK\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"h_sifat","email":"hsifat@protonmail.com"},"directories":{},"maintainers":[{"name":"h_sifat","email":"hsifat@protonmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/handy-types_2.0.0_1661179968352_0.9041095151452192"},"_hasShrinkwrap":false},"2.1.0":{"name":"handy-types","version":"2.1.0","description":"A collection of small utility functions to check variable types","keywords":["types","validator","type-checker","type alias"],"author":{"name":"Sifat Hossain","email":"hsifat@protonmail.com"},"repository":{"type":"git","url":"git+https://github.com/h-sifat/handy-types.git"},"bugs":{"url":"https://github.com/h-sifat/handy-types/issues"},"homepage":"https://github.com/h-sifat/handy-types#readme","license":"MIT","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"test":"jest","test:watch":"jest --watch","test:coverage":"jest --coverage","build":"webpack","prebuild":"npm test","prepublishOnly":"npm run build"},"devDependencies":{"@types/jest":"^27.5.2","jest":"^27.2.5","ts-jest":"^27.0.5","ts-loader":"^9.3.1","typescript":"^4.4.3","webpack":"^5.74.0","webpack-cli":"^4.10.0"},"_id":"handy-types@2.1.0","gitHead":"85b5e2a00a2fe2c4fc3ac6d10068356881664eee","_nodeVersion":"20.10.0","_npmVersion":"10.2.3","dist":{"integrity":"sha512-nht2S3QBKs5Zy6Af6jl33sMHJO2cioeshsq7yFpzsjli+yqwl4CkBkjfCdG7ucs9OxJzaRlVPeJfODhrPpX0nQ==","shasum":"f1042563a04278f4f2bbb0be778271771e107993","tarball":"https://registry.npmjs.org/handy-types/-/handy-types-2.1.0.tgz","fileCount":11,"unpackedSize":32105,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC7bX7Ioh+JwzKA6CCtLefJ3qhPPBhBd8NTRoKabJ9vkAIgbDfodaDcBheRmgbI7jgJ23rLA6R6Z7gY7+bY3YvWMB0="}]},"_npmUser":{"name":"h_sifat","email":"hsifat@protonmail.com"},"directories":{},"maintainers":[{"name":"h_sifat","email":"hsifat@protonmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/handy-types_2.1.0_1702612519392_0.02017936135913656"},"_hasShrinkwrap":false}},"time":{"created":"2021-10-08T18:35:57.823Z","1.0.0":"2021-10-08T18:35:57.976Z","modified":"2023-12-15T03:55:19.739Z","1.0.1":"2021-10-08T18:56:22.156Z","1.1.0":"2021-10-11T16:24:22.625Z","1.2.0":"2021-10-30T03:10:16.540Z","1.3.0":"2021-11-08T14:43:41.501Z","1.4.0":"2021-11-11T07:02:54.042Z","2.0.0":"2022-08-22T14:52:48.641Z","2.1.0":"2023-12-15T03:55:19.588Z"},"maintainers":[{"name":"h_sifat","email":"hsifat@protonmail.com"}],"description":"A collection of small utility functions to check variable types","homepage":"https://github.com/h-sifat/handy-types#readme","keywords":["types","validator","type-checker","type alias"],"repository":{"type":"git","url":"git+https://github.com/h-sifat/handy-types.git"},"author":{"name":"Sifat Hossain","email":"hsifat@protonmail.com"},"bugs":{"url":"https://github.com/h-sifat/handy-types/issues"},"license":"MIT","readme":"# Handy-Types\n\n![Module Type](https://img.shields.io/badge/Module%20Type-UMD-brightgreen)\n![Npm Version](https://img.shields.io/npm/v/handy-types)\n![GitHub Tag](https://img.shields.io/github/v/tag/h-sifat/handy-types)\n![GitHub Issues](https://img.shields.io/github/issues/h-sifat/handy-types)\n\nA simple and lite weight validation library to reduce boilerplate in your\nJavaScript / TypeScript validation code.\n\nIt consists of many utility type predicate functions like `\"integer\"`,\n`\"positive_integer\"`, `\"non_empty_string\"`, `\"plain_object\"` and so on. Still\nnot impressed? How about `\"string[]\"` to represent a string array or\n`\"non_empty_string | non_empty_string[]\"` to represent a non empty string or an\narray of non empty string(s)? TypeScript type annotation is also supported. The\nlibrary is fully tested and has **100%** test coverage.\n\n## Importing\n\nThe library uses **UMD** module system so it's compatible with all JavaScript\nmodule systems.\n\n### JavaScript / TypeScript\n\n```js\n// es modules\nimport { is, assert, cache, handyTypes, typeNames } from \"handy-types\";\n\n// commonjs modules\nconst { is, assert, cache, handyTypes, typeNames } = require(\"handy-types\");\n```\n\n### In HTML with the `<script>` tag\n\n```html\n<script src=\"https://unpkg.com/handy-types\"></script>\n<!-- it will be available as a global object by the name \"handy_types\" -->\n```\n\n## Usages\n\nThis library exposes the following 5 entities\n\n1. **handyTypes:** An object containing all the type predicate functions. For\n   example, `handyTypes.positive_integer(2); // true`.\n\n1. **typeNames:** An object containing all the names of predicate functions of\n   `handyTypes`.\n   For example: `typeNames[\"positive_integer\"]; // \"Positive Integer\"`.\n   It may be used to generate meaningful error messages.\n\n1. **is:** a predicate function that uses all the functions in `handyTypes`\n   object to validate data. For example, `is(\"string\", \"a string\"); // true`. It\n   has a `cache` method with the same function signature as itself. The\n   `it.cache()` method can be used to cache parsed schemas to improve\n   performance.\n\n1. **assert:** a utility function similar to `is` but used for making\n   assertions. It also has a `cache` method similar to `is`.\n\n1. **cache:** An object used to manage schema caches of `is.cache()` and\n   `assert.cache()` functions.\n\n### Type schema syntax\n\nA type schema is a string passed into the `is` and `assert` function to\nrepresent a type. There are three types of type schema:\n\n1. **Basic:** Just a simple handy type name such as `\"string\"`,\n   `\"non_empty_array\"` etc.\n\n1. **Array:** If we add the `\"[]\"` suffix after any handy type name it\n   represents an array of that type. So `\"string[]\"` would represent and array\n   of string.\n\n1. **Union:** We can combine two or more type schema with a pipe `\"|\"` character\n   to represent an union. For example, `\"string | string[]\"` to represent a\n   string or an array of string(s).\n\n## Usages of `is()`\n\nThe `is` predicate function has the following signature.\n\n```ts\ninterface Is {\n  <Type>(schema: string, value: unknown): value is Type;\n  cache<Type>(schema: string, value: unknown): value is Type;\n}\n```\n\nThe reason it's a generic function with a type parameter named `Type` is to\nsupport typescript type annotation. For example:\n\n#### TypeScript Example\n\n```ts\nlet value: unknown;\n\nif (is<string | string[]>(\"non_empty_string | non_empty_string[]\", value)) {\n  value; // let value: string | string[]\n}\n```\n\nIn the if block the type of `value` variable is `string | string[]`. We've to\npass the type of value (`string | string[]`) manually because it's not possible\nto process an union schema with TypeScript to determine it's actual type.\n\nBut if this seems a little bit of extra work to you then you can use the basic\ntype predicate functions directly from the `handyTypes` object . For\nexample:\n\n```ts\nlet value: unknown;\n\nif (handyTypes.integer(value)) {\n  value; // let value: number\n}\n```\n\nHere in the if block the type of `value` variable will be set to\n`number` automatically. But the downsides of this approach are:\n\n1. We can't use array or union type schemas\n2. `handyTypes.integer(value)` doesn't seem intuitive because most of the time\n   a predicate function starts with the word **is** as a convention.\n\n#### JavaScript Example\n\nFor JavaScript just remove the generic type argument.\n\n```js\nconst hobbies = \"programming\";\nif (is(\"non_empty_string | non_empty_string[]\", hobbies)) {\n  hobbies;\n  // so `hobbies` is either a non_empty_string or a\n  // non_empty_string array\n}\n```\n\n### Usages of `is.cache()`\n\nUse the `is.cache()` function instead of `is` for **array** and **union**\nschemas to improve performance. It will parse and cache the schema so that it\ndoesn't have to waste time parsing the same schema again and again.\n\n#### TypeScript Example\n\n```ts\nif (is.cache<string | string[]>(\"string | string[]\", value)) {\n  value; // here value is of type: string | string[]\n}\n```\n\n#### JavaScript Example\n\n```ts\nif (is.cache(\"string | string[]\", value)) {\n  value; // here value is of type: string | string[]\n}\n```\n\n## Usages of `assert`\n\nWe can use the `assert` function to make assertions. It has the following\nfunction signature:\n\n```ts\ninterface Assert {\n  <Type>(\n    schema: string,\n    value: unknown,\n    errorInfo?: ErrorInformation\n  ): asserts value is Type;\n  cache<Type>(\n    schema: string,\n    value: unknown,\n    errorInfo?: ErrorInformation\n  ): asserts value is Type;\n}\n```\n\nHere `ErrorInformation` refers to the interface below.\n\n```ts\ninterface ErrorInformation {\n  name?: string;\n  message?: string;\n  code?: string | number;\n  otherInfo?: object;\n}\n```\n\nJust like the `is` function it takes a type schema and the variable we're making\nassertion on as it's first and second arguments respectively. Then we can\nprovide more information in the `errorInfo` object to customize the error\nobject.\n\nExamples:\n\n```ts\nlet value: unknown;\n\nassert<number>(\"integer\", value);\n// throws error: `Value must be of type Integer`\n\nassert<number>(\"integer\", value, {\n  name: \"Age\",\n  code: \"INVALID_AGE\",\n});\n// throws error: `Age must be of type Integer`, with code: \"INVALID_AGE\"\n\n// Use custom message instead of generating one\nassert<string>(\"non_empty_string\", value, {\n  message: \"Invalid path\",\n  otherInfo: {\n    path: value,\n    errorId: -3,\n  },\n});\n// throws error: `Invalid path` , path: undefined, errorId: -3\n```\n\n### Usages of `assert.cache()`\n\nIt serves the same purpose as `is.cache()`, it caches parsed schemas.\n\n```ts\nassert.cache<string | string[]>(\n  \"non_empty_string | non_empty_string[]\",\n  value,\n  { name: \"hobbies\" }\n); // use caching for improved performance\n```\n\n## Usages of the `cache` object\n\nThe `cache` object can be used to manage schema caches. It has the following\ninterface.\n\n```ts\nReadonly<{\n  readonly size: number;\n  has(schema: string): boolean;\n  delete(schema: string): boolean;\n  clear(): void;\n}>;\n```\n\nExamples:\n\n```ts\nconsole.log(cache.size); // 0\n\nconst schema = \"integer | integer[]\";\n\nis.cache<number | number[]>(schema, 23);\n\nconsole.log(cache.size); // 1\n\nconsole.log(cache.has(schema)); // true\n\n// use the delete method to delete a specific schema cache\ncache.delete(schema); // true\n\nconsole.log(cache.size); // 0\n\n// clear all caches\ncache.clear();\n```\n\n## All handy types\n\nBelow are the lists of all the type predicates available in the `handyTypes`\nobject.\n\n### Base Types\n\n| Type Name   | Full Name   | Implementation                                      |\n| ----------- | ----------- | --------------------------------------------------- |\n| boolean     | Boolean     | `typeof value === \"boolean\"`                        |\n| symbol      | Symbol      | `typeof value === \"symbol\"`                         |\n| string      | String      | `typeof value === \"string\"`                         |\n| object      | Object      | `typeof value === \"object\"`                         |\n| big_integer | Big Integer | `typeof value === \"bigint\"`                         |\n| function    | Function    | `typeof value === \"function\"`                       |\n| undefined   | Undefined   | `typeof value === \"undefined\"`                      |\n| **number**  | Number      | `typeof value === \"number\" && !Number.isNaN(value)` |\n\n**Note:** The type `number` is not just `typeof value === \"number\"`!\n\n### Number Types\n\n| Type Name           | Full Name           | Implementation                   |\n| ------------------- | ------------------- | -------------------------------- |\n| finite_number       | Finite Number       | `Number.isFinite(n)`             |\n| positive_number     | Positive Number     | `handyTypes.number(n) && n > 0`  |\n| non_negative_number | Non Negative Number | `handyTypes.number(n) && n >= 0` |\n| negative_number     | Negative Number     | `handyTypes.number(n) && n < 0`  |\n| non_positive_number | Non Positive Number | `handyTypes.number(n) && n <= 0` |\n\n### Integer Types\n\n| Type Name            | Full Name            | Implementation                  |\n| -------------------- | -------------------- | ------------------------------- |\n| integer              | Integer              | `Number.isInteger(i)`           |\n| safe_integer         | Safe Integer         | `Number.isSafeInteger(i)`       |\n| positive_integer     | Positive Integer     | `Number.isInteger(i) && i > 0`  |\n| non_negative_integer | Non Negative Integer | `Number.isInteger(i) && i >= 0` |\n| negative_integer     | Negative Integer     | `Number.isInteger(i) && i < 0`  |\n| non_positive_integer | Non Positive Integer | `Number.isInteger(i) && i <= 0` |\n\n### Bytewise Integer Types\n\n| Type Name              | Full Name               | Range                                   |\n| ---------------------- | ----------------------- | --------------------------------------- |\n| 8bit_integer           | 8 Bit Integer           | **-128** to **127**                     |\n| 8bit_unsigned_integer  | 8 Bit Unsigned Integer  | **0** to **255**                        |\n| 16bit_integer          | 16 Bit Integer          | **-32,768** to **32,767**               |\n| 16bit_unsigned_integer | 16 Bit Unsigned Integer | **0** to **65,535**                     |\n| 32bit_integer          | 32 Bit Integer          | **-2,147,483,648** to **2,147,483,647** |\n| 32bit_unsigned_integer | 32 Bit Unsigned Integer | **0** to **4,294,967,295**              |\n\n### Array Types\n\n| Type Name       | Full Name       | Implementation                               |\n| --------------- | --------------- | -------------------------------------------- |\n| array           | Array           | `Array.isArray(value)`                       |\n| non_empty_array | Non-Empty Array | `Array.isArray(value) && value.length !== 0` |\n\n### Object Types\n\n| Type Name       | Full Name       | Implementation                                                         |\n| --------------- | --------------- | ---------------------------------------------------------------------- |\n| non_null_object | Non-Null Object | `typeof value === \"object\" && value !== null`                          |\n| plain_object    | Plain Object    | `typeof value === \"object\" && value !== null && !Array.isArray(value)` |\n\n### String Types\n\n| Type Name                | Full Name                  | Implementation                                       |\n| ------------------------ | -------------------------- | ---------------------------------------------------- |\n| non_empty_string         | Non-Empty String           | `typeof value === \"string\" && value !== \"\"`          |\n| trimmed_non_empty_string | Non-Empty String (trimmed) | `typeof value === \"string\" && !!value.trim().length` |\n\n### Other Types\n\n| Type Name   | Full Name    | Implementation                            |\n| ----------- | ------------ | ----------------------------------------- |\n| nan         | Not A Number | `Number.isNaN(value)`                     |\n| any         | Any          | `true` // returns true for any value      |\n| nullish     | Nullish      | `value === null \\|\\| value === undefined` |\n| non_nullish | Non-Nullish  | `value !== null && value !== undefined`   |\n\nIf you find any bug or want to improve something please feel free to open an\nissue. Pull requests are also welcomed.\n","readmeFilename":"README.md"}