Home Reference Source

Function

Static Public Summary
public

getDefined(target: Object, options: Object): Object

Takes an object and returns a new object that contains only the "defined" values.

Static Public

public getDefined(target: Object, options: Object): Object source

import getDefined from '@loopmode/defined/src/getDefined.js'

Takes an object and returns a new object that contains only the "defined" values.

Values are dropped if they either are included in the drop array, or they are an empty object and the keepObjects flag is not set.

Params:

NameTypeAttributeDescription
target Object

An object with properties that shall be omitted if empty

options Object
  • optional

Optional settings

options.drop Array
  • optional
  • default: [undefined]

Values that should be treated as "non-defined" values

options.keepObjects Boolean
  • optional

Whether to keep values that are an empty object

Return:

Object

A new object with only the "defined" values of target