this.sizes[i] = nodes.length; for (const j in nodes) { if (nodes.hasOwnProperty(j)) { const node = nodes[j]; this.biases[i][j] = layer[node].bias; if (json.hasOwnProperty('trainOpts')) { this.updateTrainingOptions(json.trainOpts);
function checkAliveMiners() { debug(threadName + "Verifying if miners are still alive"); for (let minerId in activeMiners) { if (activeMiners.hasOwnProperty(minerId)) { let miner = activeMiners[minerId]; if (Date.now() - miner.lastContact > global.config.pool.minerTimeout * 1000) { process.send({type: 'removeMiner', data: miner.port}); delete activeMiners[minerId]; } } } }
// options is optional glob(self.fileManagerPath + pattern, function (er, files) { var cleanFiles = []; for (var fileFilter in files) { if (files.hasOwnProperty(fileFilter)) { cleanFiles.push(files[fileFilter].replace(self.fileManagerPath, "")); } } callback(er, cleanFiles); });
/** * Push to array * @param values * @return {Number} */ push(...values) { for (let a in values) { if(values.hasOwnProperty(a)) { this._push(values[a]); } } return this.length; }
/** * Get results of voting at this moment */ getResultsOfVoting() { let results = {}; let voteVariants = this.contract.variants; for (let no in voteVariants) { if(voteVariants.hasOwnProperty(no)) { results[voteVariants[no]] = this._voteResults[no]; } } return JSON.stringify({results, state: this._voteState}); }
editedData(){ const{persons}=this.state; for (let key in persons) { if (persons.hasOwnProperty(key)) { let value = persons[key]; if(key == 'startDate' || key == 'endDate'){ value=new Date(value); } this.setState({[key]:value}); } } }
function newBlockTemplate(template) { let buffer = new Buffer(template.blocktemplate_blob, 'hex'); let previous_hash = new Buffer(32); buffer.copy(previous_hash, 0, 7, 39); console.log(threadName + 'New block to mine at height: ' + template.height + '. Difficulty: ' + template.difficulty); if (activeBlockTemplate) { pastBlockTemplates.enq(activeBlockTemplate); } activeBlockTemplate = new BlockTemplate(template); for (let minerId in activeMiners) { if (activeMiners.hasOwnProperty(minerId)) { let miner = activeMiners[minerId]; debug(threadName + "Updating worker " + miner.payout + " With new work at height: " + template.height); miner.sendNewJob(); } } }
function o(){var e,t,n,o,i,s,a;for(var l in S)if(S.hasOwnProperty(l)){if(e=[],t=S[l],t.name&&(e.push(t.name.toLowerCase()),t.options&&t.options.aliases&&t.options.aliases.length))for(n=0;n<t.options.aliases.length;n++)e.push(t.options.aliases[n].toLowerCase());for(o=r(t.fn,"function")?t.fn():t.fn,i=0;i<e.length;i++)s=e[i],a=s.split("."),1===a.length?Modernizr[a[0]]=o:(!Modernizr[a[0]]||Modernizr[a[0]]instanceof Boolean||(Modernizr[a[0]]=new Boolean(Modernizr[a[0]])),Modernizr[a[0]][a[1]]=o),C.push((o?"":"no-")+a.join("-"))}}
// Открываем базу данных _db.open (function (err, db) { // Открываем коллекцию. Если её не существует, она будет создана db.collection(_collectionName, function(err, collection) { // Получаем все элементы коллекции с помощью find() collection.find(function(err, cursor) { cursor.each(function(err, item) { // Null обозначает последний элемент if (item != null) { if (!result.hasOwnProperty (item.docid)) result[item.docid] = [item]; else result[item.docid].push(item); } else callbackFunction (result); }); db.close(); }); }); });
function retargetMiners() { debug(threadName + "Performing difficulty check on miners"); console.log('Performing difficulty update on miners'); for (let minerId in activeMiners) { if (activeMiners.hasOwnProperty(minerId)) { let miner = activeMiners[minerId]; if (!miner.fixed_diff) { miner.updateDifficulty(); } } } }
/** * Получает коллбек по таймстампу * @param timestamp * @return {*} */ function getThrustedAwait(timestamp) { for (let a in thrustedAwait) { if(thrustedAwait.hasOwnProperty(a)) { if(Number(thrustedAwait[a].timestamp) === Number(timestamp)) { return thrustedAwait[a]; } } } return false; }
function _searchOnChildren(json, queryRegex, previousPath, result, options) { const keys = Object.keys(json); for(let index in keys) { if(!keys.hasOwnProperty(index)) { continue; } const key = keys[index]; const currentPath = previousPath.slice(); currentPath.push(key); if (queryRegex.exec(key)) { _addResult(currentPath, result, 'KEY', options); } const nextNode = json[key]; _searchOnNode(nextNode, queryRegex, currentPath, result, options); } }
/** * Find files in a dir and run loadAimlFile on them * @param {String} dir * @return {Undefined} */ loadDir (dir, callback) { var files = fs.readdirSync(dir); debug('Loading dir' + dir); for (var i in files) { if (!files.hasOwnProperty(i)) continue; var name = dir + '/' + files[i]; if (fs.statSync(name).isDirectory()) { debug('Ignoring directory: ' + name); } else if (name.substr(-5).toLowerCase() === '.aiml') { this.loadFile(name, callback); } } }
/** * Возвращает адрес сокет по адресу шины сообщений * @param address * @return {*} */ function getSocketByBusAddress(address) { const sockets = getCurrentPeers(true); for (let i in sockets) { if(sockets.hasOwnProperty(i)) { if(sockets[i] && sockets[i].nodeMetaInfo) { if(sockets[i].nodeMetaInfo.messageBusAddress === address) { return sockets[i]; } } } } return false; }
custom(optional) { if (_.isObject(optional)) { let keys = Object.keys(optional); for (let i in keys) { // Condition validate object params if (keys.hasOwnProperty(i) && _.isObject(optional[keys[i]])) { let key = keys[i], opt = optional[keys[i]]; this[key](opt) } else { throw new Error('ERROR toolbars throw exception: Toolbars optional accept object params.'); } } } }