Skip to content

Commit

Permalink
refactor: fix typo in removeMeta option for removeItem (#281)
Browse files Browse the repository at this point in the history
  • Loading branch information
Timbological authored Aug 7, 2023
1 parent d6f7629 commit da1d16d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions docs/content/2.usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,13 @@ If value is `undefined`, it is same as calling `removeItem(key)`.
await storage.setItemRaw("data/test.bin", new Uint8Array([1, 2, 3]));
```

### `removeItem(key, opts = { removeMeta = true })`
### `removeItem(key, opts = { removeMeta = false })`

Remove a value (and it's meta) from storage.

```js
await storage.removeItem("foo:bar");
await storage.removeItem("foo:bar", { removeMeta: true });
// same as await storage.removeItem("foo:bar", true);
```

### `getMeta(key, opts = { nativeOnly? })`
Expand Down
4 changes: 2 additions & 2 deletions src/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,15 +276,15 @@ export function createStorage<T extends StorageValue>(
async removeItem(key, opts = {}) {
// TODO: Remove in next major version
if (typeof opts === "boolean") {
opts = { removeMata: opts };
opts = { removeMeta: opts };
}
key = normalizeKey(key);
const { relativeKey, driver } = getMount(key);
if (!driver.removeItem) {
return; // Readonly
}
await asyncCall(driver.removeItem, relativeKey, opts);
if (opts.removeMata) {
if (opts.removeMeta || opts.removeMata /* #281 */) {
await asyncCall(driver.removeItem, relativeKey + "$", opts);
}
if (!driver.watch) {
Expand Down
4 changes: 2 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ export interface Storage<T extends StorageValue = StorageValue> {
removeItem: (
key: string,
opts?:
| (TransactionOptions & { removeMata?: boolean })
| boolean /* legacy: removeMata */
| (TransactionOptions & { removeMeta?: boolean })
| boolean /* legacy: removeMeta */
) => Promise<void>;
// Meta
getMeta: (
Expand Down

0 comments on commit da1d16d

Please sign in to comment.