Socket
Socket
Sign inDemoInstall

typechecker

Package Overview
Dependencies
Maintainers
1
Versions
135
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typechecker - npm Package Compare versions

Comparing version 2.0.1 to 2.0.2

2

LICENSE.md
(The MIT License)
Copyright © 2013+ [Bevry Pty Ltd](http://bevry.me) <us@bevry.me>
Copyright © 2011-2012 Benjamin Lupton <b@lupton.cc>
Copyright © 2011-2012 [Benjamin Lupton](http://balupton.com) <b@lupton.cc>

@@ -6,0 +6,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

@@ -1,2 +0,2 @@

// Generated by CoffeeScript 1.6.2
// Generated by CoffeeScript 1.6.3
var typeChecker,

@@ -11,3 +11,2 @@ __hasProp = {}.hasOwnProperty;

var result, type, _i, _len, _ref;
result = 'object';

@@ -47,3 +46,2 @@ _ref = ['Array', 'RegExp', 'Date', 'Function', 'Boolean', 'Number', 'Error', 'String', 'Null', 'Undefined'];

var _ref;
return (_ref = typeof Array.isArray === "function" ? Array.isArray(value) : void 0) != null ? _ref : typeChecker.getObjectType(value) === '[object Array]';

@@ -71,3 +69,2 @@ },

var empty, key;
empty = true;

@@ -74,0 +71,0 @@ if (value != null) {

{
"name": "typechecker",
"version": "2.0.1",
"description": "Utilities to get and check variable types (isString, isPlainObject, isRegExp, etc)",
"homepage": "https://github.com/bevry/typechecker",
"keywords": [
"types","type"
],
"author": "Bevry Pty Ltd <us@bevry.me> (http://bevry.me)",
"maintainers": [
"Benjamin Lupton <b@lupton.cc> (https://github.com/balupton)"
],
"contributors": [
"Benjamin Lupton <b@lupton.cc> (https://github.com/balupton)"
],
"bugs": {
"url": "https://github.com/bevry/typechecker/issues"
},
"repository" : {
"type": "git",
"url": "http://github.com/bevry/typechecker.git"
},
"engines" : {
"node": ">=0.4"
},
"dependencies": {},
"devDependencies": {
"coffee-script": "~1.6.2",
"joe": "~1.1.2",
"chai": "~1.5.0"
},
"directories": {
"lib": "./out/lib"
},
"scripts": {
"test": "node ./out/test/typechecker-test.js --joe-reporter=list"
},
"main": "./out/lib/typechecker.js"
}
"name": "typechecker",
"version": "2.0.2",
"description": "Utilities to get and check variable types (isString, isPlainObject, isRegExp, etc)",
"homepage": "https://github.com/bevry/typechecker",
"keywords": [
"types",
"type",
"check",
"gettype",
"isstring",
"isregexp",
"isregex",
"isplainobject",
"isobject",
"iserror",
"isnumber",
"isdate",
"isarguments",
"isarray",
"isnull",
"isempty",
"isundefined",
"isemptyobject"
],
"author": "Bevry Pty Ltd <us@bevry.me> (http://bevry.me)",
"maintainers": [
"Benjamin Lupton <b@lupton.cc> (https://github.com/balupton)"
],
"contributors": [
"Benjamin Lupton <b@lupton.cc> (https://github.com/balupton)"
],
"bugs": {
"url": "https://github.com/bevry/typechecker/issues"
},
"repository": {
"type": "git",
"url": "http://github.com/bevry/typechecker.git"
},
"engines": {
"node": ">=0.4"
},
"dependencies": {},
"devDependencies": {
"coffee-script": "~1.6.2",
"joe": "~1.3.0",
"joe-reporter-console": "~1.2.1"
},
"directories": {
"lib": "./out/lib"
},
"scripts": {
"prepublish": "npm install typechecker@latest",
"test": "node ./out/test/everything-test.js"
},
"main": "./out/lib/typechecker.js"
}

@@ -1,2 +0,7 @@

# TypeChecker [![Build Status](https://secure.travis-ci.org/bevry/typechecker.png?branch=master)](http://travis-ci.org/bevry/typechecker)
# TypeChecker
[![Build Status](https://secure.travis-ci.org/bevry/typechecker.png?branch=master)](http://travis-ci.org/bevry/typechecker)
[![NPM version](https://badge.fury.io/js/typechecker.png)](https://npmjs.org/package/typechecker)
[![Flattr this project](https://raw.github.com/balupton/flattr-buttons/master/badge-89x18.gif)](http://flattr.com/thing/344188/balupton-on-Flattr)
Utilities to get and check variable types (isString, isPlainObject, isRegExp, etc)

@@ -24,26 +29,33 @@

``` javascript
require('typechecker').isRegExp(/^a/)
require('typechecker').isRegExp(/^a/) // returns true
```
### Available Methods
### Methods
- `getObjectType` (e.g. `[object RegExp]`)
- `getType` (e.g. `regexp`)
- `isPlainObject` (checks for no custom prototype)
- `isError`
- `isDate`
- `isArguments`
- `isFunction`
- `isRegExp`
- `isArray`
- `isNumber`
- `isString`
- `isBoolean`
- `isNull`
- `isUndefined`
- `isEmpty` (checks for `null` or `undefined`)
- `isEmptyObject` (checks for no keys that are its own)
- `getObjectType` - returns the object string of the value, e.g. when passed `/^a/` it'll return `"[object RegExp]"`
- `getType` - returns lower case string of the type, e.g. when passed `/^a/` it'll return `"regex"`
- `isPlainObject` - returns `true` if the value doesn't have a custom prototype
- `isError` - returns `true` if the value an error, otherwise `false`
- `isDate` - returns `true` if the value is a date, otherwise `false`
- `isArguments` - returns `true` if the value is function arguments, otherwise `false`
- `isFunction` - returns `true` if the value is a function, otherwise `false`
- `isRegExp` - returns `true` if the value is a regular expression instance, otherwise `false`
- `isArray` - returns `true` if the value is an array, otherwise `false`
- `isNumber` - returns `true` if the value is a number (`"2"` is a string), otherwise `false`
- `isString` - returns `true` if the value is a string, otherwise `false`
- `isBoolean` - returns `true` if the value is a boolean, otherwise `false`
- `isNull` - returns `true` if the value is null, otherwise `false`
- `isUndefined` - returns `true` if the value is undefined, otherwise `false`
- `isEmpty` - returns `true` if the value is `null` or `undefined`
- `isEmptyObject` - returns `true` if the object has no keys that are its own
### Notes
Why should I use this instead of say `instanceof`? Under certain circumstances `instanceof` may not return the correct results.
This occurs with [node's vm module](http://nodejs.org/api/vm.html#vm_globals) especially, and circumstances where an object's prototype has been dereferenced from the original.
As such, for basic `==` and `===` checks (like `a === null`), you're fine not using this, but for checks when you would have done `instanceof` (like `err instanceof Error`), you should try to use this instead.
Plus things like `isEmptyObject` and `isPlainObject` are darn useful!
## History

@@ -50,0 +62,0 @@ You can discover the history inside the [History.md](https://github.com/bevry/typechecker/blob/master/History.md#files) file

Sorry, the diff of this file is not supported yet

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