@zohodesk/utils
Version:
DOT Utils Collection
54 lines (45 loc) • 1.1 kB
JavaScript
import { emptyObject, mergeObjects, updateObjectValueByKey, removeObjectByKey, removeObjectByKeys } from "./objectCRUD";
import { DUMMY_OBJECT } from "../constantProps/constant";
class ObjectManager {
constructor() {
let initialObject = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DUMMY_OBJECT;
this.object = initialObject;
}
setValue(newObject) {
this.object = mergeObjects({
object: this.object,
newObject
});
return this.object;
}
clearValue() {
this.object = emptyObject();
return this.object;
}
updateValueByKey(key, value) {
this.object = updateObjectValueByKey({
object: this.object,
key,
value
});
return this.object;
}
removeValueByKeys(keys) {
this.object = removeObjectByKeys({
object: this.object,
keys
});
return this.object;
}
removeValueByKey(key) {
this.object = removeObjectByKey({
object: this.object,
key
});
return this.object;
}
getValue() {
return this.object;
}
}
export default ObjectManager;