/** * Retrieves all fields from the specified user. * * @param {object} user - user with a list of fields */ const getFields = ( user: GSuiteNewUser ): GSuiteNewUserField[] => Object.keys( user ) .filter( ( key ) => 'uuid' !== key ) .map( ( key ) => user[ key ] )
export default function keepValidImages( minWidth, minHeight ) { return function keepValidImagesForWidthAndHeight( post ) { const imageFilter = imageHasMinWidthAndHeight( minWidth, minHeight ); if ( post.images ) { post.images = filter( post.images, imageFilter ); } if ( post.content_images ) { post.content_images = filter( post.content_images, imageFilter ); } return post; }; }
createSelector( ( state, siteId, productSlug ) => { const plansBySiteId = getPlansBySiteId( state, siteId ); if ( ! plansBySiteId || ! plansBySiteId.data ) { return null; } return plansBySiteId.data.filter( ( plan ) => plan.productSlug === productSlug ).shift(); }, ( state, siteId ) => getPlansBySiteId( state, siteId ) )
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 filterFunction = ( note ) => some( [ 'unread' === filterName && noteHasFilteredRead( state, note.id ), activeTab().filter( note ), ] )
const getModularLodashDecs = ( requires ) => requires.filter( ( { value: { init } } ) => init.type === 'CallExpression' && init.callee.name === 'require' && init.arguments.length && init.arguments[ 0 ].value && init.arguments[ 0 ].value.startsWith( 'lodash/' ) )
describe('ones', () => { test('should return an array with all ones', () => { const temp = ones(10); const tempCheck = temp.filter((el) => el === 1); expect(temp.length).toBe(tempCheck.length); }); });
readdirSync( dir ) .filter( ignored ) .forEach( function ( path ) { path = join( dir, path ); if ( statSync( path ).isDirectory() ) { exports.files( path, ext, ret ); } else if ( path.match( re ) ) { ret.push( path ); } } );
createSelector( ( state ) => { return state.reader.tags.items ? sortBy( filter( state.reader.tags.items, ( tag ) => tag.isFollowing ), 'slug' ) : null; // no data loaded }, ( state ) => [ state.reader.tags.items ] )
initialize() { this._connectLayers(); this.initializeLayers(this.layers); this._model = this.layers.filter((l) => l instanceof Model); }
/* * Returns edits that are not yet applied, i.e.: * - when updating, the property doesn't already have the desired value in `savedMetadata` * - when deleting, the property is still present in `savedMetadata` */ export function getUnappliedMetadataEdits( edits, savedMetadata ) { return filter( edits, ( edit ) => isUnappliedMetadataEdit( edit, savedMetadata ) ); }
export function getPluginsWithUpdates( state, siteIds ) { return filter( getPlugins( state, siteIds ), _filters.updates ).map( ( plugin ) => ( { ...plugin, version: plugin?.update?.new_version, type: 'plugin', } ) ); }
jest.fn( ( query, listener ) => { if ( listeners[ query ] ) { listeners[ query ] = listeners[ query ].filter( ( item ) => item !== listener ); } } )