1
0
mirror of https://github.com/ascribe/onion.git synced 2025-02-08 10:27:33 +01:00
onion/js/utils/general_utils.js
2015-05-19 17:01:28 +02:00

22 lines
554 B
JavaScript

// TODO: Create Unittests that test all functions
let GeneralUtils = {
/**
* Removes undefined and null values from an key-value object.
*/
sanitize(obj) {
Object
.keys(obj)
.map((key) => {
// By matching null with a double equal, we can match undefined and null
// http://stackoverflow.com/a/15992131
if(obj[key] == null) {
delete obj[key];
}
});
return obj;
}
};
export default GeneralUtils;