Skip to content

Ability to not set when undefined or conditional function #40

Open
@gbalbuena

Description

@gbalbuena

Given this object:

{
  "body": "{}",
  "headers": {
    "access-control-allow-origin": undefined,
    "content-type": "application/json; charset=utf-8",
  },
  "statusCode": 200
}

I would like to do:

const allowCORS = false;

immutable(obj)
  .set('headers.access-control-allow-origin', '*', allowCORS)
  .value();

And get this as result value

{
  "body": "{}",
  "headers": {
    "content-type": "application/json; charset=utf-8",
  },
  "statusCode": 200
}

Instead of

{
  "body": "{}",
  "headers": {
    "access-control-allow-origin": undefined,
    "content-type": "application/json; charset=utf-8",
  },
  "statusCode": 200
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions