{"id":13455178,"url":"https://github.com/simonepri/env-dot-prop","last_synced_at":"2025-04-14T19:43:50.408Z","repository":{"id":48595480,"uuid":"97963976","full_name":"simonepri/env-dot-prop","owner":"simonepri","description":"♻️ Get, set, or delete nested properties of process.env using a dot path","archived":false,"fork":false,"pushed_at":"2021-07-19T04:16:09.000Z","size":112,"stargazers_count":33,"open_issues_count":3,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-11T20:49:14.096Z","etag":null,"topics":["configs","dot-prop","env","env-dot-prop","environment-variables","environment-vars","nodejs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/simonepri.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-21T15:47:23.000Z","updated_at":"2023-09-10T01:34:52.000Z","dependencies_parsed_at":"2022-08-27T21:23:48.195Z","dependency_job_id":null,"html_url":"https://github.com/simonepri/env-dot-prop","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonepri%2Fenv-dot-prop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonepri%2Fenv-dot-prop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonepri%2Fenv-dot-prop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonepri%2Fenv-dot-prop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simonepri","download_url":"https://codeload.github.com/simonepri/env-dot-prop/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248949670,"owners_count":21188123,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["configs","dot-prop","env","env-dot-prop","environment-variables","environment-vars","nodejs"],"created_at":"2024-07-31T08:01:02.113Z","updated_at":"2025-04-14T19:43:50.384Z","avatar_url":"https://github.com/simonepri.png","language":"JavaScript","funding_links":[],"categories":["Packages","包","目录","Miscellaneous"],"sub_categories":["Miscellaneous","其他","杂项"],"readme":"\u003ch1 align=\"center\"\u003e\n  \u003ca href=\"https://github.com/simonepri/env-dot-prop\"\u003e\n    \u003cimg src=\"https://github.com/simonepri/env-dot-prop/raw/master/media/env-dot-prop.png\" alt=\"env-dot-prop\" /\u003e\n  \u003c/a\u003e\n\u003c/h1\u003e\n\u003cp align=\"center\"\u003e\n  \u003c!-- Version - npm --\u003e\n  \u003ca href=\"https://www.npmjs.com/package/env-dot-prop\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/v/env-dot-prop.svg\" alt=\"Latest version on npm\" /\u003e\n  \u003c/a\u003e\n  \u003c!-- Downloads - npm --\u003e\n  \u003ca href=\"https://npm-stat.com/charts.html?package=env-dot-prop\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/dt/env-dot-prop.svg\" alt=\"Downloads on npm\" /\u003e\n  \u003c/a\u003e\n  \u003c!-- License - MIT --\u003e\n  \u003ca href=\"https://github.com/simonepri/env-dot-prop/tree/master/license\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/license/simonepri/env-dot-prop.svg\" alt=\"Project license\" /\u003e\n  \u003c/a\u003e\n  \u003c!-- Awesome - Node --\u003e\n  \u003ca href=\"https://github.com/sindresorhus/awesome-nodejs\"\u003e\n    \u003cimg src=\"https://awesome.re/mentioned-badge.svg\" alt=\"Awesome project\" /\u003e\n  \u003c/a\u003e\n\n  \u003cbr/\u003e\n\n  \u003c!-- Lint --\u003e\n  \u003ca href=\"https://github.com/simonepri/env-dot-prop/actions?query=workflow:lint+branch:master\"\u003e\n    \u003cimg src=\"https://github.com/simonepri/env-dot-prop/workflows/lint/badge.svg?branch=master\" alt=\"Lint status\" /\u003e\n  \u003c/a\u003e\n  \u003c!-- Test - macOS --\u003e\n  \u003ca href=\"https://github.com/simonepri/env-dot-prop/actions?query=workflow:test-macos+branch:master\"\u003e\n    \u003cimg src=\"https://github.com/simonepri/env-dot-prop/workflows/test-macos/badge.svg?branch=master\" alt=\"Test macOS status\" /\u003e\n  \u003c/a\u003e\n  \u003c!-- Test - Ubuntu --\u003e\n  \u003ca href=\"https://github.com/simonepri/env-dot-prop/actions?query=workflow:test-ubuntu+branch:master\"\u003e\n    \u003cimg src=\"https://github.com/simonepri/env-dot-prop/workflows/test-ubuntu/badge.svg?branch=master\" alt=\"Test Ubuntu status\" /\u003e\n  \u003c/a\u003e\n  \u003c!-- Test - Windows --\u003e\n  \u003ca href=\"https://github.com/simonepri/env-dot-prop/actions?query=workflow:test-windows+branch:master\"\u003e\n    \u003cimg src=\"https://github.com/simonepri/env-dot-prop/workflows/test-windows/badge.svg?branch=master\" alt=\"Test Windows status\" /\u003e\n  \u003c/a\u003e\n\n  \u003cbr/\u003e\n\n  \u003c!-- Coverage - Codecov --\u003e\n  \u003ca href=\"https://codecov.io/gh/simonepri/env-dot-prop\"\u003e\n    \u003cimg src=\"https://img.shields.io/codecov/c/github/simonepri/env-dot-prop/master.svg\" alt=\"Codecov Coverage report\" /\u003e\n  \u003c/a\u003e\n  \u003c!-- DM - Snyk --\u003e\n  \u003ca href=\"https://snyk.io/test/github/simonepri/env-dot-prop?targetFile=package.json\"\u003e\n    \u003cimg src=\"https://snyk.io/test/github/simonepri/env-dot-prop/badge.svg?targetFile=package.json\" alt=\"Known Vulnerabilities\" /\u003e\n  \u003c/a\u003e\n  \u003c!-- DM - David --\u003e\n  \u003ca href=\"https://david-dm.org/simonepri/env-dot-prop\"\u003e\n    \u003cimg src=\"https://david-dm.org/simonepri/env-dot-prop/status.svg\" alt=\"Dependency Status\" /\u003e\n  \u003c/a\u003e\n\n  \u003cbr/\u003e\n\n  \u003c!-- Code Style - XO-Prettier --\u003e\n  \u003ca href=\"https://github.com/xojs/xo\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/code_style-XO+Prettier-5ed9c7.svg\" alt=\"XO Code Style used\" /\u003e\n  \u003c/a\u003e\n  \u003c!-- Test Runner - AVA --\u003e\n  \u003ca href=\"https://github.com/avajs/ava\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/test_runner-AVA-fb3170.svg\" alt=\"AVA Test Runner used\" /\u003e\n  \u003c/a\u003e\n  \u003c!-- Test Coverage - Istanbul --\u003e\n  \u003ca href=\"https://github.com/istanbuljs/nyc\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/test_coverage-NYC-fec606.svg\" alt=\"Istanbul Test Coverage used\" /\u003e\n  \u003c/a\u003e\n  \u003c!-- Init - ni --\u003e\n  \u003ca href=\"https://github.com/simonepri/ni\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/initialized_with-ni-e74c3c.svg\" alt=\"NI Scaffolding System used\" /\u003e\n  \u003c/a\u003e\n  \u003c!-- Release - np --\u003e\n  \u003ca href=\"https://github.com/sindresorhus/np\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/released_with-np-6c8784.svg\" alt=\"NP Release System used\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n  ♻️ Get, set, or delete nested properties of process.env using a dot path\n  \u003cbr/\u003e\n\n  \u003csub\u003e\n    Coded with ❤️ by \u003ca href=\"#authors\"\u003eSimone Primarosa\u003c/a\u003e.\n  \u003c/sub\u003e\n\u003c/p\u003e\n\n## Background\n\nThis package aim to let you access to your environment variables as if they were JavaScript object.\nSee [this guide][12factorsguide] to understand how to use this package to create a [12 Factor compliant][12factors] configuration system for you app.\n\n## Install\n\n```\n$ npm install --save env-dot-prop\n```\n\n## Usage\n\n```js\nconst envDotProp = require('env-dot-prop');\n\n// Let's assume process.env contains the following keys\nprocess.env = {\n  FOO_BAR: 'unicorn',\n  'FOO_DOT.DOT': 'pony',\n  'FOO_UND\\\\_UND': 'whale'\n};\n\nconsole.log(process.env);\n// =\u003e { FOO_BAR: 'unicorn', 'FOO_DOT.DOT': 'pony', 'FOO_UND\\_UND': 'whale' }\nenvDotProp.get('');\n// =\u003e { foo: { bar: 'unicorn', 'dot.dot': 'pony', und_und: 'whale' } }\n\n// getter\nenvDotProp.get('foo.bar');\n// =\u003e 'unicorn'\n\nenvDotProp.get('foo.notDefined.deep');\n// =\u003e undefined\n\nenvDotProp.get('foo.notDefined.deep', 'default value');\n// =\u003e 'default value'\n\nenvDotProp.get('foo.dot\\\\.dot');\n// =\u003e 'pony'\n\n// setter\nenvDotProp.set('foo.bar', 'b');\nenvDotProp.get('foo.bar');\n// =\u003e 'b'\n\nenvDotProp.get('');\n// =\u003e { foo: { bar: 'b', 'dot.dot': 'pony', und_und: 'whale' } }\n\nenvDotProp.set('foo.baz.e', 'x');\nenvDotProp.get('foo.baz.e');\n// =\u003e 'x'\nenvDotProp.get('foo.baz');\n// =\u003e { e: 'x' }\n\nenvDotProp.get('');\n// =\u003e { foo: { bar: 'b', baz: { e: 'x' }, 'dot.dot': 'pony', und_und: 'whale' } }\n\n// has\nenvDotProp.has('foo.bar');\n// =\u003e true\n\n// deleter\nenvDotProp.delete('foo.bar');\nenvDotProp.get('foo');\n// =\u003e { baz: { e: 'x' }, 'dot.dot': 'pony', und_und: 'whale' }\n\nenvDotProp.delete('foo.baz.e');\nenvDotProp.get('foo.baz');\n// =\u003e undefined\n\nenvDotProp.set('n1', 42, {stringify: false});\nenvDotProp.get('n1', {parse: false});\n// =\u003e 42\nenvDotProp.get('n1', {parse: true});\n// =\u003e 42\n\nenvDotProp.set('n2', 42, {stringify: true});\nenvDotProp.get('n2', {parse: false});\n// =\u003e '42'\nenvDotProp.get('n2', {parse: true});\n// =\u003e 42\n\nenvDotProp.set('n3', 42);\nenvDotProp.get('n3');\n// =\u003e 42\n\nenvDotProp.set('n4', '42');\nenvDotProp.get('n4');\n// =\u003e '42'\n\nenvDotProp.get('');\n// =\u003e { n1: '42', n1: 42, n3: 42, n4: '42', foo: { 'dot.dot': 'pony', und_und: 'whale' } }\nconsole.log(process.env);\n// =\u003e { 'FOO_DOT.DOT': 'pony', 'FOO_UND\\_UND': 'whale', N1: '42', N2: 42, N3: 42, N4: '42' }\n```\n\n## API\n\n\u003ca name=\"get\"\u003e\u003c/a\u003e\n\n## get(path, [defaultValue], [opts]) ⇒ \u003ccode\u003eany\u003c/code\u003e\nGets the values of environment variables at the path specified.\n\n**Kind**: global function  \n**Returns**: \u003ccode\u003eany\u003c/code\u003e - The values of environment variables associated with the path specified.  \n**Access**: public  \n\n| Param | Type | Default | Description |\n| --- | --- | --- | --- |\n| path | \u003ccode\u003estring\u003c/code\u003e |  | Dot separated path. |\n| [defaultValue] | \u003ccode\u003eany\u003c/code\u003e |  | Default value to return if there is not any environment variable that matches the path provided. |\n| [opts] | \u003ccode\u003eObject\u003c/code\u003e |  | Additional options. |\n| [opts.parse] | \u003ccode\u003eboolean\u003c/code\u003e | \u003ccode\u003efalse\u003c/code\u003e | If true the value retrieved is converted to the proper type. |\n| [opts.caseSensitive] | \u003ccode\u003eboolean\u003c/code\u003e | \u003ccode\u003efalse\u003c/code\u003e | If true no case conversion will be performed from the dot path provided to the env key search. Eg: 'tesT.kEy' will look for tesT_kEy environment variable instead of TEST_KEY. |\n\n\u003ca name=\"set\"\u003e\u003c/a\u003e\n\n## set(path, value, [opts])\nSets an env key at the path specified. If nested keys are present they will\nbe deleted.\n\n**Kind**: global function  \n**Access**: public  \n\n| Param | Type | Default | Description |\n| --- | --- | --- | --- |\n| path | \u003ccode\u003estring\u003c/code\u003e |  | Dot separated path. |\n| value | \u003ccode\u003estring\u003c/code\u003e |  | Value to set. |\n| [opts] | \u003ccode\u003eobject\u003c/code\u003e |  | Additional options. |\n| [opts.stringify] | \u003ccode\u003eboolean\u003c/code\u003e | \u003ccode\u003efalse\u003c/code\u003e | If true the value provided is converted to string. |\n| [opts.caseSensitive] | \u003ccode\u003eboolean\u003c/code\u003e | \u003ccode\u003efalse\u003c/code\u003e | If true no case conversion is performed from the dot path provided to the env key search. Eg: 'tesT.kEy' will look for tesT_kEy environment variable instead of TEST_KEY. |\n\n\u003ca name=\"del\"\u003e\u003c/a\u003e\n\n## del(path, [opts])\nDeletes an env key at the path specified.\nIf nested keys are present they will be deleted too.\n\n**Kind**: global function  \n**Access**: public  \n\n| Param | Type | Default | Description |\n| --- | --- | --- | --- |\n| path | \u003ccode\u003estring\u003c/code\u003e |  | A dot separated path. |\n| [opts] | \u003ccode\u003eobject\u003c/code\u003e |  | Additional options. |\n| [opts.caseSensitive] | \u003ccode\u003eboolean\u003c/code\u003e | \u003ccode\u003efalse\u003c/code\u003e | If true no case conversion is performed from the dot path provided to the env key search. Eg: 'tesT.kEy' will look for tesT_kEy environment variable instead of TEST_KEY. |\n\n\u003ca name=\"has\"\u003e\u003c/a\u003e\n\n## has(path, [opts]) ⇒ \u003ccode\u003eboolean\u003c/code\u003e\nReturns whether an env key exists at the path specified.\n\n**Kind**: global function  \n**Returns**: \u003ccode\u003eboolean\u003c/code\u003e - true if exists at least one environment variables with that\npath prefix.  \n**Access**: public  \n\n| Param | Type | Default | Description |\n| --- | --- | --- | --- |\n| path | \u003ccode\u003estring\u003c/code\u003e |  | Dot separated path. |\n| [opts] | \u003ccode\u003eobject\u003c/code\u003e |  | Additional options. |\n| [opts.caseSensitive] | \u003ccode\u003eboolean\u003c/code\u003e | \u003ccode\u003efalse\u003c/code\u003e | If true no case conversion is performed from the dot path provided to the env key search. Eg: 'tesT.kEy' will look for tesT_kEy environment variable instead of TEST_KEY. |\n\n## Authors\n\n- **Simone Primarosa** - *Github* ([@simonepri][github:simonepri]) • *Twitter* ([@simoneprimarosa][twitter:simoneprimarosa])\n\nSee also the list of [contributors][contributors] who participated in this project.\n\n## License\n\nThis project is licensed under the MIT License - see the [license][license] file for details.\n\n\n\u003c!-- Links --\u003e\n[start]: https://github.com/simonepri/env-dot-prop#start-of-content\n[new issue]: https://github.com/simonepri/env-dot-prop/issues/new\n[contributors]: https://github.com/simonepri/env-dot-prop/contributors\n\n[license]: https://github.com/simonepri/env-dot-prop/tree/master/license\n\n[github:simonepri]: https://github.com/simonepri\n[twitter:simoneprimarosa]: http://twitter.com/intent/user?screen_name=simoneprimarosa\n\n[12factors]: https://12factor.net/config\n[12factorsguide]: https://github.com/simonepri/env-dot-prop/wiki/Create-a-12-factor-compliant-configuration-system\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonepri%2Fenv-dot-prop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimonepri%2Fenv-dot-prop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonepri%2Fenv-dot-prop/lists"}