Allow handler to be undefined
This commit is contained in:
		@@ -14,6 +14,8 @@ class ClientCompat
 | 
			
		||||
		});
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	_nop() { }
 | 
			
		||||
 | 
			
		||||
	async _connect()
 | 
			
		||||
	{
 | 
			
		||||
		if( this.client.isReady )
 | 
			
		||||
@@ -23,6 +25,7 @@ class ClientCompat
 | 
			
		||||
 | 
			
		||||
	async GET( key, handler )
 | 
			
		||||
	{
 | 
			
		||||
		handler = handler || this._nop;
 | 
			
		||||
		try
 | 
			
		||||
		{
 | 
			
		||||
			await this._connect();
 | 
			
		||||
@@ -36,6 +39,7 @@ class ClientCompat
 | 
			
		||||
 | 
			
		||||
	async HGET( key, field, handler )
 | 
			
		||||
	{
 | 
			
		||||
		handler = handler || this._nop;
 | 
			
		||||
		try
 | 
			
		||||
		{
 | 
			
		||||
			await this._connect();
 | 
			
		||||
@@ -49,6 +53,7 @@ class ClientCompat
 | 
			
		||||
 | 
			
		||||
	async HGETALL( key, handler )
 | 
			
		||||
	{
 | 
			
		||||
		handler = handler || this._nop;
 | 
			
		||||
		try
 | 
			
		||||
		{
 | 
			
		||||
			await this._connect();
 | 
			
		||||
@@ -62,9 +67,7 @@ class ClientCompat
 | 
			
		||||
 | 
			
		||||
	async DEL( key, handler )
 | 
			
		||||
	{
 | 
			
		||||
		if( !handler )
 | 
			
		||||
			throw new Error( "handler cannot be undefined" );
 | 
			
		||||
 | 
			
		||||
		handler = handler || this._nop;
 | 
			
		||||
		try
 | 
			
		||||
		{
 | 
			
		||||
			await this._connect();
 | 
			
		||||
@@ -78,6 +81,7 @@ class ClientCompat
 | 
			
		||||
 | 
			
		||||
	async HDEL( key, field, handler )
 | 
			
		||||
	{
 | 
			
		||||
		handler = handler || this._nop;
 | 
			
		||||
		try
 | 
			
		||||
		{
 | 
			
		||||
			await this._connect();
 | 
			
		||||
@@ -91,6 +95,7 @@ class ClientCompat
 | 
			
		||||
 | 
			
		||||
	async TTL( key, handler )
 | 
			
		||||
	{
 | 
			
		||||
		handler = handler || this._nop;
 | 
			
		||||
		try
 | 
			
		||||
		{
 | 
			
		||||
			await this._connect();
 | 
			
		||||
@@ -104,6 +109,7 @@ class ClientCompat
 | 
			
		||||
 | 
			
		||||
	async compatExec( multi, handler )
 | 
			
		||||
	{
 | 
			
		||||
		handler = handler || this._nop;
 | 
			
		||||
		try
 | 
			
		||||
		{
 | 
			
		||||
			await this._connect();
 | 
			
		||||
 
 | 
			
		||||
@@ -62,8 +62,8 @@ class Session extends EventEmitter
 | 
			
		||||
		} );
 | 
			
		||||
 | 
			
		||||
		this.__sess = {};
 | 
			
		||||
		this.__emitOk = ( e, m ) => {
 | 
			
		||||
			_self.__emit( e, "set", new SessionEventArgs( m ) );
 | 
			
		||||
		this.__emitOk = ( m, err ) => {
 | 
			
		||||
			_self.__emit( err, "set", new SessionEventArgs( m ) );
 | 
			
		||||
		};
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -86,7 +86,7 @@ class Session extends EventEmitter
 | 
			
		||||
				.HSET( this.id, "spawn", new Date().getTime() )
 | 
			
		||||
				.HSET( this.id, "lifespan", ttl )
 | 
			
		||||
				.EXPIRE( this.id, ttl )
 | 
			
		||||
			, ( data, err ) => ( handler || this.__emitOk)( err, data )
 | 
			
		||||
			, handler || this.__emitOk
 | 
			
		||||
		);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -120,7 +120,7 @@ class Session extends EventEmitter
 | 
			
		||||
		var _self = this;
 | 
			
		||||
		Client.HGET(
 | 
			
		||||
			this.id, name
 | 
			
		||||
			, function( err, rep )
 | 
			
		||||
			, function( rep, err )
 | 
			
		||||
			{
 | 
			
		||||
				_self.__emitOk( err );
 | 
			
		||||
				_self.__sess[ name ] = rep;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user