Socket
Socket
Sign inDemoInstall

postcss-minify-font-values

Package Overview
Dependencies
5
Maintainers
8
Versions
43
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 6.0.1 to 6.0.2

4

package.json
{
"name": "postcss-minify-font-values",
"version": "6.0.1",
"version": "6.0.2",
"description": "Minify font declarations with PostCSS",

@@ -34,3 +34,3 @@ "main": "src/index.js",

"devDependencies": {
"postcss": "^8.4.32"
"postcss": "^8.4.35"
},

@@ -37,0 +37,0 @@ "peerDependencies": {

@@ -35,7 +35,3 @@ 'use strict';

} else if (lowerCasedProp === 'font') {
const tree = valueParser(value);
tree.nodes = minifyFont(tree.nodes, opts);
return tree.toString();
return minifyFont(value, opts);
}

@@ -42,0 +38,0 @@

'use strict';
const { unit } = require('postcss-value-parser');
const valueParser = require('postcss-value-parser');
const keywords = require('./keywords');

@@ -8,13 +8,38 @@ const minifyFamily = require('./minify-family');

/**
* Adds missing spaces before strings.
*
* @param toBeSpliced {Set<number>}
* @param {import('postcss-value-parser').Node[]} nodes
* @return {void}
*/
function normalizeNodes(nodes, toBeSpliced) {
for (const index of toBeSpliced) {
nodes.splice(
index,
0,
/** @type {import('postcss-value-parser').SpaceNode} */ ({
type: 'space',
value: ' ',
})
);
}
}
/**
* @param {string} unminified
* @param {import('../index').Options} opts
* @return {import('postcss-value-parser').Node[]}
* @return {string}
*/
module.exports = function (nodes, opts) {
let i, max, node, family;
module.exports = function (unminified, opts) {
const tree = valueParser(unminified);
const nodes = tree.nodes;
let familyStart = NaN;
let hasSize = false;
const toBeSpliced = new Set();
for (i = 0, max = nodes.length; i < max; i += 1) {
node = nodes[i];
for (const [i, node] of nodes.entries()) {
if (node.type === 'string' && i > 0 && nodes[i - 1].type !== 'space') {
toBeSpliced.add(i);
}

@@ -27,3 +52,2 @@ if (node.type === 'word') {

const value = node.value.toLowerCase();
if (

@@ -36,3 +60,3 @@ value === 'normal' ||

familyStart = i;
} else if (keywords.style.has(value) || unit(value)) {
} else if (keywords.style.has(value) || valueParser.unit(value)) {
familyStart = i;

@@ -46,3 +70,3 @@ } else if (keywords.variant.has(value)) {

familyStart = i;
} else if (keywords.size.has(value) || unit(value)) {
} else if (keywords.size.has(value) || valueParser.unit(value)) {
familyStart = i;

@@ -63,7 +87,9 @@ hasSize = true;

normalizeNodes(nodes, toBeSpliced);
familyStart += 2;
family = minifyFamily(nodes.slice(familyStart), opts);
const family = minifyFamily(nodes.slice(familyStart), opts);
return nodes.slice(0, familyStart).concat(family);
tree.nodes = nodes.slice(0, familyStart).concat(family);
return tree.toString();
};

@@ -1,2 +0,2 @@

declare function _exports(nodes: import('postcss-value-parser').Node[], opts: import('../index').Options): import('postcss-value-parser').Node[];
declare function _exports(unminified: string, opts: import('../index').Options): string;
export = _exports;
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc