Skip to content

Commit

Permalink
docs: improve inline docs
Browse files Browse the repository at this point in the history
  • Loading branch information
kitsonk committed Jan 12, 2024
1 parent 264c870 commit 19506a0
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 5 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 Kitson P. Kelly
Copyright (c) 2023 - 2024 Kitson P. Kelly

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ results based on how many batches the operations was broken up into.
A set of APIs for storing arbitrarily sized blobs in Deno KV. Currently Deno KV
has a limit of key values being 64k. The `set()` function breaks down a blob
into chunks and manages sub-keys to store the complete value. The `get()`
function reverses that process.
function reverses that process, and `remove()` will delete the key, sub-keys and
values.

### `set()`

Expand Down Expand Up @@ -71,7 +72,7 @@ matching keys.
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 _descendents_ of a
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.

### `uniqueCount()`
Expand All @@ -80,6 +81,6 @@ 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 _descendents_ of a
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.
10 changes: 10 additions & 0 deletions blob.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/**
* A set of APIs for storing arbitrarily sized blobs in Deno KV. Currently Deno
* KV has a limit of key values being 64k. The {@linkcode set} function breaks
* down a blob into chunks and manages sub-keys to store the complete value. The
* {@linkcode get} function reverses that process, and {@linkcode remove}
* function will delete the key, sub-keys and values.
*
* @module
*/

import { batchedAtomic, type BatchedAtomicOperation } from "./batchedAtomic.ts";
import { keys } from "./keys.ts";

Expand Down
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kitsonk/kv_toolbox",
"version": "0.6.0",
"version": "0.6.1",
"exports": {
"./batchedAtomic": "./batchedAtomic.ts",
"./blob": "./blob.ts",
Expand Down
29 changes: 29 additions & 0 deletions keys.ts
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) {
Expand Down

0 comments on commit 19506a0

Please sign in to comment.