@effect/io
Advanced tools
Comparing version 0.34.0 to 0.35.0
@@ -17,12 +17,2 @@ /** | ||
* @since 1.0.0 | ||
*/ | ||
export type NonEmptyArrayConfig = [Config<any>, ...Array<Config<any>>]; | ||
/** | ||
* @since 1.0.0 | ||
*/ | ||
export type TupleConfig<T extends NonEmptyArrayConfig> = { | ||
[K in keyof T]: [T[K]] extends [Config<infer A>] ? A : never; | ||
}; | ||
/** | ||
* @since 1.0.0 | ||
* @category symbols | ||
@@ -78,2 +68,6 @@ */ | ||
} : never) | Config<A>; | ||
/** | ||
* @since 1.0.0 | ||
*/ | ||
type Narrow<A> = (A extends [] ? [] : never) | A; | ||
} | ||
@@ -86,18 +80,9 @@ /** | ||
*/ | ||
export declare const all: { | ||
<A, T extends ReadonlyArray<Config<any>>>(self: Config<A>, ...args: T): Config<[ | ||
A, | ||
...(T["length"] extends 0 ? [] : { | ||
[K in keyof T]: [T[K]] extends [Config<infer A>] ? A : never; | ||
}) | ||
]>; | ||
<T extends ReadonlyArray<Config<any>>>(args: [...T]): Config<T[number] extends never ? [] : { | ||
[K in keyof T]: [T[K]] extends [Config<infer A>] ? A : never; | ||
}>; | ||
<T extends Readonly<{ | ||
[K: string]: Config<any>; | ||
}>>(args: T): Config<{ | ||
[K in keyof T]: [T[K]] extends [Config<infer A>] ? A : never; | ||
}>; | ||
}; | ||
export declare const all: <Arg extends Iterable<Config<any>> | Record<string, Config<any>>>(arg: Config.Narrow<Arg>) => Config<[ | ||
Arg | ||
] extends [ReadonlyArray<Config<any>>] ? { | ||
-readonly [K in keyof Arg]: [Arg[K]] extends [Config<infer A>] ? A : never; | ||
} : [Arg] extends [Iterable<Config<infer A>>] ? Array<A> : [Arg] extends [Record<string, Config<any>>] ? { | ||
-readonly [K in keyof Arg]: [Arg[K]] extends [Config<infer A>] ? A : never; | ||
} : never>; | ||
/** | ||
@@ -109,3 +94,3 @@ * Constructs a config for an array of values. | ||
*/ | ||
export declare const arrayOf: <A>(config: Config<A>, name?: string | undefined) => Config<ReadonlyArray<A>>; | ||
export declare const array: <A>(config: Config<A>, name?: string | undefined) => Config<ReadonlyArray<A>>; | ||
/** | ||
@@ -117,3 +102,3 @@ * Constructs a config for a boolean value. | ||
*/ | ||
export declare const bool: (name?: string | undefined) => Config<boolean>; | ||
export declare const boolean: (name?: string | undefined) => Config<boolean>; | ||
/** | ||
@@ -125,3 +110,3 @@ * Constructs a config for a sequence of values. | ||
*/ | ||
export declare const chunkOf: <A>(config: Config<A>, name?: string | undefined) => Config<Chunk.Chunk<A>>; | ||
export declare const chunk: <A>(config: Config<A>, name?: string | undefined) => Config<Chunk.Chunk<A>>; | ||
/** | ||
@@ -147,3 +132,3 @@ * Constructs a config for a date value. | ||
*/ | ||
export declare const float: (name?: string | undefined) => Config<number>; | ||
export declare const number: (name?: string | undefined) => Config<number>; | ||
/** | ||
@@ -264,3 +249,3 @@ * Constructs a config for a integer value. | ||
*/ | ||
export declare const optional: <A>(self: Config<A>) => Config<Option.Option<A>>; | ||
export declare const option: <A>(self: Config<A>) => Config<Option.Option<A>>; | ||
/** | ||
@@ -294,3 +279,3 @@ * Constructs a new primitive config. | ||
*/ | ||
export declare const setOf: <A>(config: Config<A>, name?: string | undefined) => Config<HashSet.HashSet<A>>; | ||
export declare const hashSet: <A>(config: Config<A>, name?: string | undefined) => Config<HashSet.HashSet<A>>; | ||
/** | ||
@@ -330,3 +315,3 @@ * Constructs a config for a string value. | ||
*/ | ||
export declare const table: <A>(config: Config<A>, name?: string | undefined) => Config<HashMap.HashMap<string, A>>; | ||
export declare const hashMap: <A>(config: Config<A>, name?: string | undefined) => Config<HashMap.HashMap<string, A>>; | ||
/** | ||
@@ -333,0 +318,0 @@ * Constructs a config from some configuration wrapped with the `Wrap<A>` utility type. |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.zipWith = exports.zip = exports.withDescription = exports.withDefault = exports.validate = exports.unwrap = exports.table = exports.sync = exports.suspend = exports.succeed = exports.string = exports.setOf = exports.secret = exports.repeat = exports.primitive = exports.orElseIf = exports.orElse = exports.optional = exports.nested = exports.mapOrFail = exports.mapAttempt = exports.map = exports.logLevel = exports.isConfig = exports.integer = exports.float = exports.fail = exports.date = exports.chunkOf = exports.bool = exports.arrayOf = exports.all = exports.ConfigTypeId = void 0; | ||
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.isConfig = exports.integer = exports.hashSet = exports.hashMap = exports.fail = exports.date = exports.chunk = exports.boolean = exports.array = exports.all = exports.ConfigTypeId = void 0; | ||
var internal = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/internal/config")); | ||
@@ -31,3 +31,3 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
exports.all = all; | ||
const arrayOf = internal.arrayOf; | ||
const array = internal.array; | ||
/** | ||
@@ -39,4 +39,4 @@ * Constructs a config for a boolean value. | ||
*/ | ||
exports.arrayOf = arrayOf; | ||
const bool = internal.bool; | ||
exports.array = array; | ||
const boolean = internal.boolean; | ||
/** | ||
@@ -48,4 +48,4 @@ * Constructs a config for a sequence of values. | ||
*/ | ||
exports.bool = bool; | ||
const chunkOf = internal.chunkOf; | ||
exports.boolean = boolean; | ||
const chunk = internal.chunk; | ||
/** | ||
@@ -57,3 +57,3 @@ * Constructs a config for a date value. | ||
*/ | ||
exports.chunkOf = chunkOf; | ||
exports.chunk = chunk; | ||
const date = internal.date; | ||
@@ -75,3 +75,3 @@ /** | ||
exports.fail = fail; | ||
const float = internal.float; | ||
const number = internal.number; | ||
/** | ||
@@ -83,3 +83,3 @@ * Constructs a config for a integer value. | ||
*/ | ||
exports.float = float; | ||
exports.number = number; | ||
const integer = internal.integer; | ||
@@ -179,3 +179,3 @@ /** | ||
exports.orElseIf = orElseIf; | ||
const optional = internal.optional; | ||
const option = internal.option; | ||
/** | ||
@@ -187,3 +187,3 @@ * Constructs a new primitive config. | ||
*/ | ||
exports.optional = optional; | ||
exports.option = option; | ||
const primitive = internal.primitive; | ||
@@ -214,3 +214,3 @@ /** | ||
exports.secret = secret; | ||
const setOf = internal.setOf; | ||
const hashSet = internal.hashSet; | ||
/** | ||
@@ -222,3 +222,3 @@ * Constructs a config for a string value. | ||
*/ | ||
exports.setOf = setOf; | ||
exports.hashSet = hashSet; | ||
const string = internal.string; | ||
@@ -256,3 +256,3 @@ /** | ||
exports.sync = sync; | ||
const table = internal.table; | ||
const hashMap = internal.hashMap; | ||
/** | ||
@@ -274,3 +274,3 @@ * Constructs a config from some configuration wrapped with the `Wrap<A>` utility type. | ||
*/ | ||
exports.table = table; | ||
exports.hashMap = hashMap; | ||
const unwrap = internal.unwrap; | ||
@@ -277,0 +277,0 @@ /** |
import type * as Config from "@effect/io/Config"; | ||
export declare const all: { | ||
<A, T extends ReadonlyArray<Config.Config<any>>>(self: Config.Config<A>, ...args: T): Config.Config<[ | ||
A, | ||
...(T["length"] extends 0 ? [] : { | ||
[K in keyof T]: [T[K]] extends [Config.Config<infer A>] ? A : never; | ||
}) | ||
]>; | ||
<T extends ReadonlyArray<Config.Config<any>>>(args: [...T]): Config.Config<T[number] extends never ? [] : { | ||
[K in keyof T]: [T[K]] extends [Config.Config<infer A>] ? A : never; | ||
}>; | ||
<T extends Readonly<{ | ||
[K: string]: Config.Config<any>; | ||
}>>(args: T): Config.Config<{ | ||
[K in keyof T]: [T[K]] extends [Config.Config<infer A>] ? A : never; | ||
}>; | ||
}; | ||
export declare const all: <Arg extends Iterable<Config.Config<any>> | Record<string, Config.Config<any>>>(arg: Config.Config.Narrow<Arg>) => Config.Config<[Arg] extends [readonly Config.Config<any>[]] ? { -readonly [K in keyof Arg]: [Arg[K]] extends [Config.Config<infer A>] ? A : never; } : [Arg] extends [Iterable<Config.Config<infer A_1>>] ? A_1[] : [Arg] extends [Record<string, Config.Config<any>>] ? { -readonly [K_1 in keyof Arg]: [Arg[K_1]] extends [Config.Config<infer A_2>] ? A_2 : never; } : never>; | ||
//# sourceMappingURL=config.d.ts.map |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.zipWith = exports.zip = exports.withDescription = exports.withDefault = exports.validate = exports.unwrap = exports.table = exports.sync = exports.suspend = exports.succeed = exports.string = exports.setOf = exports.secret = exports.repeat = exports.primitive = exports.orElseIf = exports.orElse = exports.optional = exports.nested = exports.missingError = exports.mapOrFail = exports.mapAttempt = exports.map = exports.logLevel = exports.isConfig = exports.integer = exports.float = exports.fail = exports.date = exports.chunkOf = exports.bool = exports.arrayOf = exports.all = exports.ConfigTypeId = void 0; | ||
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.missingError = exports.mapOrFail = exports.mapAttempt = exports.map = exports.logLevel = exports.isConfig = exports.integer = exports.hashSet = exports.hashMap = exports.fail = exports.date = exports.chunk = exports.boolean = exports.array = exports.all = exports.ConfigTypeId = void 0; | ||
var Chunk = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/Chunk")); | ||
@@ -38,3 +38,3 @@ var Either = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/Either")); | ||
/** @internal */ | ||
const bool = name => { | ||
const boolean = name => { | ||
const config = primitive("a boolean property", text => { | ||
@@ -66,13 +66,13 @@ switch (text) { | ||
/** @internal */ | ||
exports.bool = bool; | ||
const arrayOf = (config, name) => { | ||
return map(Chunk.toReadonlyArray)(chunkOf(config, name)); | ||
exports.boolean = boolean; | ||
const array = (config, name) => { | ||
return map(Chunk.toReadonlyArray)(chunk(config, name)); | ||
}; | ||
/** @internal */ | ||
exports.arrayOf = arrayOf; | ||
const chunkOf = (config, name) => { | ||
exports.array = array; | ||
const chunk = (config, name) => { | ||
return map(name === undefined ? repeat(config) : nested(name)(repeat(config)), Chunk.unsafeFromArray); | ||
}; | ||
/** @internal */ | ||
exports.chunkOf = chunkOf; | ||
exports.chunk = chunk; | ||
const date = name => { | ||
@@ -99,7 +99,7 @@ const config = primitive("a date property", text => { | ||
exports.fail = fail; | ||
const float = name => { | ||
const config = primitive("a float property", text => { | ||
const number = name => { | ||
const config = primitive("a number property", text => { | ||
const result = Number.parseFloat(text); | ||
if (Number.isNaN(result)) { | ||
return Either.left(configError.InvalidData([], `Expected an float value but received ${text}`)); | ||
return Either.left(configError.InvalidData([], `Expected an number value but received ${text}`)); | ||
} | ||
@@ -111,3 +111,3 @@ return Either.right(result); | ||
/** @internal */ | ||
exports.float = float; | ||
exports.number = number; | ||
const integer = name => { | ||
@@ -192,3 +192,3 @@ const config = primitive("an integer property", text => { | ||
exports.orElseIf = orElseIf; | ||
const optional = self => { | ||
const option = self => { | ||
return orElseIf({ | ||
@@ -200,3 +200,3 @@ orElse: () => succeed(Option.none()), | ||
/** @internal */ | ||
exports.optional = optional; | ||
exports.option = option; | ||
const primitive = (description, parse) => { | ||
@@ -225,8 +225,8 @@ const primitive = Object.create(proto); | ||
exports.secret = secret; | ||
const setOf = (config, name) => { | ||
const newConfig = map(chunkOf(config), HashSet.fromIterable); | ||
const hashSet = (config, name) => { | ||
const newConfig = map(chunk(config), HashSet.fromIterable); | ||
return name === undefined ? newConfig : nested(name)(newConfig); | ||
}; | ||
/** @internal */ | ||
exports.setOf = setOf; | ||
exports.hashSet = hashSet; | ||
const string = name => { | ||
@@ -237,13 +237,9 @@ const config = primitive("a text property", Either.right); | ||
exports.string = string; | ||
const all = function () { | ||
if (arguments.length === 1) { | ||
if (typeof arguments[0] === "object" && arguments[0] !== null && isConfig(arguments[0])) { | ||
return map(arguments[0], x => [x]); | ||
} else if (Array.isArray(arguments[0])) { | ||
return tuple(arguments); | ||
} else { | ||
return struct(arguments[0]); | ||
} | ||
const all = arg => { | ||
if (Array.isArray(arg)) { | ||
return tuple(arg); | ||
} else if (Symbol.iterator in arg) { | ||
return tuple([...arg]); | ||
} | ||
return tuple(arguments); | ||
return struct(arg); | ||
}; | ||
@@ -291,5 +287,5 @@ exports.all = all; | ||
exports.sync = sync; | ||
const table = (config, name) => { | ||
const hashMap = (config, name) => { | ||
const table = Object.create(proto); | ||
table._tag = OpCodes.OP_TABLE; | ||
table._tag = OpCodes.OP_HASHMAP; | ||
table.valueConfig = config; | ||
@@ -299,3 +295,3 @@ return name === undefined ? table : nested(name)(table); | ||
/** @internal */ | ||
exports.table = table; | ||
exports.hashMap = hashMap; | ||
const isConfig = u => typeof u === "object" && u != null && ConfigTypeId in u; | ||
@@ -302,0 +298,0 @@ /** @internal */ |
@@ -211,3 +211,3 @@ "use strict"; | ||
} | ||
case OpCodes.OP_TABLE: | ||
case OpCodes.OP_HASHMAP: | ||
{ | ||
@@ -362,3 +362,3 @@ return core.suspend(() => core.flatMap(prefix => core.flatMap(keys => { | ||
const optionalIndex = Option.flatMap(parseInteger)(matchedIndex !== undefined && matchedIndex.length > 0 ? Option.some(matchedIndex) : Option.none()); | ||
return Option.all(optionalString, optionalIndex); | ||
return Option.all([optionalString, optionalIndex]); | ||
} | ||
@@ -365,0 +365,0 @@ return Option.none(); |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.OP_ZIP_WITH = exports.OP_TABLE = exports.OP_SEQUENCE = exports.OP_PRIMITIVE = exports.OP_NESTED = exports.OP_MAP_OR_FAIL = exports.OP_LAZY = exports.OP_FALLBACK = exports.OP_FAIL = exports.OP_DESCRIBED = exports.OP_CONSTANT = void 0; | ||
exports.OP_ZIP_WITH = exports.OP_SEQUENCE = exports.OP_PRIMITIVE = exports.OP_NESTED = exports.OP_MAP_OR_FAIL = exports.OP_LAZY = exports.OP_HASHMAP = exports.OP_FALLBACK = exports.OP_FAIL = exports.OP_DESCRIBED = exports.OP_CONSTANT = void 0; | ||
/** @internal */ | ||
@@ -36,7 +36,7 @@ const OP_CONSTANT = "Constant"; | ||
exports.OP_SEQUENCE = OP_SEQUENCE; | ||
const OP_TABLE = "Table"; | ||
const OP_HASHMAP = "HashMap"; | ||
/** @internal */ | ||
exports.OP_TABLE = OP_TABLE; | ||
exports.OP_HASHMAP = OP_HASHMAP; | ||
const OP_ZIP_WITH = "ZipWith"; | ||
exports.OP_ZIP_WITH = OP_ZIP_WITH; | ||
//# sourceMappingURL=config.js.map |
{ | ||
"name": "@effect/io", | ||
"version": "0.34.0", | ||
"version": "0.35.0", | ||
"license": "MIT", | ||
@@ -10,3 +10,3 @@ "repository": { | ||
"dependencies": { | ||
"@effect/data": "^0.15.0" | ||
"@effect/data": "^0.16.0" | ||
}, | ||
@@ -13,0 +13,0 @@ "publishConfig": { |
@@ -19,14 +19,2 @@ /** | ||
* @since 1.0.0 | ||
*/ | ||
export type NonEmptyArrayConfig = [Config<any>, ...Array<Config<any>>] | ||
/** | ||
* @since 1.0.0 | ||
*/ | ||
export type TupleConfig<T extends NonEmptyArrayConfig> = { | ||
[K in keyof T]: [T[K]] extends [Config<infer A>] ? A : never | ||
} | ||
/** | ||
* @since 1.0.0 | ||
* @category symbols | ||
@@ -89,2 +77,7 @@ */ | ||
| Config<A> | ||
/** | ||
* @since 1.0.0 | ||
*/ | ||
export type Narrow<A> = (A extends [] ? [] : never) | A | ||
} | ||
@@ -98,25 +91,14 @@ | ||
*/ | ||
export const all: { | ||
<A, T extends ReadonlyArray<Config<any>>>( | ||
self: Config<A>, | ||
...args: T | ||
): Config< | ||
[ | ||
A, | ||
...(T["length"] extends 0 ? [] | ||
: { [K in keyof T]: [T[K]] extends [Config<infer A>] ? A : never }) | ||
] | ||
> | ||
<T extends ReadonlyArray<Config<any>>>( | ||
args: [...T] | ||
): Config< | ||
T[number] extends never ? [] | ||
: { [K in keyof T]: [T[K]] extends [Config<infer A>] ? A : never } | ||
> | ||
<T extends Readonly<{ [K: string]: Config<any> }>>( | ||
args: T | ||
): Config< | ||
{ [K in keyof T]: [T[K]] extends [Config<infer A>] ? A : never } | ||
> | ||
} = internal.all | ||
export const all: <Arg extends Iterable<Config<any>> | Record<string, Config<any>>>( | ||
arg: Config.Narrow<Arg> | ||
) => Config< | ||
[Arg] extends [ReadonlyArray<Config<any>>] ? { | ||
-readonly [K in keyof Arg]: [Arg[K]] extends [Config<infer A>] ? A : never | ||
} | ||
: [Arg] extends [Iterable<Config<infer A>>] ? Array<A> | ||
: [Arg] extends [Record<string, Config<any>>] ? { | ||
-readonly [K in keyof Arg]: [Arg[K]] extends [Config<infer A>] ? A : never | ||
} | ||
: never | ||
> = internal.all | ||
@@ -129,3 +111,3 @@ /** | ||
*/ | ||
export const arrayOf: <A>(config: Config<A>, name?: string | undefined) => Config<ReadonlyArray<A>> = internal.arrayOf | ||
export const array: <A>(config: Config<A>, name?: string | undefined) => Config<ReadonlyArray<A>> = internal.array | ||
@@ -138,3 +120,3 @@ /** | ||
*/ | ||
export const bool: (name?: string | undefined) => Config<boolean> = internal.bool | ||
export const boolean: (name?: string | undefined) => Config<boolean> = internal.boolean | ||
@@ -147,3 +129,3 @@ /** | ||
*/ | ||
export const chunkOf: <A>(config: Config<A>, name?: string | undefined) => Config<Chunk.Chunk<A>> = internal.chunkOf | ||
export const chunk: <A>(config: Config<A>, name?: string | undefined) => Config<Chunk.Chunk<A>> = internal.chunk | ||
@@ -172,3 +154,3 @@ /** | ||
*/ | ||
export const float: (name?: string | undefined) => Config<number> = internal.float | ||
export const number: (name?: string | undefined) => Config<number> = internal.number | ||
@@ -304,3 +286,3 @@ /** | ||
*/ | ||
export const optional: <A>(self: Config<A>) => Config<Option.Option<A>> = internal.optional | ||
export const option: <A>(self: Config<A>) => Config<Option.Option<A>> = internal.option | ||
@@ -341,3 +323,3 @@ /** | ||
*/ | ||
export const setOf: <A>(config: Config<A>, name?: string | undefined) => Config<HashSet.HashSet<A>> = internal.setOf | ||
export const hashSet: <A>(config: Config<A>, name?: string | undefined) => Config<HashSet.HashSet<A>> = internal.hashSet | ||
@@ -382,4 +364,4 @@ /** | ||
*/ | ||
export const table: <A>(config: Config<A>, name?: string | undefined) => Config<HashMap.HashMap<string, A>> = | ||
internal.table | ||
export const hashMap: <A>(config: Config<A>, name?: string | undefined) => Config<HashMap.HashMap<string, A>> = | ||
internal.hashMap | ||
@@ -386,0 +368,0 @@ /** |
@@ -132,4 +132,4 @@ import * as Chunk from "@effect/data/Chunk" | ||
export interface Table extends | ||
Op<OpCodes.OP_TABLE, { | ||
readonly op: OpCodes.OP_TABLE | ||
Op<OpCodes.OP_HASHMAP, { | ||
readonly op: OpCodes.OP_HASHMAP | ||
readonly valueConfig: Config.Config<unknown> | ||
@@ -150,3 +150,3 @@ }> | ||
/** @internal */ | ||
export const bool = (name?: string): Config.Config<boolean> => { | ||
export const boolean = (name?: string): Config.Config<boolean> => { | ||
const config = primitive( | ||
@@ -182,8 +182,8 @@ "a boolean property", | ||
/** @internal */ | ||
export const arrayOf = <A>(config: Config.Config<A>, name?: string): Config.Config<ReadonlyArray<A>> => { | ||
return pipe(chunkOf(config, name), map(Chunk.toReadonlyArray)) | ||
export const array = <A>(config: Config.Config<A>, name?: string): Config.Config<ReadonlyArray<A>> => { | ||
return pipe(chunk(config, name), map(Chunk.toReadonlyArray)) | ||
} | ||
/** @internal */ | ||
export const chunkOf = <A>(config: Config.Config<A>, name?: string): Config.Config<Chunk.Chunk<A>> => { | ||
export const chunk = <A>(config: Config.Config<A>, name?: string): Config.Config<Chunk.Chunk<A>> => { | ||
return map(name === undefined ? repeat(config) : nested(name)(repeat(config)), Chunk.unsafeFromArray) | ||
@@ -222,5 +222,5 @@ } | ||
/** @internal */ | ||
export const float = (name?: string): Config.Config<number> => { | ||
export const number = (name?: string): Config.Config<number> => { | ||
const config = primitive( | ||
"a float property", | ||
"a number property", | ||
(text) => { | ||
@@ -232,3 +232,3 @@ const result = Number.parseFloat(text) | ||
[], | ||
`Expected an float value but received ${text}` | ||
`Expected an number value but received ${text}` | ||
) | ||
@@ -368,3 +368,3 @@ ) | ||
/** @internal */ | ||
export const optional = <A>(self: Config.Config<A>): Config.Config<Option.Option<A>> => { | ||
export const option = <A>(self: Config.Config<A>): Config.Config<Option.Option<A>> => { | ||
return pipe( | ||
@@ -407,4 +407,4 @@ self, | ||
/** @internal */ | ||
export const setOf = <A>(config: Config.Config<A>, name?: string): Config.Config<HashSet.HashSet<A>> => { | ||
const newConfig = map(chunkOf(config), HashSet.fromIterable) | ||
export const hashSet = <A>(config: Config.Config<A>, name?: string): Config.Config<HashSet.HashSet<A>> => { | ||
const newConfig = map(chunk(config), HashSet.fromIterable) | ||
return name === undefined ? newConfig : nested(name)(newConfig) | ||
@@ -422,36 +422,21 @@ } | ||
export const all: { | ||
<A, T extends ReadonlyArray<Config.Config<any>>>( | ||
self: Config.Config<A>, | ||
...args: T | ||
): Config.Config< | ||
[ | ||
A, | ||
...(T["length"] extends 0 ? [] | ||
: { [K in keyof T]: [T[K]] extends [Config.Config<infer A>] ? A : never }) | ||
] | ||
> | ||
<T extends ReadonlyArray<Config.Config<any>>>( | ||
args: [...T] | ||
): Config.Config< | ||
T[number] extends never ? [] | ||
: { [K in keyof T]: [T[K]] extends [Config.Config<infer A>] ? A : never } | ||
> | ||
<T extends Readonly<{ [K: string]: Config.Config<any> }>>( | ||
args: T | ||
): Config.Config< | ||
{ [K in keyof T]: [T[K]] extends [Config.Config<infer A>] ? A : never } | ||
> | ||
} = function() { | ||
if (arguments.length === 1) { | ||
if (typeof arguments[0] === "object" && arguments[0] !== null && isConfig(arguments[0])) { | ||
return map(arguments[0], (x) => [x]) | ||
} else if (Array.isArray(arguments[0])) { | ||
return tuple(arguments) | ||
} else { | ||
return struct(arguments[0] as Readonly<{ [K: string]: Config.Config<any> }>) | ||
export const all = <Arg extends Iterable<Config.Config<any>> | Record<string, Config.Config<any>>>( | ||
arg: Config.Config.Narrow<Arg> | ||
): Config.Config< | ||
[Arg] extends [ReadonlyArray<Config.Config<any>>] ? { | ||
-readonly [K in keyof Arg]: [Arg[K]] extends [Config.Config<infer A>] ? A : never | ||
} | ||
: [Arg] extends [Iterable<Config.Config<infer A>>] ? Array<A> | ||
: [Arg] extends [Record<string, Config.Config<any>>] ? { | ||
-readonly [K in keyof Arg]: [Arg[K]] extends [Config.Config<infer A>] ? A : never | ||
} | ||
: never | ||
> => { | ||
if (Array.isArray(arg)) { | ||
return tuple(arg) as any | ||
} else if (Symbol.iterator in arg) { | ||
return tuple([...(arg as Iterable<Config.Config<any>>)]) as any | ||
} | ||
return tuple(arguments) | ||
} as any | ||
return struct(arg) as any | ||
} | ||
@@ -501,5 +486,5 @@ const struct = <NER extends Record<string, Config.Config<any>>>(r: NER): Config.Config< | ||
/** @internal */ | ||
export const table = <A>(config: Config.Config<A>, name?: string): Config.Config<HashMap.HashMap<string, A>> => { | ||
export const hashMap = <A>(config: Config.Config<A>, name?: string): Config.Config<HashMap.HashMap<string, A>> => { | ||
const table = Object.create(proto) | ||
table._tag = OpCodes.OP_TABLE | ||
table._tag = OpCodes.OP_HASHMAP | ||
table.valueConfig = config | ||
@@ -506,0 +491,0 @@ return name === undefined ? table : nested(name)(table) |
@@ -342,3 +342,3 @@ import * as Context from "@effect/data/Context" | ||
} | ||
case OpCodes.OP_TABLE: { | ||
case OpCodes.OP_HASHMAP: { | ||
return core.suspend(() => | ||
@@ -683,3 +683,3 @@ pipe( | ||
) | ||
return Option.all(optionalString, optionalIndex) | ||
return Option.all([optionalString, optionalIndex]) | ||
} | ||
@@ -686,0 +686,0 @@ return Option.none() |
@@ -56,6 +56,6 @@ /** @internal */ | ||
/** @internal */ | ||
export type OP_TABLE = typeof OP_TABLE | ||
export type OP_HASHMAP = typeof OP_HASHMAP | ||
/** @internal */ | ||
export const OP_TABLE = "Table" as const | ||
export const OP_HASHMAP = "HashMap" as const | ||
@@ -62,0 +62,0 @@ /** @internal */ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6371086
113727
+ Added@effect/data@0.16.3(transitive)
- Removed@effect/data@0.15.1(transitive)
Updated@effect/data@^0.16.0