UNPKG

veffect

Version:

powerful TypeScript validation library built on the robust foundation of Effect combining exceptional type safety, high performance, and developer experience. Taking inspiration from Effect's functional principles, VEffect delivers a balanced approach tha

318 lines (317 loc) 8.91 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.zipWith = exports.zip = exports.withDescription = exports.withDefault = exports.validate = exports.unwrap = exports.sync = exports.suspend = exports.succeed = exports.string = exports.secret = exports.repeat = exports.primitive = exports.orElseIf = exports.orElse = exports.option = exports.number = exports.nested = exports.mapOrFail = exports.mapAttempt = exports.map = exports.logLevel = exports.literal = exports.isConfig = exports.integer = exports.hashSet = exports.hashMap = exports.fail = exports.duration = exports.date = exports.chunk = exports.boolean = exports.array = exports.all = exports.ConfigTypeId = void 0; var internal = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("./internal/config.js")); function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); } function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } /** * @since 2.0.0 * @category symbols */ const ConfigTypeId = exports.ConfigTypeId = internal.ConfigTypeId; /** * Constructs a config from a tuple / struct / arguments of configs. * * @since 2.0.0 * @category constructors */ const all = exports.all = internal.all; /** * Constructs a config for an array of values. * * @since 2.0.0 * @category constructors */ const array = exports.array = internal.array; /** * Constructs a config for a boolean value. * * @since 2.0.0 * @category constructors */ const boolean = exports.boolean = internal.boolean; /** * Constructs a config for a sequence of values. * * @since 2.0.0 * @category constructors */ const chunk = exports.chunk = internal.chunk; /** * Constructs a config for a date value. * * @since 2.0.0 * @category constructors */ const date = exports.date = internal.date; /** * Constructs a config that fails with the specified message. * * @since 2.0.0 * @category constructors */ const fail = exports.fail = internal.fail; /** * Constructs a config for a float value. * * @since 2.0.0 * @category constructors */ const number = exports.number = internal.number; /** * Constructs a config for a integer value. * * @since 2.0.0 * @category constructors */ const integer = exports.integer = internal.integer; /** * Constructs a config for a literal value. * * @example * import { Config } from "effect" * * const config = Config.literal("http", "https")("PROTOCOL") * * @since 2.0.0 * @category constructors */ const literal = exports.literal = internal.literal; /** * Constructs a config for a `LogLevel` value. * * @since 2.0.0 * @category constructors */ const logLevel = exports.logLevel = internal.logLevel; /** * Constructs a config for a duration value. * * @since 2.5.0 * @category constructors */ const duration = exports.duration = internal.duration; /** * This function returns `true` if the specified value is an `Config` value, * `false` otherwise. * * This function can be useful for checking the type of a value before * attempting to operate on it as an `Config` value. For example, you could * use `isConfig` to check the type of a value before using it as an * argument to a function that expects an `Config` value. * * @param u - The value to check for being a `Config` value. * * @returns `true` if the specified value is a `Config` value, `false` * otherwise. * * @since 2.0.0 * @category refinements */ const isConfig = exports.isConfig = internal.isConfig; /** * Returns a config whose structure is the same as this one, but which produces * a different value, constructed using the specified function. * * @since 2.0.0 * @category mapping */ const map = exports.map = internal.map; /** * Returns a config whose structure is the same as this one, but which may * produce a different value, constructed using the specified function, which * may throw exceptions that will be translated into validation errors. * * @since 2.0.0 * @category utils */ const mapAttempt = exports.mapAttempt = internal.mapAttempt; /** * Returns a new config whose structure is the samea as this one, but which * may produce a different value, constructed using the specified fallible * function. * * @since 2.0.0 * @category utils */ const mapOrFail = exports.mapOrFail = internal.mapOrFail; /** * Returns a config that has this configuration nested as a property of the * specified name. * * @since 2.0.0 * @category utils */ const nested = exports.nested = internal.nested; /** * Returns a config whose structure is preferentially described by this * config, but which falls back to the specified config if there is an issue * reading from this config. * * @since 2.0.0 * @category utils */ const orElse = exports.orElse = internal.orElse; /** * Returns configuration which reads from this configuration, but which falls * back to the specified configuration if reading from this configuration * fails with an error satisfying the specified predicate. * * @since 2.0.0 * @category utils */ const orElseIf = exports.orElseIf = internal.orElseIf; /** * Returns an optional version of this config, which will be `None` if the * data is missing from configuration, and `Some` otherwise. * * @since 2.0.0 * @category utils */ const option = exports.option = internal.option; /** * Constructs a new primitive config. * * @since 2.0.0 * @category constructors */ const primitive = exports.primitive = internal.primitive; /** * Returns a config that describes a sequence of values, each of which has the * structure of this config. * * @since 2.0.0 * @category utils */ const repeat = exports.repeat = internal.repeat; /** * Constructs a config for a secret value. * * @since 2.0.0 * @category constructors */ const secret = exports.secret = internal.secret; /** * Constructs a config for a sequence of values. * * @since 2.0.0 * @category constructors */ const hashSet = exports.hashSet = internal.hashSet; /** * Constructs a config for a string value. * * @since 2.0.0 * @category constructors */ const string = exports.string = internal.string; /** * Constructs a config which contains the specified value. * * @since 2.0.0 * @category constructors */ const succeed = exports.succeed = internal.succeed; /** * Lazily constructs a config. * * @since 2.0.0 * @category constructors */ const suspend = exports.suspend = internal.suspend; /** * Constructs a config which contains the specified lazy value. * * @since 2.0.0 * @category constructors */ const sync = exports.sync = internal.sync; /** * Constructs a config for a sequence of values. * * @since 2.0.0 * @category constructors */ const hashMap = exports.hashMap = internal.hashMap; /** * Constructs a config from some configuration wrapped with the `Wrap<A>` utility type. * * For example: * * ``` * import { Config, unwrap } from "./Config" * * interface Options { key: string } * * const makeConfig = (config: Config.Wrap<Options>): Config<Options> => unwrap(config) * ``` * * @since 2.0.0 * @category constructors */ const unwrap = exports.unwrap = internal.unwrap; /** * Returns a config that describes the same structure as this one, but which * performs validation during loading. * * @since 2.0.0 * @category utils */ const validate = exports.validate = internal.validate; /** * Returns a config that describes the same structure as this one, but has the * specified default value in case the information cannot be found. * * @since 2.0.0 * @category utils */ const withDefault = exports.withDefault = internal.withDefault; /** * Adds a description to this configuration, which is intended for humans. * * @since 2.0.0 * @category utils */ const withDescription = exports.withDescription = internal.withDescription; /** * Returns a config that is the composition of this config and the specified * config. * * @since 2.0.0 * @category zipping */ const zip = exports.zip = internal.zip; /** * Returns a config that is the composes this config and the specified config * using the provided function. * * @since 2.0.0 * @category zipping */ const zipWith = exports.zipWith = internal.zipWith; //# sourceMappingURL=Config.js.map