Anonymous avatar Anonymous committed 9626954

sigh. I guess object iterators should support own properties only when told.

Comments (0)

Files changed (1)

 		return values;
 	},
 
-	'oeach': function(object, fun) {
+	'oeach': function(object, fun, own) {
 		for (var key in object) {
-			if (object.hasOwnProperty(key)) {
+			if (!own || object.hasOwnProperty(key)) {
 				if (fun.call(this, key, object[key], object) === batteries.$break) {
 					break;
 				}
 		}
 	},
 
-	'omap': function(object, fun) {
+	'omap': function(object, fun, own) {
 		var mapped = batteries.heir(object.prototype);
 		for (var key in object) {
-			if (object.hasOwnProperty(key)) {
+			if (!own || object.hasOwnProperty(key)) {
 				mapped[key] = fun.call(this, key, object[key], object);
 			}
 		}
 		return mapped;
 	},
 
-	'ofilter': function(object, fun) {
+	'ofilter': function(object, fun, own) {
 		var filtered = batteries.heir(object.prototype);
 		for (var key in object) {
-			if (object.hasOwnProperty(key)) {
+			if (!own || object.hasOwnProperty(key)) {
 				if (fun.call(this, key, object[key], object)) {
 					filtered[key] = object[key];
 				}
 	},
 
 	'type': function(v) {
-		var type = 'undefined';
+		var type;
 		var to = typeof v;
 		if (to == 'object') {
 			if (v == null) {
 				type = 'null';
 			} else if ('length' in v) {
 				type = 'array';
+			} else if (v.constructor == RegExp) {
+				type = 'regexp';
 			} else {
 				type = 'object';
 			}
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.