Welcome! Log In Create A New Profile

Advanced

[njs] Types: added TS description for items() introduced in f5428bc87159.

Dmitry Volyntsev
September 12, 2023 02:58PM
details: https://hg.nginx.org/njs/rev/586767a28478
branches:
changeset: 2199:586767a28478
user: Dmitry Volyntsev <xeioex@nginx.com>
date: Tue Sep 12 11:36:15 2023 -0700
description:
Types: added TS description for items() introduced in f5428bc87159.

diffstat:

test/ts/test.ts | 5 +++++
ts/ngx_core.d.ts | 6 ++++++
2 files changed, 11 insertions(+), 0 deletions(-)

diffs (35 lines):

diff -r 6b3176692593 -r 586767a28478 test/ts/test.ts
--- a/test/ts/test.ts Mon Sep 11 20:34:48 2023 -0700
+++ b/test/ts/test.ts Tue Sep 12 11:36:15 2023 -0700
@@ -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<string>, numeric: NgxSharedDict<number>) {
+ var s:NgxKeyValuePair<string> = dict.items()[0];
+ var v:number = numeric.incr('foo', 1);
+}
diff -r 6b3176692593 -r 586767a28478 ts/ngx_core.d.ts
--- a/ts/ngx_core.d.ts Mon Sep 11 20:34:48 2023 -0700
+++ b/ts/ngx_core.d.ts Tue Sep 12 11:36:15 2023 -0700
@@ -250,6 +250,7 @@ interface NgxFetchOptions {
declare class SharedMemoryError extends Error {}

type NgxSharedDictValue = string | number;
+type NgxKeyValuePair<V> = { key: string, value: V };

/**
* Interface of a dictionary shared among the working processes.
@@ -315,6 +316,11 @@ interface NgxSharedDict<V extends string
? (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<V>[];
+ /**
* @returns The free page size in bytes.
* Note that even if the free page is zero the dictionary may still accept
* new values if there is enough space in the occupied pages.
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] Types: added TS description for items() introduced in f5428bc87159.

Dmitry Volyntsev 236 September 12, 2023 02:58PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 288
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready