Compare commits
6 Commits
Author | SHA1 | Date |
---|---|---|
Bauke | 137c8eb290 | |
Bauke | f4fa51251e | |
Bauke | dd3eb83ed8 | |
Bauke | 01792d43d2 | |
Bauke | c464983440 | |
Bauke | 9fc2dbcbcb |
|
@ -1,5 +1,4 @@
|
|||
import process from "node:process";
|
||||
|
||||
import {build} from "esbuild";
|
||||
import {cmd} from "web-ext";
|
||||
|
||||
|
|
22
package.json
22
package.json
|
@ -2,7 +2,7 @@
|
|||
"name": "@holllo/webextension-storage",
|
||||
"description": "Ergonomic WebExtension storage helper.",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"version": "0.1.0",
|
||||
"version": "0.2.0",
|
||||
"type": "module",
|
||||
"homepage": "https://git.bauke.xyz/Holllo/webextension-storage",
|
||||
"bugs": {
|
||||
|
@ -26,17 +26,17 @@
|
|||
"webextension-polyfill": "^0.10.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@bauke/eslint-config": "^0.1.2",
|
||||
"@bauke/prettier-config": "^0.1.2",
|
||||
"@holllo/test": "^0.1.0",
|
||||
"@types/node": "^18.11.17",
|
||||
"@types/webextension-polyfill": "^0.9.2",
|
||||
"esbuild": "^0.16.8",
|
||||
"tsx": "^3.12.1",
|
||||
"typescript": "^4.9.4",
|
||||
"web-ext": "^7.4.0",
|
||||
"@bauke/eslint-config": "^0.1.4",
|
||||
"@bauke/prettier-config": "^0.1.4",
|
||||
"@holllo/test": "^0.2.1",
|
||||
"@types/node": "^20.10.2",
|
||||
"@types/webextension-polyfill": "^0.10.7",
|
||||
"esbuild": "^0.19.8",
|
||||
"tsx": "^4.6.2",
|
||||
"typescript": "^5.3.2",
|
||||
"web-ext": "^7.8.0",
|
||||
"webextension-polyfill": "^0.10.0",
|
||||
"xo": "^0.53.1"
|
||||
"xo": "^0.56.0"
|
||||
},
|
||||
"prettier": "@bauke/prettier-config",
|
||||
"xo": {
|
||||
|
|
5397
pnpm-lock.yaml
5397
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
|
@ -2,7 +2,7 @@ import browser from "webextension-polyfill";
|
|||
|
||||
export type StorageArea = browser.Storage.StorageArea;
|
||||
|
||||
type ValueOptions<T> = {
|
||||
export type ValueOptions<T> = {
|
||||
/** A function to convert a string to the type `T`. */
|
||||
deserialize: (input: string) => T;
|
||||
/** The key to use for storage. */
|
||||
|
@ -35,10 +35,10 @@ export async function createValue<T>(
|
|||
type Props<T> = Required<ValueOptions<T>>;
|
||||
|
||||
export class Value<T> implements Props<T> {
|
||||
public readonly deserialize: Props<T>["deserialize"];
|
||||
public readonly key: Props<T>["key"];
|
||||
public readonly serialize: Props<T>["serialize"];
|
||||
public readonly storage: Props<T>["storage"];
|
||||
public deserialize: Props<T>["deserialize"];
|
||||
public key: Props<T>["key"];
|
||||
public serialize: Props<T>["serialize"];
|
||||
public storage: Props<T>["storage"];
|
||||
|
||||
private inner: Props<T>["value"];
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import browser from "webextension-polyfill";
|
||||
|
||||
import {createValue} from "../build/index.js";
|
||||
|
||||
const updatedDate = await createValue<Date>({
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import {setup, type TestContext} from "@holllo/test";
|
||||
import browser from "webextension-polyfill";
|
||||
|
||||
import {createValue, type Value} from "../source/index.js";
|
||||
|
||||
const create = async <T>(
|
||||
|
@ -34,10 +33,10 @@ const sampleObject: SampleObject = {
|
|||
status: "passed",
|
||||
};
|
||||
|
||||
const group = await setup("Value<T>", async (group) => {
|
||||
await setup("Value<T>", async (group) => {
|
||||
const samples = [
|
||||
["number", "testNumber", Math.PI],
|
||||
["string", "testString", "A string to test with!" as string],
|
||||
["string", "testString", "A string to test with!"],
|
||||
["SampleObject", "testSampleObject", sampleObject],
|
||||
] as const;
|
||||
|
||||
|
|
Loading…
Reference in New Issue