Added Util.isPlainObject().

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4952 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2008-03-04 23:33:59 +00:00
parent 4f0d94df11
commit b279ef6eb8
2 changed files with 11 additions and 1 deletions
+1 -1
View File
@@ -229,7 +229,7 @@ public class StringUtil
}
return "Array(" + s + ")";
} else if (obj.constructor == Object) {
} else if (Util.isPlainObject(obj)) {
// TODO: maybe do this for any dynamic object? (would have to use describeType)
s = "";
for (var prop :String in obj) {
+10
View File
@@ -23,6 +23,8 @@ package com.threerings.util {
import flash.utils.ByteArray;
import flash.utils.describeType; // function import
public class Util
{
/**
@@ -58,6 +60,14 @@ public class Util
}
}
/**
* Returns true if the specified object is just a regular old associative hash.
*/
public static function isPlainObject (obj :Object) :Boolean
{
return (obj != null) && ("Object" == describeType(obj).@name.toString());
}
/**
* Is the specified object 'simple': one of the basic built-in flash types.
*/