@typeforce/elvis
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

elvis

NPM NPM CDN LICENSE

Return an alternative value if a specific value is null or undefined.

Usage

    npm install @typeforce/elvis --save   # Install package via NPM
    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.

Content Delivery Network (CDN)

This package can be imported via unpkg as demonstrated below.

    <script src="https://unpkg.com/@typeforce/elvis/dist/index.min.js"></script>
    <script type="application/javascript">
        var x = "foo";
        console.log(elvis(x, "bar"));
        // -> "foo"!
    </script>

Build & Test

When building the project, a folder named dist/ will be created if it does not already exist, where the compiled code will be outputted to. Type declaration files will also be generated and outputted to the dist/ folder.

A minified Javascript version of the entire project will be generated and outputted to dist/index.min.js.

    npm install     # Installs dependencies.
    npm run build   # Build the project.

This package uses Gulp for building, and Chai and Mocha for testing.

    npm test       # Run tests.

License

Refer to the LICENSE file for license information.

Dependencies (1)

Dev Dependencies (10)

Package Sidebar

Install

npm i @typeforce/elvis

Weekly Downloads

2

Version

1.0.2

License

MIT

Unpacked Size

7.99 kB

Total Files

8

Last publish

Collaborators

  • mgthomas99