vinyl-named2
v1.0.0
Published
Give vinyl files chunk names.
Downloads
1
Readme
vinyl-named2
Give vinyl files arbitrary chunk names, using through2
, with type declarations.
Usage
const named = require('vinyl-named2');
const fs = require('vinyl-fs');
const through = require('through2');
fs.src('src/*.js')
.pipe(named())
.pipe(through.obj((file) => {
// file.named now equals the basename minus the extension.
}));
// Or, return a name for a given file.
fs.src('src/*.js')
.pipe(named((file) => 'your own name'));
// Or, specify a custom name property.
fs.src('src/*.js')
.pipe(named(function (file) {
file.customName = 'your name';
this.push(file);
}));
TypeScript
import named from 'vinyl-named2';
import * as fs from 'vinyl-fs';
import * as through from 'through2';
fs.src('src/*.js')
.pipe(named())
.pipe(through.obj((file) => {
// file.named now equals the basename minus the extension.
}));
// Or, return a name for a given file.
fs.src('src/*.js')
.pipe(named((file) => 'your own name'));
// Or, specify a custom name property.
fs.src('src/*.js')
.pipe(named(function (this, file) {
file.customName = 'your name';
this.push(file);
}));