0.0.0 • Published 10 years ago

default-opts v0.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
10 years ago

default-opts Build Status

Set default values for opts.

Functions

Please note that this is directly from test/basic.js

var test = require('tape');
var defOpts = require('default-opts');

var opts = {"boolean":true,"number":123,"string":"Hello World"};
var defaults = {"boolean":false,"number":321,"string":"Goodbye World","default":"default"};

test('sync', function(t) {
	t.plan(1);
	var syncResult = defOpts.optsSync(opts, defaults);
	t.equal(syncResult, {"boolean":true,"number":123,"string":"Hello World","default":"default"});
});

test('async', function(t) {
	t.plan(1);
	defOpts.opts(opts, defaults, function(err, result) {
		t.equal(result, {"boolean":true,"number":123,"string":"Hello World","default":"default"});
});

test('promise', function(t) {
	t.plan(1);
	defOpts.opts(opts, defaults).then(function(result) {
		t.equal(result, {"boolean":true,"number":123,"string":"Hello World","default":"default"});
	});
});

License

MIT

0.0.0

10 years ago