Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
martinszeltins opened this issue Nov 30, 2023 · 0 comments · May be fixed by #382
Open

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

martinszeltins opened this issue Nov 30, 2023 · 0 comments · May be fixed by #382

Comments

@martinszeltins
Copy link

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant