The filter functionality within a Vue watched function doesn't appear to be functioning as expected. Despite returning false for the E: object and true for all other items, the E: object remains in the array when it should have been removed.
Below is the object passed to the component via prop:
[
{
"fs": "C:",
"type": "NTFS",
"size": 273649844224,
"used": 265129050112,
"use": 96.88624192856284,
"mount": "C:"
},
{
"fs": "D:",
"type": "NTFS",
"size": 1000202039296,
"used": 879919800320,
"use": 87.97420578539696,
"mount": "D:"
},
{
"fs": "E:",
"type": "NTFS",
"size": 524283904,
"used": 35745792,
"use": 6.818022015796998,
"mount": "E:"
},
{
"fs": "F:",
"type": "NTFS",
"size": 250058108928,
"used": 193818132480,
"use": 77.50923707729336,
"mount": "F:"
},
{
"fs": "G:",
"type": "NTFS",
"size": 249464614912,
"used": 149687517184,
"use": 60.00350680468374,
"mount": "G:"
}
]
Component Script:
export default {
name: "DISK",
props: ["diskinfo"],
watch: {
diskinfo: function () {
if (typeof this.diskinfo !== "undefined") {
// convert to GB
this.diskinfo.forEach((disk) => {
disk.used = (disk.used / 1073741824).toFixed(0);
disk.size = (disk.size / 1073741824).toFixed(0);
});
// remove if < 1 gb
this.diskinfo.filter((disk) => disk.size === "0"); //π‘π‘π‘ Not filtering
}
},
},
};