MCPcopy Create free account
hub / github.com/ampproject/amphtml / toArrayOrDefault

Function toArrayOrDefault

build-system/tasks/dep-check.js:301–309  ·  view source on GitHub ↗

* Put value in Array context. * * @param {GlobsDef|string|undefined} value * @param {!GlobsDef} defaultValue * @return {!GlobsDef}

(value, defaultValue)

Source from the content-addressed store, hash-verified

299 * @return {!GlobsDef}
300 */
301function toArrayOrDefault(value, defaultValue) {
302 if (Array.isArray(value)) {
303 return value;
304 }
305 if (typeof value === 'string') {
306 return [value];
307 }
308 return defaultValue;
309}
310
311/**
312 * Flatten array of arrays if necessary.

Callers 1

RuleFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected