-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
45 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,32 @@ | ||
/** | ||
* APIs for dealing with Deno KV keys. | ||
* | ||
* {@linkcode equals} compares if two {@linkcode Deno.KvKey}s are equal. Because | ||
* key parts can be an {@linkcode Uint8Array} they need to be compared deeply | ||
* in a way that avoids security exploits. | ||
* | ||
* {@linkcode keys} is like Deno KV `.list()` except instead of returning an | ||
* async iterator of entries, it return an array of {@linkcode Deno.KvKey}s. | ||
* | ||
* {@linkcode startsWith} determines if the `key` starts with the `prefix` | ||
* provided, returning `true` if does, otherwise `false`. | ||
* | ||
* {@linkcode unique} resolves with an array of unique sub keys/prefixes for the | ||
* provided prefix. This is useful when storing keys and values in a | ||
* hierarchical/tree view, where you are retrieving a list and you want to know | ||
* all the unique _descendants_ of a key in order to be able to enumerate them. | ||
* | ||
* {@linkcode uniqueCount} resolves with an array of values which contain the | ||
* unique sub keys/prefixes for the provided prefix along with a count of how | ||
* many keys there are. This is useful when storing keys and values in a | ||
* hierarchical/tree view, where you are retrieving a list and you want to know | ||
* all the unique _descendants_ of a key (and the count of keys that match that | ||
* prefix) in order to be able to enumerate them or provide information about | ||
* them. | ||
* | ||
* @module | ||
*/ | ||
|
||
import { timingSafeEqual } from "https://deno.land/[email protected]/crypto/timing_safe_equal.ts"; | ||
|
||
function addIfUnique(set: Set<Deno.KvKeyPart>, item: Uint8Array) { | ||
|