郑人有且置履者,先自度其足,而置之其坐。至之市,而忘操之。已得履,乃曰:“吾忘持度!”反归取之。及反,市罢,遂不得履。人曰:“何不试之以足? ”曰:“宁信度,无自信也。” – 《郑人买履》
郑人有且置履者,先自度其足,而置之其坐。至之市,而忘操之。已得履,乃曰:“吾忘持度!”反归取之。及反,市罢,遂不得履。人曰:“何不试之以足? ”曰:“宁信度,无自信也。”
– 《郑人买履》
现实中,人可以是郑人加强版,因许多尺度并无标准。
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
function FQKTask(params) { this.params = params; }FQKTask.prototype = {func: undefined};function FQKTaskQueue() { this._pendingTasks = []; this._runningTasks = [];}FQKTaskQueue.prototype = { _maxOperationCount: 1, _pendingTasks: undefined, _runningTasks: undefined, isFunction: function (functionToCheck) { var getType = {}; return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]'; }, setMaxOperationCount: function (count) { if(count > 0) { this._maxOperationCount = Number(count); } }, addTask: function (task) { if(!(task instanceof FQKTask)) { return ; } if(!this.isFunction(task.func)) { throw new Error('You must define task\'s func'); } if(this._runningTasks.length < this._maxOperationCount) { this._runningTasks.push(task); task.func(task); } else { this._pendingTasks.push(task); } }, removeTask: function (task) { if(!(task instanceof FQKTask)) { return ; } var index = this._runningTasks.indexOf(task); if (index >= 0) { this._runningTasks.splice(index, 1); } if(this._pendingTasks.length > 0) { var pendingTask = this._pendingTasks[0]; this._pendingTasks.splice(0, 1); this.addTask(pendingTask); } }};