{"id":15931832,"url":"https://github.com/victornpb/default-args","last_synced_at":"2025-03-06T16:48:25.877Z","repository":{"id":57685791,"uuid":"492247485","full_name":"victornpb/default-args","owner":"victornpb","description":"A simple function for providing default options to arguments. No dependencies, tiny amount of code.","archived":false,"fork":false,"pushed_at":"2023-01-26T15:57:17.000Z","size":538,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-24T23:36:26.713Z","etag":null,"topics":["arguments","deep","default","defaults","extend","extends","options","parameters","recursive"],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/default-args","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/victornpb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"custom":["https://www.buymeacoffee.com/vitim"],"github":null,"patreon":null,"open_collective":null,"ko_fi":"victornpb","tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null}},"created_at":"2022-05-14T15:00:37.000Z","updated_at":"2022-06-03T22:41:27.000Z","dependencies_parsed_at":"2023-02-14T19:16:14.595Z","dependency_job_id":null,"html_url":"https://github.com/victornpb/default-args","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":"victornpb/template-library-with-rollup","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/victornpb%2Fdefault-args","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/victornpb%2Fdefault-args/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/victornpb%2Fdefault-args/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/victornpb%2Fdefault-args/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/victornpb","download_url":"https://codeload.github.com/victornpb/default-args/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242250437,"owners_count":20096891,"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":["arguments","deep","default","defaults","extend","extends","options","parameters","recursive"],"created_at":"2024-10-07T01:40:29.820Z","updated_at":"2025-03-06T16:48:25.849Z","avatar_url":"https://github.com/victornpb.png","language":"JavaScript","readme":"# default-args\n\u003c!-- badge --\u003e\n[![Version](https://img.shields.io/npm/v/default-args.svg?style=flat-square)](https://www.npmjs.com/package/default-args)\n[![CodeFactor](https://www.codefactor.io/repository/github/victornpb/default-args/badge?style=flat-square)](https://www.codefactor.io/repository/github/victornpb/default-args)\n![Snyk Vulnerabilities for GitHub Repo](https://img.shields.io/snyk/vulnerabilities/github/victornpb/tiny-dedent?style=flat-square)\n[![bundlephobia](https://img.shields.io/bundlephobia/minzip/default-args?style=flat-square)](https://www.npmjs.com/package/default-args)\n\n[![Downloads](https://img.shields.io/npm/dt/default-args.svg?style=flat-square)](https://www.npmjs.com/package/default-args)\n[![Node](https://img.shields.io/node/v/default-args.svg?style=flat-square)](package.json)\n[![LICENSE](https://img.shields.io/github/license/victornpb/default-args?style=flat-square)](LICENSE)\n\u003c!-- endbadge --\u003e\n\n![carbon-3](https://user-images.githubusercontent.com/3372598/175796626-18513d8d-06ad-4cbc-a17d-5f67f7248e5a.png)\n\nA simple function for providing defaults to an options to argument. No dependencies, tiny amount of code.\n\ndefault-args makes input validation simpler, by always ensuring you will have well defined object shape you can work with.\n\nIt also prevents the inclusion of extraneous properties by only copying properties that are defined in the default options object. This ensures that the final object only contains the properties that are specified. This not only prevents unexpected behavior but also potential security vulnerabilities caused by the inclusion of extraneous properties.\n\nBy using this package you also eliminate a class of vulnerability called [object prototype pollution](https://learn.snyk.io/lessons/prototype-pollution/javascript/) by correctly handling options.\n\n\n## Usage\n\n```js\nimport defaults from 'default-args';\n\nfunction helloWorld(options) {\n    options = defaults({\n        foo: true,\n        bar: {\n            a: 1,\n            b: 2,\n        },\n    }, options);\n\n    // do something with options\n}\n```\n## Installation\n\n### [NPM](https://npmjs.com/package/default-args)\n\n    npm install default-args\n### [Yarn](https://github.com/yarnpkg/yarn)\n\n    yarn add default-args\n\n### CDN\n\n    \u003cscript type=\"text/javascript\" src=\"https://unpkg.com/default-args/\"\u003e\u003c/script\u003e\n\n## Packages\n\n\u003c!-- Output table (auto generated do not modify) --\u003e\n\n| File                      | Module Type | Transpiled | Source Maps |\n|---------------------------|-------------|------------|-------------|\n| dist/default-args.esm.mjs | esm         | No         | No          |\n| dist/default-args.cjs.js  | cjs         | Yes        | Yes         |\n| dist/default-args.esm.js  | esm         | Yes        | Yes         |\n| dist/default-args.js      | umd         | Yes        | Yes         |\n\n\u003c!-- END --\u003e\n\n\n\n## License\n\nThe code is available under the [MIT](LICENSE) license.\n\n## Contributing\n\nWe are open to contributions, see [CONTRIBUTING.md](CONTRIBUTING.md) for more info.\n","funding_links":["https://www.buymeacoffee.com/vitim","https://ko-fi.com/victornpb"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvictornpb%2Fdefault-args","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvictornpb%2Fdefault-args","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvictornpb%2Fdefault-args/lists"}