New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cheque

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cheque

Type checking, for when you only use JavaScript's Good Parts.

  • 0.2.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
534
increased by27.14%
Maintainers
1
Weekly downloads
 
Created
Source

Cheque.js npm Version Build Status Coverage Status

Type checking, for when you only use JavaScript’s Good Parts.

API

'use strict';

var isInt = function(x) {
  return typeof x == 'number' && x % 1 === 0;
};

module.exports = {

  isUndefined: function(x) {
    return typeof x == 'undefined';
  },

  isNull: function(x) {
    return x === null;
  },

  isBoolean: function(x) {
    return x === true || x === false;
  },

  isFloat: function(x) { // an integer is also a float
    return typeof x == 'number' && isFinite(x);
  },

  isInt: isInt,
  isInteger: isInt,

  isString: function(x) {
    return typeof x == 'string';
  },

  isNaN: function(x) {
    return x != x;
  },

  isObject: function(x) { // a "plain" object
    return typeof x == 'object' && !!x && x.constructor === Object;
  },

  isArray: Array.isArray || function(x) {
    return Object.prototype.toString.call(x) == '[object Array]';
  },

  isFunction: function(x) {
    return typeof x == 'function';
  }

};

You must not do terrible things like:

var boo = new Boolean(true);
var bad = new Number(42);
var noo = new String('foo');

Instead, do:

var yay = true;
var god = 42;
var yes = 'foo';

There are lots of tests.

Installation

Install via npm:

$ npm i --save cheque

Changelog

  • 0.2.0
    • Add polyfill for Array.isArray
  • 0.1.0
    • Initial release

License

MIT license

Keywords

FAQs

Package last updated on 31 Dec 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc