onItem can be a promise factory or just a factory. It should return null when the item should be filtered out.
761144
function (streamIterator, onItem) {
  StreamIterator.apply(this, arguments);

  this._streamIterator = streamIterator;
  this._onItem = onItem;

  // Pipe data so that we can filter it in FilteredStreamIterator
  streamIterator.pipe(this);
}
542964
function (type, item) {
        switch(type) {
            case simpleTypes.undefined:
            case simpleTypes.null:
                return true;
            case simpleTypes.string:
                if (item.trim().length === 0) {
                    return true;
                }
                return false;
            case simpleTypes.object:
                return (Object.keys(item).length === 0);
            case simpleTypes.array:
                return (item.length === 0);
            default:
                return false;
        };
    }
834247
@Override
    public AbstractItem findById(long itemID) throws MessageStoreException
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "findById", Long.valueOf(itemID));

        AbstractItem item = _findById(itemID);

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "findById", item);
        return item;
    }
232425
@Override
	public <D, F, P> Promise<D, F, P> when(Promise<D, F, P> promise) {
		if (promise instanceof AndroidDeferredObject) {
			return promise;
		}
		return new AndroidDeferredObject<D, F, P>(promise).promise();
	}
371578
function enqueueEvent( self, eventItem ) {
   if( self.eventQueue_.length === 0 ) {
      self.nextTick_( () => {
         const queuedEvents = self.eventQueue_;

         self.eventQueue_ = [];

         processWaitingPublishPromises( self, processQueue( self, queuedEvents ) );
      } );
   }
   self.eventQueue_.push( eventItem );
}
1370638
function (item) {
        /* istanbul ignore if */
        // The persistence service should always be set before calling this method.
        // This check is an additional precaution.
        if (!__private.provider) {
            log.error('Unable to perform remote operation. The persistence service has not been set');
            return;
        }

        if (item.value instanceof Array) {
            item.value.forEach(function (e) {
                updateRemoteItem(e);
            });
        } else if (item !== undefined && item.type !== undefined) {
            const url = __private.provider + '/' + appName + '/' + _convertKey(item.key);
            if (item.value === undefined) {
                request.delete(url, _handleRequestError);
            } else {
                request.post(url, {
                    headers: { 'Content-Type': Constants.HTTP_CONTENT_TYPE_JSON },
                    json: { value: item.value, type: item.type, timestamp: item.timestamp }
                }, _handleRequestError);
            }
        }
    }
318700
function(query) {
        var items = [];
        for (var i = 0; i < this._store.length; i++) {
            items.push(JSON.parse(this._store.getItem(this._store.key(i))));
        }
        return resolvedPromise(_.query(items, query));
    }
105541
function firstOrDefault(arr, filter) {
    for (const item of arr) {
        if (filter(item))
            return item;
    }
    return null;
}
1322823
function removeItem(key, callback) {
	        var self = this;

	        // Cast the key to a string, as that's all we can set as a key.
	        if (typeof key !== 'string') {
	            globalObject.console.warn(key + ' used as a key, but it is not a string.');
	            key = String(key);
	        }

	        var promise = self.ready().then(function () {
	            var dbInfo = self._dbInfo;
	            localStorage.removeItem(dbInfo.keyPrefix + key);
	        });

	        executeCallback(promise, callback);
	        return promise;
	    }
829074
@SuppressWarnings("unchecked")
	private ApiAdapter<A> nullSafeApiAdapter(ApiAdapter<A> apiAdapter) {
		if (apiAdapter != null) {
			return apiAdapter;
		}
		return (ApiAdapter<A>) NullApiAdapter.INSTANCE;
	}
1139259
function() {
      var staleItemViews = [];
      var modelsWithViews = _.clone(this.__modelToViewMap);
      _.each(this.modelsToRender(), function(model) {
        var itemView = this.getItemViewFromModel(model);
        if (itemView) {
          delete modelsWithViews[model[this.__modelId]];
        }
      }, this);
      _.each(modelsWithViews, function(viewId, modelId) {
        var itemView = this.getTrackedView(viewId);
        if (itemView) {
          staleItemViews.push({ view: itemView, modelId: modelId });
        }
      }, this);
      return staleItemViews;
    }
1137474
function prepareItem ( item, cleanUrls ) {
	const promise = cleanUrls ? got.head(item.url) : Promise.resolve({ url: item.url });
	return promise
		.then(( res ) => {
			return res.url;
		}, () => {
			return item.url;
		})
		.then(( url ) => {
			return {
				url: cleanUrls ? stripMobileUrl(url) : url,
				description: item.title,
				toread: 'yes'
			};
		});
}
702407
function (item) {
        if (this.state.held && this.state.dragged && this.state.dragged.item === item) {
          return this.state.draggedStyle;
        }
        return undefined;
      }
970353
function getItem(id) {
  return new Promise((resolve, reject) => {
    return instance.pkgs.then(db => {
      const req = db.transaction(db.name)
        .objectStore(db.name).get(id);
      req.onsuccess = event => resolve(event.target.result);
      req.onerror = event => reject(event);
    });
  });
}
774420
function(arr, callback) {

        var result = arr.map(callback);

        return result.filter(function(item) {
            return item !== undefined && item !== null;
        });
    }
1160799
function getItem(key, callback) {
        var self = this;

        // Cast the key to a string, as that's all we can set as a key.
        if (typeof key !== 'string') {
            window.console.warn(key +
                                ' used as a key, but it is not a string.');
            key = String(key);
        }

        var promise = new Promise(function(resolve, reject) {
            self.ready().then(function() {
                try {
                    var dbInfo = self._dbInfo;
                    var result = localStorage.getItem(dbInfo.keyPrefix + key);

                    // If a result was found, parse it from the serialized
                    // string into a JS object. If result isn't truthy, the key
                    // is likely undefined and we'll pass it straight to the
                    // callback.
                    if (result) {
                        result = _deserialize(result);
                    }

                    resolve(result);
                } catch (e) {
                    reject(e);
                }
            })["catch"](reject);
        });

        executeCallback(promise, callback);
        return promise;
    }
778955
function(data) {
            var count, obj, result = [], item, iterateItem;
            if(!data || typeof data === 'string') {
                return null; 
            }

            if($.isArray(data)) { //array
                /* 
                   function to iterate inside item of array if item is object.
                   Caclulates count of keys in item and store in obj. 
                */
                iterateItem = function (k, v) {
                    obj = {value: k, text: v};
                    if(count++ >= 2) {
                        return false;// exit from `each` if item has more than one key.
                    }
                };
            
                for(var i = 0; i < data.length; i++) {
                    item = data[i]; 
                    if(typeof item === 'object') {
                        count = 0; //count of keys inside item
                        $.each(item, iterateItem);
                        //case: [{val1: 'text1'}, {val2: 'text2} ...]
                        if(count === 1) { 
                            result.push(obj); 
                            //case: [{value: 1, text: 'text1'}, {value: 2, text: 'text2'}, ...]
                        } else if(count > 1) {
                            //removed check of existance: item.hasOwnProperty('value') && item.hasOwnProperty('text')
                            if(item.children) {
                                item.children = this.makeArray(item.children);   
                            }
                            result.push(item);
                        }
                    } else {
                        //case: ['text1', 'text2' ...]
                        result.push({value: item, text: item}); 
                    }
                }
            } else {  //case: {val1: 'text1', val2: 'text2, ...}
                $.each(data, function (k, v) {
                    result.push({value: k, text: v});
                });  
            }
            return result;
        }