Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,24 @@ npx nypm i ohash

```js
// ESM import
import { hash, serialize, isEqual, diff, digest } from "ohash";
import { hash, serialize, digest } from "ohash";
import { isEqual, diff } from "ohash/utils";

// Dynamic import
const { hash } = await import("ohash");
const { hash, serialize, digest } = await import("ohash");
const { isEqual, diff } = await import("ohash/utils");
```

<details>
<summary>Import from CDN</summary>

```js
// ESM import
import { hash } from "https://esm.sh/ohash";
import { hash, serialize, digest } from "https://esm.sh/ohash";
import { isEqual, diff } from "https://esm.sh/ohash/utils";

// Dynamic import
const { hash } = await import("https://esm.sh/ohash");
const { hash, serialize, digest } = await import("https://esm.sh/ohash");
const { isEqual, diff } = await import("https://esm.sh/ohash/utils");
```

</details>
Expand Down Expand Up @@ -86,7 +89,7 @@ console.log(digest("Hello World"));
Compare two objects using `===` and then fallbacks to compare based on their [serialized](#serializeinput-options) values.

```js
import { isEqual } from "ohash";
import { isEqual } from "ohash/utils";

// true
console.log(isEqual({ a: 1, b: 2 }, { b: 2, a: 1 }));
Expand All @@ -99,7 +102,7 @@ Compare two objects with nested [serialization](#serializeinput-options). Return
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.

```js
import { diff } from "ohash";
import { diff } from "ohash/utils";

const createObject = () => ({
foo: "bar",
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},
"./utils": {
"types": "./dist/utils/index.d.mts",
"default": "./dist/utils/index.mjs"
},
"./crypto": {
"node": {
"types": "./dist/crypto/node/index.d.mts",
Expand Down
4 changes: 0 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,3 @@ export { hash } from "./hash";

// Crypto
export { digest } from "ohash/crypto";

// Utils
export { isEqual } from "./utils/is-equal";
export { diff } from "./utils/diff";
2 changes: 2 additions & 0 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { isEqual } from "./is-equal";
export { diff } from "./diff";
Loading