Skip to content

Commit 260ec1b

Browse files
committed
updates
1 parent 0ed5747 commit 260ec1b

File tree

4 files changed

+488
-712
lines changed

4 files changed

+488
-712
lines changed

index.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import cssSelectorSplitter from "css-selector-splitter";
33
import cssSelectorTokenizer from "css-selector-tokenizer";
44
import {validate} from "csstree-validator";
55
import knownCssProperties from "known-css-properties";
6-
import memo from "nano-memoize";
6+
import memize from "memize";
77
import perfectionist from "perfectionist";
88
import postcss from "postcss";
99
import postcssDiscardDuplicates from "postcss-discard-duplicates";
@@ -182,8 +182,8 @@ const defaults = {
182182

183183
const prefix = "source #";
184184
const atRulesWithNoSelectors = new Set(["keyframes"]);
185-
const splitDecls = memo(str => splitString(str, {separator: ";", quotes: [`"`, `'`]}).map(s => s.trim()));
186-
const splitSelectors = memo(str => splitString(str, {separator: ",", quotes: [`"`, `'`]}).map(s => s.trim()));
185+
const splitDecls = memize(str => splitString(str, {separator: ";", quotes: [`"`, `'`]}).map(s => s.trim()));
186+
const splitSelectors = memize(str => splitString(str, {separator: ",", quotes: [`"`, `'`]}).map(s => s.trim()));
187187
const joinSelectors = selectors => selectors.join(", ");
188188
const uniq = arr => Array.from(new Set(arr));
189189
const varRe = /var\(--(?!uso-var-expanded).+?\)/;
@@ -199,7 +199,7 @@ function getProperty(decl) {
199199
}
200200
}
201201

202-
const selectorsIntersect = memo((a, b) => {
202+
const selectorsIntersect = memize((a, b) => {
203203
try {
204204
const {nodes: nodesA} = cssSelectorTokenizer.parse(a);
205205
const {nodes: nodesB} = cssSelectorTokenizer.parse(b);
@@ -272,7 +272,7 @@ function rewriteSelectors(selectors, opts, src) {
272272
return ret;
273273
}
274274

275-
const normalizeHexColor = memo(value => {
275+
const normalizeHexColor = memize(value => {
276276
if ([4, 5].includes(value.length)) {
277277
const [h, r, g, b, a] = value;
278278
return `${h}${r}${r}${g}${g}${b}${b}${a || "f"}${a || "f"}`;
@@ -282,7 +282,7 @@ const normalizeHexColor = memo(value => {
282282
return value;
283283
});
284284

285-
const alphaToHex = memo(alpha => {
285+
const alphaToHex = memize(alpha => {
286286
if (alpha === undefined) return "";
287287
if (alpha > 1) alpha = 1;
288288
if (alpha < 0) alpha = 0;
@@ -299,7 +299,7 @@ const cssValueKeywords = new Set([
299299
"unset",
300300
]);
301301

302-
const isColor = memo(value => {
302+
const isColor = memize(value => {
303303
value = value.toLowerCase();
304304
if (cssColorNames[value]) return true;
305305
if (cssValueKeywords.has(value)) return true;
@@ -332,7 +332,7 @@ function hexFromColorFunction(node) {
332332
return null;
333333
}
334334

335-
const normalizeColor = memo(value => {
335+
const normalizeColor = memize(value => {
336336
value = value.toLowerCase();
337337

338338
if (value in cssColorNames) {
@@ -388,7 +388,7 @@ function normalizeDecl({prop, raws, value, important}) {
388388
}
389389

390390
// returns an array of declarations
391-
const parseDecl = memo((declString) => {
391+
const parseDecl = memize((declString) => {
392392
declString = declString.trim().replace(/;+$/, "").trim();
393393

394394
const ret = [];
@@ -466,15 +466,15 @@ function hasDeclarations(root) {
466466
return false;
467467
}
468468

469-
const usoVarToCssVar = memo(value => {
469+
const usoVarToCssVar = memize(value => {
470470
return value.replace(/\/\*\[\[(.+?)\]\]\*\//g, (_, name) => `var(--uso-var-expanded-${name})`);
471471
});
472472

473-
const cssVarToUsoVars = memo(value => {
473+
const cssVarToUsoVars = memize(value => {
474474
return value.replace(/var\(--(uso-var-expanded-)(.+?)\)/g, (_, _prefix, name) => `/*[[${name}]]*/`);
475475
});
476476

477-
const isValidDeclaration = memo((prop, value) => {
477+
const isValidDeclaration = memize((prop, value) => {
478478
if (!knownProperties.has(prop) && !/^--./.test(prop)) {
479479
return false;
480480
}
@@ -495,7 +495,7 @@ function makeComment(text) {
495495
});
496496
}
497497

498-
const assignNewColor = memo((normalizedColor, newValue) => {
498+
const assignNewColor = memize((normalizedColor, newValue) => {
499499
if (newValue === "$invert") {
500500
let [_, r, g, b, a] = /^#(..)(..)(..)(..)$/.exec(normalizedColor);
501501
r = (255 - parseInt(r, 16)).toString(16).padStart(2, "0");

0 commit comments

Comments
 (0)