lib/ambush.js
function update(id, object) {
	// Validations
	if (!_isValidId(id)) {
		return false;
	}

	// Action
	const index = _getIndexOfId(id);

	if (index > -1) {
		if (_isValidAmbushOnUpdate(id, object)) {
			const current = goblin.ambush[index];
			const newAmbush = Object.assign({}, current, object);
			newAmbush.description = _cleanDescription(newAmbush.description);

			// Set updated ambush
			goblin.ambush[index] = newAmbush;
			goblin.ambushEmitter.emit(
				'change',
				{
					type: 'update',
					oldValue: JSONfn.clone(current),
					value: JSONfn.clone(goblin.ambush[index])
				}
			);
		}
	} else {
		logger('AMBUSH_UPDATE_INVALID_REFERENCE');
	}

	return true;
}
function update(id, object) {
	// Validations
	if (!_isValidId(id)) {
		return false;
	}

	// Action
	const index = _getIndexOfId(id);

	if (index > -1) {
		if (_isValidAmbushOnUpdate(id, object)) {
			const current = goblin.ambush[index];
			const newAmbush = Object.assign({}, current, object);
			newAmbush.description = _cleanDescription(newAmbush.description);

			// Set updated ambush
			goblin.ambush[index] = newAmbush;
			goblin.ambushEmitter.emit(
				'change',
				{
					type: 'update',
					oldValue: JSONfn.clone(current),
					value: JSONfn.clone(goblin.ambush[index])
				}
			);
		}
	} else {
		logger('AMBUSH_UPDATE_INVALID_REFERENCE');
	}

	return true;
}
function update ( id , object ) { // Validations if ( ! _isValidId ( id ) ) { return false ; } // Action const index = _getIndexOfId ( id ) ; if ( index > - 1 ) { if ( _isValidAmbushOnUpdate ( id , object ) ) { const current = goblin . ambush [ index ] ; const newAmbush = Object . assign ( { } , current , object ) ; newAmbush . description = _cleanDescription ( newAmbush . description ) ; // Set updated ambush goblin . ambush [ index ] = newAmbush ; goblin . ambushEmitter . emit ( 'change' , { type : 'update' , oldValue : JSONfn . clone ( current ) , value : JSONfn . clone ( goblin . ambush [ index ] ) } ) ; } } else { logger ( 'AMBUSH_UPDATE_INVALID_REFERENCE' ) ; } return true ; }
Updates an ambush function.

@param {string} id Ambush function id.
@param {Ambush} object Ambush function data.
@returns {bool} If updated or not.
Updates an ambush function .