panto-transformer
v0.2.5
Published
Base transformer for panto
Downloads
16
Readme
panto-transformer
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