Luciano Ramalho avatar Luciano Ramalho committed d6a6840

added comments to all functions

Comments (0)

Files changed (1)

lilacs/vendor/isisdm_t2/_attachments/isisdm.js

-var ISIS = (function () { 
+var ISIS = (function () {
+    // functions in this module assume an ISIS-JSON type 2 record structure
+
     var my = {};
 
     function getonesub(field, key, missing) {
+        // returns the first occurrence of the subfield identified by key;
+        // if the key is "*", returns the first occurrence of any subfield,
+        // which may be the main subfield or another subfield if there is no
+        // main subfield; if the key is not found in the field, returns missing
+        // value;
+        // NOTE: by convention, ISIS-JSON type 2 records use the "_" key for the
+        // main subfield;
         var i;
         for (i=0; i<field.length; i++) {
             // the == below is intentional, so that a key 1 matches "1", as
         }
         return missing;
     };
-    
+
     my.getallraw = function(record, tag, stop) {
+        // returns all occurrences of a tag in "raw" format; for an ISIS-JSON
+        // type 2 record this means each occurrence is an association list of
+        // subfield keys and values;
         if (! (tag in record)) return [];
         if (typeof stop === "number") {
             return record[tag].slice(0, stop);
     }
 
     my.get = function(record, tag, missing) {
-        // assuming an ISIS-JSON type 2 record, returns the first occurrence
-        // of a field identified by tag; otherwise returns missing value;
+        // returns the first occurrence of a field identified by tag with
+        // subfields concatenated; if tag is not found, returns missing value;
         var fields = my.getall(record, tag, 1);
         return fields.length > 0 ? fields[0] : missing;
     };
+
     my.getall = function(record, tag, stop) {
-        // assuming an ISIS-JSON type 2 record, returns the every occurrence
-        // of a field identified by tag; otherwise returns value of missing;
-        // the optional stop argument limits the number of occurrences returned;
+        // returns an array containing every occurrence of a field identified by
+        // tag with subfields concatenated; the optional stop argument limits
+        // the number of occurrences returned;
         var fields, field, res, i, j;
         fields = my.getallraw(record, tag, stop);
         res = [];
     };
 
     my.getallsub = function(record, tag, key, missing) {
+        // returns an array containing every occurrence of a subfield identified
+        // by tag and key; the missing value is returned for each ocurrence of
+        // the tag where the key is not found;
         var fields, res, i;
         fields = my.getallraw(record, tag);
         res = [];
     };
 
     my.getsub = function(record, tag, key, missing) {
+        // returns the first occurrence of a subfield identified by tag and key;
+        // if tag or key are not found, returns missing value;
         var fields = my.getallraw(record, tag, 1);
         return fields.length > 0 ? getonesub(fields[0], key, missing) : missing;
     }
-    
-    
+
+
     return my;
 }());
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.