All models which have a visibility property, can use this static helper function.
Filter models by visibility.

@param {Array|Object} items
@param {Array} visibility
@param {Boolean} [explicit]
@param {Function} [fn]
@returns {Array|Object} filtered items
488339
function filterByVisibility(items, visibility, explicit, fn) {
        var memo = _.isArray(items) ? [] : {};

        if (_.includes(visibility, 'all')) {
            return fn ? _.map(items, fn) : items;
        }

        // We don't want to change the structure of what is returned
        return _.reduce(items, function (items, item, key) {
            if (!item.visibility && !explicit || _.includes(visibility, item.visibility)) {
                var newItem = fn ? fn(item) : item;
                if (_.isArray(items)) {
                    memo.push(newItem);
                } else {
                    memo[key] = newItem;
                }
            }
            return memo;
        }, memo);
    }
1356621
function (name, items) {
    var List = this.get('List');
    var list = this.lists[name];
    if (typeof list === 'undefined') {
      var opts = lazy.clone(this.options);
      opts.items = items || this.items;
      opts.collection = this;
      this.lists[name] = list = new List(opts);
    }
    return list;
  }
861527
function _setContextMenuItemsVisible(enabled, items) {
        items.forEach(function (item) {
            CommandManager.get(item).setEnabled(enabled);
        });
    }
1278655
function(items) {
        return items.sort(function(a, b) {
            return a.title.localeCompare(b.title);
        });
    }
404307
function (items, namespace) {
            return can.each(items, function (item) {
                if (item && item.unbind) {
                    item.unbind("change" + namespace);
                }
            });
        }
1055013
function(items) {

		var result = true,
			i = 0,
			count = items.length;

		for (; i < count; i++) {

			if (this.SIMPLE_TYPES.indexOf(Firestorm.getType(items[i])) == -1) {
				result = false;
				break;
			}

		}

		return result;

	}
370532
function(fn) {
    var views;

    // If the filter argument is a String, then return a chained Version of the
    // elements. The value at the specified filter may be undefined, a single
    // view, or an array of views; in all cases, chain on a flat array.
    if (typeof fn === "string") {
      fn = this.sections[fn] || fn;
      views = this.views[fn] || [];

      // If Views is undefined you are concatenating an `undefined` to an array
      // resulting in a value being returned.  Defaulting to an array prevents
      // this.
      //return _.chain([].concat(views || []));
      return _.chain([].concat(views));
    }

    // Generate an array of all top level (no deeply nested) Views flattened.
    views = _.chain(this.views).map(function(view) {
      return _.isArray(view) ? view : [view];
    }, this).flatten();

    // If the argument passed is an Object, then pass it to `_.where`.
    if (typeof fn === "object") {
      return views.where(fn);
    }

    // If a filter function is provided, run it on all Views and return a
    // wrapped chain. Otherwise, simply return a wrapped chain of all Views.
    return typeof fn === "function" ? views.filter(fn) : views;
  }
1038494
function badItems(rule, a) {
    check.verify.array(a, 'expected array to find bad items');
    return a.filter(notModifier(rule));
  }
452196
function Views(options) {
  Collection.call(this, options);
  this.options.collection = this.options.collection || this;
  this.define('View', this.options.View || require('./view'));
  this.define('Item', this.View);
}
1296237
function flatFilter(filterString) {

    var filter_list = [];

    if (typeof filterString == 'string') {
        filter_list = matches$1(filterString);
    } else if (Array.isArray(filterString)) {
        filter_list = filterString;
    }

    var allFilter = [];

    filter_list.forEach(function (filterObj) {
        var filterName = filterObj.arr[0];

        if (GLFilter[filterName]) {
            var f = makeFilterFunction(filterObj);

            if (f.type == 'convolution' || f.type == 'shader') {
                allFilter.push(f);
            } else {
                f.forEach(function (subFilter) {
                    allFilter = allFilter.concat(flatFilter(subFilter));
                });
            }
        }
    });

    // console.log(filter_list, allFilter)

    return allFilter;
}
56073
def _where(self, filter_fn):
        '''  '''
        assert callable(filter_fn), 'filter_fn needs to be callable'
        return VList(i for i in self if filter_fn(i()))
