UNPKG

the-moby-effect

Version:
66 lines (64 loc) 2.69 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AddressString = exports.AddressBigint = exports.Address = void 0; var Schema = _interopRequireWildcard(require("effect/Schema")); var IPv4 = _interopRequireWildcard(require("./ipv4.js")); var IPv6 = _interopRequireWildcard(require("./ipv6.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; } /** * IPv4 or IPv6 addresses schema. * * @since 1.0.0 */ /** * An IP address in string format, which is either an IPv4 or IPv6 address. * * @since 1.0.0 * @category Schemas */ const AddressString = exports.AddressString = /*#__PURE__*/Schema.Union(IPv4.IPv4String, IPv6.IPv6String).annotations({ identifier: "AddressString", description: "An ipv4 or ipv6 address in string format" }); /** * An IP address, which is either an IPv4 or IPv6 address. * * @since 1.0.0 * @category Schemas * @example * import * as Schema from "effect/Schema"; * import { Address } from "the-moby-effect/schemas/index.js"; * * const decodeAddress = Schema.decodeSync(Address); * * assert.throws(() => decodeAddress("1.1.b.1")); * assert.throws(() => * decodeAddress("2001:0db8:85a3:0000:0000:8a2e:0370:7334:") * ); * * assert.doesNotThrow(() => decodeAddress("1.1.1.2")); * assert.doesNotThrow(() => * decodeAddress("2001:0db8:85a3:0000:0000:8a2e:0370:7334") * ); * * @see {@link IPv4.IPv4} * @see {@link IPv6.IPv6} */ const Address = exports.Address = /*#__PURE__*/Schema.Union(IPv4.IPv4, IPv6.IPv6).annotations({ identifier: "Address", description: "An ipv4 or ipv6 address" }); /** * An IP address as a bigint. * * @since 1.0.0 * @category Schemas */ const AddressBigint = exports.AddressBigint = /*#__PURE__*/Schema.Union(IPv4.IPv4Bigint, IPv6.IPv6Bigint).annotations({ identifier: "AddressBigint", description: "An ipv4 or ipv6 address as a bigint" }); //# sourceMappingURL=address.js.map