MCPcopy
hub / github.com/typestyle/typestyle / extend

Function extend

src/internal/utilities.ts:34–64  ·  view source on GitHub ↗
(...objects: (NestedCSSProperties | undefined | null | false)[])

Source from the content-addressed store, hash-verified

32 * Note: if two objects have the same property the last one wins
33 */
34export function extend(...objects: (NestedCSSProperties | undefined | null | false)[]): NestedCSSProperties {
35 /** The final result we will return */
36 const result: CSSProperties & Record<string, any> = {};
37 for (const object of objects) {
38 if (object == null || object === false) {
39 continue;
40 }
41 for (const key in object) {
42
43 /** Falsy values except a explicit 0 is ignored */
44 const val: any = (object as any)[key];
45 if (!val && val !== 0) {
46 continue;
47 }
48
49 /** if nested media or pseudo selector */
50 if (key === '$nest' && val) {
51 result[key] = result['$nest'] ? extend(result['$nest'], val) : val;
52 }
53 /** if freestyle sub key that needs merging. We come here due to our recursive calls */
54 else if ((key.indexOf('&') !== -1 || key.indexOf('@media') === 0)) {
55 result[key] = result[key] ? extend(result[key], val) : val;
56 }
57 else {
58 result[key] = val;
59 }
60 }
61 }
62
63 return result;
64}
65
66
67/**

Callers 3

TypeStyleClass · 0.90
mediaFunction · 0.85
extend.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…