🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

postcss-normalize-string

Package Overview
Dependencies
Maintainers
7
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-normalize-string - npm Package Compare versions

Comparing version

to
5.1.0

types/index.d.ts

6

package.json
{
"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(