Skip to content

isEmpty() returns true if one of the keys in object is "length" #366

Open
@martinszeltins

Description

@martinszeltins

There is a bug in the isEmpty function. I wanted to test if my object is empty using the isEmpty radash function. If given an empty object like myObject = {} it correctly says that it is empty. If the object is not empty like myObject = { a: 1 } it correctly says that it is not empty. But if my object contains the length key and the value of it is 0 then it incorrectly assumes the whole object is empty.

Example (can be tested on Radash Playground):

var radash = require("radash")

const shipment = {
    status: "DRAFT",
    length: 0,
    name: "Joe Doe"
}

console.log(radash.isEmpty(shipment)) // true

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