Skip to content

pantojs/panto-transformer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Base transformer for panto

Resources

License

Stars

Watchers

Forks

Packages

No packages published