lib/api.js
function _wrapAcknowledgement(ack) {
	let handled = false;
	const wrappedAck = function (firstArg, ...restArgs) {
		if (handled) {
			throw new Error('Acknowledgement already handled');
		}

		handled = true;

		if (isError(firstArg)) {
			firstArg = serializeError(firstArg);
		}

		ack(firstArg, ...restArgs);
	};

	Object.defineProperty(wrappedAck, 'handled', {
		get() {
			return handled;
		}
	});

	return wrappedAck;
}
function _wrapAcknowledgement(ack) {
	let handled = false;
	const wrappedAck = function (firstArg, ...restArgs) {
		if (handled) {
			throw new Error('Acknowledgement already handled');
		}

		handled = true;

		if (isError(firstArg)) {
			firstArg = serializeError(firstArg);
		}

		ack(firstArg, ...restArgs);
	};

	Object.defineProperty(wrappedAck, 'handled', {
		get() {
			return handled;
		}
	});

	return wrappedAck;
}
function _wrapAcknowledgement ( ack ) { let handled = false ; const wrappedAck = function ( firstArg , ... restArgs ) { if ( handled ) { throw new Error ( 'Acknowledgement already handled' ) ; } handled = true ; if ( isError ( firstArg ) ) { firstArg = serializeError ( firstArg ) ; } ack ( firstArg , ... restArgs ) ; } ; Object . defineProperty ( wrappedAck , 'handled' , { get ( ) { return handled ; } } ) ; return wrappedAck ; }
By default, Errors get serialized to empty objects when run through JSON.stringify.
This function wraps an "acknowledgement" callback and checks if the first argument
is an Error. If it is, that Error is serialized _before_ being sent off to Socket.IO
for serialization to be sent across the wire.
@param ack {Function}
@private
@ignore
@returns {Function}
By default Errors get serialized to empty objects when run through JSON . stringify . This function wraps an acknowledgement callback and checks if the first argument is an Error . If it is that Error is serialized _before_ being sent off to Socket . IO for serialization to be sent across the wire .