{"name":"ycb","version":"2.3.0","description":"YCB is a multi-dimensional configuration library that builds bundles from resource files describing a variety of values.","author":{"name":"Ric Allinson","email":"allinson@yahoo-inc.com"},"license":"BSD","contributors":[{"name":"Drew Folta","email":"folta@yahoo-inc.com"},{"name":"Michael Ridgway","email":"mridgway@yahoo-inc.com"},{"name":"Caridy Patino","email":"caridy@yahoo-inc.com"},{"name":"Isao Yagi","email":"isao@yahoo-inc.com"}],"main":"index","scripts":{"cover":"nyc npm run test","lint":"eslint . && prettier --check .","lint:fix":"eslint . --fix && prettier --write .","pretest":"npm run lint","test":"mocha tests/unit --recursive --reporter spec","posttest":"node -r ./tests/edgeRuntime.js ./node_modules/.bin/mocha tests/unit --recursive --reporter spec"},"devDependencies":{"eslint":"^9.0.0","mocha":"^10.0.0","nyc":"^17.0.0","prettier":"^3.0.0"},"repository":{"type":"git","url":"git://github.com/yahoo/ycb.git"},"bugs":{"url":"https://github.com/yahoo/ycb/issues"},"prettier":{"printWidth":120,"singleQuote":true,"tabWidth":4},"_id":"ycb@2.3.0","gitHead":"7abffb55e61eaa2961c31397d4beb5d81234efdc","homepage":"https://github.com/yahoo/ycb#readme","_nodeVersion":"20.16.0","_npmVersion":"10.8.1","dist":{"integrity":"sha512-cT7iPmHhT40SSE++JTzLNJZ0pyhL7teHxVDPcML9R0bi8Gsht0X9uMnZ4NjlSUzDpIVxSiPFHuGS5T+cVtaQAA==","shasum":"ab1652fd2db3c69032dd1a1fea7424e82a4dadda","tarball":"http://registry-npm.ywwl.com/ycb/download/ycb-2.3.0.tgz","fileCount":12,"unpackedSize":53780,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEEmNozx9vaH1hMZy0/blUbn8d6gh1glCTCg43NqvJfgAiEAooXNhOOPeHH+dHOheZsUOhGOtMVAhT0Bw3nhHnr/M7s="}],"size":11565,"noattachment":false,"key":"/ycb/-/ycb-2.3.0.tgz"},"_npmUser":{"name":"snyamathi","email":"snyamathi@gmail.com"},"directories":{},"maintainers":[{"name":"caridy","email":"caridy@gmail.com"},{"name":"snyamathi","email":"snyamathi@gmail.com"},{"name":"drewfolta","email":"drew@folta.net"},{"name":"redonkulus","email":"seth@bertalotto.net"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ycb_2.3.0_1726157964986_0.18690527049556582"},"_hasShrinkwrap":false,"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","publish_time":1726157965182,"_cnpm_publish_time":1726157965182,"dist-tags":{"beta":"1.0.5","latest":"2.3.0"}}