From fc87c009806dcc98867f6b58efe29b042aa01dee Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Mon, 18 May 2026 23:10:59 +0800 Subject: node: update --- node_modules/svgo/plugins/sortDefsChildren.js | 58 --------------------------- 1 file changed, 58 deletions(-) delete mode 100644 node_modules/svgo/plugins/sortDefsChildren.js (limited to 'node_modules/svgo/plugins/sortDefsChildren.js') diff --git a/node_modules/svgo/plugins/sortDefsChildren.js b/node_modules/svgo/plugins/sortDefsChildren.js deleted file mode 100644 index 6ae5d421..00000000 --- a/node_modules/svgo/plugins/sortDefsChildren.js +++ /dev/null @@ -1,58 +0,0 @@ -'use strict'; - -exports.name = 'sortDefsChildren'; -exports.description = 'Sorts children of to improve compression'; - -/** - * Sorts children of defs in order to improve compression. - * Sorted first by frequency then by element name length then by element name (to ensure grouping). - * - * @author David Leston - * - * @type {import('./plugins-types').Plugin<'sortDefsChildren'>} - */ -exports.fn = () => { - return { - element: { - enter: (node) => { - if (node.name === 'defs') { - /** - * @type {Map} - */ - const frequencies = new Map(); - for (const child of node.children) { - if (child.type === 'element') { - const frequency = frequencies.get(child.name); - if (frequency == null) { - frequencies.set(child.name, 1); - } else { - frequencies.set(child.name, frequency + 1); - } - } - } - node.children.sort((a, b) => { - if (a.type !== 'element' || b.type !== 'element') { - return 0; - } - const aFrequency = frequencies.get(a.name); - const bFrequency = frequencies.get(b.name); - if (aFrequency != null && bFrequency != null) { - const frequencyComparison = bFrequency - aFrequency; - if (frequencyComparison !== 0) { - return frequencyComparison; - } - } - const lengthComparison = b.name.length - a.name.length; - if (lengthComparison !== 0) { - return lengthComparison; - } - if (a.name !== b.name) { - return a.name > b.name ? -1 : 1; - } - return 0; - }); - } - }, - }, - }; -}; -- cgit v1.2.3