Package Exports
- set-default-value
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (set-default-value) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
setDefaultValue
Sets a Default-Value, if null or undefined is given
API
defaults(<Any>, options?).to(<Any>)
options = {
checkNull: Boolean,
checkUndefined: Boolean
};
It checks for null and undefined by default.
Example
Replaces null-values
import defaults from "set-default-value";
const value = defaults(null).to(5);
console.log(value) // 5
Replaces undefined
import defaults from "set-default-value";
const value = defaults(undefined).to(5);
console.log(value) // 5