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:
@@ -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) {
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user