panto-transformer

0.2.5 • Public • Published

panto-transformer

NPM version Downloads Build Status Coverage Status Dependency status Dev Dependency status

Base transformer for panto.

Transformer can transform the content or anything else of a file or multiple files.It is used to pipe into streams to a chain.

const Transformer = require('panto-transformer');
 
class CustomTransformer extends Transformer {
    transformAll(files) {
        return super.transformAll(files);
    }
    _transform(file) {
        return Promise.resolve(panto._.extend(file, {
            content: 'This is inserted by cutsom transformer'
        }));
    }
    isTorrential() {
        return false;
    }
    isCacheable() {
        return true;
    }
}
 
new CustomTransformer({
    isSkip: '3rd/*.js'
}).transformAll(files).then(...)

options

  • options: Object, options
  • options.isSkip: Boolean|Function|String|RegExp, if skip this transformer on the file
  • options.isCacheable: Boolean, if is cacheable, used by isCacheable function by default

apis

  • transformAll(array): Promise, call transform
  • transform(object): Promise, call _transform
  • isTorrential(): Boolean, if torrential, default false
  • isCacheable(): Boolean, if cacheable, default equals options.isCacheable

Readme

Keywords

Package Sidebar

Install

npm i panto-transformer

Weekly Downloads

5

Version

0.2.5

License

Apache-2.0

Last publish

Collaborators

  • yinyongcom666