Skip to content

Commit

Permalink
Merge pull request #252 from NextFaze/master
Browse files Browse the repository at this point in the history
Update typings
  • Loading branch information
kriszyp authored Jul 11, 2023
2 parents 6e4146d + 4dabe52 commit 1e4de38
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
31 changes: 31 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,20 +326,51 @@ declare namespace lmdb {
maxDbs?: number
/** Set a longer delay (in milliseconds) to wait longer before committing writes to increase the number of writes per transaction (higher latency, but more efficient) **/
commitDelay?: number
/**
* This can be used to specify the initial amount of how much virtual memory address space (in bytes) to allocate for mapping to the database files.
* Setting a map size will typically disable remapChunks by default unless the size is larger than appropriate for the OS. Different OSes have different allocation limits.
**/
mapSize?: number
/**
* This defines the page size of the database. This defaults to the default page size of the OS (usually 4,096, except on MacOS with M-series, which is 16,384 bytes).
* You may want to consider setting this to 8,192 for databases larger than available memory (and moreso if you have range queries) or 4,096 for databases that can mostly cache in memory.
* Note that this only effects the page size of new databases (does not affect existing databases). */
pageSize?: number
/** This enables committing transactions where LMDB waits for a transaction to be fully flushed to disk after the transaction has been committed and defaults to being enabled on non-Windows OSes. This option is discussed in more detail below. */
overlappingSync?: boolean
/** Resolve asynchronous operations when commits are finished and visible and include a separate promise for when a commit is flushed to disk, as a flushed property on the commit promise. Note that you can alternately use the flushed property on the database. */
separateFlushed?: boolean
/**
* This a flag to specify if dynamic memory mapping should be used. Enabling this generally makes read operations a little bit slower, but frees up more mapped memory, making it friendlier to other applications.
* This is enabled by default on 32-bit operating systems (which require this to go beyond 4GB database size) if mapSize is not specified, otherwise it is disabled by default.
**/
remapChunks?: boolean
/** This provides a small performance boost (when not using useWritemap) for writes, by skipping zero'ing out malloc'ed data, but can leave application data in unused portions of the database. This is recommended unless there are concerns of database files being accessible. */
noMemInit?: boolean
/** Use writemaps, discouraged at this. This improves performance by reducing malloc calls, but it is possible for a stray pointer to corrupt data. */
useWritemap?: boolean
/** Treat path as a filename instead of directory (this is the default if the path appears to end with an extension and has '.' in it) */
noSubdir?: boolean
/**
* Does not explicitly flush data to disk at all. This can be useful for temporary databases where durability/integrity is not necessary, and can significantly improve write performance that is I/O bound.
* However, we discourage this flag for data that needs integrity and durability in storage, since it can result in data loss/corruption if the computer crashes.
**/
noSync?: boolean
/** This isn't as dangerous as `noSync`, but doesn't improve performance much either. */
noMetaSync?: boolean
/** Self-descriptive */
readOnly?: boolean
/** The maximum number of concurrent read transactions (readers) to be able to open ([more information](http://www.lmdb.tech/doc/group__mdb.html#gae687966c24b790630be2a41573fe40e2)). */
maxReaders?: number
/** This enables encryption, and the provided value is the key that is used for encryption. This may be a buffer or string, but must be 32 bytes/characters long. This uses the Chacha8 cipher for fast and secure on-disk encryption of data. */
encryptionKey?: string | Buffer
/**
* This is enabled by default and will ensure that all asynchronous write operations performed in the same event turn will be batched together into the same transaction.
* Disabling this allows lmdb-js to commit a transaction at any time, and asynchronous operations will only be guaranteed to be in the same transaction if explicitly batched together (with transaction, batch, ifVersion).
* If this is disabled (set to false), you can control how many writes can occur before starting a transaction with txnStartThreshold (allow a transaction will still be started at the next event turn if the threshold is not met).
* Disabling event turn batching (and using lower txnStartThreshold values) can facilitate a faster response time to write operations. txnStartThreshold defaults to 5.
**/
eventTurnBatching?: boolean
}
interface RootDatabaseOptionsWithPath extends RootDatabaseOptions {
path?: string
Expand Down
1 change: 1 addition & 0 deletions test/types/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const path = 'type-test-store'

expectType<RootDatabase>(open(path, { compression: true }))
expectType<RootDatabase>(open({ path, compression: true }))
expectType<RootDatabase>(open(path, { encryptionKey: 'Use this key to encrypt the data' }))

const defaultStore = open({ path, compression: true })
expectType<boolean>(await defaultStore.put('foo', { bar: 'baz' }))
Expand Down

0 comments on commit 1e4de38

Please sign in to comment.