import { AnyJson, JsonArray, JsonMap, Nullable, Optional } from '../types'; /** * Narrows an `unknown` value to an `AnyJson` if it is type-compatible\*, or returns `undefined` otherwise. * * _* This is not a 100% safe operation -- it will not deeply validate plain object or array structures * to ensure that they contain only `AnyJson` values. When type-narrowing potential objects or arrays with this * function, it's the responsibility of the caller to understand the risks of making such a shallow type assertion * over the `value` data._ * * @param value The value to test. */ export declare function coerceAnyJson(value: unknown): Optional; /** * Narrows an `unknown` value to an `AnyJson` if it is type-compatible, or returns the provided default otherwise. * * @param value The value to test. * @param defaultValue The default to return if `value` was undefined or of the incorrect type. */ export declare function coerceAnyJson(value: unknown, defaultValue: AnyJson): AnyJson; /** * Narrows an object of type `T` to a `JsonMap` using a shallow type-compatibility check. Use this when the source of * the object is known to be JSON-compatible and you want simple type coercion to a `JsonMap`. Use {@link toJsonMap} * instead when the `value` object _cannot_ be guaranteed to be JSON-compatible and you want an assurance of runtime * type safety. This is a shortcut for writing `asJsonMap(coerceAnyJson(value))`. * * @param value The object to coerce. */ export declare function coerceJsonMap(value: Nullable): Optional; /** * Narrows an object of type `T` to a `JsonMap` using a shallow type-compatibility check. Use this when the source of * the object is known to be JSON-compatible and you want simple type coercion to a `JsonMap`. Use {@link toJsonMap} * instead when the `value` object _cannot_ be guaranteed to be JSON-compatible and you want an assurance of runtime * type safety. This is a shortcut for writing `asJsonMap(coerceAnyJson(value)) ?? defaultValue`. * * @param value The object to coerce. * @param defaultValue The default to return if `value` was not defined. */ export declare function coerceJsonMap(value: Nullable, defaultValue: JsonMap): JsonMap; /** * Narrows an array of type `T` to a `JsonArray` using a shallow type-compatibility check. Use this when the source of * the array is known to be JSON-compatible and you want simple type coercion to a `JsonArray`. Use {@link toJsonArray} * instead when the `value` array _cannot_ be guaranteed to be JSON-compatible and you want an assurance of runtime * type safety. This is a shortcut for writing `asJsonArray(coerceAnyJson(value))`. * * @param value The array to coerce. */ export declare function coerceJsonArray(value: Nullable): Optional; /** * Narrows an array of type `T` to a `JsonArray` using a shallow type-compatibility check. Use this when the source of * the array is known to be JSON-compatible and you want simple type coercion to a `JsonArray`. Use {@link toJsonArray} * instead when the `value` array _cannot_ be guaranteed to be JSON-compatible and you want an assurance of runtime * type safety. This is a shortcut for writing `asJsonArray(coerceAnyJson(value)) ?? defaultValue`. * * @param value The array to coerce. * @param defaultValue The default to return if `value` was not defined. */ export declare function coerceJsonArray(value: Nullable, defaultValue: JsonArray): JsonArray;