Skip to content

Conversation

@TPXP
Copy link
Contributor

@TPXP TPXP commented Jul 30, 2024

Proposed changes

Correct the type definition for NgxSharedDict.items(). At runtime, I found out it returns an array of [key, value] objects, just like Object.items(). As documented here https://nginx.org/en/docs/njs/reference.html#dict_items

Checklist

Before creating a PR, run through this checklist and mark each as complete:

  • I have read the CONTRIBUTING document
  • If applicable, I have added tests that prove my fix is effective or that my feature works
  • If applicable, I have checked that any relevant tests pass after adding my changes

Minimal reproduction

function dumpItems(r) {
  ngx.shared.myarray.set("hello", "world")
  console.log(ngx.shared.myarray.items()[0])
}

Console output

2024/07/30 12:14:42 [info] 22#22: *1 js: ['hello','world']

@xeioex xeioex self-requested a review August 7, 2024 22:00
Copy link
Contributor

@xeioex xeioex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have our own commit log rules. The best way to get it is to grep commit history.

Proposed commit log:

Types: fixed NgxKeyValuePair definition.

NgxSharedDict.items() returns an array of `[key, value]` pairs, as `Object.entries()`.

NgxSharedDict.items() returns an array of `[key, value]` pairs, as `Object.entries()`.
@TPXP
Copy link
Contributor Author

TPXP commented Aug 14, 2024

Thanks for your feedback, I've reworded the commit and updated the type definition since adding names to array entries doesn't change much indeed (I hoped it would give some hints in IDEs but that does not seem to be the case).

@TPXP TPXP requested a review from xeioex August 14, 2024 09:59
@xeioex xeioex merged commit 4630230 into nginx:master Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants