MCPcopy Create free account
hub / github.com/melonjs/melonJS / parseRadiiArgument

Function parseRadiiArgument

packages/melonjs/src/polyfill/roundrect.ts:254–296  ·  view source on GitHub ↗

@ignore

(
		value: any,
	)

Source from the content-addressed store, hash-verified

252
253 /** @ignore */
254 function parseRadiiArgument(
255 value: any,
256 ):
257 | [number, number, number, number]
258 | [number, number, number]
259 | [number, number]
260 | [number]
261 | unknown[] {
262 // https://webidl.spec.whatwg.org/#es-union
263 // with 'optional (unrestricted double or DOMPointInit
264 // or sequence<(unrestricted double or DOMPointInit)>) radii = 0'
265 const type = typeof value;
266
267 if (type === "undefined" || value === null) {
268 return [0];
269 }
270 if (type === "function") {
271 return [NaN];
272 }
273 if (type === "object") {
274 if (typeof value[Symbol.iterator] === "function") {
275 return [...value].map((elem) => {
276 // https://webidl.spec.whatwg.org/#es-union
277 // with '(unrestricted double or DOMPointInit)'
278 const elemType = typeof elem;
279 if (elemType === "undefined" || elem === null) {
280 return 0;
281 }
282 if (elemType === "function") {
283 return NaN;
284 }
285 if (elemType === "object") {
286 return toDOMPointInit(elem);
287 }
288 return toUnrestrictedNumber(elem);
289 });
290 }
291
292 return [toDOMPointInit(value)];
293 }
294
295 return [toUnrestrictedNumber(value)];
296 }
297
298 /** @ignore */
299 function toUnrestrictedNumber(value: any) {

Callers 1

roundRectFunction · 0.85

Calls 2

toDOMPointInitFunction · 0.85
toUnrestrictedNumberFunction · 0.85

Tested by

no test coverage detected