Function diMapOnce

Combine multiple states to one with further caching within diInit callback

const nums = dis((ns, n) => [...ns, n], [])
const prefix = dic<string>()
const numbers = diMapOnce((prefix, nums) => `${prefix} ${nums}`, prefix, nums)
prefix('Numbers: ')
nums(1)
nums(2)
nums(3)
numbers() // Numbers: 1,2,3
nums(4)
numbers() // Numbers: 1,2,3 - because cached
  • Type Parameters

    • T1
    • R

    Parameters

    • pred: ((x1: T1) => R)
        • (x1): R
        • Parameters

          Returns R

    • fn1: ((...args: any[]) => T1)
        • (...args): T1
        • Parameters

          • Rest...args: any[]

          Returns T1

    Returns (() => R) & {
        raw: ((x1: T1) => R);
    }

  • Type Parameters

    • T1
    • T2
    • R

    Parameters

    • pred: ((x1: T1, x2: T2) => R)
        • (x1, x2): R
        • Parameters

          Returns R

    • fn1: ((...args: any[]) => T1)
        • (...args): T1
        • Parameters

          • Rest...args: any[]

          Returns T1

    • fn2: ((...args: any[]) => T2)
        • (...args): T2
        • Parameters

          • Rest...args: any[]

          Returns T2

    Returns (() => R) & {
        raw: ((x1: T1, x2: T2) => R);
    }

  • Type Parameters

    • T1
    • T2
    • T3
    • R

    Parameters

    • pred: ((x1: T1, x2: T2, x3: T3) => R)
        • (x1, x2, x3): R
        • Parameters

          Returns R

    • fn1: ((...args: any[]) => T1)
        • (...args): T1
        • Parameters

          • Rest...args: any[]

          Returns T1

    • fn2: ((...args: any[]) => T2)
        • (...args): T2
        • Parameters

          • Rest...args: any[]

          Returns T2

    • fn3: ((...args: any[]) => T3)
        • (...args): T3
        • Parameters

          • Rest...args: any[]

          Returns T3

    Returns (() => R) & {
        raw: ((x1: T1, x2: T2, x3: T3) => R);
    }

  • Type Parameters

    • T1
    • T2
    • T3
    • T4
    • R

    Parameters

    • pred: ((x1: T1, x2: T2, x3: T3, x4: T4) => R)
        • (x1, x2, x3, x4): R
        • Parameters

          Returns R

    • fn1: ((...args: any[]) => T1)
        • (...args): T1
        • Parameters

          • Rest...args: any[]

          Returns T1

    • fn2: ((...args: any[]) => T2)
        • (...args): T2
        • Parameters

          • Rest...args: any[]

          Returns T2

    • fn3: ((...args: any[]) => T3)
        • (...args): T3
        • Parameters

          • Rest...args: any[]

          Returns T3

    • fn4: ((...args: any[]) => T4)
        • (...args): T4
        • Parameters

          • Rest...args: any[]

          Returns T4

    Returns (() => R) & {
        raw: ((x1: T1, x2: T2, x3: T3, x4: T4) => R);
    }

  • Type Parameters

    • T1
    • T2
    • T3
    • T4
    • T5
    • R

    Parameters

    • pred: ((x1: T1, x2: T2, x3: T3, x4: T4, x5: T5) => R)
        • (x1, x2, x3, x4, x5): R
        • Parameters

          Returns R

    • fn1: ((...args: any[]) => T1)
        • (...args): T1
        • Parameters

          • Rest...args: any[]

          Returns T1

    • fn2: ((...args: any[]) => T2)
        • (...args): T2
        • Parameters

          • Rest...args: any[]

          Returns T2

    • fn3: ((...args: any[]) => T3)
        • (...args): T3
        • Parameters

          • Rest...args: any[]

          Returns T3

    • fn4: ((...args: any[]) => T4)
        • (...args): T4
        • Parameters

          • Rest...args: any[]

          Returns T4

    • fn5: ((...args: any[]) => T5)
        • (...args): T5
        • Parameters

          • Rest...args: any[]

          Returns T5

    Returns (() => R) & {
        raw: ((x1: T1, x2: T2, x3: T3, x4: T4, x5: T5) => R);
    }

  • Type Parameters

    • T1
    • T2
    • T3
    • T4
    • T5
    • T6
    • R

    Parameters

    • pred: ((x1: T1, x2: T2, x3: T3, x4: T4, x5: T5, x6: T6) => R)
        • (x1, x2, x3, x4, x5, x6): R
        • Parameters

          Returns R

    • fn1: ((...args: any[]) => T1)
        • (...args): T1
        • Parameters

          • Rest...args: any[]

          Returns T1

    • fn2: ((...args: any[]) => T2)
        • (...args): T2
        • Parameters

          • Rest...args: any[]

          Returns T2

    • fn3: ((...args: any[]) => T3)
        • (...args): T3
        • Parameters

          • Rest...args: any[]

          Returns T3

    • fn4: ((...args: any[]) => T4)
        • (...args): T4
        • Parameters

          • Rest...args: any[]

          Returns T4

    • fn5: ((...args: any[]) => T5)
        • (...args): T5
        • Parameters

          • Rest...args: any[]

          Returns T5

    • fn6: ((...args: any[]) => T6)
        • (...args): T6
        • Parameters

          • Rest...args: any[]

          Returns T6

    Returns (() => R) & {
        raw: ((x1: T1, x2: T2, x3: T3, x4: T4, x5: T5, x6: T6) => R);
    }

  • Type Parameters

    • T1
    • T2
    • T3
    • T4
    • T5
    • T6
    • T7
    • R

    Parameters

    • pred: ((x1: T1, x2: T2, x3: T3, x4: T4, x5: T5, x6: T6, x7: T7) => R)
        • (x1, x2, x3, x4, x5, x6, x7): R
        • Parameters

          Returns R

    • fn1: ((...args: any[]) => T1)
        • (...args): T1
        • Parameters

          • Rest...args: any[]

          Returns T1

    • fn2: ((...args: any[]) => T2)
        • (...args): T2
        • Parameters

          • Rest...args: any[]

          Returns T2

    • fn3: ((...args: any[]) => T3)
        • (...args): T3
        • Parameters

          • Rest...args: any[]

          Returns T3

    • fn4: ((...args: any[]) => T4)
        • (...args): T4
        • Parameters

          • Rest...args: any[]

          Returns T4

    • fn5: ((...args: any[]) => T5)
        • (...args): T5
        • Parameters

          • Rest...args: any[]

          Returns T5

    • fn6: ((...args: any[]) => T6)
        • (...args): T6
        • Parameters

          • Rest...args: any[]

          Returns T6

    • fn7: ((...args: any[]) => T7)
        • (...args): T7
        • Parameters

          • Rest...args: any[]

          Returns T7

    Returns (() => R) & {
        raw: ((x1: T1, x2: T2, x3: T3, x4: T4, x5: T5, x6: T6, x7: T7) => R);
    }

  • Type Parameters

    • T1
    • T2
    • T3
    • T4
    • T5
    • T6
    • T7
    • T8
    • R

    Parameters

    • pred: ((x1: T1, x2: T2, x3: T3, x4: T4, x5: T5, x6: T6, x7: T7, x8: T8) => R)
        • (x1, x2, x3, x4, x5, x6, x7, x8): R
        • Parameters

          Returns R

    • fn1: ((...args: any[]) => T1)
        • (...args): T1
        • Parameters

          • Rest...args: any[]

          Returns T1

    • fn2: ((...args: any[]) => T2)
        • (...args): T2
        • Parameters

          • Rest...args: any[]

          Returns T2

    • fn3: ((...args: any[]) => T3)
        • (...args): T3
        • Parameters

          • Rest...args: any[]

          Returns T3

    • fn4: ((...args: any[]) => T4)
        • (...args): T4
        • Parameters

          • Rest...args: any[]

          Returns T4

    • fn5: ((...args: any[]) => T5)
        • (...args): T5
        • Parameters

          • Rest...args: any[]

          Returns T5

    • fn6: ((...args: any[]) => T6)
        • (...args): T6
        • Parameters

          • Rest...args: any[]

          Returns T6

    • fn7: ((...args: any[]) => T7)
        • (...args): T7
        • Parameters

          • Rest...args: any[]

          Returns T7

    • fn8: ((...args: any[]) => T8)
        • (...args): T8
        • Parameters

          • Rest...args: any[]

          Returns T8

    Returns (() => R) & {
        raw: ((x1: T1, x2: T2, x3: T3, x4: T4, x5: T5, x6: T6, x7: T7, x8: T8) => R);
    }

  • Type Parameters

    • T1
    • T2
    • T3
    • T4
    • T5
    • T6
    • T7
    • T8
    • T9
    • R

    Parameters

    • pred: ((x1: T1, x2: T2, x3: T3, x4: T4, x5: T5, x6: T6, x7: T7, x8: T8, x9: T9) => R)
        • (x1, x2, x3, x4, x5, x6, x7, x8, x9): R
        • Parameters

          Returns R

    • fn1: ((...args: any[]) => T1)
        • (...args): T1
        • Parameters

          • Rest...args: any[]

          Returns T1

    • fn2: ((...args: any[]) => T2)
        • (...args): T2
        • Parameters

          • Rest...args: any[]

          Returns T2

    • fn3: ((...args: any[]) => T3)
        • (...args): T3
        • Parameters

          • Rest...args: any[]

          Returns T3

    • fn4: ((...args: any[]) => T4)
        • (...args): T4
        • Parameters

          • Rest...args: any[]

          Returns T4

    • fn5: ((...args: any[]) => T5)
        • (...args): T5
        • Parameters

          • Rest...args: any[]

          Returns T5

    • fn6: ((...args: any[]) => T6)
        • (...args): T6
        • Parameters

          • Rest...args: any[]

          Returns T6

    • fn7: ((...args: any[]) => T7)
        • (...args): T7
        • Parameters

          • Rest...args: any[]

          Returns T7

    • fn8: ((...args: any[]) => T8)
        • (...args): T8
        • Parameters

          • Rest...args: any[]

          Returns T8

    • fn9: ((...args: any[]) => T9)
        • (...args): T9
        • Parameters

          • Rest...args: any[]

          Returns T9

    Returns (() => R) & {
        raw: ((x1: T1, x2: T2, x3: T3, x4: T4, x5: T5, x6: T6, x7: T7, x8: T8, x9: T9) => R);
    }

  • Type Parameters

    • T1
    • T2
    • T3
    • T4
    • T5
    • T6
    • T7
    • T8
    • T9
    • T10
    • R

    Parameters

    • pred: ((x1: T1, x2: T2, x3: T3, x4: T4, x5: T5, x6: T6, x7: T7, x8: T8, x9: T9, x10: T10) => R)
        • (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10): R
        • Parameters

          Returns R

    • fn1: ((...args: any[]) => T1)
        • (...args): T1
        • Parameters

          • Rest...args: any[]

          Returns T1

    • fn2: ((...args: any[]) => T2)
        • (...args): T2
        • Parameters

          • Rest...args: any[]

          Returns T2

    • fn3: ((...args: any[]) => T3)
        • (...args): T3
        • Parameters

          • Rest...args: any[]

          Returns T3

    • fn4: ((...args: any[]) => T4)
        • (...args): T4
        • Parameters

          • Rest...args: any[]

          Returns T4

    • fn5: ((...args: any[]) => T5)
        • (...args): T5
        • Parameters

          • Rest...args: any[]

          Returns T5

    • fn6: ((...args: any[]) => T6)
        • (...args): T6
        • Parameters

          • Rest...args: any[]

          Returns T6

    • fn7: ((...args: any[]) => T7)
        • (...args): T7
        • Parameters

          • Rest...args: any[]

          Returns T7

    • fn8: ((...args: any[]) => T8)
        • (...args): T8
        • Parameters

          • Rest...args: any[]

          Returns T8

    • fn9: ((...args: any[]) => T9)
        • (...args): T9
        • Parameters

          • Rest...args: any[]

          Returns T9

    • fn10: ((...args: any[]) => T10)
        • (...args): T10
        • Parameters

          • Rest...args: any[]

          Returns T10

    Returns (() => R) & {
        raw: ((x1: T1, x2: T2, x3: T3, x4: T4, x5: T5, x6: T6, x7: T7, x8: T8, x9: T9, x10: T10) => R);
    }