Skip to content

Commit cbb0cc9

Browse files
committedFeb 19, 2025·
chore: update readme
1 parent b1cfd79 commit cbb0cc9

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed
 

‎README.md

+17-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# ohash
1+
# #️ ohash
22

33
<!-- automd:badges bundlephobia codecov -->
44

@@ -9,7 +9,7 @@
99

1010
<!-- /automd -->
1111

12-
Fast data [hashing](https://en.wikipedia.org/wiki/Hash_function) utils.
12+
Simple data [hashing](https://en.wikipedia.org/wiki/Hash_function) utils.
1313

1414
> [!NOTE]
1515
> You are on active v2 development branch. Check [v1](https://github.com/unjs/ohash/tree/v1) for ohash v1 docs.
@@ -23,20 +23,29 @@ Install [`ohash`](https://www.npmjs.com/package/ohash):
2323
npx nypm i ohash
2424
```
2525

26-
**Then import it:**
26+
**Import:**
2727

2828
```js
2929
// ESM import
3030
import { hash, serialize, isEqual, diff, digest } from "ohash";
3131

3232
// Dynamic import
3333
const { hash } = await import("ohash");
34+
```
35+
36+
<details>
37+
<summary>Import from CDN</summary>
3438

35-
// import from CDN
39+
```js
40+
// ESM import
3641
import { hash } from "https://esm.sh/ohash";
42+
43+
// Dynamic import
3744
const { hash } = await import("https://esm.sh/ohash");
3845
```
3946

47+
</details>
48+
4049
## `hash(input, options?)`
4150

4251
Hashes any JS value into a string.
@@ -50,7 +59,7 @@ console.log(hash({ foo: "bar" }));
5059

5160
**How it works:**
5261

53-
- If input is not a string, it will be serialized into a string like `object:1:string:3:foo:string:3:bar,` using [`serialize()`](#serializeinput-options).
62+
- If the input is not a string, it will be serialized into a string like `object:1:string:3:foo:string:3:bar,` using [`serialize()`](#serializeinput-options).
5463
- Then it is hashed using [SHA-256](https://en.wikipedia.org/wiki/SHA-2) algorithm and encoded as a [Base64](https://en.wikipedia.org/wiki/Base64) string using [`digest()`](#digeststr).
5564

5665
## `serialize(input, options?)`
@@ -66,7 +75,7 @@ console.log(serialize({ foo: "bar" }));
6675

6776
## `digest(str)`
6877

69-
Create a [sha256](https://en.wikipedia.org/wiki/SHA-2) digest from input (string) and returns the hash as a base64 string.
78+
Create a [sha256](https://en.wikipedia.org/wiki/SHA-2) digest from input (string) and return the hash as a base64 string.
7079

7180
> [!IMPORTANT]
7281
> The `+`, `/`, and `=` characters are removed from base64 result to maximize compatibility.
@@ -80,7 +89,7 @@ console.log(digest("Hello World"));
8089

8190
## `isEqual(obj1, obj2, options?)`
8291

83-
Compare two objects using `===` then fallbacks to compare based on their [serialized](#serializeinput-options) values.
92+
Compare two objects using `===` and then fallbacks to compare based on their [serialized](#serializeinput-options) values.
8493

8594
```js
8695
import { isEqual } from "ohash";
@@ -93,7 +102,7 @@ console.log(isEqual({ a: 1, b: 2 }, { b: 2, a: 1 }));
93102

94103
Compare two objects with nested [serialization](#serializeinput-options). Returns an array of changes.
95104

96-
Returned value is an array of diff entries with `$key`, `$hash`, `$value` and `$props`. When logging, a string version of changelog is displayed.
105+
The returned value is an array of diff entries with `$key`, `$hash`, `$value`, and `$props`. When logging, a string version of the changelog is displayed.
97106

98107
```js
99108
import { diff } from "ohash";

0 commit comments

Comments
 (0)
Please sign in to comment.