{"id":25180638,"url":"https://github.com/base-repos/base-plugins","last_synced_at":"2025-05-07T06:04:32.929Z","repository":{"id":57163573,"uuid":"43847200","full_name":"base-repos/base-plugins","owner":"base-repos","description":"Add \"smart plugin\" support to your base application. Adds a `.run` method, allowing plugins to be called on a given object, at any time.","archived":false,"fork":false,"pushed_at":"2017-04-01T19:39:25.000Z","size":36,"stargazers_count":21,"open_issues_count":2,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-30T00:34:52.106Z","etag":null,"topics":["assemble","base","generate","plugin","plugins","smart-plugin","toolkit","update","verb"],"latest_commit_sha":null,"homepage":"https://github.com/node-base","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/base-repos.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-10-07T22:00:11.000Z","updated_at":"2025-01-31T00:40:55.000Z","dependencies_parsed_at":"2022-09-01T00:21:07.217Z","dependency_job_id":null,"html_url":"https://github.com/base-repos/base-plugins","commit_stats":null,"previous_names":["node-base/base-plugins","base-repos/base-plugins"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/base-repos%2Fbase-plugins","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/base-repos%2Fbase-plugins/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/base-repos%2Fbase-plugins/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/base-repos%2Fbase-plugins/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/base-repos","download_url":"https://codeload.github.com/base-repos/base-plugins/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252522171,"owners_count":21761685,"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":["assemble","base","generate","plugin","plugins","smart-plugin","toolkit","update","verb"],"created_at":"2025-02-09T16:19:11.034Z","updated_at":"2025-05-07T06:04:32.908Z","avatar_url":"https://github.com/base-repos.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# base-plugins [![NPM version](https://img.shields.io/npm/v/base-plugins.svg?style=flat)](https://www.npmjs.com/package/base-plugins) [![NPM monthly downloads](https://img.shields.io/npm/dm/base-plugins.svg?style=flat)](https://npmjs.org/package/base-plugins)  [![NPM total downloads](https://img.shields.io/npm/dt/base-plugins.svg?style=flat)](https://npmjs.org/package/base-plugins) [![Linux Build Status](https://img.shields.io/travis/node-base/base-plugins.svg?style=flat\u0026label=Travis)](https://travis-ci.org/node-base/base-plugins)\n\n\u003e Adds 'smart plugin' support to your base application.\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/):\n\n```sh\n$ npm install --save base-plugins\n```\n\n**What does this do?**\n\nThis plugin augments the generic plugin functionality that ships with [base](https://github.com/node-base/base).\n\n* Without this plugin, any plugins that registered with the `use` method and are only called once upon init.\n* With this plugin, other plugins that return a function will be pushed onto a `plugins` array, and can be called again later with the `run` method.\n\n## Usage\n\n```js\nvar plugins = require('base-plugins');\nvar Base = require('base');\nvar base = new Base();\n\n// register the `plugins` plugin\nbase.use(plugins());\n```\n\n## Examples\n\n### .use example\n\nOnce the `use` method is called:\n\n1. a `fns` array is added to the instance for storing plugin functions\n2. a `run` method is added to the instance for running stored plugins\n3. the `use` method is modified so that anytime a function is returned by a plugin, the function will be pushed onto the `fns` array. Aside from that, you shouldn't see any difference in how the `use` method works.\n\n## .run example\n\nThe `run` method iterates over the `fns` array and calls each stored plugin function on the given object.\n\n```js\nvar collection = {};\nbase.use(function(app) {\n  app.x = 'y';\n  return function(obj) {\n    obj.a = 'b';\n  };\n});\nbase.run(collection);\n\nconsole.log(base.x);\n//=\u003e 'y'\nconsole.log(collection.a);\n//=\u003e 'b'\n```\n\n## API\n\n### [.use](index.js#L54)\n\nDefine a plugin function to be called immediately upon init. The only parameter exposed to the plugin is the application instance.\n\nAlso, if a plugin returns a function, the function will be pushed\nonto the `fns` array, allowing the plugin to be called at a\nlater point, elsewhere in the application.\n\n**Params**\n\n* `fn` **{Function}**: plugin function to call\n* `returns` **{Object}**: Returns the item instance for chaining.\n\n**Example**\n\n```js\n// define a plugin\nfunction foo(app) {\n  // do stuff\n}\n\n// register plugins\nvar app = new Base()\n  .use(foo)\n  .use(bar)\n  .use(baz)\n```\n\n### [.run](index.js#L69)\n\nRun all plugins\n\n**Params**\n\n* `value` **{Object}**: Object to be modified by plugins.\n* `returns` **{Object}**: Returns the item instance for chaining.\n\n**Example**\n\n```js\nvar config = {};\napp.run(config);\n```\n\n## About\n\n### Related projects\n\n* [base-cli](https://www.npmjs.com/package/base-cli): Plugin for base-methods that maps built-in methods to CLI args (also supports methods from a… [more](https://github.com/node-base/base-cli) | [homepage](https://github.com/node-base/base-cli \"Plugin for base-methods that maps built-in methods to CLI args (also supports methods from a few plugins, like 'base-store', 'base-options' and 'base-data'.\")\n* [base-config](https://www.npmjs.com/package/base-config): base-methods plugin that adds a `config` method for mapping declarative configuration values to other 'base… [more](https://github.com/node-base/base-config) | [homepage](https://github.com/node-base/base-config \"base-methods plugin that adds a `config` method for mapping declarative configuration values to other 'base' methods or custom functions.\")\n* [base-data](https://www.npmjs.com/package/base-data): adds a `data` method to base-methods. | [homepage](https://github.com/node-base/base-data \"adds a `data` method to base-methods.\")\n* [base-fs](https://www.npmjs.com/package/base-fs): base-methods plugin that adds vinyl-fs methods to your 'base' application for working with the file… [more](https://github.com/node-base/base-fs) | [homepage](https://github.com/node-base/base-fs \"base-methods plugin that adds vinyl-fs methods to your 'base' application for working with the file system, like src, dest, copy and symlink.\")\n* [base-option](https://www.npmjs.com/package/base-option): Adds a few options methods to base, like `option`, `enable` and `disable`. See the readme… [more](https://github.com/node-base/base-option) | [homepage](https://github.com/node-base/base-option \"Adds a few options methods to base, like `option`, `enable` and `disable`. See the readme for the full API.\")\n* [base](https://www.npmjs.com/package/base): Framework for rapidly creating high quality node.js applications, using plugins like building blocks | [homepage](https://github.com/node-base/base \"Framework for rapidly creating high quality node.js applications, using plugins like building blocks\")\n\n### Contributing\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).\n\n### Building docs\n\n_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_\n\nTo generate the readme, run the following command:\n\n```sh\n$ npm install -g verbose/verb#dev verb-generate-readme \u0026\u0026 verb\n```\n\n### Running tests\n\nRunning and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:\n\n```sh\n$ npm install \u0026\u0026 npm test\n```\n\n### Author\n\n**Jon Schlinkert**\n\n* [github/jonschlinkert](https://github.com/jonschlinkert)\n* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)\n\n### License\n\nCopyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).\nReleased under the [MIT License](LICENSE).\n\n***\n\n_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.4.3, on April 01, 2017._","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbase-repos%2Fbase-plugins","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbase-repos%2Fbase-plugins","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbase-repos%2Fbase-plugins/lists"}