{"id":15743597,"url":"https://github.com/doowb/context-manager","last_synced_at":"2025-09-01T16:45:40.988Z","repository":{"id":19646004,"uuid":"22898452","full_name":"doowb/context-manager","owner":"doowb","description":"Manage context for templates.","archived":false,"fork":false,"pushed_at":"2015-02-21T06:35:18.000Z","size":152,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-08-21T09:38:12.147Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/doowb.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":"2014-08-13T01:34:22.000Z","updated_at":"2021-04-12T22:09:51.000Z","dependencies_parsed_at":"2022-09-18T23:40:35.313Z","dependency_job_id":null,"html_url":"https://github.com/doowb/context-manager","commit_stats":null,"previous_names":["assemble/context-manager"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/doowb/context-manager","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doowb%2Fcontext-manager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doowb%2Fcontext-manager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doowb%2Fcontext-manager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doowb%2Fcontext-manager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/doowb","download_url":"https://codeload.github.com/doowb/context-manager/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doowb%2Fcontext-manager/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273158250,"owners_count":25055859,"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","status":"online","status_checked_at":"2025-09-01T02:00:09.058Z","response_time":120,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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-10-04T03:20:40.993Z","updated_at":"2025-09-01T16:45:40.961Z","avatar_url":"https://github.com/doowb.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# context-manager [![NPM version](https://badge.fury.io/js/context-manager.svg)](http://badge.fury.io/js/context-manager)\n\n\u003e Manage context for templates.\n\n## Install with [npm](npmjs.org)\n\n```bash\nnpm i context-manager --save\n```\n\n## Usage\n\n```js\nvar context = require('context-manager');\n```\n\n## API\n### [Context](index.js#L20)\n\n\nCreate an instance of `Context`.\n\n### [.setContext](index.js#L40)\n\nAdd a context level, optionally passing a value to start with.\n\n* `name` **{String}**: The name of the context to add.    \n* `level` **{Number}**: Numerical value representing the order in which this level should be merged versus other lvl.    \n* `value` **{Object}**: Optionally pass an object to start with.    \n\n```js\ncontext.setContext('locals', {a: 'b'});\n```\n\n### [.getContext](index.js#L60)\n\nGet the raw (un-merged) context for `name`.\n\n* `name` **{String}**: The context to get.    \n* `returns`: {*}  \n\n```js\ncontext.setContext('a', {a: 'b'});\ncontext.getContext('a');\n// =\u003e {a: 'b'}\n```\n\n### [.extendContext](index.js#L78)\n\nExtend context `name` with the given `value`\n\n* `name` **{String}**    \n* `key` **{String}**    \n* `value` **{Object}**    \n* `returns`: {String}  \n\n```js\ncontext.setContext('locals', {a: 'b'});\n```\n\n### [.setLevel](index.js#L107)\n\nSet the level for a context. This determines the order in which the context will be merged when `.calculate()` is called.\n\n* `name` **{String}**: The name of the context.    \n* `level` **{Number}**: The level (number) to set for the level.    \n\n```js\nif (foo) {\n  context.setLevel('locals', 10);\n} else {\n  context.setLevel('locals', 0);\n}\n```\n\n### [.calculate](index.js#L142)\n\nCalculate the context, optionally passing a callback `fn` for sorting. _(Note that sorting must be done on levels, not on the context names)_.\n\n* `keys` **{String|Array}**: Key, or array of keys for context levels to include.    \n* `fn` **{Function}**: Sort function for determining the order of merging.    \n\n```js\napp.calculate(['a', 'b'], function(a, b) {\n  return app.lvl[a] - app.lvl[a];\n});\n```\n\n### [.resetContexts](index.js#L166)\n\n\nClear all contexts.\n\n## Author\n\n**Jon Schlinkert**\n \n+ [github/assemble](https://github.com/assemble)\n+ [twitter/assemble](http://twitter.com/assemble) \n\n## License\nCopyright (c) 2015 Jon Schlinkert  \nReleased under the  license\n\n***\n\n_This file was generated by [verb](https://github.com/assemble/verb) on February 21, 2015._","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoowb%2Fcontext-manager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdoowb%2Fcontext-manager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoowb%2Fcontext-manager/lists"}