{"_id":"@beesley/ts-env","_rev":"1-dc53de0e2abd54e0907ef63e371de143","name":"@beesley/ts-env","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@beesley/ts-env","version":"1.0.0","description":"An environment variable reader for TypeScript","repository":{"type":"git","url":"git+https://github.com/bbeesley/ts-env.git"},"keywords":["typescript","env",".env","environment","variables"],"license":"MIT","publishConfig":{"access":"public"},"type":"module","exports":{".":{"types":"./dist/types/index.d.ts","import":"./dist/esm/index.js","require":"./dist/cjs/index.cjs"}},"module":"./dist/esm/index.js","main":"./dist/cjs/index.cjs","types":"./dist/types/index.d.ts","engines":{"node":">=18.12"},"directories":{"doc":"./docs"},"scripts":{"readme:typedoc":"typedoc --plugin typedoc-plugin-markdown","documentation":"run-s readme:*","compile:esm":"tsc","lint":"xo && tsc --noEmit -p tsconfig-lint.json","pretest":"npm run lint","compile:cjs":"babel src --out-dir dist/cjs --extensions '.ts,.cjs,.mjs' --ignore '**/*.test.ts' --source-maps --out-file-extension '.cjs'","compile":"run-p compile:*","test":"npx ava","prerelease":"npm run documentation","release":"npx semantic-release"},"devDependencies":{"@babel/cli":"^7.22.6","@babel/core":"^7.22.8","@babel/preset-env":"^7.22.7","@babel/preset-typescript":"^7.22.5","@beesley/tsconfig":"^3.0.0","@commitlint/cli":"^17.6.6","@commitlint/config-conventional":"^17.6.6","@semantic-release/changelog":"^6.0.3","@semantic-release/commit-analyzer":"^11.0.0","@semantic-release/git":"^10.0.1","@semantic-release/github":"^9.0.3","@semantic-release/npm":"^11.0.0","@semantic-release/release-notes-generator":"^12.0.0","@smithy/types":"^1.1.1","@types/js-yaml":"^4.0.5","@types/jsdom":"^21.1.1","@types/node":"^18.18.3","@types/sinon":"^10.0.15","@types/yargs":"^17.0.24","ava":"^5.3.1","aws-sdk-client-mock":"^3.0.0","babel-plugin-replace-import-extension":"^1.1.3","delay":"^6.0.0","documentation":"^14.0.2","npm-run-all":"^4.1.5","prettier":"^3.0.0","sinon":"^16.1.0","typedoc":"^0.25.0","typedoc-plugin-markdown":"^3.15.3","typescript":"^5.1.6","xo":"^0.56.0"},"eslintConfig":{"parserOptions":{"project":["./tsconfig.json","./tsconfig-lint.json"]}},"xo":{"space":true,"prettier":true,"rules":{"func-names":["error","always"],"@typescript-eslint/no-implicit-any-catch":"off","ava/use-test":"off","eqeqeq":"off","import/extensions":"off","n/file-extension-in-import":"off","n/prefer-global/process":"off","no-await-in-loop":"off","no-eq-null":"off","unicorn/no-array-reduce":"off","unicorn/no-process-exit":"off"},"overrides":[{"files":"**/*.ts","rules":{"@typescript-eslint/naming-convention":["error",{"selector":"default","format":["camelCase"]},{"selector":"variable","format":["camelCase","UPPER_CASE","PascalCase"]},{"selector":"parameter","format":["camelCase","PascalCase"]},{"selector":"typeLike","format":["PascalCase"]},{"selector":"classProperty","format":["camelCase"]},{"selector":"objectLiteralProperty","format":null},{"selector":"typeProperty","format":null},{"selector":"enum","format":["PascalCase","UPPER_CASE"]},{"selector":"enumMember","format":null}]}},{"files":"**/*.test.ts","rules":{"import/no-extraneous-dependencies":"off","@typescript-eslint/naming-convention":"off"}}]},"ava":{"files":["tests/*.test.ts","tests/*.test.js"],"failFast":false,"failWithoutAssertions":false,"verbose":true,"extensions":{"ts":"module","js":true},"nodeArguments":["--loader=ts-node/esm","--experimental-specifier-resolution=node"],"timeout":"5m","snapshotDir":"__snapshots__"},"release":{"branches":["main","next"],"plugins":[["@semantic-release/commit-analyzer",{"releaseRules":[{"type":"docs","release":"patch"},{"type":"refactor","release":"patch"}]}],"@semantic-release/release-notes-generator",["@semantic-release/changelog",{"changelogFile":"CHANGELOG.md"}],"@semantic-release/npm","@semantic-release/github",["@semantic-release/git",{"assets":["docs/**","package.json","CHANGELOG.md","README.md"],"message":"chore(release): ${nextRelease.version} 🚀 [skip ci]\n\n${nextRelease.notes}"}]]},"_id":"@beesley/ts-env@1.0.0","gitHead":"c4fc5403bdebf277ecc18a9fda72bad6b9c6ab05","bugs":{"url":"https://github.com/bbeesley/ts-env/issues"},"homepage":"https://github.com/bbeesley/ts-env#readme","_nodeVersion":"18.18.0","_npmVersion":"10.2.0","dist":{"integrity":"sha512-hLzt7LL0PU0yTIgQawqNZvVGyZe5z3Di7rKAaAE6IQfrNF8jSnJOeZaYzLQbUo/N5Aj+ZqgQ/dAeEIkuDi/tjQ==","shasum":"9ffcf697903da0d1686dfa3f7f4d16ab7c54fe86","tarball":"https://registry.npmjs.org/@beesley/ts-env/-/ts-env-1.0.0.tgz","fileCount":87,"unpackedSize":42468,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDuVPBa93Pz1t4CuGqMEj1tMk83PD3mTNIwyNpiShGnygIhAOfSe3cn8Sy23ZrFLfy040rYf95PXzoej0vpoijfPGNK"}]},"_npmUser":{"name":"bbeesley","email":"bbeesley@me.com"},"maintainers":[{"name":"bbeesley","email":"bbeesley@me.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-env_1.0.0_1696600180476_0.016097111231944572"},"_hasShrinkwrap":false},"1.0.1":{"name":"@beesley/ts-env","version":"1.0.1","description":"An environment variable reader for TypeScript","repository":{"type":"git","url":"git+https://github.com/bbeesley/ts-env.git"},"keywords":["typescript","env",".env","environment","variables"],"license":"MIT","publishConfig":{"access":"public"},"type":"module","exports":{".":{"types":"./dist/types/index.d.ts","import":"./dist/esm/index.js","require":"./dist/cjs/index.cjs"}},"module":"./dist/esm/index.js","main":"./dist/cjs/index.cjs","types":"./dist/types/index.d.ts","engines":{"node":">=18.12"},"directories":{"doc":"./docs"},"scripts":{"readme:typedoc":"typedoc --plugin typedoc-plugin-markdown","documentation":"run-s readme:*","compile:esm":"tsc","lint":"xo && tsc --noEmit -p tsconfig-lint.json","pretest":"npm run lint","compile:cjs":"babel src --out-dir dist/cjs --extensions '.ts,.cjs,.mjs' --ignore '**/*.test.ts' --source-maps --out-file-extension '.cjs'","compile":"run-p compile:*","test":"npx ava","prerelease":"npm run documentation","release":"npx semantic-release"},"devDependencies":{"@babel/cli":"^7.22.6","@babel/core":"^7.22.8","@babel/preset-env":"^7.22.7","@babel/preset-typescript":"^7.22.5","@beesley/tsconfig":"^3.0.0","@commitlint/cli":"^17.6.6","@commitlint/config-conventional":"^17.6.6","@semantic-release/changelog":"^6.0.3","@semantic-release/commit-analyzer":"^11.0.0","@semantic-release/git":"^10.0.1","@semantic-release/github":"^9.0.3","@semantic-release/npm":"^11.0.0","@semantic-release/release-notes-generator":"^12.0.0","@smithy/types":"^1.1.1","@types/js-yaml":"^4.0.5","@types/jsdom":"^21.1.1","@types/node":"^18.18.3","@types/sinon":"^10.0.15","@types/yargs":"^17.0.24","ava":"^5.3.1","aws-sdk-client-mock":"^3.0.0","babel-plugin-replace-import-extension":"^1.1.3","delay":"^6.0.0","documentation":"^14.0.2","npm-run-all":"^4.1.5","prettier":"^3.0.0","sinon":"^16.1.0","typedoc":"^0.25.0","typedoc-plugin-markdown":"^3.15.3","typescript":"^5.1.6","xo":"^0.56.0"},"eslintConfig":{"parserOptions":{"project":["./tsconfig.json","./tsconfig-lint.json"]}},"xo":{"space":true,"prettier":true,"rules":{"func-names":["error","always"],"@typescript-eslint/no-implicit-any-catch":"off","ava/use-test":"off","eqeqeq":"off","import/extensions":"off","n/file-extension-in-import":"off","n/prefer-global/process":"off","no-await-in-loop":"off","no-eq-null":"off","unicorn/no-array-reduce":"off","unicorn/no-process-exit":"off"},"overrides":[{"files":"**/*.ts","rules":{"@typescript-eslint/naming-convention":["error",{"selector":"default","format":["camelCase"]},{"selector":"variable","format":["camelCase","UPPER_CASE","PascalCase"]},{"selector":"parameter","format":["camelCase","PascalCase"]},{"selector":"typeLike","format":["PascalCase"]},{"selector":"classProperty","format":["camelCase"]},{"selector":"objectLiteralProperty","format":null},{"selector":"typeProperty","format":null},{"selector":"enum","format":["PascalCase","UPPER_CASE"]},{"selector":"enumMember","format":null}]}},{"files":"**/*.test.ts","rules":{"import/no-extraneous-dependencies":"off","@typescript-eslint/naming-convention":"off"}}]},"ava":{"files":["tests/*.test.ts","tests/*.test.js"],"failFast":false,"failWithoutAssertions":false,"verbose":true,"extensions":{"ts":"module","js":true},"nodeArguments":["--loader=ts-node/esm","--experimental-specifier-resolution=node"],"timeout":"5m","snapshotDir":"__snapshots__"},"release":{"branches":["main","next"],"plugins":[["@semantic-release/commit-analyzer",{"releaseRules":[{"type":"docs","release":"patch"},{"type":"refactor","release":"patch"}]}],"@semantic-release/release-notes-generator",["@semantic-release/changelog",{"changelogFile":"CHANGELOG.md"}],"@semantic-release/npm","@semantic-release/github",["@semantic-release/git",{"assets":["docs/**","package.json","CHANGELOG.md","README.md"],"message":"chore(release): ${nextRelease.version} 🚀 [skip ci]\n\n${nextRelease.notes}"}]]},"_id":"@beesley/ts-env@1.0.1","gitHead":"86254b4b8ef4dfdc6c064333586bfaa2f255fba0","bugs":{"url":"https://github.com/bbeesley/ts-env/issues"},"homepage":"https://github.com/bbeesley/ts-env#readme","_nodeVersion":"18.18.0","_npmVersion":"10.2.0","dist":{"integrity":"sha512-CarSPOnqMQeHd6pC0ULfuAhc1ASO0FJATJbkp74EFvU51hX8OeaWYfVJXZ/Iua5jUOweVTaUYsiyqiKUQpNMSg==","shasum":"ff438b470cd8288f1be5b0ad6281d1d15ce6ba61","tarball":"https://registry.npmjs.org/@beesley/ts-env/-/ts-env-1.0.1.tgz","fileCount":87,"unpackedSize":42180,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIH73Hry/b5gPi0O8V9mu9Xymx9e9FVzFtan6go8e/zE2AiA6VO6UP10KrWm92w5d2k76nSzHlPCZTisPRBqu3cZXJQ=="}]},"_npmUser":{"name":"bbeesley","email":"bbeesley@me.com"},"maintainers":[{"name":"bbeesley","email":"bbeesley@me.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ts-env_1.0.1_1696600793080_0.09407383539703318"},"_hasShrinkwrap":false}},"time":{"created":"2023-10-06T13:49:40.362Z","1.0.0":"2023-10-06T13:49:40.748Z","modified":"2023-10-06T13:59:53.496Z","1.0.1":"2023-10-06T13:59:53.299Z"},"maintainers":[{"name":"bbeesley","email":"bbeesley@me.com"}],"description":"An environment variable reader for TypeScript","homepage":"https://github.com/bbeesley/ts-env#readme","keywords":["typescript","env",".env","environment","variables"],"repository":{"type":"git","url":"git+https://github.com/bbeesley/ts-env.git"},"bugs":{"url":"https://github.com/bbeesley/ts-env/issues"},"license":"MIT","readme":"# @beesley/ts-env / [Exports](docs/modules.md)\n\n[![Build, Test & Publish Main](https://github.com/bbeesley/ts-env/actions/workflows/build-test-on-push.yml/badge.svg)](https://github.com/bbeesley/ts-env/actions/workflows/build-test-on-push.yml) [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/) [![semantic-release: angular](https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release)\n\nAn environment variable reader for TypeScript. Simple and minimal. ✨\n\nThis is basically the package created by @lpgera, but since that package doesn't play well at all with typescript when you're using es modules I've forked it and rebuilt is as a universal package to work with either es modules or common js.\n\n## Install\n\nThis package requires `typescript` to be installed.\n\n```bash\n# with npm\nnpm install @beesley/ts-env\n\n# or with Yarn\nyarn add @beesley/ts-env\n```\n\n## Example\n\nReading different types of environment variables without `ts-env`:\n\n```typescript\nif (!process.env.PORT) {\n  throw new Error('process.env.PORT is missing')\n}\nif (!process.env.DATABASE) {\n  throw new Error('process.env.DATABASE is missing')\n}\n\nconst port: number = parseInt(process.env.PORT)\nconst database: string = process.env.DATABASE\nconst debug: boolean | undefined = process.env.DEBUG === 'true'\n```\n\nDoing the same with `ts-env`:\n\n```typescript\nimport tsEnv from '@beesley/ts-env'\n\nconst port: number = tsEnv.numberOrThrow('PORT')\nconst database: string = tsEnv.stringOrThrow('DATABASE')\nconst debug: boolean | undefined = tsEnv.boolean('DEBUG')\n```\n\n## API\n\n### .string(key: string): string | undefined\n\nReads a string value from `process.env[key]`.\n\n### .stringOrThrow(key: string): string\n\nReads a string value from `process.env[key]`.\nThrows an error if it's `undefined`.\n\n### .boolean(key: string): boolean | undefined\n\nReads a boolean value from `process.env[key]`.\n\"0\" and \"false\" are considered `false`, \"1\" and \"true\" are considered `true`.\nEverything else will be read as `undefined`.\n\n### .booleanOrThrow(key: string): boolean\n\nReads a boolean value from `process.env[key]`.\n\"0\" and \"false\" are considered `false`, \"1\" and \"true\" are considered `true`.\nEverything else will result in an error thrown.\n\n### .number(key: string): number | undefined\n\nReads a number value from `process.env[key]`.\nIf a number cannot be parsed, it will return `undefined`.\n\n### .numberOrThrow(key: string): number\n\nReads a number value from `process.env[key]`.\nIf a number cannot be parsed, an error will be thrown.\n\n### .stringArray(key: string, separator: string = ','): string[] | undefined\n\nReads a string array from `process.env[key]`.\n\n### .stringArrayOrThrow(key: string, separator: string = ','): string[]\n\nReads a string array from `process.env[key]`.\nThrows an error if it's `undefined`.\n\n### .numberArray(key: string, separator: string = ','): number[] | undefined\n\nReads a number array from `process.env[key]`.\nIf any item cannot be parsed, it will return `undefined`.\n\n### .numberArrayOrThrow(key: string, separator: string = ','): number[]\n\nReads a number array from `process.env[key]`.\nIf any item cannot be parsed, an error will be thrown.\n","readmeFilename":"README.md"}