From 3fa5796687b872a7cb0e5cf86d743896e6abfbe2 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Wed, 4 Aug 2021 09:58:12 +0300 Subject: Switch to using for...of (#414) --- lib/rfs.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/rfs.js b/lib/rfs.js index 7ffb235..850c93f 100644 --- a/lib/rfs.js +++ b/lib/rfs.js @@ -81,7 +81,9 @@ module.exports = class { return; } - node.nodes.filter(node => node.type === 'word').forEach(node => { + const wordNodes = node.nodes.filter(node => node.type === 'word'); + + for (const node of wordNodes) { node.value = node.value.replace(/^(-?\d*\.?\d+)(.*)/g, (match, value, unit) => { value = Number.parseFloat(value); @@ -116,7 +118,7 @@ module.exports = class { return `calc(-${this.toFixed(baseValue, this.opts.unitPrecision)}${this.opts.unit} - ${this.toFixed(diff * 100 / this.opts.breakpoint, this.opts.unitPrecision)}${viewportUnit})`; }); - }); + } // Now we will transform the existing rgba() function node // into a word node with the hex value -- cgit v1.2.3