Skip to content

Commit 5e2826c

Browse files
committed
Update angular.d.ts - JSDoc-ed the $cacheFactory
1 parent fefe9f1 commit 5e2826c

File tree

1 file changed

+74
-13
lines changed

1 file changed

+74
-13
lines changed

angularjs/angular.d.ts

Lines changed: 74 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,37 +1032,98 @@ declare module angular {
10321032
disableAutoScrolling(): void;
10331033
}
10341034

1035-
///////////////////////////////////////////////////////////////////////////
1036-
// CacheFactoryService
1037-
// see http://docs.angularjs.org/api/ng.$cacheFactory
1038-
///////////////////////////////////////////////////////////////////////////
1035+
/**
1036+
* $cacheFactory - service in module ng
1037+
*
1038+
* Factory that constructs Cache objects and gives access to them.
1039+
*
1040+
* see https://docs.angularjs.org/api/ng/service/$cacheFactory
1041+
*/
10391042
interface ICacheFactoryService {
1040-
// Lets not foce the optionsMap to have the capacity member. Even though
1041-
// it's the ONLY option considered by the implementation today, a consumer
1042-
// might find it useful to associate some other options to the cache object.
1043-
//(cacheId: string, optionsMap?: { capacity: number; }): CacheObject;
1044-
(cacheId: string, optionsMap?: { capacity: number; }): ICacheObject;
1043+
/**
1044+
* Factory that constructs Cache objects and gives access to them.
1045+
*
1046+
* @param cacheId Name or id of the newly created cache.
1047+
* @param optionsMap Options object that specifies the cache behavior. Properties:
1048+
*
1049+
* capacity — turns the cache into LRU cache.
1050+
*/
1051+
(cacheId: string, optionsMap?: { capacity?: number; }): ICacheObject;
10451052

1046-
// Methods bellow are not documented
1053+
/**
1054+
* Get information about all the caches that have been created.
1055+
* @returns key-value map of cacheId to the result of calling cache#info
1056+
*/
10471057
info(): any;
1058+
1059+
/**
1060+
* Get access to a cache object by the cacheId used when it was created.
1061+
*
1062+
* @param cacheId Name or id of a cache to access.
1063+
*/
10481064
get(cacheId: string): ICacheObject;
10491065
}
10501066

1067+
/**
1068+
* $cacheFactory.Cache - type in module ng
1069+
*
1070+
* A cache object used to store and retrieve data, primarily used by $http and the script directive to cache templates and other data.
1071+
*
1072+
* see https://docs.angularjs.org/api/ng/type/$cacheFactory.Cache
1073+
*/
10511074
interface ICacheObject {
1075+
/**
1076+
* Retrieve information regarding a particular Cache.
1077+
*/
10521078
info(): {
1079+
/**
1080+
* the id of the cache instance
1081+
*/
10531082
id: string;
1083+
1084+
/**
1085+
* the number of entries kept in the cache instance
1086+
*/
10541087
size: number;
10551088

1056-
// Not garanteed to have, since it's a non-mandatory option
1057-
//capacity: number;
1089+
//...: any additional properties from the options object when creating the cache.
10581090
};
1091+
1092+
/**
1093+
* Inserts a named entry into the Cache object to be retrieved later, and incrementing the size of the cache if the key was not already present in the cache. If behaving like an LRU cache, it will also remove stale entries from the set.
1094+
*
1095+
* It will not insert undefined values into the cache.
1096+
*
1097+
* @param key the key under which the cached data is stored.
1098+
* @param value the value to store alongside the key. If it is undefined, the key will not be stored.
1099+
*/
10591100
put<T>(key: string, value?: T): T;
1101+
1102+
/**
1103+
* Retrieves named data stored in the Cache object.
1104+
*
1105+
* @param key the key of the data to be retrieved
1106+
*/
10601107
get(key: string): any;
1108+
1109+
/**
1110+
* Removes an entry from the Cache object.
1111+
*
1112+
* @param key the key of the entry to be removed
1113+
*/
10611114
remove(key: string): void;
1115+
1116+
/**
1117+
* Clears the cache object of any entries.
1118+
*/
10621119
removeAll(): void;
1120+
1121+
/**
1122+
* Destroys the Cache object entirely, removing it from the $cacheFactory set.
1123+
*/
10631124
destroy(): void;
10641125
}
1065-
1126+
10661127
///////////////////////////////////////////////////////////////////////////
10671128
// CompileService
10681129
// see http://docs.angularjs.org/api/ng.$compile

0 commit comments

Comments
 (0)