A repository packages that provides from various datasource.
yarn add @jamashita/catacombe
- IndexedDB
- LocalStorage
- SessionStorage
> node -v
v20.12.2
> npm -v
10.5.0
> yarn -v
1.22.21
git cz
An error class for data source that extends RuntimeError
from @jamashita/anden
.
This class provides a simple interface for making API requests to the server. FetchResponseType
represents the type of
data that you can retrieve from the server. It can be one of the following values: 'arrayBuffer'
, 'blob'
, 'json'
,
or 'text'
.
This is a constructor for a class that always returns a response of the given type
.
Sends a DELETE request to the server at the specified url
. Returns a promise that resolves to the server's response
with the specified data type
.
Sends a GET request to the server at the specified url
. Returns a promise that resolves to the server's response with
the specified data type
.
Sends a HEAD request to the server at the specified url
. Returns a promise that resolves to the server's response with
the specified data type
.
Sends a POST request to the server at the specified url
with an optional body payload
. Returns a promise that
resolves to the server's response with the specified data type
.
Sends a PUT request to the server at the specified url
with an optional body payload
. Returns a promise that
resolves to the server's response with the specified data type
.
FetchError
is an error type for Fetch
. It extends the DataSourceError
class.
This class provides a simple interface for interacting with files on the file system.
Checks whether a file with the given path
exists. Returns a promise that resolves to true
if the file exists,
or false
if it does not exist.
Reads the contents of a file with the given path
. Returns a promise that resolves to a Buffer
object containing the
file's data.
Writes the given data to the file with the given path
. data
can be either a Buffer
object or a string. Returns a
promise that resolves when the write operation is complete.
FileError
is an error type for File
. It extends the DataSourceError
class.
This class provides a simple interface for storing data in memory.
This is a constructor for a class that retains data for a specified number of seconds
. If you set the seconds to
Infinity
, the data will be retained forever.
Retrieves the value associated with the given identifier
. The type of the returned value is specified by the generic
type H
.
Stores the given value
with the given identifier
. The stored value can be retrieved using the get method with the
same identifier
.
HeapError
is an error type for Heap
. It extends the DataSourceError
class.
This class provides a simple interface for storing data into MySQL.
Commits the pending transactions.
Executes the SQL statement. The result R
will be returned. The value
is assigned to the prepared statement before
execution.
Terminates the current connection to the resource.
Rollbacks the current transactions.
Executes the sql
statement. The result R
will be returned. The value
is assigned to the prepared statement before
execution.
This method handles a single transaction, with R
indicating the returned value. The ISQL
instance is used to execute
SQL statements within the transaction.
Executes the SQL statement. The result R
will be returned. The value
is assigned to the prepared statement before
execution.
Returns the Connection
.
Executes the given transaction
. If successful, commit the changes and release the connection. If not, roll back the
transaction and release the connection.
MySQLError
is an error type for MySQL
. It extends the DataSourceError
class.
Deletes the values associated with the keys specified in the keys
list. Returns true
if all keys were successfully
deleted.
Checks if the specified keys in the keys
list exist and return true
if all of them do, otherwise return false
.
Assigns an expiration time of seconds
to the key specified in key
. Returns true
if the operation was successful.
Returns RedisHash
.
Returns RedisList
.
Returns RedisSet
.
Returns RedisString
.
Adds the event listener.
Broadcasts a message
to the specified channel
. Returns the number of clients that received the message.
Begins listening for events on the specified channel
.
Stops listening for events on the specified channels
.
RedisError
is an error type for Redis
. It extends the DataSourceError
class.
Redis methods for hash.
Removes the field specified in field
from the Hash stored at the key specified in key
. Returns the number of fields
that were removed.
Gets the value of the given field
from the Hash stored at the key specified in key
. Return null
if the value does
not exist.
Returns true
if the given field
exists in the Hash stored at the key specified in key
.
Retrieves the number of fields in the Hash stored at the given key
.
Sets the value of field
in the Hash stored at the key specified key
to the given value
. Returns true
if
the field
is new, false
if it was updated.
Redis methods for list.
Retrieves all elements stored under the given key
as an Array.
Retrieves the length of the list stored at the given key
.
Returns the last element of the list stored in the given key
and remove it from the list. May return null
if it has
no elements.
Adds the given value
to the end of the list stored in the given key
. Then return the current length of the list.
Removes the given value
from the the list stored in the given key
. Return the current length of the list.
Retrieves a subset of elements from the list stored in key
, starting at offset
index and ending at offset + limit
index.
Returns the first element of the list stored in the given key
and remove it from the list. May return null
if it has
no elements.
Redis methods for set.
Adds the given values
to the Set stored in specified key
. Returns the number of elements added to the set, not
including already existing elements.
Retrieves all values stored under the given key
as a Set.
Returns true
if the given value
exists in the Set stored at the key specified in key
.
Retrieves the length of the Set stored at the given key
.
Removes and returns a random element from the Set stored in the given key
. May return null
if it has no elements.
Retrieves a random element from the Set stored at the specified key
.
Removes the given values
from the the Set stored in the given key
. Returns the current size of the Set.
Redis methods for string.
Retrieves the value stored at the given key
as a string. May return null
if the key does not exist or the value
stored at the key
is not a string.
Store the given value
at the given key
. Return true
if the operation was successful.
This class provides a simple interface for sending requests to the server and receiving a response.
RequestResponseType
represents the type of data that can be retrieved from the server, and it can be one of the
following values: 'buffer'
, 'json'
, or 'text'
.
This is a constructor for a class that returns a response of the specified type
for every request.
Sends a DELETE request to the server at the specified url
. Returns a promise that resolves to the server's response
with the specified data type
.
Sends a GET request to the server at the specified url
. Returns a promise that resolves to the server's response with
the specified data type
.
Sends a HEAD request to the server at the specified url
. Returns a promise that resolves to the server's response with
the specified data type
.
Sends a POST request to the server at the specified url
with an optional body payload
. Returns a promise that
resolves to the server's response with the specified data type
.
Sends a PUT request to the server at the specified url
with an optional body payload
. Returns a promise that
resolves to the server's response with the specified data type
.
RequestError
is an error type for Request
. It extends the DataSourceError
class.