]> git.ardis.lu - static-encrypt/commitdiff
Add *.d.ts files
authorArdis Lu <ardisglu@gmail.com>
Sat, 9 Sep 2023 03:30:04 +0000 (20:30 -0700)
committerArdis Lu <ardisglu@gmail.com>
Sat, 9 Sep 2023 03:30:04 +0000 (20:30 -0700)
README.md
decrypt.d.ts [new file with mode: 0644]
encrypt.d.ts [new file with mode: 0644]

index 310b7b40a7ef967250d33b2e9370a5a2fbef2b8d..bc2d0f87d56b44ef0cdef5a2ead5577339d15b53 100644 (file)
--- a/README.md
+++ b/README.md
@@ -85,3 +85,13 @@ You can also import the function dynamically (useful for lazy-loading or testing
 ```javascript
 const { decrypt } = await import('https://cdn.statically.io/gh/ardislu/static-encrypt/master/decrypt.js');
 ```
+
+### TypeScript
+
+`*.d.ts` files are generated from the [JSDoc](https://jsdoc.app/) comments using `tsc`:
+
+```
+tsc --declaration --emitDeclarationOnly --allowJs .\decrypt.js .\encrypt.js
+```
+
+These `*.d.ts` files allow `encrypt` and `decrypt` to be imported in `.ts` files with typing.
diff --git a/decrypt.d.ts b/decrypt.d.ts
new file mode 100644 (file)
index 0000000..1ca1795
--- /dev/null
@@ -0,0 +1,7 @@
+/**
+ * Decrypt an encrypted string.
+ * @param {string} content - The ciphertext to decrypt.
+ * @param {string} password - The password used to encrypt the string.
+ * @returns {Promise<string>} A promise that resolves to the plaintext.
+ */
+export function decrypt(content: string, password: string): Promise<string>;
diff --git a/encrypt.d.ts b/encrypt.d.ts
new file mode 100644 (file)
index 0000000..158def8
--- /dev/null
@@ -0,0 +1,7 @@
+/**
+ * Encrypt a string.
+ * @param {string} plaintext - The string to encrypt.
+ * @param {string} password - The password used to encrypt the string.
+ * @returns {Promise<string>} A promise that resolves to the ciphertext.
+ */
+export function encrypt(plaintext: string, password: string): Promise<string>;
This page took 0.043581 seconds and 4 git commands to generate.