MCPcopy Create free account
hub / github.com/NativeScript/NativeScript / parseClipPath

Function parseClipPath

packages/core/ui/styling/style-properties.ts:104–130  ·  view source on GitHub ↗
(value: string)

Source from the content-addressed store, hash-verified

102}
103
104function parseClipPath(value: string): string | ClipPathFunction {
105 const funcStartIndex = value.indexOf('(');
106 const funcEndIndex = value.lastIndexOf(')');
107
108 if (funcStartIndex > -1 && funcEndIndex > -1) {
109 const functionName = value.substring(0, funcStartIndex).trim();
110
111 switch (functionName) {
112 case 'rect':
113 case 'circle':
114 case 'ellipse':
115 case 'polygon':
116 case 'inset': {
117 return new ClipPathFunction(functionName, value.substring(funcStartIndex + 1, funcEndIndex));
118 }
119 default:
120 throw new Error(`Clip-path function ${functionName} is not valid.`);
121 }
122 } else {
123 if (value === 'none') {
124 return null;
125 }
126
127 // Only shape functions and none are supported for now
128 throw new Error(`Clip-path value ${value} is not valid.`);
129 }
130}
131
132function parseShorthandPositioning(value: string): ShorthandPositioning {
133 const arr = value.split(/[ ,]+/);

Callers 1

valueConverterFunction · 0.85

Calls 2

indexOfMethod · 0.80
lastIndexOfMethod · 0.80

Tested by

no test coverage detected