Options
All
  • Public
  • Public/Protected
  • All
Menu

Module vx-tools/objectFilter

对象过滤器

Index

Functions

Functions

objectFilter

  • objectFilter<T, U>(keys: U[], source: T): {[ key in U]: any }
  • 对象过滤器

    summary

    通过关键字列表,抽取对象对应字段值,生成新的对象. 只做浅层映射

    example
    const source = {
      id: 12,
      name: 'coco',
      job: 'IT'
    }
    const keys = ['name', 'job']
    const target = objectFilter(keys, source) 
    => { name: 'coco', job: 'IT' }
    

    Type parameters

    • T: {}

    • U: string | number | symbol

    Parameters

    • keys: U[]
    • source: T

    Returns {[ key in U]: any }

Generated using TypeDoc