forked from darkreader/darkreader
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.ts
More file actions
23 lines (20 loc) · 668 Bytes
/
Copy pathutils.ts
File metadata and controls
23 lines (20 loc) · 668 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import {classes} from '../utils';
function toArray<T>(x: T | T[]) {
return Array.isArray(x) ? x : [x];
}
export function mergeClass(
cls: string | {[cls: string]: any} | (string | {[cls: string]: any})[],
propsCls: string | {[cls: string]: any} | (string | {[cls: string]: any})[]
) {
const normalized = toArray(cls).concat(toArray(propsCls));
return classes(...normalized);
}
export function omitAttrs(omit: string[], attrs: Malevic.NodeAttrs) {
const result: Malevic.NodeAttrs = {};
Object.keys(attrs).forEach((key) => {
if (omit.indexOf(key) < 0) {
result[key] = attrs[key];
}
});
return result;
}