Skip to content

Checks to make sure JavaScript objects properties are set.

Notifications You must be signed in to change notification settings

iifeoluwa/propset

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

propset contributions welcomeBuild Status

propset verifies that all the needed properties for your JavaScript objects are set

Table of Contents

  1. Implementation
  2. Contributing
  3. License

Implementation

Installation

To install run npm install propset

Usage

You can begin using propset once it has been installed and added to your script like so;

const propset = require('propset');

Signature

propset(object, array|string)

First parameter is the object to be tested. Second parameter should contain names of properties in the object to be tested. These properties would be ignored i.e propset would not check if those properties are set.

Demo

const propset = require('propset')

let testObject = {
	firstName:"John", 
	lastName:"Doe", 
	age:50, 
	eyeColor:"blue"
}

if (propset(testObject)){
	console.log('All object properties are set.')
}

let anotherTestObject = {
        firstName:"John", 
        lastName:"Doe", 
        age:null, 
        eyeColor:undefined
}

//the properties passed as the second argument are ignored and the object test passes.
if (propset(anotherTestObject, ['age', 'eyeColor'])){
        console.log('All object properties are set.')
}

Back to top

Contributing

PRs are welcome but kindly open an issue first to discuss potential changes/additions.

Back to top

License

(The MIT License)

Copyright (c) 2014 Bill Gooch

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be

included in all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF

MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Back to top

About

Checks to make sure JavaScript objects properties are set.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published