Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "xform/swizzle"

Index

Functions

Functions

swizzle

  • swizzle<T>(order: PropertyKey[]): Transducer<T, any[]>
  • swizzle<T>(order: PropertyKey[], src: Iterable<any>): IterableIterator<any[]>
  • Transducer which performs value reordering on inputs using provided property order. Accepts arrays or objects as input, but always yields arrays.

    example
    [...swizzle([3,0,2,1], [[1,2,3,4], [10,20,30,40]])]
    // [ [ 4, 1, 3, 2 ], [ 40, 10, 30, 20 ] ]
    
    [...swizzle([0,0,1,1], [[1,2,3,4], [10,20,30,40]])]
    // [ [ 1, 1, 2, 2 ], [ 10, 10, 20, 20 ] ]
    
    [...swizzle(["z","x"], [{x: 1, y: 2, z: 3}])]
    // [ [ 3, 1 ] ]

    {@link @thi.ng/arrays#swizzle}

    Type parameters

    • T

    Parameters

    • order: PropertyKey[]

      key order

    Returns Transducer<T, any[]>

  • Type parameters

    • T

    Parameters

    • order: PropertyKey[]
    • src: Iterable<any>

    Returns IterableIterator<any[]>

Generated using TypeDoc