{"id":15743630,"url":"https://github.com/doowb/map-config","last_synced_at":"2025-03-13T10:30:47.743Z","repository":{"id":57291146,"uuid":"42899637","full_name":"doowb/map-config","owner":"doowb","description":"Map configuration objects to application methods.","archived":false,"fork":false,"pushed_at":"2016-02-24T04:37:55.000Z","size":49,"stargazers_count":5,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-11T03:58:19.030Z","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":"2015-09-21T23:38:31.000Z","updated_at":"2021-04-12T22:04:14.000Z","dependencies_parsed_at":"2022-09-01T15:21:29.256Z","dependency_job_id":null,"html_url":"https://github.com/doowb/map-config","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doowb%2Fmap-config","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doowb%2Fmap-config/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doowb%2Fmap-config/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doowb%2Fmap-config/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/doowb","download_url":"https://codeload.github.com/doowb/map-config/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221360656,"owners_count":16805031,"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":[],"created_at":"2024-10-04T03:20:48.694Z","updated_at":"2024-10-24T23:21:17.100Z","avatar_url":"https://github.com/doowb.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# map-config [![NPM version](https://img.shields.io/npm/v/map-config.svg)](https://www.npmjs.com/package/map-config) [![Build Status](https://img.shields.io/travis/doowb/map-config.svg)](https://travis-ci.org/doowb/map-config)\n\n\u003e Map configuration objects to application methods.\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/):\n\n```sh\n$ npm i map-config --save\n```\n\n## Usage\n\n```js\nvar MapConfig = require('map-config');\n```\n\n## API\n\n### [MapConfig](index.js#L24)\nCreate a new instance of MapConfig with a specified map and application.\n\n**Params**\n\n* `app` **{Object}**: Object containing the methods that will be called based on the map specification.    \n* `map` **{Object}**: Optional object specifying how to map a configuration to an application.    \n\n**Example**\n\n```js\nvar mapper = new MapConfig(app, map);\n```\n\n### [.map](index.js#L63)\nMap properties to methods and/or functions.\n\n**Params**\n\n* `key` **{String}**: property key to map.    \n* `val` **{Function|Object}**: Optional function to call when a config has the given key. Functions will be passed `(val, key, config)` when called. Functions may also take a callback to indicate async usage. May also pass another instance of MapConfig to be processed.    \n* `returns` **{Object}** `this`: to enable chaining  \n\n**Example**\n\n```js\nmapper\n  .map('baz')\n  .map('bang', function(val, key, config) {\n  });\n```\n\n### [.alias](index.js#L122)\nCreate an `alias` for property `key`.\n\n**Params**\n\n* `alias` **{String}**: Alias to use for `key`.    \n* `key` **{String}**: Actual property or method on `app`.    \n* `returns` **{Object}**: Returns the instance for chaining.  \n\n**Example**\n\n```js\nmapper.alias('foo', 'bar');\n```\n\n### [.process](index.js#L143)\nProcess a configuration object with the already configured `map` and `app`.\n\n**Params**\n\n* `config` **{Object}**: Configuration object to map to application methods.    \n* `cb` **{Function}**: Optional callback function that will be called when finished or if an error occurs during processing.    \n\n**Example**\n\n```js\nmapper.process(config);\n```\n\n### [.addKey](index.js#L217)\nAdd a key to the `.keys` array. May also be used to add an array of namespaced keys to the `.keys` array. Useful for mapping \"sub-configs\" to a key in a parent config.\n\n**Params**\n\n* `key` **{String}**: key to push onto `.keys`    \n* `arr` **{Array}**: Array of sub keys to push onto `.keys`    \n* `returns` **{Object}** `this`: for chaining  \n\n**Example**\n\n```js\nmapper.addKey('foo');\nconsole.log(mapper.keys);\n//=\u003e ['foo']\n\nvar one = new MapConfig();\nvar two = new MapConfig();\ntwo.map('foo');\ntwo.map('bar');\ntwo.map('baz');\n\n// map config `two` to config `one`\none.map('two', function(val, key, config, next) {\n  two.process(val, next);\n});\n\n// map keys from config `two` to config `one`\none.addKey('two', two.keys);\nconsole.log(one.keys);\n//=\u003e ['two.foo', 'two.bar', 'two.baz']\n```\n\n## Related projects\n* [assemble](https://www.npmjs.com/package/assemble): Assemble is a powerful, extendable and easy to use static site generator for node.js. Used… [more](https://www.npmjs.com/package/assemble) | [homepage](https://github.com/assemble/assemble)\n* [generate](https://www.npmjs.com/package/generate): Fast, composable, highly extendable project generator with a user-friendly and expressive API. | [homepage](https://github.com/generate/generate)\n* [templates](https://www.npmjs.com/package/templates): System for creating and managing template collections, and rendering templates with any node.js template engine.… [more](https://www.npmjs.com/package/templates) | [homepage](https://github.com/jonschlinkert/templates)\n* [update](https://www.npmjs.com/package/update): Easily keep anything in your project up-to-date by installing the updaters you want to use… [more](https://www.npmjs.com/package/update) | [homepage](https://github.com/update/update)\n* [verb](https://www.npmjs.com/package/verb): Documentation generator for GitHub projects. Verb is extremely powerful, easy to use, and is used… [more](https://www.npmjs.com/package/verb) | [homepage](https://github.com/verbose/verb)\n\n## Running tests\nInstall dev dependencies:\n\n```sh\n$ npm i -d \u0026\u0026 npm test\n```\n\n## Contributing\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/doowb/map-config/issues/new).\n\n## Author\n**Brian Woodward**\n\n+ [github/doowb](https://github.com/doowb)\n+ [twitter/doowb](http://twitter.com/doowb)\n\n## License\nCopyright © 2016 [Brian Woodward](https://github.com/doowb)\nReleased under the [MIT license](https://github.com/doowb/map-config/blob/master/LICENSE).\n\n***\n\n_This file was generated by [verb](https://github.com/verbose/verb), v0.1.0, on February 23, 2016._\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoowb%2Fmap-config","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdoowb%2Fmap-config","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoowb%2Fmap-config/lists"}