Re: libseed-list Fwd: [Bug 610317] New: Provide a builtin dir() function

Apart from the rather awful name (When I first saw it, I expected it to scan directories) - A more generic function may be better..

Note: - this does not mess with prototypes, which can cause real nightmares..

Object.filter =  function(o, fn, scope){
           var ret = [];
           for(var p in o){
               if( , o[p], p, o, ret) === false){ return ret; };
	    return ret;

Object.filter(obj, function(v, k, o, ret) {
			 if (typeof(k) != 'number') ret.push(k);
      ).join(' ,');

It made me wonder how much of the JS 1.6 iterator support is available in webkit.. - never really looked at it, as it's been so mozilla specific before..


Tim Horton wrote:
Do people think this belongs on the Seed object (Seed.dir()) or should it be global? We were trying not to clutter up the global namespace, but making it global would probably make it more obvious for people coming from elsewhere.

Begin forwarded message:

*From: *"seed" ( <>) <bugzilla gnome org <mailto:bugzilla gnome org>>
*Date: *February 17, 2010 17:11:02 EST
*To: *hortont424 gmail com <mailto:hortont424 gmail com>
*Subject: **[Bug 610317] New: Provide a builtin dir() function*
 seed | libseed | git head

          Summary: Provide a builtin dir() function
   Classification: Other
          Product: seed
          Version: git head
       OS/Version: Linux
           Status: UNCONFIRMED
         Severity: normal
         Priority: Normal
        Component: libseed
       AssignedTo: seed-maint gnome bugs
       ReportedBy: diegoe gnome org
     GNOME target: ---
    GNOME version: ---

Just like in Python, this is doable in Javascript easily:

function dir(object)
   methods = [];
   for (z in object) if (typeof(z) != 'number') methods.push(z);
   return methods.join(', ');

Configure bugmail:
------- You are receiving this mail because: -------
You are watching the assignee of the bug.


libseed-list mailing list
libseed-list gnome org

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]