/** * This module targets objects in the sense of product types. For objects in * the sense of maps see the `Record` module. * * @since 0.14.0 */ /** * Merge two structs together. For merging many identical structs, instead * consider defining a semigroup. * * @example * import { merge } from 'fp-ts-std/Struct' * * assert.deepStrictEqual(merge({ a: 1, b: 2 })({ b: 'two', c: true }), { a: 1, b: 'two', c: true }) * * @category 3 Functions * @since 0.14.0 */ export declare const merge: (x: A) => (y: C) => A & C; /** * Pick a set of keys from a struct. The value-level equivalent of the `Pick` * type. * * @example * import { pick } from 'fp-ts-std/Struct' * import { pipe } from 'fp-ts/function' * * const picked = pipe( * { a: 1, b: 'two', c: [true] }, * pick(['a', 'c']) * ) * * assert.deepStrictEqual(picked, { a: 1, c: [true] }) * * @category 3 Functions * @since 0.14.0 */ export declare const pick: (ks: K[]) => (x: A) => Pick; /** * Like `pick`, but allows you to specify the input struct upfront. * * @example * import { pickFrom } from 'fp-ts-std/Struct' * * type MyType = { a: number; b: string; c: ReadonlyArray } * const picked = pickFrom()(['a', 'c']) * * assert.deepStrictEqual(picked({ a: 1, b: 'two', c: [true] }), { a: 1, c: [true] }) * * @category 3 Functions * @since 0.14.0 */ export declare const pickFrom: () => (ks: K[]) => (x: A) => Pick; /** * Get the value for a key in a struct. * * @example * import { get } from 'fp-ts-std/Struct' * * type Person = { name: string; age: number } * const person: Person = { name: 'Albert', age: 76 } * * const getName = get('name') * * assert.strictEqual(getName(person), 'Albert') * * @category 3 Functions * @since 0.17.0 */ export declare const get: (k: K) => (x: Record) => A; /** * Omit a set of keys from a struct. The value-level equivalent of the `Omit` * type. * * @example * import { omit } from 'fp-ts-std/Struct' * * const sansB = omit(['b']) * * assert.deepStrictEqual(sansB({ a: 1, b: 'two', c: [true] }), { a: 1, c: [true] }) * * @category 3 Functions * @since 0.14.0 */ export declare const omit: (ks: K[]) => >(x: A) => Omit; /** * Like `omit`, but allows you to specify the input struct upfront. * * @example * import { omitFrom } from 'fp-ts-std/Struct' * * type MyType = { a: number; b: string; c: ReadonlyArray } * const sansB = omitFrom()(['b']) * * assert.deepStrictEqual(sansB({ a: 1, b: 'two', c: [true] }), { a: 1, c: [true] }) * * @category 3 Functions * @since 0.15.0 */ export declare const omitFrom: () => (ks: K[]) => (x: A) => Omit; type OptionalKeys = { [K in keyof O]-?: Record extends Pick ? K : never; }[keyof O]; type Exact = A & Record, never>; /** * Provide default values for an object with optional properties. * * @example * import { withDefaults } from 'fp-ts-std/Struct' * import { pipe } from 'fp-ts/function' * * const aOptB: { a: number; b?: string } = { a: 1 } * * assert.deepStrictEqual(pipe(aOptB, withDefaults({ b: 'foo' })), { a: 1, b: 'foo' }) * * @category 3 Functions * @since 0.15.0 */ export declare const withDefaults: ]-?: Exclude; }, PT>>(defaults: PT) => (t: T) => PT & T; type MaybePartial = A | Partial; type RenameKey, I extends keyof A, J extends string> = { [K in keyof A as K extends I ? J : K]: A[K]; }; /** * Rename a key in a struct, preserving the value. If the new key already * exists, the old key will be overwritten. Optionality is preserved. * * @example * import { renameKey } from 'fp-ts-std/Struct' * * type Foo = { a: string; b: number } * type Bar = { a: string; c: number } * * const fooBar: (x: Foo) => Bar = renameKey('b')('c') * * @category 3 Functions * @since 0.15.0 */ export declare const renameKey: (oldK: I) => (newK: J) => >>(x: A) => RenameKey; export {}; //# sourceMappingURL=Struct.d.ts.map