@@ -790,6 +790,40 @@ var angularFunction = {
790
790
}
791
791
} ;
792
792
793
+ function hashKey ( obj ) {
794
+ var objType = typeof obj ;
795
+ var key = obj ;
796
+ if ( objType == 'object' ) {
797
+ keyType = typeof ( key = obj . $hashKey ) ;
798
+ if ( typeof key == 'function' ) {
799
+ // must invoke on object to keep the right this
800
+ key = obj . $hashKey ( ) ;
801
+ } else if ( key === undefined ) {
802
+ key = obj . $hashKey = nextUid ( ) ;
803
+ }
804
+ } ;
805
+ return objType + ':' + key ;
806
+ }
807
+
808
+ function HashMap ( ) { }
809
+ HashMap . prototype = {
810
+ put : function ( key , value ) {
811
+ var _key = hashKey ( key ) ;
812
+ var oldValue = this [ _key ] ;
813
+ this [ _key ] = value ;
814
+ return oldValue ;
815
+ } ,
816
+ get : function ( key ) {
817
+ return this [ hashKey ( key ) ] ;
818
+ } ,
819
+ remove : function ( key ) {
820
+ var _key = hashKey ( key ) ;
821
+ var value = this [ _key ] ;
822
+ delete this [ _key ] ;
823
+ return value ;
824
+ }
825
+ } ;
826
+
793
827
function defineApi ( dst , chain ) {
794
828
angular [ dst ] = angular [ dst ] || { } ;
795
829
forEach ( chain , function ( parent ) {
@@ -802,6 +836,8 @@ defineApi('Array', [angularGlobal, angularCollection, angularArray]);
802
836
defineApi ( 'Object' , [ angularGlobal , angularCollection , angularObject ] ) ;
803
837
defineApi ( 'String' , [ angularGlobal , angularString ] ) ;
804
838
defineApi ( 'Date' , [ angularGlobal , angularDate ] ) ;
839
+ // TODO: enable and document this API
840
+ //defineApi('HashMap', [HashMap]);
805
841
//IE bug
806
842
angular [ 'Date' ] [ 'toString' ] = angularDate [ 'toString' ] ;
807
843
defineApi ( 'Function' , [ angularGlobal , angularCollection , angularFunction ] ) ;
0 commit comments