Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

check

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

check

Check configurations completeness

  • 0.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
841
increased by13.19%
Maintainers
1
Weekly downloads
 
Created
Source

node-check

Configuration checker.

Build Status

Install

npm install check

(Or clone the repo.)

Usage

var check = require('check');

var config = {
    database: {hostname: 'example.com', debug: false},
	someOtherSetting: 'bar'
};

check(config)
	.has('database.hostname') // Implicitly checks 'database'
	.isBoolean('database.debug')
	.has('missingSetting')   // Missing key - this will make check fail.
	.assert();               // Assert if anything isn't as required.

Will produce an error not entirely unlike this:

AssertionError: Incorrect configuration:
    Missing key 'missingSetting'.
at functionA (/your/source/code/a.js:line:col)
at functionB (/your/source/code/b.js:line:col)
...
at EventEmitter._tickCallback (node.js:190:38)

API

Initialization

check(object-literal)

Returns an chainable object whereon the following functions can be used.

.has(key)

Tests if the given key is present. This also works with dot-notation, so has('foo.bar') will check if foo exists and then if foo has a bar-thing stuck on.

.isArguments(key)

.isArray(key)

.isBoolean(key)

.isDate(key)

.isDirectory(key)

.isFile(key)

.isFunction(key)

.isNumber(key)

.isObject(key)

.isRegExp(key)

.isSocket(key)

.isString(key)

.isSymbolicLink(key)

First checks if the key is present (as if running .has(key)), and if the given key is the right type.

.assert()

Stops the chaining and assert() if any keys were missing.

.ok()

Stops the chaining and returns if any errors were found.

.errors()

Stops the chaining and returns a list of errors (if any).

Bugs

Plenty! Report them! And add ideas for great features.

License

ISC; see LICENSE.

FAQs

Package last updated on 02 Aug 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc