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

Function arrayOf

lib.commonjs/providers/format.js:21–31  ·  view source on GitHub ↗
(format, allowNull)

Source from the content-addressed store, hash-verified

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

Callers 2

format.jsFile · 0.70

Calls 2

isArrayMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected