Gathering detailed insights and metrics for base-compose
Gathering detailed insights and metrics for base-compose
Gathering detailed insights and metrics for base-compose
Gathering detailed insights and metrics for base-compose
npm install base-compose
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
4 Stars
69 Commits
3 Watching
1 Branches
3 Contributors
Updated on 13 Sept 2022
Minified
Minified + Gzipped
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
3.1%
4,107
Compared to previous day
Last week
3.6%
22,675
Compared to previous week
Last month
9.9%
89,782
Compared to previous month
Last year
63.4%
1,737,362
Compared to previous year
Selectively merge values from one or more generators onto the current application instance.
Install with npm:
1$ npm install --save base-compose
This plugin requires the base-generators to be registered first. If not already registered, you can do so now by following these instructions.
1var compose = require('base-compose'); 2var Base = require('base'); 3var app = new Base(); 4 5// register the "compose" plugin 6app.use(compose());
Heads up!
Some of the methods exposed on .compose expect for app
to be an instance of templates, or for specific plugins to be registered first.
You don't need to register all of the plugins prescribed below, just use the plugins you need with the methods you need. base-compose
will give you detailed error messages when something is missing.
More information is provided in the methods documentation below.
Setup a composition by passing in an array of generators to compose elements. If a generator cannot be found, an error will be thrown.
Params
parent
{Object}: Parent generator to lookup generators.names
{String|Array}: One or more generator names or instances.returns
{Object}: Returns an instance of Compose
Example
1app.compose(base, ['a', 'b', 'c']) 2 .data() 3 .options() 4 .helpers() 5 .views();
Merge the options from each generator into the app
options. This method requires using the [base-option][base-option] plugin.
Params
key
{String}: Optionally pass the name of a property to merge from the options
object. Dot-notation may be used for nested properties.returns
{Object}: Returns the Compose
instance for chainingExample
1a.option({foo: 'a'}); 2b.option({foo: 'b'}); 3c.option({foo: 'c'}); 4 5app.compose(base, ['a', 'b', 'c']) 6 .options(); 7 8console.log(app.options); 9//=> {foo: 'c'}
Merge the cache.data
object from each generator onto the app.cache.data
object. This method requires the .data()
method from templates.
Params
key
{String}: Optionally pass a key to merge from the data
object.returns
{Object}: Returns the Compose
instance for chainingExample
1a.data({foo: 'a'}); 2b.data({foo: 'b'}); 3c.data({foo: 'c'}); 4 5app.compose(base, ['a', 'b', 'c']) 6 .data(); 7 8console.log(app.cache.data); 9//=> {foo: 'c'}
Merge the engines from each generator into the app
engines. This method requires the .engine()
methods from templates.
returns
{Object}: Returns the Compose
instance for chainingExample
1app.compose(base, ['a', 'b', 'c']) 2 .engines();
Merge the helpers from each generator into app.helpers
. Requires the .helper
method from templates.
returns
{Object}: Returns the Compose
instance for chainingExample
1app.compose(base, ['a', 'b', 'c']) 2 .helpers();
Merge generator.questions.cache
from specified generators onto app.questions.cache
. Requires the base-questions plugin to be registered.
returns
{Object}: Returns the Compose
instance for chainingExample
1app.compose(base, ['a', 'b', 'c']) 2 .questions();
Merge the pipeline plugins from each generator onto app.plugins
. Requires the base-pipeline plugin to be registered.
returns
{Object}: Returns the Compose
instance for chainingExample
1app.compose(base, ['a', 'b', 'c']) 2 .pipeline();
Copy the specified tasks and task-dependencies from each generator onto app.tasks
. Requires using the base-task plugin to be registered.
Params
tasks
{String|Array}: One or more task names (optional)returns
{Object}: Returns the Compose
instance for chainingExample
1app.compose(base, ['a', 'b', 'c']) 2 .tasks(['foo', 'bar', 'default']); 3 4// or to copy all tasks 5app.compose(base, ['a', 'b', 'c']) 6 .tasks();
Copy view collections and views from each generator onto app
. Expects app
to be an instance of templates.
Params
names
{Array|String}: (optional) Names of one or more collections to copy. If undefined all collections will be copied.filter
{Function}: Optionally pass a filter function to filter views copied from each collection. The filter function exposes key
, view
and collection
as arguments. If used, the function must return true
to copy a view.returns
{Object}: Returns the Compose
instance for chainingExample
1app.compose(base, ['a', 'b', 'c']) 2 .views();
Returns an iterator function for iterating over an array of generators. The iterator takes a fn
that exposes the current generator being iterated over (generator
) and the app passed into the original function as arguments. No binding is done within the iterator so the function passed in can be safely bound.
Params
names
{Array}: Names of generators to iterate over (optional).iteratorFn
{Function}: Function to invoke for each generator in generators
. Exposes app
and generator
as arguments.returns
{Object}: Returns the Compose
instance for chainingExample
1app.compose(base, ['a', 'b', 'c']) 2 .iterator(function(generator, app) { 3 // do work 4 app.data(generator.cache.data); 5 }); 6 7// optionally pass an array of additional generator names as the 8// first argument. If generator names are defined on `iterator`, 9// any names passed to `.compose()` will be ignored. 10app.compose(base, ['a', 'b', 'c']) 11 .iterator(['d', 'e', 'f'], function(generator, app) { 12 // do stuff to `generator` and `app` 13 });
Follow these instructions to install and register the base-generators plugin before registering base-compose
.
Install base-generators
1$ npm install base-generators --save
Register base-generators
1var generators = require('base-generators'); 2var compose = require('base-compose'); 3var Base = require('base'); 4var app = new Base(); 5 6// register plugins 7app.use(generators()); 8app.use(compose());
You might also be interested in these projects:
This document was generated by verb-readme-generator (a verb generator), please don't edit directly. Any changes to the readme must be made in .verb.md. See Building Docs.
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue. Or visit the verb-readme-generator project to submit bug reports or pull requests for the readme layout template.
Generate readme and API documentation with verb:
1$ npm install -g verb verb-readme-generator && verb
Install dev dependencies:
1$ npm install -d && npm test
Brian Woodward
Copyright © 2016, Brian Woodward. Released under the MIT license.
This file was generated by verb, v0.9.0, on June 11, 2016.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
security policy file not detected
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More