Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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.1 to 0.1.2

28

lib/types.js

@@ -10,3 +10,3 @@

init: function(){
[ "string", "number", "boolean", "array", "object", "function", "date", "regexp", "error", "undefined"].forEach( function( type ){
[ "string", "number", "boolean", "array", "object", "function", "date", "regexp", "error", "undefined", "buffer", "null" ].forEach( function( type ){
this[ type + "Array" ] = function( arg ){

@@ -16,4 +16,6 @@ return this.__array( arg, type );

this[ type.substr( 0, 1 ) ] = this[ type ].bind( this );
this[ type.substr( 0, 1 ) + "a" ] = this[ type + "Array" ].bind( this );
if ( type === "string" || type === "number" || type === "boolean" || type === "undefined" ){
this[ type.substr( 0, 1 ) ] = this[ type ].bind( this );
this[ type.substr( 0, 1 ) + "a" ] = this[ type + "Array" ].bind( this );
}
}.bind( this ) );

@@ -32,6 +34,8 @@ }

, undefined: function( arg ){ return typeof arg === "undefined" }
, buffer: function( arg ){ return Buffer.isBuffer( arg ); }
, null: function( arg ){ return null === arg; }
, __array: function( arg, type ){
if ( !this.a( arg ) ) return false;
if ( !this.array( arg ) ) return false;
var i = arg.length;

@@ -50,8 +54,12 @@ while( i-- ) if ( !this[ type ]( arg[ i ] ) ) return false;

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";
types.b( item ) ? "boolean" :
types.array( item ) ? "array" :
types.function( item ) ? "function" :
types.date( item ) ? "date" :
types.regexp( item ) ? "regexp" :
types.error( item ) ? "error" :
types.buffer( item ) ? "buffer" :
types.null( item ) ? "null" :
types.u( item ) ? "undefined" :
types.object( item ) ? "object" : "unknown";
};

@@ -58,0 +66,0 @@

{
"name": "ee-types"
, "description": "Reliabale type detection"
, "version": "0.1.1"
, "version": "0.1.2"
, "homepage": "https://github.com/eventEmitter/ee-types"

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

@@ -36,2 +36,4 @@ # ee-types

type.array()
type.buffer()
type.null()
type.undefined()

@@ -41,12 +43,6 @@

type.s()
type.n()
type.b()
type.f()
type.o()
type.d()
type.e()
type.r()
type.a()
type.u()
type.s() // string
type.n() // number
type.b() // boolean
type.u() // undefined

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

@@ -16,9 +16,23 @@

console.log( type.array( [] ) );
console.log( type.null( null ) );
console.log( type.undefined() );
console.log( type.buffer( new Buffer( "hi" ) ) );
console.log( type.stringArray( [ 1, "asas" ] ) );
console.log( type.ba( [ true, false ] ) );
console.log( type.ba( [ true, false ] ) );
console.log( type( "ee" ), type( /f/ ) );
console.log(
type( "ee" )
, type( /f/ )
, type( undefined )
, type( true )
, type( new Error( "oo" ) )
, type( function(){} )
, type( new Buffer( "w2" ) )
, type( null )
, type( new Date() )
, type( new Number(3) )
, type( [] )
, type( {} ) );
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