juliangruber / juliangruber/json-store

db.get returns the entire store if key is 0

Open
#2 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
17
Forks
6
PR merge metrics
No merged PRs in 30d

Description

Similar to issue #1. To reproduce:

```
const JSONStore = require('json-store')
const db = JSONStore('./index.json')

db.set(0, 'zero')
db.get('zero')
// => returns { '0': 'zero' }, but should return 'zero'
```

The cause is [this line](https://github.com/juliangruber/json-store/blob/6e53a83af1e61fec9fa5dfcf19f161df1cf0d61b/index.js#L10), which checks if `key` is truthy. Instead, it should explicitly check whether `key` is defined.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.