Skip to content

Commit

Permalink
perf(api): move message to posthtml constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
Scrum committed Feb 9, 2018
1 parent dcdb3e7 commit c51e40f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 22 deletions.
22 changes: 0 additions & 22 deletions lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,6 @@
function Api () {
this.walk = walk
this.match = match
/**
* Tree messages to store and pass metadata between plugins
*
* @memberof tree
* @type {Array} messages
*
* @example
* ```js
* export default function plugin (options = {}) {
* return function (tree) {
* tree.messages.push({
* type: 'dependency',
* file: 'path/to/dependency.html',
* from: tree.options.from
* })
*
* return tree
* }
* }
* ```
*/
this.messages = []
}

/**
Expand Down
24 changes: 24 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,30 @@ function PostHTML (plugins) {
this.name = pkg.name
this.plugins = typeof plugins === 'function' ? [plugins] : plugins || []

/**
* Tree messages to store and pass metadata between plugins
*
* @memberof tree
* @type {Array} messages
*
* @example
* ```js
* export default function plugin (options = {}) {
* return function (tree) {
* tree.messages.push({
* type: 'dependency',
* file: 'path/to/dependency.html',
* from: tree.options.from
* })
*
* return tree
* }
* }
* ```
*/
this.messages = []

// extend api methods
Api.call(this)
}

Expand Down

0 comments on commit c51e40f

Please sign in to comment.