hapijs / hapijs/yar

Add a new method called pop()

Open
#166 1 comment 0 reactions 0 assignees View on GitHub
feature
Dominant language
JavaScript
Stars
132
Forks
59
PR merge metrics
No merged PRs in 30d

Description

### Runtime

nodejs

### Runtime version

20.10.0

### Module version

11.0.1

### Used with

hapi

### Any other relevant information

_No response_

### What problem are you trying to solve?

Currently, my colleagues and I are using your plugin on this project [Pix](https://github.com/1024pix/pix), and we've noticed that the use of the method `get()` isn't clear, especially when someone unfamiliar with the plugin sees this line `request.yar.get('key', true);`.

It's not clear what the value `true` means. For that we need to go to the documentation page. It will be great to use something like `pop('key')`.

We think that as JavaScript developers we will somehow see more frequently this method `pop` used with arrays.

### Do you have a new or modified API suggestion to solve the problem?

This method `pop()` will have an argument which is the `key` and will removes the key if it is available in the store.
If the key does not exist, it will return `null` as value.

I have created a PR #167

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.