483173
function (items, options) {
            var removed = [];

            if (!_.isArray(items)) {
                items = [items];
            }
            var item;
            for (var i = 0; i < items.length; i++) {
                item = this.removeAt(this.indexOf(items[i]), options);
                item && removed.push(item);
            }
            return removed;
        }
237595
function todolist_items(node)
{

  var self = this;
  
  /* ATTRIBUTES */
  
  /* the main title of the item, this is placed as text */
  this.title = "";
  
  /* whether or not the checkbox has been clicked */
  this.complete = false;
  
  /* whether this item should be displayed */
  this.hide = false;
  
  /* tells if favorite is active, updates svg to show yellow one */
  this.favorite = false;
  
  /* passed oncomplete method fired when checkbox is clicked */
  this.onComplete = function(){};
  
  /* oassed ondelete method fired when trashcan is clicked */
  this.onDelete = function(){};
  
  /* FILTERS */
  
  /* simple filter that changed display css style based on `hide` */
  this.filters.isHidden = function(v)
  {
    return (v ? 'none' : 'inherit');
  }
  
  /* filter that returns color based on `complete` for the item background */
  this.filters.statusBackground = function(v)
  {
    /* sometimes checkbox returns value as string, this will be fixed later */
    v = (typeof v === 'string' ? (v === 'true') : v);
    return (v ? '#5a8451' : '#FFF');
  }
  
  /* filter that returns color based on `complete` for the text color */
  this.filters.statusColor = function(v)
  {
     /* sometimes checkbox returns value as string, this will be fixed later */
    v = (typeof v === 'string' ? (v === 'true') : v);
    return (v ? '#FFF' : '#888787');
  }
  
  /* helps with checking the input when the value changes, will not be needed when input update is done */
  this.filters.placecheck = function(v)
  {
    node.querySelector('input').checked = (typeof v === 'string' ? (v === 'true') : !!v);
    return v;
  }
  
  /* changes css class based on `favorite` property */
  this.filters.activeFav = function(v)
  {
    return (v ? 'active' : '');
  }
  
  /* simple filter that prepends a `-` to a string if it is not empty, use for classnames etc */
  this.filters.prependDash = function(v)
  {
    return (v.length !== 0 ? '-'+v : v);
  }
  
  /* EVENTS */
  
  /* fires when checkbox is clicked */
  this.onClickComplete = function(e)
  {
    /* assign checked value */
    self.complete = this.checked;
    
    /* fire passed oncomplete method */
    self.onComplete(self.complete);
  }
  
  /* fires if favorite was clicked */
  this.onClickFavorite = function(e)
  {
    self.favorite = !self.favorite;
  }
  
  /* fires passed ondelete when trashcan is clicked */
  this.onClickDelete = function(e)
  {
    self.onDelete(self.title);
  }
}
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;
    }
1314300
def get_visible_items(self):
        """"""
        items = []
        iterator = QTreeWidgetItemIterator(self)
        while iterator.value():
            item = iterator.value()
            if not item.isHidden():
                if item.parent():
                    if item.parent().isExpanded():
                        items.append(item)
                else:
                    items.append(item)
            iterator += 1
        return items
347276
public List<I_CmsContextMenuItem> filterVisible(List<I_CmsContextMenuItem> items) {

        List<I_CmsContextMenuItem> result = Lists.newArrayList();
        for (I_CmsContextMenuItem item : items) {
            CmsMenuItemVisibilityMode visibility = getVisibility(item);
            if (!visibility.isInVisible()) {
                result.add(item);
            }
        }
        return result;
    }
802813
function(items, data) {
					var inputManager = data.handler.inputManager || that.inputManager;
					if (inputManager && inputManager.getReadOnly()) {
						return false;
					}
					var editor = data.handler.editor || that.editor;
					var formatter = data.handler.formatter || that.formatter;
					return editor && editor.installed && formatter && formatter.isVisible();
				}