npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

chex-storage

v1.0.0

Published

A wrapper library for Chrome extension storage local - the standard storage in the chrome extension.

Downloads

8

Readme

Chex storage

chex-storage is a wrapper library for Chrome extension storage local - the standard storage in the chrome extension.

Install

  # Yarn
  yarn add chex-storage

  # npm
  npm install chex-storage

Get started

  // db.ts
  import ChexDatabase, { ChexTable } from "chex-storage";
  import { ConfigureLLM, Conversation, Marking, Message, Note } from "typing";

  const store = new ChexDatabase("chex-storage") as ChexDatabase & {
    user: ChexTable<Marking, "id">;
  };

  store.tables({
    user: "++id",
  });

  export { store };

API-Reference

Type Parameters

  • TData: The type of data stored in the table.
  • TKeyPropName extends keyof TData: The key property name of the data.

Constructor

constructor(database: string, name: string, keyName: StorageKey<TKeyPropName>)

Creates a new instance of the ChexTable class.

  • Parameters:
    • database (string): The name of the database.
    • name (string): The name of the table.
    • keyName (StorageKey): The key name for the table.

Methods

add(data: Optional<TData, TKeyPropName>): Promise<TData[TKeyPropName]>

Adds new data to the table and returns the key of the added data.

Parameters:

  • data (Optional<TData, TKeyPropName>): The data to add.

Returns:

  • Promise<TData[TKeyPropName]>: A promise that resolves to the key of the added data.

bulkAdd(data: Optional<TData, TKeyPropName>[]): Promise<void>

Adds multiple data entries to the table.

Parameters:

  • data (Optional<TData, TKeyPropName>[]): An array of data to add.

Returns:

  • Promise<void>: A promise that resolves when the data is added.

get(): Promise<TData[]>

get(key: TData[TKeyPropName]): Promise<TData | undefined>

Gets all data from the table or gets data by a specific key.

Parameters:

  • key (TData[TKeyPropName], optional): The key of the data to retrieve.

Returns:

  • Promise<TData[]>: A promise that resolves to an array of all data (when no key is provided).
  • Promise<TData | undefined>: A promise that resolves to the data with the specified key or undefined if not found.

update(keyValue: TData[TKeyPropName], change: Partial<Omit<TData, TKeyPropName>>): Promise<TData[TKeyPropName]>

Updates data in the table by key and returns the key of the updated data.

Parameters:

  • keyValue (TData[TKeyPropName]): The key of the data to update.
  • change (Partial<Omit<TData, TKeyPropName>>): The changes to apply.

Returns:

  • Promise<TData[TKeyPropName]>: A promise that resolves to the key of the updated data.

updateAll(change: Partial<Omit<TData, TKeyPropName>>): Promise<void>

Updates all data in the table with the specified changes.

Parameters:

  • change (Partial<Omit<TData, TKeyPropName>>): The changes to apply to all data.

Returns:

  • Promise<void>: A promise that resolves when the data is updated.

delete(keyValue: TData[TKeyPropName]): Promise<void>

Deletes data from the table by key.

Parameters:

  • keyValue (TData[TKeyPropName]): The key of the data to delete.

Returns:

  • Promise<void>: A promise that resolves when the data is deleted.

bulkDelete(keyValues: TData[TKeyPropName][]): Promise<void>

Deletes multiple data entries from the table by their keys.

Parameters:

  • keyValues (TData[TKeyPropName][]): An array of keys of the data to delete.

Returns:

  • Promise<void>: A promise that resolves when the data is deleted.

filter filter(callback: (row: TData) => boolean):Promise<TData[]>

Query data with the same of filter factory function

Parameters:

  • callback ((row: TData) => boolean): A filter function to apply to each row of data.

Returns:

  • Promise<void>: A promise that resolves when the data is deleted.

where(keyWhere: string): ChexStorageWhereMethods<TData>

Returns a ChexStorageWhereMethods instance for querying data with the specified key condition.

Parameters:

  • keyWhere (string): The key condition for querying data.

Returns:

  • Promise<TData[]>: A promise that resolves to an array of data matching the filter criteria.

ChexStorageWhereMethods

equals(val: any): Promise<TData[]>

Queries the table for data where the specified key equals the given value.

Parameters:

  • val (any): The value to compare against the key.

Returns:

  • Promise<TData[]>: A promise that resolves to an array of data matching the condition.