From b6843ce5b9ab25ca2ec7eb7dd3313e4e812cd334 Mon Sep 17 00:00:00 2001 From: Spotandjake <40705786+spotandjake@users.noreply.github.com> Date: Sat, 2 Mar 2024 18:59:28 -0500 Subject: [PATCH] chore(docs): Add examples to `Hash` module (#2011) --- stdlib/hash.gr | 6 ++++++ stdlib/hash.md | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/stdlib/hash.gr b/stdlib/hash.gr index f4dfcbdf8..2da37f2b2 100644 --- a/stdlib/hash.gr +++ b/stdlib/hash.gr @@ -3,6 +3,9 @@ * * @example from "hash" include Hash * + * @example Hash.hash(1) + * @example Hash.hash("Hello World") + * * @since v0.1.0 */ module Hash @@ -237,6 +240,9 @@ let rec hashOne = (val, depth) => { * @param anything: The value to hash * @returns A hash for the given value * + * @example assert Hash.hash(1) == Hash.hash(1) + * @example assert Hash.hash("Hello World") == Hash.hash("Hello World") + * * @since v0.1.0 */ @unsafe diff --git a/stdlib/hash.md b/stdlib/hash.md index f2ea75b0a..ba8b09e82 100644 --- a/stdlib/hash.md +++ b/stdlib/hash.md @@ -13,6 +13,14 @@ No other changes yet. from "hash" include Hash ``` +```grain +Hash.hash(1) +``` + +```grain +Hash.hash("Hello World") +``` + ## Values Functions and constants included in the Hash module. @@ -42,3 +50,13 @@ Returns: |----|-----------| |`Number`|A hash for the given value| +Examples: + +```grain +assert Hash.hash(1) == Hash.hash(1) +``` + +```grain +assert Hash.hash("Hello World") == Hash.hash("Hello World") +``` +