From e39feba7d3418e0bbc70f42acba30f42f053e77b Mon Sep 17 00:00:00 2001 From: Dmitry Volyntsev Date: Tue, 12 Sep 2023 11:36:15 -0700 Subject: [PATCH] Types: added TS description for items() introduced in f5428bc87159. --- test/ts/test.ts | 5 +++++ ts/ngx_core.d.ts | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/test/ts/test.ts b/test/ts/test.ts index c43ba093..a30e02fe 100644 --- a/test/ts/test.ts +++ b/test/ts/test.ts @@ -321,3 +321,8 @@ function ngx_object() { ngx.log(ngx.WARN, Buffer.from(ngx.error_log_path)); ngx.log(ngx.ERR, ngx.version); } + +function ngx_shared(dict: NgxSharedDict, numeric: NgxSharedDict) { + var s:NgxKeyValuePair = dict.items()[0]; + var v:number = numeric.incr('foo', 1); +} diff --git a/ts/ngx_core.d.ts b/ts/ngx_core.d.ts index fd06e302..af8fc4f3 100644 --- a/ts/ngx_core.d.ts +++ b/ts/ngx_core.d.ts @@ -250,6 +250,7 @@ interface NgxFetchOptions { declare class SharedMemoryError extends Error {} type NgxSharedDictValue = string | number; +type NgxKeyValuePair = { key: string, value: V }; /** * Interface of a dictionary shared among the working processes. @@ -314,6 +315,11 @@ interface NgxSharedDict { incr: V extends number ? (key: string, delta: V, init?: number) => number : never; + /** + * @param maxCount The maximum number of pairs to retrieve (default is 1024). + * @returns An array of the key-value pairs. + */ + items(maxCount?: number): NgxKeyValuePair[]; /** * @returns The free page size in bytes. * Note that even if the free page is zero the dictionary may still accept -- 2.47.3