|
|
|
@ -73,22 +73,6 @@ function isObject(value) {
|
|
|
|
|
return (value != null && typeof value === "object" && !Array.isArray(value));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO: Move to separate package, decide whether to keep the nested array detection or not - that should probably just be part of the handler?
|
|
|
|
|
function mapMaybeArray(value, handler) {
|
|
|
|
|
// NOTE: This is async!
|
|
|
|
|
if (Array.isArray(value)) {
|
|
|
|
|
return Promise.map(value, (item, i) => {
|
|
|
|
|
if (Array.isArray(item)) {
|
|
|
|
|
throw new Error(`Encountered a nested array, which is not allowed; maybe you forgot to flatten it?`);
|
|
|
|
|
} else {
|
|
|
|
|
return handler(item, i);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
return handler(value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Possible values of a schema property:
|
|
|
|
|
true, null, object with only special keys (but not $recurse) -- fetch value and return it as-is
|
|
|
|
|
false -- do not fetch value at all
|
|
|
|
|