@@ -3,7 +3,7 @@ import cssSelectorSplitter from "css-selector-splitter";
3
3
import cssSelectorTokenizer from "css-selector-tokenizer" ;
4
4
import { validate } from "csstree-validator" ;
5
5
import knownCssProperties from "known-css-properties" ;
6
- import memo from "nano-memoize " ;
6
+ import memize from "memize " ;
7
7
import perfectionist from "perfectionist" ;
8
8
import postcss from "postcss" ;
9
9
import postcssDiscardDuplicates from "postcss-discard-duplicates" ;
@@ -182,8 +182,8 @@ const defaults = {
182
182
183
183
const prefix = "source #" ;
184
184
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 ( ) ) ) ;
187
187
const joinSelectors = selectors => selectors . join ( ", " ) ;
188
188
const uniq = arr => Array . from ( new Set ( arr ) ) ;
189
189
const varRe = / v a r \( - - (? ! u s o - v a r - e x p a n d e d ) .+ ?\) / ;
@@ -199,7 +199,7 @@ function getProperty(decl) {
199
199
}
200
200
}
201
201
202
- const selectorsIntersect = memo ( ( a , b ) => {
202
+ const selectorsIntersect = memize ( ( a , b ) => {
203
203
try {
204
204
const { nodes : nodesA } = cssSelectorTokenizer . parse ( a ) ;
205
205
const { nodes : nodesB } = cssSelectorTokenizer . parse ( b ) ;
@@ -272,7 +272,7 @@ function rewriteSelectors(selectors, opts, src) {
272
272
return ret ;
273
273
}
274
274
275
- const normalizeHexColor = memo ( value => {
275
+ const normalizeHexColor = memize ( value => {
276
276
if ( [ 4 , 5 ] . includes ( value . length ) ) {
277
277
const [ h , r , g , b , a ] = value ;
278
278
return `${ h } ${ r } ${ r } ${ g } ${ g } ${ b } ${ b } ${ a || "f" } ${ a || "f" } ` ;
@@ -282,7 +282,7 @@ const normalizeHexColor = memo(value => {
282
282
return value ;
283
283
} ) ;
284
284
285
- const alphaToHex = memo ( alpha => {
285
+ const alphaToHex = memize ( alpha => {
286
286
if ( alpha === undefined ) return "" ;
287
287
if ( alpha > 1 ) alpha = 1 ;
288
288
if ( alpha < 0 ) alpha = 0 ;
@@ -299,7 +299,7 @@ const cssValueKeywords = new Set([
299
299
"unset" ,
300
300
] ) ;
301
301
302
- const isColor = memo ( value => {
302
+ const isColor = memize ( value => {
303
303
value = value . toLowerCase ( ) ;
304
304
if ( cssColorNames [ value ] ) return true ;
305
305
if ( cssValueKeywords . has ( value ) ) return true ;
@@ -332,7 +332,7 @@ function hexFromColorFunction(node) {
332
332
return null ;
333
333
}
334
334
335
- const normalizeColor = memo ( value => {
335
+ const normalizeColor = memize ( value => {
336
336
value = value . toLowerCase ( ) ;
337
337
338
338
if ( value in cssColorNames ) {
@@ -388,7 +388,7 @@ function normalizeDecl({prop, raws, value, important}) {
388
388
}
389
389
390
390
// returns an array of declarations
391
- const parseDecl = memo ( ( declString ) => {
391
+ const parseDecl = memize ( ( declString ) => {
392
392
declString = declString . trim ( ) . replace ( / ; + $ / , "" ) . trim ( ) ;
393
393
394
394
const ret = [ ] ;
@@ -466,15 +466,15 @@ function hasDeclarations(root) {
466
466
return false ;
467
467
}
468
468
469
- const usoVarToCssVar = memo ( value => {
469
+ const usoVarToCssVar = memize ( value => {
470
470
return value . replace ( / \/ \* \[ \[ ( .+ ?) \] \] \* \/ / g, ( _ , name ) => `var(--uso-var-expanded-${ name } )` ) ;
471
471
} ) ;
472
472
473
- const cssVarToUsoVars = memo ( value => {
473
+ const cssVarToUsoVars = memize ( value => {
474
474
return value . replace ( / v a r \( - - ( u s o - v a r - e x p a n d e d - ) ( .+ ?) \) / g, ( _ , _prefix , name ) => `/*[[${ name } ]]*/` ) ;
475
475
} ) ;
476
476
477
- const isValidDeclaration = memo ( ( prop , value ) => {
477
+ const isValidDeclaration = memize ( ( prop , value ) => {
478
478
if ( ! knownProperties . has ( prop ) && ! / ^ - - ./ . test ( prop ) ) {
479
479
return false ;
480
480
}
@@ -495,7 +495,7 @@ function makeComment(text) {
495
495
} ) ;
496
496
}
497
497
498
- const assignNewColor = memo ( ( normalizedColor , newValue ) => {
498
+ const assignNewColor = memize ( ( normalizedColor , newValue ) => {
499
499
if ( newValue === "$invert" ) {
500
500
let [ _ , r , g , b , a ] = / ^ # ( ..) ( ..) ( ..) ( ..) $ / . exec ( normalizedColor ) ;
501
501
r = ( 255 - parseInt ( r , 16 ) ) . toString ( 16 ) . padStart ( 2 , "0" ) ;
0 commit comments