1.1.0 • Published 4 years ago

obj-prop v1.1.0

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

obj-prop

A clear and simple way to validate and manipulate properties of an object. All the methods are:

  • hasNoProperties
  • hasProperties
  • hasTheseProperties
  • deleteProperties
  • nullProperties and
  • clearProperties

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 };
1.1.0

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago