MCPcopy Create free account
hub / github.com/PageLeay/celestial-runtime / arrayOf

Function arrayOf

lib.esm/providers/format.js:17–27  ·  view source on GitHub ↗
(format, allowNull)

Source from the content-addressed store, hash-verified

15 });
16}
17export function arrayOf(format, allowNull) {
18 return ((array) => {
19 if (allowNull && array == null) {
20 return null;
21 }
22 if (!Array.isArray(array)) {
23 throw new Error("not an array");
24 }
25 return array.map((i) => format(i));
26 });
27}
28// Requires an object which matches a fleet of other formatters
29// Any FormatFunc may return `undefined` to have the value omitted
30// from the result object. Calls preserve `this`.

Callers 2

format.jsFile · 0.70

Calls 2

isArrayMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected