{"id":21270429,"url":"https://github.com/dan503/defaultto","last_synced_at":"2026-02-13T10:19:17.592Z","repository":{"id":57211798,"uuid":"73162095","full_name":"Dan503/defaultTo","owner":"Dan503","description":"Easily set defaults to an object at multiple depths","archived":false,"fork":false,"pushed_at":"2016-11-20T00:50:06.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-08-29T22:00:40.411Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"HTML","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/Dan503.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":"2016-11-08T07:50:57.000Z","updated_at":"2016-11-20T00:37:49.000Z","dependencies_parsed_at":"2022-09-08T21:20:31.047Z","dependency_job_id":null,"html_url":"https://github.com/Dan503/defaultTo","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/Dan503/defaultTo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dan503%2FdefaultTo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dan503%2FdefaultTo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dan503%2FdefaultTo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dan503%2FdefaultTo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Dan503","download_url":"https://codeload.github.com/Dan503/defaultTo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dan503%2FdefaultTo/sbom","scorecard":{"id":36465,"data":{"date":"2025-08-11","repo":{"name":"github.com/Dan503/defaultTo","commit":"0d373d7f567a9b735722adf4f09c24d20073c6c1"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Code-Review","score":0,"reason":"Found 0/28 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-14T20:25:50.794Z","repository_id":57211798,"created_at":"2025-08-14T20:25:50.794Z","updated_at":"2025-08-14T20:25:50.794Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29401556,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-13T06:24:03.484Z","status":"ssl_error","status_checked_at":"2026-02-13T06:23:12.830Z","response_time":78,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2024-11-21T08:17:25.780Z","updated_at":"2026-02-13T10:19:17.552Z","avatar_url":"https://github.com/Dan503.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# defaultTo\nEasily set defaults to an object at multiple depths\n\n`````\nnpm install default-to --save\n`````\n\nThis function is essentially the opposite of my [replaceValues](https://www.npmjs.com/package/replace-values) function.\n\n##JS Usage\n\nThis is how you would use it in a javascript file\n\n###Single level\n\n`````js\nvar defaultTo = require('default-to');\n\nvar example = { one: 1 };\n\nvar defaultToExample = defaultTo(example, {\n    one: 'one',\n    two: 'two',\n    three: 'three'\n});\n`````\n\nIn this case `example` would now equal this:\n\n`````js\n{\n    one: 1,\n    two: 'two',\n    three: 'three'\n}\n`````\n\n###Nested\n\nThe function can also assign defaults to nested objects\n\n`````js\nvar defaultTo = require('default-to');\n\nvar example = {\n    one: {\n        number: 10,\n    }\n};\n\nvar defaultToExample = defaultTo(example, {\n    one: {\n        number: 1,\n        string: 'one'\n    },\n    two: {\n        number: 2,\n        string: 'two'\n    }\n});\n`````\n\nIn this case `defaultToExample` would now equal this:\n\n`````js\n{\n    one: {\n        number: 10,\n        string: 'one'\n    },\n    two: {\n        number: 2,\n        string: 'two'\n    }\n}\n`````\n\n###Flat\n\nYou can also just use it on flat variables\n\n`````js\nvar example = defaultTo(variable, 'default value');\n`````\n\nin the above code snippet, if `variable` is defined,  `example` would equal `variable` else it will equal `'default value'`. It is the equivelant of writing this:\n\n````js\nvar example = typeof variable !== 'undefined' ? variable : 'default value';\n````\n\n##Pug and Jade usage\n\nThis npm package also comes with [Pug and Jade](https://pugjs.org/api/getting-started.html) versions of the function. To use the function in your pug/jade templates add this to the top of your base pug/jade file:\n\n`````jade\ninclude ../../node_modules/default-to/defaultTo\n`````\n\nMake sure the path is correct, it will be different depending on your folder structure. It is a relative path from the file it is being included in. Also, note that there is no file extension in the example.\n\nAfter including that line, you can use it in the same ways that I have used it above except you need to make sure you nest the js inside a js block. This is especially usefull for mixins\n\n``````jade\nmixin module(spec)\n    -\n        spec = defaultTo(spec, {\n            classes: {\n                outer: 'outer',\n                inner: 'inner'\n            },\n        })\n    .module(class=spec.classes.outer)\n        .module__inner(class=spec.classes.inner)\n``````\n\n##More functionality\n\nThese features are only available in the js version and they assume you are able to use ES6 syntax.\n\n###applyDefaults\n\nThis is a small variation on the defaultTo function that overides the origional variable without having to reference it first.\n\n`````js\nimport { applyDefaults } from 'default-to';\n\nvar example = {\n    two: {\n        a: 'zzz'\n    }\n};\n\napplyDefaults(example, {\n    one: 1,\n    two : {\n        a: 'aaa',\n        b: 'bbb'\n    },\n    three: 3\n});\n\n//example now equals { one: 1, two: {a:'zzz', b: 'bbb' }, three: 3}\n`````\n\n**WARNING!!!** in order to use this version of defaultTo, `example` **must** already be defined as something.\n\nIn the standard defaultTo function you can get away with the variable being undefined when parsing it into the function but `applyDefaults` needs to at least have an empty object to be parsed into the function for it to work.\n\nYou can get around this by using it like this inside a function when es6 syntax is available to you.\n\n`````````js\nfunction funcName(variable = {}){\n    applyDefaults(variable, {\n        one: 'one',\n        two: 'two',\n        three: 'three'\n    });\n}\n`````````\n\n##Breaking changes\n\n**v2.0.0:** The replaceValues function has been moved from the default-to package into it's own [seperate npm package](https://www.npmjs.com/package/replace-values). Also the replaceValues function syntax is more reminiscent of the defaultTo function syntax in how it is used now rather than the applyDefaults syntax.\n\n##Developers\n\nWhen publishing, use the [babel-it](https://github.com/IonicaBizau/babel-it) npm plugin to to convert the js files into es5 syntax for better environment support.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdan503%2Fdefaultto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdan503%2Fdefaultto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdan503%2Fdefaultto/lists"}