Files
PyUIBuilder/src/utils/common.js

24 lines
474 B
JavaScript
Raw Normal View History

// contains commonly used functions to manipulate objects, array etc.
export function removeDuplicateObjects(array, key) {
const seen = new Set()
return array.filter(item => {
if (!seen.has(item[key])) {
seen.add(item[key])
return true
}
return false
})
2024-09-13 16:03:58 +05:30
}
/**
* capitalize the first letter
* @param {string} str
* @returns
*/
export function capitalize(str) {
return str.charAt(0).toUpperCase() + str.slice(1)
}