panto-transformer

Base transformer for panto

Usage no npm install needed!

<script type="module">
  import pantoTransformer from 'https://cdn.skypack.dev/panto-transformer';
</script>

README

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