fix: hydrate in twind-v1-plugin (#1050)

This commit is contained in:
y3km21
2023-03-13 01:31:41 +09:00
committed by GitHub
parent 7e72fa236c
commit 7f2ec612b2
15 changed files with 597 additions and 2 deletions
@@ -0,0 +1,26 @@
/**
* Returns the number of string duplicates that compare two string[].
*/
export function cmpStringArray(a: string[], b: string[]) {
const bSet = new Set(b);
const duplicateString = a.filter((value) => {
return bSet.has(value);
});
return duplicateString.length;
}
/**
* Returns the number of csstext duplicates that compare two cssrulelist.
*/
export function cmpCssRules(a: CSSRuleList, b: CSSRuleList) {
const aCssTextArray = Array.from(a).map((elem: CSSRule) => {
return elem.cssText;
});
const bCssTextArray = Array.from(b).map((elem: CSSRule) => {
return elem.cssText;
});
return cmpStringArray(aCssTextArray, bCssTextArray);
}