Location: A review of cardiac cellular electrophysiology models @ a26c8f6bf655 / dojo-presentation / js / dojo / dojox / lang / functional / object.js

Author:
David Nickerson <david.nickerson@gmail.com>
Date:
2021-09-15 12:24:03+12:00
Desc:
Updates to FHN model: * Make sure model is valid OpenCOR CellML Text format; * Make sure model is valid CellML; * Add SED-ML for single stimulus experiment. Using OpenCOR snapshot 2021-09-14
Permanent Source URI:
https://staging.physiomeproject.org/workspace/a1/rawfile/a26c8f6bf655d7de97fbc8d4197ca492804c735a/dojo-presentation/js/dojo/dojox/lang/functional/object.js

dojo.provide("dojox.lang.functional.object");

dojo.require("dojox.lang.functional.lambda");

// This module adds high-level functions and related constructs:
//	- object/dictionary helpers

// Defined methods:
//	- take any valid lambda argument as the functional argument
//	- skip all attributes that are present in the empty object 
//		(IE and/or 3rd-party libraries).

(function(){
	var d = dojo, df = dojox.lang.functional, empty = {};

	d.mixin(df, {
		// object helpers
		keys: function(/*Object*/ obj){
			// summary: returns an array of all keys in the object
			var t = [];
			for(var i in obj){
				if(i in empty){ continue; }
				t.push(i);
			}
			return	t; // Array
		},
		values: function(/*Object*/ obj){
			// summary: returns an array of all values in the object
			var t = [];
			for(var i in obj){
				if(i in empty){ continue; }
				t.push(obj[i]);
			}
			return	t; // Array
		},
		filterIn: function(/*Object*/ obj, /*Function|String|Array*/ f, /*Object?*/ o){
			// summary: creates new object with all attributes that pass the test 
			//	implemented by the provided function.
			o = o || d.global; f = df.lambda(f);
			var t = {}, v;
			for(var i in obj){
				if(i in empty){ continue; }
				v = obj[i];
				if(f.call(o, v, i, obj)){ t[i] = v; }
			}
			return t;	// Object
		},
		forIn: function(/*Object*/ obj, /*Function|String|Array*/ f, /*Object?*/ o){
			// summary: iterates over all object attributes.
			o = o || d.global; f = df.lambda(f);
			for(var i in obj){
				if(i in empty){ continue; }
				f.call(o, obj[i], i, obj);
			}
			return o;	// Object
		},
		mapIn: function(/*Object*/ obj, /*Function|String|Array*/ f, /*Object?*/ o){
			// summary: creates new object with the results of calling 
			//	a provided function on every attribute in this object.
			o = o || d.global; f = df.lambda(f);
			var t = {};
			for(var i in obj){
				if(i in empty){ continue; }
				t[i] = f.call(o, obj[i], i, obj);
			}
			return t;	// Object
		}
	});
})();