mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
Add types for dexie-batch (#37160)
This commit is contained in:
parent
388b2e06bd
commit
bb36642c70
27
types/dexie-batch/dexie-batch-tests.ts
Normal file
27
types/dexie-batch/dexie-batch-tests.ts
Normal file
@ -0,0 +1,27 @@
|
||||
import DexieBatch = require('dexie-batch');
|
||||
import Dexie from 'dexie';
|
||||
|
||||
const db = new Dexie('MyDatabase');
|
||||
const collection = db.table<string, number>('table').toCollection();
|
||||
|
||||
new DexieBatch({ batchSize: 10, limit: 10 }).each(collection, (item, index) => {
|
||||
item; // $ExpectType string
|
||||
index; // $ExpectType number
|
||||
});
|
||||
|
||||
new DexieBatch({ batchSize: 10 }).eachBatch(collection, (items, index) => {
|
||||
items; // $ExpectType string[]
|
||||
index; // $ExpectType number
|
||||
});
|
||||
|
||||
new DexieBatch({ batchSize: 10 }).eachBatchParallel(collection, (items, index) => {
|
||||
items; // $ExpectType string[]
|
||||
index; // $ExpectType number
|
||||
});
|
||||
|
||||
new DexieBatch({ batchSize: 10 }).eachBatchSerial(collection, (items, index) => {
|
||||
items; // $ExpectType string[]
|
||||
index; // $ExpectType number
|
||||
});
|
||||
|
||||
new DexieBatch({ batchSize: 10 }).isParallel(); // $ExpectType boolean
|
||||
30
types/dexie-batch/index.d.ts
vendored
Normal file
30
types/dexie-batch/index.d.ts
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
// Type definitions for dexie-batch 0.4
|
||||
// Project: https://github.com/raphinesse/dexie-batch#readme
|
||||
// Definitions by: Florian Keller <https://github.com/ffflorian>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import { Dexie } from 'dexie';
|
||||
|
||||
declare namespace DexieBatch {
|
||||
interface Options {
|
||||
batchSize: number;
|
||||
limit?: number;
|
||||
}
|
||||
type Callback<T> = (item: T, index: number) => void;
|
||||
}
|
||||
|
||||
declare class DexieBatch {
|
||||
private readonly opts: DexieBatch.Options;
|
||||
|
||||
constructor(opts: DexieBatch.Options);
|
||||
|
||||
isParallel(): boolean;
|
||||
|
||||
each<T>(collection: Dexie.Collection<T, any>, callback: DexieBatch.Callback<T>): Dexie.Promise<number>;
|
||||
eachBatch<T>(collection: Dexie.Collection<T, any>, callback: DexieBatch.Callback<T[]>): Dexie.Promise<number>;
|
||||
eachBatchParallel<T>(collection: Dexie.Collection<T, any>, callback: DexieBatch.Callback<T[]>): Dexie.Promise<number>;
|
||||
eachBatchSerial<T>(collection: Dexie.Collection<T, any>, callback: DexieBatch.Callback<T[]>, batchIdx?: number): Dexie.Promise<number>;
|
||||
}
|
||||
|
||||
export as namespace DexieBatch;
|
||||
export = DexieBatch;
|
||||
6
types/dexie-batch/package.json
Normal file
6
types/dexie-batch/package.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"dexie": "^2.0.0"
|
||||
}
|
||||
}
|
||||
24
types/dexie-batch/tsconfig.json
Normal file
24
types/dexie-batch/tsconfig.json
Normal file
@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"dom",
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"dexie-batch-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/dexie-batch/tslint.json
Normal file
1
types/dexie-batch/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user