Welcome! Log In Create A New Profile

Advanced

[njs] Added njs.version_number property.

Dmitry Volyntsev
April 28, 2022 11:32PM
details: https://hg.nginx.org/njs/rev/900d3ba62bcb
branches:
changeset: 1847:900d3ba62bcb
user: Dmitry Volyntsev <xeioex@nginx.com>
date: Thu Apr 28 17:59:03 2022 -0700
description:
Added njs.version_number property.

diffstat:

src/njs.h | 1 +
src/njs_builtin.c | 8 ++++++++
src/test/njs_unit_test.c | 7 ++++---
3 files changed, 13 insertions(+), 3 deletions(-)

diffs (53 lines):

diff -r 4d71bdf8663d -r 900d3ba62bcb src/njs.h
--- a/src/njs.h Thu Apr 28 17:49:59 2022 -0700
+++ b/src/njs.h Thu Apr 28 17:59:03 2022 -0700
@@ -12,6 +12,7 @@
#include <njs_auto_config.h>

#define NJS_VERSION "0.7.4"
+#define NJS_VERSION_NUMBER 0x000704


#include <unistd.h> /* STDOUT_FILENO, STDERR_FILENO */
diff -r 4d71bdf8663d -r 900d3ba62bcb src/njs_builtin.c
--- a/src/njs_builtin.c Thu Apr 28 17:49:59 2022 -0700
+++ b/src/njs_builtin.c Thu Apr 28 17:59:03 2022 -0700
@@ -1693,6 +1693,14 @@ static const njs_object_prop_t njs_njs_

{
.type = NJS_PROPERTY,
+ .name = njs_string("version_number"),
+ .value = njs_value(NJS_NUMBER, 1, NJS_VERSION_NUMBER),
+ .configurable = 1,
+ .enumerable = 1,
+ },
+
+ {
+ .type = NJS_PROPERTY,
.name = njs_string("dump"),
.value = njs_native_function(njs_ext_dump, 0),
.configurable = 1,
diff -r 4d71bdf8663d -r 900d3ba62bcb src/test/njs_unit_test.c
--- a/src/test/njs_unit_test.c Thu Apr 28 17:49:59 2022 -0700
+++ b/src/test/njs_unit_test.c Thu Apr 28 17:59:03 2022 -0700
@@ -13448,6 +13448,10 @@ static njs_unit_test_t njs_test[] =
{ njs_str("Object.values(njs)[0] === njs.version"),
njs_str("true") },

+ { njs_str("njs.version.split('.')"
+ ".map(v => parseInt(v)).reduce((p, c) => p * 256 + c) == njs.version_number"),
+ njs_str("true") },
+
{ njs_str("Object.values(process)"),
njs_str("") },

@@ -17644,9 +17648,6 @@ static njs_unit_test_t njs_test[] =
{ njs_str("var o = Object.defineProperty({}, 'a', { set(){}, enumerable: true }); njs.dump(o)"),
njs_str("{a:'[Setter]'}") },

- { njs_str("njs.dump(njs) == `njs {version:'${njs.version}'}`"),
- njs_str("true") },
-
{ njs_str("var a = []; a[0] = a; njs.dump(a)"),
njs_str("[[Circular]]") },

_______________________________________________
nginx-devel mailing list -- nginx-devel@nginx.org
To unsubscribe send an email to nginx-devel-leave@nginx.org
Subject Author Views Posted

[njs] Added njs.version_number property.

Dmitry Volyntsev 368 April 28, 2022 11:32PM



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

Online Users

Guests: 73
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready