Author: ygrego Date: 2015-02-23 08:32:09 +0000 (Mon, 23 Feb 2015) New Revision: 846 Url: http://forge.nuiton.org/projects/sandbox/repository/revisions/846 Log: The class "Collection" inherit from Array. That's more powerfull to create a type which looks like to a collection. Modified: oipf/js/lib/Collection.js Modified: oipf/js/lib/Collection.js =================================================================== --- oipf/js/lib/Collection.js 2015-02-20 14:37:07 UTC (rev 845) +++ oipf/js/lib/Collection.js 2015-02-23 08:32:09 UTC (rev 846) @@ -5,20 +5,9 @@ * Instances of a Collection< T > class SHALL be considered to be immutable, except by APIs defined on the collection. * Attempts to insert items into instances of a Collection< T > class using array notation SHALL fail. */ -var Collection = Class.extend({ - - elts: null, - +var Collection = Array.extend({ /* * Description: - * The number of items in the collection. - * - * Visibility Type: readonly Integer - */ - length: null, - - /* - * Description: * Return the item at position index in the collection, or undefined if no item is present at that position. * * Argument: @@ -27,13 +16,11 @@ */ item: function(index) { - return (this.length==0)? null: this.elts[index]; + return (this.length==0)? null: (this)[index]; }, init: function(elements) { - - this.length = elements.length; - this.elts = elements; + this.push(elements); } }); \ No newline at end of file
participants (1)
-
ygregoï¼ users.nuiton.org