Helma Logo
main list history

Version 1 by hannes on 30. April 2009, 11:34

1This page is a copy of the original *Modules* page. While the the Modules page will assume the role of documenting the modules in Helma NG, this page will provide a place for discussion: Which modules and function should ship with helma-ng, and how they should be structured in directories and modules.
2
3(Note: I've removed the empty module headers from the page, as they were outdated and made it harder to assess the actual content in here. -hns)
4
5=== core
6
7Core could be renamed to "lang" or "javascript" because all modules here are extending original Javascript objects. Mozilla docs refers to these objects as "Core" (Core JavaScript 1.5 Reference:Global Objects:Array:indexOf at http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:Array:indexOf) in their reference. What do you think? Should we stay with "Core"? Or should we change that? (matt) +/-
8
9==== array.js
10
11<a href="http://www.prototypejs.org">prototype.js</a> provides a bunch of neat functions: <a href="http://www.prototypejs.org/api/enumerable">Enumerable Docs</a> and <a href="http://www.prototypejs.org/api/array">Array Docs</a>. prototype.js could be offered as a replacement or addition to the current array.js -> see <a href="https://dev.helma.org/trac/helma/browser/sandbox/aida/modules/javascript/prototype.js">/sandbox/aida/modules/javascript/prototype.js</a>
12
13===== Array.prototype.contains
14
15works, but could be replaced by prototype.js>Enumerable>include ; see: http://www.prototypejs.org/api/enumerable/include, for compaitibility reasons we could add a conatains alias
16
17===== Array.union
18
19Has a bug when the source objects look similar, but are not
20
21 var obj1 = {test:"one"};
22 var obj2 = {test:"one"};
23 (obj1 != obj2) === true;
24 var arr1 = [obj1];
25 var arr2 = [obj2];
26 Array.union(arr1, arr2); // => [{test:"one"}]
27                          //    instead of [{test:"one"}, {test:"one"}]
28 
29Array.union could be replaced by using the prototyp.js .uniq() function. It's not very fast, but it works like expected.
30
31 // replacement using prototype.js
32 var result = arr1.concat(ar2).uniq();
33 // or:
34 Array.union = function() {
35  var r = [];
36      $A(arguments).forEach(function(arr) { r = r.concat(arr).uniq() });
37      return r;
38 }
39
40===== Array.intersection
41
42not tested yet
43
44 // replacement using prototype.js
45 var result = arr1.intersect(ar2).uniq();