diff --git a/README.md b/README.md
index eed7a94..bb055e9 100644
--- a/README.md
+++ b/README.md
@@ -1,9 +1,9 @@
-# Astro Resume
+# Astro deserialize
Utilities for serializing data from server for use in the client.
-1. `Resumable` Astro component takes `id` and `data`
-1. `resume(id: string): Object` function for use int he client takes an `id` string and returns the `data` as Object
+1. `Serialize` Astro component takes `id` and `data`
+1. `deserialize(id: string): Object` function for use int he client takes an `id` string and returns the `data` as Object
## Installation & Usage
@@ -21,18 +21,18 @@ Serializing and deserializing basic primitive data
```astro
---
-import Resumable from "@ayco/astro-resume";
+import Serialize from "@ayco/astro-resume";
const data = {
hello: 'world',
}
---
-
+
@@ -44,7 +44,7 @@ You can define a type for the data and use it in the client script.
```astro
---
-import Resumable from "@ayco/astro-resume";
+import Serialize from "@ayco/astro-resume";
const data = {
hello: 'world',
@@ -54,10 +54,10 @@ const data = {
export type Data = typeof data;
---
-
+
diff --git a/index.ts b/index.ts
index cc0b985..1f73bd8 100644
--- a/index.ts
+++ b/index.ts
@@ -1,5 +1,5 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
-import Resumable from './src/Resumable.astro';
-export default Resumable;
-export * from './src/resume';
+import Serialize from './src/Serialize.astro';
+export default Serialize;
+export * from './src/deserialize';
diff --git a/package.json b/package.json
index 33eb810..74968c1 100644
--- a/package.json
+++ b/package.json
@@ -14,8 +14,8 @@
".": "./index.ts"
},
"files": [
- "src/Resumable.astro",
- "src/resume.ts",
+ "src/Serialize.astro",
+ "src/deserialize.ts",
"index.ts"
],
"scripts": {
diff --git a/src/Resumable.astro b/src/Serialize.astro
similarity index 76%
rename from src/Resumable.astro
rename to src/Serialize.astro
index 068e2c1..eba46bd 100644
--- a/src/Resumable.astro
+++ b/src/Serialize.astro
@@ -3,11 +3,11 @@ type Primitive = string | number | boolean | null | undefined;
export interface Props {
/**
- * The id that the client script will pass to the `resume()` function
+ * The id that the client script will pass to the `deserialize()` function
*/
id: string;
/**
- * The data to be serialized and accessed in the client script with `resume()`
+ * The data to be serialized and accessed in the client script with `deserialize()`
*/
data: Record;
}
diff --git a/src/resume.ts b/src/deserialize.ts
similarity index 56%
rename from src/resume.ts
rename to src/deserialize.ts
index b15d133..351721d 100644
--- a/src/resume.ts
+++ b/src/deserialize.ts
@@ -1,14 +1,14 @@
-export function resume(id: string): T {
+export function deserialize(id: string): T {
const element = document.querySelector(`#${id}`);
if (element?.value)
return JSON.parse(element.value)
- throw Error(`The call resume('${id}') did not find any data.
+ throw Error(`The call deserialize('${id}') did not find any data.
Check that the following are correct:
- - The Resumable component is used with correct props
+ - The Serialize component is used with correct props
- "data" prop is not undefined
- - "${id}" is the "id" of the Resumable component
+ - "${id}" is the "id" of the Serialize component
See examples: https://sr.ht/~ayoayco/astro-resume/#usage
Stack trace: `)
}
diff --git a/src/pages/index.astro b/src/pages/index.astro
index 2d091c1..0c3416f 100644
--- a/src/pages/index.astro
+++ b/src/pages/index.astro
@@ -1,20 +1,21 @@
---
-import Resumable from '../Resumable.astro';
+import Serialize from "../Serialize.astro";
const data = {
name: 'John Doe',
isOkay: true,
+ mood: null
}
export type Data = typeof data;
---
-
+