1.1.0 • Published 8 years ago
@primitive/is-reference v1.1.0
is-reference
Determine if a value is an instance of a primitive reference type.
A value is a reference if it is an instance of a primitive reference type, such
as String, Number, and Boolean.
Usage
npm install @primitive/is-reference --save # Install package via NPM
yarn add @primitive/is-reference # Install package via Yarn import { expect } from "chai";
import isReference from "@primitive/is-reference";
expect(isReference(new Boolean(true))).to.be.false;
expect(isReference(new String("boo"))).to.be.false;
expect(isReference(new Number(42))).to.be.false;
expect(isReference(isReference)).to.be.false;
expect(isReference(undefined)).to.be.false;
expect(isReference(null)).to.be.false;
expect(isReference("boo")).to.be.false;
expect(isReference(true)).to.be.false;
expect(isReference(42)).to.be.false;
expect(isReference(new Symbol("boo"))).to.be.false;
expect(isReference({ foo: "bar" })).to.be.false;This package contains TypeScript type declarations. Furthermore, the package uses TypeScript type guards to allow type inference to influence intellisense.
if (isReference(x)) {
// IntelliSense now knows `x` is a reference value.
let y: Reference = x;
}Content Delivery Network (CDN)
This package can be imported via unpkg as demonstrated below.
<script src="https://unpkg.com/@primitive/is-reference/dist/index.min.js">
<script type="application/javascript">
var x = new Number(42);
if (isReference(x)) {
// `x` is of a reference type!
}
</script>Build & Test
This package uses Gulp for building, and Chai and Mocha for testing.
npm install # Installs dependencies.
npm run build # Build the project.
npm test # Run tests.License
Refer to the LICENSE file for license information.