Jetpack/Collections: Difference between revisions

Jump to navigation Jump to search
m
→‎Collection: remove " : function"
m (→‎Collection: remove " : function")
Line 60: Line 60:
   * Adds one item to the list
   * Adds one item to the list
   * @param item {Object} any JS object
   * @param item {Object} any JS object
   add : function(item)
   add(item)
    
    
   * Removes one item from the list
   * Removes one item from the list
   * @param item {Object} any JS object
   * @param item {Object} any JS object
   remove : function(item)
   remove(item)
    
    
   * Add all items in |coll| to this list.
   * Add all items in |coll| to this list.
Line 72: Line 72:
   * Note: This is intentionally not overloading |add|.
   * Note: This is intentionally not overloading |add|.
   * @param coll {Collection or JS Array}
   * @param coll {Collection or JS Array}
   addAll : function(coll)
   addAll(coll)
    
    
   * Removes all items in |coll| from this list
   * Removes all items in |coll| from this list
   * @param coll {Collection or JS Array}
   * @param coll {Collection or JS Array}
   removeAll : function(coll)
   removeAll(coll)
    
    
   * Removes all items from the list.
   * Removes all items from the list.
   clear : function()
   clear()
    
    
   * The number of items in this list
   * The number of items in this list
   * @returns {Integer} (always >= 0)
   * @returns {Integer} (always >= 0)
   get length()
   length (getter)
    
    
   * Whether there are items in this list
   * Whether there are items in this list
   * @returns {Boolean}
   * @returns {Boolean}
   get isEmpty()
   isEmpty (getter)
    
    
   * Checks whether this item is in the list.
   * Checks whether this item is in the list.
   * @returns {Boolean}
   * @returns {Boolean}
   contains : function(item)
   contains(item)
    
    
   * Returns all items contained in this list,
   * Returns all items contained in this list,
Line 105: Line 105:
   *
   *
   * @returns {Array} new JS array with all items
   * @returns {Array} new JS array with all items
   contents : function()
   contents()
    
    
   * Provides an iterator, i.e. allows to write:
   * Provides an iterator, i.e. allows to write:
Line 111: Line 111:
   * for each (let item in coll)
   * for each (let item in coll)
   *  debug(item);
   *  debug(item);
   __iterator__ : function()
   __iterator__
    
    
   * Pass an object that will be called when
   * Pass an object that will be called when
Line 117: Line 117:
   * If you call this twice for the same observer, the second is a no-op.
   * If you call this twice for the same observer, the second is a no-op.
   * @param observer {CollectionObserver}
   * @param observer {CollectionObserver}
   registerObserver : function(observer)
   registerObserver(observer)
    
    
   * undo |registerObserver|
   * undo |registerObserver|
   * @param observer {CollectionObserver}
   * @param observer {CollectionObserver}
   unregisterObserver : function(observer)
   unregisterObserver(observer)


== KeyValueCollection ==
== KeyValueCollection ==
Confirmed users
596

edits

Navigation menu