{"id":20038509,"url":"https://github.com/yahoo/ycb","last_synced_at":"2025-04-12T21:26:15.276Z","repository":{"id":4301034,"uuid":"5432651","full_name":"yahoo/ycb","owner":"yahoo","description":"A multi-dimensional configuration library that builds bundles from resource files describing a variety of values.","archived":false,"fork":false,"pushed_at":"2025-03-24T16:01:02.000Z","size":465,"stargazers_count":67,"open_issues_count":1,"forks_count":24,"subscribers_count":25,"default_branch":"main","last_synced_at":"2025-04-04T00:11:30.425Z","etag":null,"topics":["configuration-library","javascript","web"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yahoo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2012-08-15T23:01:17.000Z","updated_at":"2025-03-24T16:01:06.000Z","dependencies_parsed_at":"2023-07-06T09:33:26.031Z","dependency_job_id":"ba7663db-2ce9-4914-affc-d29f9de9edc6","html_url":"https://github.com/yahoo/ycb","commit_stats":{"total_commits":176,"total_committers":23,"mean_commits":"7.6521739130434785","dds":0.7272727272727273,"last_synced_commit":"2285901914229754705881a029b26a44ff5972fd"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yahoo%2Fycb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yahoo%2Fycb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yahoo%2Fycb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yahoo%2Fycb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yahoo","download_url":"https://codeload.github.com/yahoo/ycb/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248633451,"owners_count":21136872,"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":["configuration-library","javascript","web"],"created_at":"2024-11-13T10:29:36.211Z","updated_at":"2025-04-12T21:26:15.255Z","avatar_url":"https://github.com/yahoo.png","language":"JavaScript","readme":"# Yahoo! Configuration Bundle\n\n![Build Status](https://github.com/yahoo/ycb/actions/workflows/node.js.yml/badge.svg)\n\nYCB is a multi-dimensional configuration library that builds bundles from resource files describing a variety of values. The library allows applications to configure themselves based on multiple dimensions describing locations, languages, environments, etc.\n\n### Install\n\n`npm install ycb --save`\n\n### Usage\n\n```js\nimport YCB from 'ycb';\nconst configArray = [\n    {\n        dimensions: [\n            {\n                environment: {\n                    dev: null,\n                    staging: null,\n                    test: null,\n                    prod: null,\n                },\n            },\n            {\n                device: {\n                    desktop: null,\n                    mobile: {\n                        tablet: null,\n                        smartphone: null,\n                    },\n                },\n            },\n        ],\n    },\n    {\n        settings: ['main'],\n        host: 'example.com',\n        prefix: null,\n    },\n    {\n        settings: ['environment:dev'],\n        host: 'dev.example.com',\n    },\n    {\n        settings: ['environment:staging,test'],\n        host: 'stage.example.com',\n    },\n    {\n        settings: ['device:smartphone'],\n        prefix: 'm.',\n    },\n];\n\nconst ycbObj = new YCB.Ycb(configArray);\nconst computedConfig = ycbObj.read({ environment: 'dev' });\n\nconsole.log(computedConfig.host); // dev.example.com\n```\n\n### Scheduling Changes\n\nWe can schedule configuration changes ahead of time by defining an interval along with a config and using the time aware read method. For example the following program.\n\n```js\nimport YCB from 'ycb';\nconst configArray = [\n    {\n        dimensions: [\n            {\n                environment: {\n                    dev: null,\n                    staging: null,\n                    test: null,\n                    prod: null,\n                },\n            },\n            {\n                region: {\n                    us: null,\n                    ca: null,\n                },\n            },\n        ],\n    },\n    {\n        settings: ['main'],\n        host: 'example.com',\n    },\n    {\n        settings: {\n            dimensions: ['region:us'],\n        },\n        logo: 'logo.png',\n    },\n    {\n        settings: {\n            dimensions: ['region:us'],\n            schedule: {\n                start: '2019-11-28T00:04:00Z',\n                end: '2019-11-29T00:04:00Z',\n            },\n        },\n        logo: 'thanksgiving-logo.png',\n    },\n];\n\nconst ycbObj = new YCB.Ycb(configArray, { cacheInfo: true });\nconst config1 = ycbObj.readTimeAware({ region: 'us' }, 0);\nconst config2 = ycbObj.readTimeAware({ region: 'us' }, 1574899440000);\nconst config3 = ycbObj.readTimeAware({ region: 'us' }, 1574985840001);\nconsole.log(config1);\nconsole.log(config2);\nconsole.log(config3);\n```\n\nwill print\n\n```js\n{ host: 'example.com',\n  logo: 'logo.png',\n  __ycb_expires_at__: 1574899440000 }\n{ host: 'example.com',\n  logo: 'thanksgiving-logo.png',\n  __ycb_expires_at__: 1574985840001 }\n{ host: 'example.com', logo: 'logo.png' }\n```\n\nThese intervals are closed and either `start` or `end` may be omitted to define a one sided interval.\n\nTo support proper cache expiration one may set the `cacheInfo` option, in which case the next time the config will change is added to the returned object.\n\n### Examples\n\nExamples are provided in [the tests directory](https://github.com/yahoo/ycb/tree/main/tests).\n\n### License\n\nBSD see LICENSE.txt\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyahoo%2Fycb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyahoo%2Fycb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyahoo%2Fycb/lists"}