@@ -807,6 +807,39 @@ var angularFunction = {
807807 }
808808} ;
809809
810+ function hashKey ( obj ) {
811+ var objType = typeof obj ;
812+ var key = obj ;
813+ if ( objType == 'object' ) {
814+ if ( typeof ( key = obj . $hashKey ) == 'function' ) {
815+ // must invoke on object to keep the right this
816+ key = obj . $hashKey ( ) ;
817+ } else if ( key === undefined ) {
818+ key = obj . $hashKey = nextUid ( ) ;
819+ }
820+ } ;
821+ return objType + ':' + key ;
822+ }
823+
824+ function HashMap ( ) { }
825+ HashMap . prototype = {
826+ put : function ( key , value ) {
827+ var _key = hashKey ( key ) ;
828+ var oldValue = this [ _key ] ;
829+ this [ _key ] = value ;
830+ return oldValue ;
831+ } ,
832+ get : function ( key ) {
833+ return this [ hashKey ( key ) ] ;
834+ } ,
835+ remove : function ( key ) {
836+ var _key = hashKey ( key ) ;
837+ var value = this [ _key ] ;
838+ delete this [ _key ] ;
839+ return value ;
840+ }
841+ } ;
842+
810843function defineApi ( dst , chain ) {
811844 angular [ dst ] = angular [ dst ] || { } ;
812845 forEach ( chain , function ( parent ) {
@@ -819,6 +852,8 @@ defineApi('Array', [angularGlobal, angularCollection, angularArray]);
819852defineApi ( 'Object' , [ angularGlobal , angularCollection , angularObject ] ) ;
820853defineApi ( 'String' , [ angularGlobal , angularString ] ) ;
821854defineApi ( 'Date' , [ angularGlobal , angularDate ] ) ;
855+ // TODO: enable and document this API
856+ //defineApi('HashMap', [HashMap]);
822857//IE bug
823858angular [ 'Date' ] [ 'toString' ] = angularDate [ 'toString' ] ;
824859defineApi ( 'Function' , [ angularGlobal , angularCollection , angularFunction ] ) ;
0 commit comments