Packages

A web application in pursuit of meaning in life.

Retired package: Complete rewrite, scratch old versions

Current section

Files

Jump to
udia assets node_modules mout src lang isPrimitive.js
Raw

assets/node_modules/mout/src/lang/isPrimitive.js

define(function() {
/**
* Checks if the object is a primitive
*/
function isPrimitive(value) {
// Using switch fallthrough because it's simple to read and is
// generally fast: http://jsperf.com/testing-value-is-primitive/5
switch (typeof value) {
case "string":
case "number":
case "boolean":
return true;
}
return value == null;
}
return isPrimitive;
});