/** * @since 2.0.0 */ import { Applicative, Applicative1, Applicative2, Applicative2C, Applicative3, Applicative3C } from './Applicative' import { Compactable1, Separated } from './Compactable' import { Either } from './Either' import { Eq } from './Eq' import { Filterable1 } from './Filterable' import { FilterableWithIndex1, PredicateWithIndex, RefinementWithIndex } from './FilterableWithIndex' import { Foldable as FoldableHKT, Foldable1, Foldable2, Foldable3 } from './Foldable' import { FoldableWithIndex1 } from './FoldableWithIndex' import { Predicate, Refinement } from './function' import { Functor1 } from './Functor' import { FunctorWithIndex1 } from './FunctorWithIndex' import { HKT, Kind, Kind2, Kind3, URIS, URIS2, URIS3 } from './HKT' import { Magma } from './Magma' import { Monoid } from './Monoid' import { Option } from './Option' import { Semigroup } from './Semigroup' import { Show } from './Show' import { Traversable1 } from './Traversable' import { TraversableWithIndex1 } from './TraversableWithIndex' import { Unfoldable, Unfoldable1 } from './Unfoldable' import { PipeableWilt1, PipeableWither1, Witherable1 } from './Witherable' /** * @since 2.0.0 */ export declare const getShow: (S: Show) => Show> /** * Calculate the number of key/value pairs in a record * * @since 2.0.0 */ export declare const size: (r: Record) => number /** * Test whether a record is empty * * @since 2.0.0 */ export declare const isEmpty: (r: Record) => boolean /** * @since 2.0.0 */ export declare const keys: (r: Record) => Array /** * Map a record into an array * * @example * import {collect} from 'fp-ts/Record' * * const x: { a: string, b: boolean } = { a: 'foo', b: false } * assert.deepStrictEqual( * collect((key, val) => ({key: key, value: val}))(x), * [{key: 'a', value: 'foo'}, {key: 'b', value: false}] * ) * * @since 2.0.0 */ export declare const collect: (f: (k: K, a: A) => B) => (r: Record) => Array /** * @since 2.0.0 */ export declare const toArray: (r: Record) => Array<[K, A]> /** * Unfolds a record into a list of key/value pairs * * @since 2.0.0 */ export declare function toUnfoldable( U: Unfoldable1 ): (r: Record) => Kind export declare function toUnfoldable(U: Unfoldable): (r: Record) => HKT /** * Insert or replace a key/value pair in a record * * @since 2.0.0 */ export declare function insertAt( k: K, a: A ): (r: Record) => Record /** * @since 2.0.0 */ export declare const hasOwnProperty: (k: string, r: Record) => k is K /** * Delete a key and value from a map * * @since 2.0.0 */ export declare function deleteAt( k: K ): (r: Record) => Record, A> /** * @since 2.0.0 */ export declare const updateAt: (k: string, a: A) => (r: Record) => Option> /** * @since 2.0.0 */ export declare const modifyAt: ( k: string, f: (a: A) => A ) => (r: Record) => Option> /** * Delete a key and value from a map, returning the value as well as the subsequent map * * @since 2.0.0 */ export declare function pop( k: K ): (r: Record) => Option<[A, Record, A>]> /** * Test whether one record contains all of the keys and values contained in another record * * @since 2.0.0 */ export declare const isSubrecord: ( E: Eq ) => { (that: Record): (me: Record) => boolean (me: Record, that: Record): boolean } /** * @since 2.0.0 */ export declare function getEq(E: Eq): Eq> /** * Returns a `Monoid` instance for records given a `Semigroup` instance for their values * * @example * import { semigroupSum } from 'fp-ts/Semigroup' * import { getMonoid } from 'fp-ts/Record' * * const M = getMonoid(semigroupSum) * assert.deepStrictEqual(M.concat({ foo: 123 }, { foo: 456 }), { foo: 579 }) * * @since 2.0.0 */ export declare function getMonoid(S: Semigroup): Monoid> /** * Lookup the value for a key in a record * * @since 2.0.0 */ export declare const lookup: { (k: string): (r: Record) => Option (k: string, r: Record): Option } /** * @since 2.0.0 */ export declare const empty: Record /** * Map a record passing the keys to the iterating function * * @since 2.0.0 */ export declare function mapWithIndex(f: (k: K, a: A) => B): (fa: Record) => Record /** * Map a record passing the values to the iterating function * * @since 2.0.0 */ export declare function map(f: (a: A) => B): (fa: Record) => Record /** * @since 2.0.0 */ export declare function reduceWithIndex( b: B, f: (k: K, b: B, a: A) => B ): (fa: Record) => B /** * @since 2.0.0 */ export declare function foldMapWithIndex( M: Monoid ): (f: (k: K, a: A) => M) => (fa: Record) => M /** * @since 2.0.0 */ export declare function reduceRightWithIndex( b: B, f: (k: K, a: A, b: B) => B ): (fa: Record) => B /** * Create a record with one key/value pair * * @since 2.0.0 */ export declare const singleton: (k: K, a: A) => Record /** * @since 2.0.0 */ export declare function traverseWithIndex( F: Applicative3 ): ( f: (k: K, a: A) => Kind3 ) => (ta: Record) => Kind3> export declare function traverseWithIndex( F: Applicative3C ): ( f: (k: K, a: A) => Kind3 ) => (ta: Record) => Kind3> export declare function traverseWithIndex( F: Applicative2 ): (f: (k: K, a: A) => Kind2) => (ta: Record) => Kind2> export declare function traverseWithIndex( F: Applicative2C ): (f: (k: K, a: A) => Kind2) => (ta: Record) => Kind2> export declare function traverseWithIndex( F: Applicative1 ): (f: (k: K, a: A) => Kind) => (ta: Record) => Kind> export declare function traverseWithIndex( F: Applicative ): (f: (k: K, a: A) => HKT) => (ta: Record) => HKT> /** * @since 2.0.0 */ export declare function traverse( F: Applicative3 ): (f: (a: A) => Kind3) => (ta: Record) => Kind3> export declare function traverse( F: Applicative3C ): (f: (a: A) => Kind3) => (ta: Record) => Kind3> export declare function traverse( F: Applicative2 ): (f: (a: A) => Kind2) => (ta: Record) => Kind2> export declare function traverse( F: Applicative2C ): (f: (a: A) => Kind2) => (ta: Record) => Kind2> export declare function traverse( F: Applicative1 ): (f: (a: A) => Kind) => (ta: Record) => Kind> export declare function traverse( F: Applicative ): (f: (a: A) => HKT) => (ta: Record) => HKT> /** * @since 2.0.0 */ export declare function sequence( F: Applicative3 ): (ta: Record>) => Kind3> export declare function sequence( F: Applicative3C ): (ta: Record>) => Kind3> export declare function sequence( F: Applicative2 ): (ta: Record>) => Kind2> export declare function sequence( F: Applicative2C ): (ta: Record>) => Kind2> export declare function sequence( F: Applicative1 ): (ta: Record>) => Kind> export declare function sequence( F: Applicative ): (ta: Record>) => HKT> /** * @category Witherable * @since 2.6.5 */ export declare const wither: PipeableWither1 /** * @category Witherable * @since 2.6.5 */ export declare const wilt: PipeableWilt1 /** * @since 2.0.0 */ export declare function partitionMapWithIndex( f: (key: K, a: A) => Either ): (fa: Record) => Separated, Record> /** * @since 2.0.0 */ export declare function partitionWithIndex( refinementWithIndex: RefinementWithIndex ): (fa: Record) => Separated, Record> export declare function partitionWithIndex( predicateWithIndex: PredicateWithIndex ): (fa: Record) => Separated, Record> /** * @since 2.0.0 */ export declare function filterMapWithIndex( f: (key: K, a: A) => Option ): (fa: Record) => Record /** * @since 2.0.0 */ export declare function filterWithIndex( refinementWithIndex: RefinementWithIndex ): (fa: Record) => Record export declare function filterWithIndex( predicateWithIndex: PredicateWithIndex ): (fa: Record) => Record /** * Create a record from a foldable collection of key/value pairs, using the * specified `Magma` to combine values for duplicate keys. * * @since 2.0.0 */ export declare function fromFoldable( M: Magma, F: Foldable3 ): (fka: Kind3) => Record export declare function fromFoldable( M: Magma, F: Foldable2 ): (fka: Kind2) => Record export declare function fromFoldable( M: Magma, F: Foldable1 ): (fka: Kind) => Record export declare function fromFoldable( M: Magma, F: FoldableHKT ): (fka: HKT) => Record /** * Create a record from a foldable collection using the specified functions to * * - map to key/value pairs * - combine values for duplicate keys. * * @example * import { getLastSemigroup } from 'fp-ts/Semigroup' * import { array, zip } from 'fp-ts/Array' * import { identity } from 'fp-ts/function' * import { fromFoldableMap } from 'fp-ts/Record' * * // like lodash `zipObject` or ramda `zipObj` * export const zipObject = (keys: Array, values: Array): Record => * fromFoldableMap(getLastSemigroup(), array)(zip(keys, values), identity) * * assert.deepStrictEqual(zipObject(['a', 'b'], [1, 2, 3]), { a: 1, b: 2 }) * * // build a record from a field * interface User { * id: string * name: string * } * * const users: Array = [ * { id: 'id1', name: 'name1' }, * { id: 'id2', name: 'name2' }, * { id: 'id1', name: 'name3' } * ] * * assert.deepStrictEqual(fromFoldableMap(getLastSemigroup(), array)(users, user => [user.id, user]), { * id1: { id: 'id1', name: 'name3' }, * id2: { id: 'id2', name: 'name2' } * }) * * @since 2.0.0 */ export declare function fromFoldableMap( M: Magma, F: Foldable3 ): (fa: Kind3, f: (a: A) => [K, B]) => Record export declare function fromFoldableMap( M: Magma, F: Foldable2 ): (fa: Kind2, f: (a: A) => [K, B]) => Record export declare function fromFoldableMap( M: Magma, F: Foldable1 ): (fa: Kind, f: (a: A) => [K, B]) => Record export declare function fromFoldableMap( M: Magma, F: FoldableHKT ): (fa: HKT, f: (a: A) => [K, B]) => Record /** * @since 2.0.0 */ export declare const every: (predicate: Predicate) => (r: Record) => boolean /** * @since 2.0.0 */ export declare const some: (predicate: (a: A) => boolean) => (r: Record) => boolean /** * @since 2.0.0 */ export declare const elem: ( E: Eq ) => { (a: A): (fa: Record) => boolean (a: A, fa: Record): boolean } /** * @category Filterable * @since 2.0.0 */ export declare const filter: { (refinement: Refinement): (fa: Record) => Record (predicate: Predicate): (fa: Record) => Record } /** * @category Filterable * @since 2.0.0 */ export declare const filterMap: (f: (a: A) => Option) => (fa: Record) => Record /** * @category Foldable * @since 2.0.0 */ export declare const foldMap: (M: Monoid) => (f: (a: A) => M) => (fa: Record) => M /** * @category Filterable * @since 2.0.0 */ export declare const partition: { (refinement: Refinement): ( fa: Record ) => Separated, Record> (predicate: Predicate): (fa: Record) => Separated, Record> } /** * @category Filterable * @since 2.0.0 */ export declare const partitionMap: ( f: (a: A) => Either ) => (fa: Record) => Separated, Record> /** * @category Foldable * @since 2.0.0 */ export declare const reduce: (b: B, f: (b: B, a: A) => B) => (fa: Record) => B /** * @category Foldable * @since 2.0.0 */ export declare const reduceRight: (b: B, f: (a: A, b: B) => B) => (fa: Record) => B /** * @category Compactable * @since 2.0.0 */ export declare const compact: (fa: Record>) => Record /** * @category Compactable * @since 2.0.0 */ export declare const separate: ( fa: Record> ) => Separated, Record> /** * @category instances * @since 2.0.0 */ export declare const URI = 'Record' /** * @category instances * @since 2.0.0 */ export declare type URI = typeof URI declare module './HKT' { interface URItoKind { readonly [URI]: Record } } /** * @category instances * @since 2.7.0 */ export declare const Functor: Functor1 /** * @category instances * @since 2.7.0 */ export declare const FunctorWithIndex: FunctorWithIndex1 /** * @category instances * @since 2.7.0 */ export declare const Foldable: Foldable1 /** * @category instances * @since 2.7.0 */ export declare const FoldableWithIndex: FoldableWithIndex1 /** * @category instances * @since 2.7.0 */ export declare const Compactable: Compactable1 /** * @category instances * @since 2.7.0 */ export declare const Filterable: Filterable1 /** * @category instances * @since 2.7.0 */ export declare const FilterableWithIndex: FilterableWithIndex1 /** * @category instances * @since 2.7.0 */ export declare const Traversable: Traversable1 /** * @category instances * @since 2.7.0 */ export declare const TraversableWithIndex: TraversableWithIndex1 /** * @category instances * @since 2.7.0 */ export declare const Witherable: Witherable1 /** * @category instances * @since 2.0.0 */ export declare const record: FunctorWithIndex1 & FoldableWithIndex1 & FilterableWithIndex1 & TraversableWithIndex1 & Witherable1