Return an alternative value if a value is `null` or `undefined`
npm install @typeforce/elvis[license-shield-url]: https://img.shields.io/github/license/typeforce-js/elvis.svg?style=flat-square
[license-url]: https://github.com/Typeforce-JS/elvis/blob/master/LICENSE
[npm-downloads-shield-url]: https://img.shields.io/npm/dt/@typeforce/elvis.svg?style=flat-square
[npm-version-shield-url]: https://img.shields.io/npm/v/@typeforce/elvis.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/@typeforce/elvis
[unpkg-shield-url]: https://img.shields.io/badge/unpkg-up--to--date-brightgreen.svg?style=flat-square
[unpkg-url]: https://unpkg.com/@typeforce/elvis/dist/index.min.js
[![NPM][npm-version-shield-url]][npm-url]
[![NPM][npm-downloads-shield-url]][npm-url]
[![CDN][unpkg-shield-url]][unpkg-url]
[![LICENSE][license-shield-url]][license-url]
Return an alternative value if a specific value is null or undefined.
``shell`
npm install @typeforce/elvis --save # Install package via NPM
`javascript
import { expect } from "chai";
import elvis from "@typeforce/elvis";
expect(elvis("foo", "bar")).to.equal("foo");
expect(elvis(42, 5)).to.equal(42);
expect(elvis(false, "foo")).to.equal("foo"));
expect(elvis(undefined, "bar")).to.equal("bar");
expect(elvis(null, "foo")).to.equal("foo");
expect(elvis(undefined, undefined).to.be.undefined;
expect(elvis(null, null)).to.be.null;
`
This package contains TypeScript type declarations.
This package can be imported via unpkg as demonstrated
below.
`html`
When building the project, a folder named dist/ will be created if it does notdist/
already exist, where the compiled code will be outputted to. Type declaration
files will also be generated and outputted to the folder.
A minified Javascript version of the entire project will be generated and
outputted to dist/index.min.js.
`shell`
npm install # Installs dependencies.
npm run build # Build the project.
This package uses Gulp for building, and Chai
and Mocha for testing.
`shell`
npm test # Run tests.
Refer to the LICENSE` file for license information.