Socket
Socket
Sign inDemoInstall

ee-types

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ee-types - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

46

lib/types.js

@@ -7,6 +7,6 @@

module.exports = new ( new Class( {
var Types = new Class( {
init: function(){
[ "string", "number", "boolean", "array", "object", "function", "date", "regexp", "error" ].forEach( function( type ){
[ "string", "number", "boolean", "array", "object", "function", "date", "regexp", "error", "undefined"].forEach( function( type ){
this[ type + "Array" ] = function( arg ){

@@ -21,11 +21,12 @@ return this.__array( arg, type );

, string: function( arg ){ return typeof arg === "string" || Object.prototype.toString.call( arg ) === "[object String]"; }
, number: function( arg ){ return typeof arg === "number" || Object.prototype.toString.call( arg ) === "[object Number]"; }
, boolean: function( arg ){ return typeof arg === "boolean" || Object.prototype.toString.call( arg ) === "[object Boolean]"; }
, array: function( arg ){ return util.isArray( arg ); }
, object: function( arg ){ return typeof arg === "object" }
, function: function( arg ){ return typeof arg === "function" }
, date: function( arg ){ return util.isDate( arg ); }
, regexp: function( arg ){ return util.isRegExp( arg ); }
, error: function( arg ){ return util.isError( arg ); }
, string: function( arg ){ return typeof arg === "string" || Object.prototype.toString.call( arg ) === "[object String]"; }
, number: function( arg ){ return typeof arg === "number" || Object.prototype.toString.call( arg ) === "[object Number]"; }
, boolean: function( arg ){ return typeof arg === "boolean" || Object.prototype.toString.call( arg ) === "[object Boolean]"; }
, array: function( arg ){ return util.isArray( arg ); }
, object: function( arg ){ return typeof arg === "object" }
, function: function( arg ){ return typeof arg === "function" }
, date: function( arg ){ return util.isDate( arg ); }
, regexp: function( arg ){ return util.isRegExp( arg ); }
, error: function( arg ){ return util.isError( arg ); }
, undefined: function( arg ){ return typeof arg === "undefined" }

@@ -39,3 +40,22 @@

}
} ) );
} );
var types = new Types();
var type = function( item ){
return types.s( item ) ? "string" :
types.n( item ) ? "number" :
types.a( item ) ? "array" :
types.f( item ) ? "function" :
types.d( item ) ? "date" :
types.r( item ) ? "regexp" :
types.e( item ) ? "error" :
types.u( item ) ? "undefined" : "unknown";
};
type.__proto__ = types;
module.exports = type;
{
"name": "ee-types"
, "description": "Reliabale type detection"
, "version": "0.1.0"
, "version": "0.1.1"
, "homepage": "https://github.com/eventEmitter/ee-types"

@@ -6,0 +6,0 @@ , "author": "Michael van der Weg <michael@eventemitter.com> (http://eventemitter.com/)"

@@ -20,4 +20,9 @@ # ee-types

type( 2 ) // number
## API
type() // returns the loawercase type
type.string()

@@ -32,2 +37,3 @@ type.number()

type.array()
type.undefined()

@@ -45,2 +51,3 @@ shortcut methods

type.a()
type.u()

@@ -47,0 +54,0 @@ check array and their contents. for every type above there is an array method like the one below.

@@ -21,1 +21,4 @@

console.log( type.ba( [ true, false ] ) );
console.log( type( "ee" ), type( /f/ ) );
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