postcss-normalize-string
Advanced tools
Comparing version
{ | ||
"name": "postcss-normalize-string", | ||
"version": "5.0.4", | ||
"version": "5.1.0", | ||
"description": "Normalize wrapping quotes for CSS string literals.", | ||
"main": "src/index.js", | ||
"types": "types/index.d.ts", | ||
"files": [ | ||
"src", | ||
"LICENSE-MIT" | ||
"LICENSE-MIT", | ||
"types" | ||
], | ||
@@ -10,0 +12,0 @@ "keywords": [ |
@@ -49,2 +49,13 @@ 'use strict'; | ||
/** @typedef {T_ESCAPED_SINGLE_QUOTE | T_ESCAPED_DOUBLE_QUOTE | T_SINGLE_QUOTE | T_NEWLINE} StringAstNode */ | ||
/** | ||
* @typedef {{nodes: StringAstNode[], | ||
* types: {escapedSingleQuote: number, escapedDoubleQuote: number, singleQuote: number, doubleQuote: number}, | ||
* quotes: boolean}} StringAst | ||
*/ | ||
/** | ||
* @param {StringAst} ast | ||
* @return {string} | ||
*/ | ||
function stringify(ast) { | ||
@@ -61,2 +72,6 @@ return ast.nodes.reduce((str, { value }) => { | ||
/** | ||
* @param {string} str | ||
* @return {StringAst} | ||
*/ | ||
function parse(str) { | ||
@@ -67,2 +82,3 @@ let code, next, value; | ||
/** @type StringAst */ | ||
const ast = { | ||
@@ -165,2 +181,7 @@ nodes: [], | ||
/** | ||
* @param {valueParser.StringNode} node | ||
* @param {StringAst} ast | ||
* @return {void} | ||
*/ | ||
function changeWrappingQuotes(node, ast) { | ||
@@ -192,3 +213,5 @@ const { types } = ast; | ||
/** | ||
* @param {StringAstNode[]} childNodes | ||
* @param {string} parentQuote | ||
* @return {StringAstNode[]} | ||
*/ | ||
@@ -215,2 +238,7 @@ function changeChildQuotes(childNodes, parentQuote) { | ||
/** | ||
* @param {string} value | ||
* @param {'single' | 'double'} preferredQuote | ||
* @return {string} | ||
*/ | ||
function normalize(value, preferredQuote) { | ||
@@ -242,6 +270,12 @@ if (!value || !value.length) { | ||
/** | ||
* @param {string} original | ||
* @param {Map<string, string>} cache | ||
* @param {'single' | 'double'} preferredQuote | ||
* @return {string} | ||
*/ | ||
function minify(original, cache, preferredQuote) { | ||
const key = original + '|' + preferredQuote; | ||
if (cache.has(key)) { | ||
return cache.get(key); | ||
return /** @type {string} */ (cache.get(key)); | ||
} | ||
@@ -253,2 +287,8 @@ const newValue = normalize(original, preferredQuote); | ||
/** @typedef {{preferredQuote?: 'double' | 'single'}} Options */ | ||
/** | ||
* @type {import('postcss').PluginCreator<Options>} | ||
* @param {Options} opts | ||
* @return {import('postcss').Plugin} | ||
*/ | ||
function pluginCreator(opts) { | ||
@@ -255,0 +295,0 @@ const { preferredQuote } = Object.assign( |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
12270
19.37%5
25%317
32.08%0
-100%