From 170c3ce52b989f659163362628a744684e0eaaeb Mon Sep 17 00:00:00 2001 From: emkayy Date: Tue, 12 Oct 2021 12:49:20 +0200 Subject: [PATCH] Updated readme for transformAll example --- README.md | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7f50c9c3..b224357d 100644 --- a/README.md +++ b/README.md @@ -757,10 +757,17 @@ module.exports = { to: "dest/file.txt", // The `assets` argument is an assets array for the pattern.from ("src/**/*.txt") transformAll(assets) { + // The assets parameter contains an array of assets const result = assets.reduce((accumulator, asset) => { - // The asset content can be obtained from `asset.source` using `source` method. - // The asset content is a [`Buffer`](https://nodejs.org/api/buffer.html) object, it could be converted to a `String` to be processed using `content.toString()` - const content = asset.data; + // Each `asset` contains the following data structure: + // { + // data: [`Buffer`], // asset text content can be obtained via asset.data.toString() + // sourceFilename: [`String`], + // absoluteFilename: [`String`], + // } + // The asset content can be obtained from `asset.data`. + // The asset content is a [`Buffer`](https://nodejs.org/api/buffer.html) object, it could be converted to a `String` to be processed using `data.toString()` + const content = asset.data.toString(); accumulator = `${accumulator}${content}\n`; return accumulator;