obj-prop
v1.1.0
Published
A clear and simple way to validate and manipulate properties of an object. All the methods are: * `hasNoProperties` * `hasProperties` * `hasTheseProperties` * `deleteProperties` * `nullProperties` and * `clearProperties`
Downloads
4
Readme
obj-prop
A clear and simple way to validate and manipulate properties of an object. All the methods are:
hasNoProperties
hasProperties
hasTheseProperties
deleteProperties
nullProperties
andclearProperties
Source Code
Code Examples
Example of using hasNoProperties method.
const { hasNoProperties } = require("obj-prop");
const test = {};
console.log(hasNoProperties(test)) // true
Using deleteProperties
const { deleteProperties } = require("obj-prop");
const test = {
deleteMe: "value",
"doNotDeleteMe": 1,
hello: "world"
}
deleteProperties(test, "deleteMe", "hello");
console.log(test) // { "doNotDeleteMe: 1 }
Using hasTheseProperties
import {hasTheseProperties} from 'obj-prop';
const object = {test: ''};
console.log(hasTheseProperties(object, "test", "username")) // false
Using nullProperties
const { nullProperties } = require("obj-prop");
const test = {
deleteMe: "value",
"doNotDeleteMe": 1,
hello: "world"
}
nullProperties(test, "deleteMe", "hello");
console.log(test); // { deleteMe: null, "doNotDeleteMe: 1, hello: null };