 85bf1341f3
			
		
	
	85bf1341f3
	
	
	
		
			
			Frontend Enhancements: - Complete React TypeScript frontend with modern UI components - Distributed workflows management interface with real-time updates - Socket.IO integration for live agent status monitoring - Agent management dashboard with cluster visualization - Project management interface with metrics and task tracking - Responsive design with proper error handling and loading states Backend Infrastructure: - Distributed coordinator for multi-agent workflow orchestration - Cluster management API with comprehensive agent operations - Enhanced database models for agents and projects - Project service for filesystem-based project discovery - Performance monitoring and metrics collection - Comprehensive API documentation and error handling Documentation: - Complete distributed development guide (README_DISTRIBUTED.md) - Comprehensive development report with architecture insights - System configuration templates and deployment guides The platform now provides a complete web interface for managing the distributed AI cluster with real-time monitoring, workflow orchestration, and agent coordination capabilities. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
		
			
				
	
	
		
			59 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			59 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| import toDate from "../toDate/index.js";
 | |
| import requiredArgs from "../_lib/requiredArgs/index.js";
 | |
| /**
 | |
|  * @name closestTo
 | |
|  * @category Common Helpers
 | |
|  * @summary Return a date from the array closest to the given date.
 | |
|  *
 | |
|  * @description
 | |
|  * Return a date from the array closest to the given date.
 | |
|  *
 | |
|  * @param {Date | Number} dateToCompare - the date to compare with
 | |
|  * @param {Array<Date> | Array<number>} datesArray - the array to search
 | |
|  * @returns {Date | undefined} the date from the array closest to the given date or undefined if no valid value is given
 | |
|  * @throws {TypeError} 2 arguments required
 | |
|  *
 | |
|  * @example
 | |
|  * // Which date is closer to 6 September 2015: 1 January 2000 or 1 January 2030?
 | |
|  * const dateToCompare = new Date(2015, 8, 6)
 | |
|  * const result = closestTo(dateToCompare, [
 | |
|  *   new Date(2000, 0, 1),
 | |
|  *   new Date(2030, 0, 1)
 | |
|  * ])
 | |
|  * //=> Tue Jan 01 2030 00:00:00
 | |
|  */
 | |
| export default function closestTo(dirtyDateToCompare, dirtyDatesArray) {
 | |
|   requiredArgs(2, arguments);
 | |
|   var dateToCompare = toDate(dirtyDateToCompare);
 | |
|   if (isNaN(Number(dateToCompare))) return new Date(NaN);
 | |
|   var timeToCompare = dateToCompare.getTime();
 | |
|   var datesArray;
 | |
|   // `dirtyDatesArray` is undefined or null
 | |
|   if (dirtyDatesArray == null) {
 | |
|     datesArray = [];
 | |
| 
 | |
|     // `dirtyDatesArray` is Array, Set or Map, or object with custom `forEach` method
 | |
|   } else if (typeof dirtyDatesArray.forEach === 'function') {
 | |
|     datesArray = dirtyDatesArray;
 | |
| 
 | |
|     // If `dirtyDatesArray` is Array-like Object, convert to Array. Otherwise, make it empty Array
 | |
|   } else {
 | |
|     datesArray = Array.prototype.slice.call(dirtyDatesArray);
 | |
|   }
 | |
|   var result;
 | |
|   var minDistance;
 | |
|   datesArray.forEach(function (dirtyDate) {
 | |
|     var currentDate = toDate(dirtyDate);
 | |
|     if (isNaN(Number(currentDate))) {
 | |
|       result = new Date(NaN);
 | |
|       minDistance = NaN;
 | |
|       return;
 | |
|     }
 | |
|     var distance = Math.abs(timeToCompare - currentDate.getTime());
 | |
|     if (result == null || distance < Number(minDistance)) {
 | |
|       result = currentDate;
 | |
|       minDistance = distance;
 | |
|     }
 | |
|   });
 | |
|   return result;
 | |
| } |