sodiray / radash

Functional utility library - modern, simple, typed, powerful
https://radash-docs.vercel.app
MIT License
4.18k stars 167 forks source link

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

Open martinszeltins opened 9 months ago

martinszeltins commented 9 months ago

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