function removeDuplicateWpcomRecords( domain, records ) { const rootARecords = filter( records, isRootARecord( domain ) ); const wpcomARecord = find( rootARecords, isWpcomRecord ); const customARecord = find( rootARecords, negate( isWpcomRecord ) ); if ( wpcomARecord && customARecord ) { return without( records, wpcomARecord ); } return records; }
const getNextPlugin = function ( state, siteId, forPlugin = false ) { const pluginList = getPluginsForSite( state, siteId, forPlugin ); const plugin = find( pluginList, ( item ) => { return 'wait' === item.status && item.error === null; } ); if ( typeof plugin === 'undefined' ) { return false; } return plugin; }
it( 'should display image only when provided', () => { const wrapperNoImage = shallow( <Twitter /> ); const wrapperWithImage = shallow( <Twitter image={ IMAGE_SRC_FIXTURE } /> ); const tweetWrapperNoImage = wrapperNoImage.find( Tweet ).dive(); const tweetWrapperWithImage = wrapperWithImage.find( Tweet ).dive(); // No image expect( tweetWrapperNoImage.find( '.twitter-preview__card-image' ).exists() ).toBeFalsy(); // Has image const imageEl = tweetWrapperWithImage.find( '.twitter-preview__card-image' ); expect( imageEl.exists() ).toBeTruthy(); expect( imageEl.html() ).toContain( `src="${ IMAGE_SRC_FIXTURE }"` ); } );
var options = function (localOptions) { if (localOptions) { middlewareOptions.find(function (middleware) { return middleware.options === opt }).localOptions = localOptions } syncOptions() return opt }
canPartitionsBeUsed(foundPreAggregation) { return foundPreAggregation.preAggregation.partitionGranularity && this.query.timeDimensions.length && foundPreAggregation.references.timeDimensions && foundPreAggregation.references.timeDimensions.length && this.query.timeDimensions.find(td => td.dimension === foundPreAggregation.references.timeDimensions[0].dimension); }
sendMessage(message) { if (message.unsubscribe && this.messageQueue.find(m => m.messageId === message.unsubscribe)) { this.messageQueue = this.messageQueue.filter(m => m.messageId !== message.unsubscribe); } else { this.messageQueue.push(message); } setTimeout(async () => { await this.initSocket(); this.ws.sendQueue(); }, 100); }
nextProps.action.devices.forEach(switches => { const deviceOption = this.state.deviceOptions.find(deviceOption => deviceOption.value === switches); if (deviceOption) { selectedOptions.push(deviceOption); } });
treeSelect( ( state, siteId, postId ) => [ getPostCommentItems( state, siteId, postId ) ], ( [ comments ] ) => { const firstContiguousComment = find( comments, 'contiguous' ); return firstContiguousComment ? new Date( firstContiguousComment.date ) : undefined; } )
const toChartjsOptions = (chartType, resultSet) => { // TODO: Check for supported charts let options = {}; if ((resultSet.query().timeDimensions || []).find(td => !!td.granularity)) { options.scales = { xAxes: [{ type: `time`, time: { unit: 'month' }}] }; } return options; }
findPreAggregationForQuery() { if (!this.preAggregationForQuery) { this.preAggregationForQuery = this.rollupMatchResults().find(p => p.canUsePreAggregation); } return this.preAggregationForQuery; }
stateUtilsImports.find( j.ImportSpecifier ).forEach( ( item ) => { importNames.push( { local: item.value.local.name, imported: item.value.imported.name, } ); } );
// NOTICE: Check the foreign key's reference unicity function checkUnicity(primaryKeys, uniqueIndexes, columnName) { const isUnique = uniqueIndexes !== null && uniqueIndexes.find((indexColumnName) => indexColumnName.length === 1 && indexColumnName.includes(columnName)); const isPrimary = _.isEqual([columnName], primaryKeys); return { isPrimary, isUnique }; }
function mergeMetadataEdits( edits, nextEdits ) { // remove existing edits that get updated in `nextEdits` const newEdits = reject( edits, ( edit ) => find( nextEdits, { key: edit.key } ) ); // append the new edits at the end return concat( newEdits, nextEdits ); }
setLastUpdate(db) { let lastUpdate = 0; db.find({}, (err, docs) => { docs.forEach(doc => { if (doc.ts > lastUpdate) { lastUpdate = doc.ts; } }); this.lastUpdate = lastUpdate; }); }