type
stringclasses
7 values
content
stringlengths
4
9.55k
repo
stringlengths
7
96
path
stringlengths
4
178
language
stringclasses
1 value
MethodDeclaration
getVoiceSettings(): Promise<VoiceSettings>;
0-Captain/DefinitelyTyped
types/discord-rpc/index.d.ts
TypeScript
MethodDeclaration
setVoiceSettings(args: VoiceSettings): Promise<any>;
0-Captain/DefinitelyTyped
types/discord-rpc/index.d.ts
TypeScript
MethodDeclaration
captureShortcut(callback: (shortcut: Array<{ type: number, code: number, name: string }>, stop: () => void) => void): Promise<() => void>;
0-Captain/DefinitelyTyped
types/discord-rpc/index.d.ts
TypeScript
MethodDeclaration
setActivity(args?: Presence, pid?: number): Promise<any>;
0-Captain/DefinitelyTyped
types/discord-rpc/index.d.ts
TypeScript
MethodDeclaration
clearActivity(pid?: number): Promise<any>;
0-Captain/DefinitelyTyped
types/discord-rpc/index.d.ts
TypeScript
MethodDeclaration
sendJoinInvite(user: { id: string } | string): Promise<any>;
0-Captain/DefinitelyTyped
types/discord-rpc/index.d.ts
TypeScript
MethodDeclaration
sendJoinRequest(user: { id: string } | string): Promise<any>;
0-Captain/DefinitelyTyped
types/discord-rpc/index.d.ts
TypeScript
MethodDeclaration
closeJoinRequest(user: { id: string } | string): Promise<any>;
0-Captain/DefinitelyTyped
types/discord-rpc/index.d.ts
TypeScript
MethodDeclaration
createLobby(type: string, capacity: number, metadata: any): Promise<any>;
0-Captain/DefinitelyTyped
types/discord-rpc/index.d.ts
TypeScript
MethodDeclaration
updateLobby(lobby: { id: string } | string, options?: { type: string, owner: { id: string } | string, capacity: number, metadata: any }): Promise<any>;
0-Captain/DefinitelyTyped
types/discord-rpc/index.d.ts
TypeScript
MethodDeclaration
deleteLobby(lobby: { id: string } | string): Promise<any>;
0-Captain/DefinitelyTyped
types/discord-rpc/index.d.ts
TypeScript
MethodDeclaration
connectToLobby(id: string, secret: string): Promise<any>;
0-Captain/DefinitelyTyped
types/discord-rpc/index.d.ts
TypeScript
MethodDeclaration
sendToLobby(lobby: { id: string } | string, data: any): Promise<any>;
0-Captain/DefinitelyTyped
types/discord-rpc/index.d.ts
TypeScript
MethodDeclaration
disconnectFromLobby(lobby: { id: string } | string): Promise<any>;
0-Captain/DefinitelyTyped
types/discord-rpc/index.d.ts
TypeScript
MethodDeclaration
updateLobbyMember(lobby: { id: string } | string, user: { id: string } | string, metadata: any): Promise<any>;
0-Captain/DefinitelyTyped
types/discord-rpc/index.d.ts
TypeScript
MethodDeclaration
subscribe(event: string, callback: (data: any) => void): Promise<Subscription>;
0-Captain/DefinitelyTyped
types/discord-rpc/index.d.ts
TypeScript
MethodDeclaration
subscribe(event: string, args: any, callback: (data: any) => void): Promise<Subscription>;
0-Captain/DefinitelyTyped
types/discord-rpc/index.d.ts
TypeScript
MethodDeclaration
destroy(): Promise<void>;
0-Captain/DefinitelyTyped
types/discord-rpc/index.d.ts
TypeScript
MethodDeclaration
on(event: 'ready' | 'connected', listener: () => void): this;
0-Captain/DefinitelyTyped
types/discord-rpc/index.d.ts
TypeScript
MethodDeclaration
once(event: 'ready' | 'connected', listener: () => void): this;
0-Captain/DefinitelyTyped
types/discord-rpc/index.d.ts
TypeScript
MethodDeclaration
off(event: 'ready' | 'connected', listener: () => void): this;
0-Captain/DefinitelyTyped
types/discord-rpc/index.d.ts
TypeScript
InterfaceDeclaration
interface Option { /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: (res: TaroGeneral.CallbackResult) => void /** 接口调用失败的回调函数 */ fail?: (res: TaroGeneral.CallbackResult) => void /** 接口调用成功的回调函数 */ success?: (res: TaroGeneral.CallbackResult) => void }
10088/taro
packages/taro/types/api/media/audio.d.ts
TypeScript
InterfaceDeclaration
interface Option { /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: (res: TaroGeneral.CallbackResult) => void /** 接口调用失败的回调函数 */ fail?: (res: TaroGeneral.CallbackResult) => void /** 是否与其他音频混播,设置为 true 之后,不会终止其他应用或微信内的音乐 */ mixWithOther?: boolean /** (仅在 iOS 生效)是否遵循静音开关,设置为 false 之后,...
10088/taro
packages/taro/types/api/media/audio.d.ts
TypeScript
InterfaceDeclaration
interface Option { /** 需要播放的语音文件的文件路径 */ filePath: string /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: (res: TaroGeneral.CallbackResult) => void /** 指定录音时长,到达指定的录音时长后会自动停止录音,单位:秒 */ duration?: number /** 接口调用失败的回调函数 */ fail?: (res: TaroGeneral.CallbackResult) => void ...
10088/taro
packages/taro/types/api/media/audio.d.ts
TypeScript
InterfaceDeclaration
interface Option { /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: (res: TaroGeneral.CallbackResult) => void /** 接口调用失败的回调函数 */ fail?: (res: TaroGeneral.CallbackResult) => void /** 接口调用成功的回调函数 */ success?: (result: SuccessCallbackResult) => void }
10088/taro
packages/taro/types/api/media/audio.d.ts
TypeScript
InterfaceDeclaration
interface SuccessCallbackResult extends TaroGeneral.CallbackResult { /** 支持的音频输入源列表,可在 [RecorderManager.start()](/docs/apis/media/recorder/RecorderManager#start)用。返回值定义参考 https://developer.android.com/reference/kotlin/android/media/MediaRecorder.AudioSource */ audioSources: Array<keyof audioSources> ...
10088/taro
packages/taro/types/api/media/audio.d.ts
TypeScript
InterfaceDeclaration
/** 支持的音频输入源 */ interface audioSources { /** 自动设置,默认使用手机麦克风,插上耳麦后自动切换使用耳机麦克风,所有平台适用 */ 'auto' /** 手机麦克风,仅限 iOS */ 'buildInMic' /** 耳机麦克风,仅限 iOS */ 'headsetMic' /** 麦克风(没插耳麦时是手机麦克风,插耳麦时是耳机麦克风),仅限 Android */ 'mic' /** 同 mic,适用于录制音视频内容,仅限 Android */ 'camcorder' ...
10088/taro
packages/taro/types/api/media/audio.d.ts
TypeScript
InterfaceDeclaration
/** AudioBuffer 接口表示存在内存里的一段短小的音频资源,利用 [WebAudioContext.decodeAudioData](./WebAudioContext#decodeaudiodata) 方法从一个音频文件构建,或者利用 [AudioContext.createBuffer](https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/(AudioContext.createBuffer).html) 从原始数据构建。把音频放入 AudioBuffer 后,可以传入到一个 AudioBufferSourceNode 进行播放。 *...
10088/taro
packages/taro/types/api/media/audio.d.ts
TypeScript
InterfaceDeclaration
/** `AudioContext` 实例,可通过 `Taro.createAudioContext` 获取。 * * `AudioContext` 通过 `id` 跟一个 `audio` 组件绑定,操作对应的 audio 组件。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/AudioContext.html */ interface AudioContext { /** 暂停音频。 * @supported weapp * @see ht...
10088/taro
packages/taro/types/api/media/audio.d.ts
TypeScript
InterfaceDeclaration
interface onErrorDetail extends TaroGeneral.CallbackResult { /** 错误码 */ errCode: number /** 错误信息 */ errMsg: string }
10088/taro
packages/taro/types/api/media/audio.d.ts
TypeScript
InterfaceDeclaration
interface onErrorDetailErrCode { /** 系统错误 */ 10001 /** 网络错误 */ 10002 /** 文件错误 */ 10003 /** 格式错误 */ 10004 /** 未知错误 */ '-1' }
10088/taro
packages/taro/types/api/media/audio.d.ts
TypeScript
InterfaceDeclaration
/** MediaAudioPlayer 实例,可通过 [Taro.createMediaAudioPlayer](./createMediaAudioPlayer) 接口获取实例。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/MediaAudioPlayer.html */ interface MediaAudioPlayer { /** 音量。范围 0~1 * @default 1 */ volume: number /** 启动...
10088/taro
packages/taro/types/api/media/audio.d.ts
TypeScript
InterfaceDeclaration
/** 字典对象 */ interface Constraints { /** 如果指定为 true 则禁用标准化 * @default false */ disableNormalization?: boolean }
10088/taro
packages/taro/types/api/media/audio.d.ts
TypeScript
InterfaceDeclaration
/** 一类音频处理模块,不同的Node具备不同的功能,如GainNode(音量调整)等。一个 WebAudioContextNode 可以通过上下文来创建。 * * > 目前已经支持以下Node: IIRFilterNode WaveShaperNode ConstantSourceNode ChannelMergerNode OscillatorNode GainNode BiquadFilterNode PeriodicWaveNode BufferSourceNode ChannelSplitterNode ChannelMergerNode DelayNode DynamicsCompressorNode Sc...
10088/taro
packages/taro/types/api/media/audio.d.ts
TypeScript
FunctionDeclaration
function assertEqual< T1 extends { keys(): IterableIterator<string>; has(key: string): boolean; get(key: string): any; }, T2 extends { keys(): IterableIterator<string>; has(key: string): boolean; get(key: string): any; }, >(one: T1, two: T2) { for (const key of one.keys()) { expect(two.has(key)).toB...
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
FunctionDeclaration
async function assertFileContent(content: string): Promise<void> { await expect(fs.readFile(testFilenameFull, "utf8")).resolves.toBe( content, ); }
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
FunctionDeclaration
async function assertCleanedUp() { // The other files should have been cleaned up await expect(fs.pathExists(testFilenameFull)).resolves.toBeTrue(); await expect( fs.pathExists(testFilenameFull + ".bak"), ).resolves.toBeFalse(); await expect( fs.pathExists(testFilenameFull + ".dump"), ).resol...
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
() => { const originalFS = jest.requireActual("fs-extra"); // eslint-disable-next-line @typescript-eslint/no-var-requires const wait = require("alcalzone-shared/async").wait; return { __esModule: true, // Use it when dealing with esModules ...originalFS, appendFile: jest.fn().mockImplementation(async (...arg...
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
async (...args) => { if (mockAppendFileThrottle > 0) { await wait(mockAppendFileThrottle); } return originalFS.appendFile(...args); }
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
async (...args) => { if (mockMoveFileThrottle > 0) { await wait(mockMoveFileThrottle); } return originalFS.move(...args); }
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
(path, options) => { // eslint-disable-next-line @typescript-eslint/no-var-requires const { PassThrough } = require("stream"); const { /*fd,*/ encoding } = options; // const file = fd // ? originalFS.readFileSync(fd, encoding) // : originalFS.readFileSync(path, encoding); const file = originalFS...
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
() => { ret.end(); }
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
() => { describe("validates autoCompress options", () => { it("sizeFactor <= 1", () => { expect( () => new JsonlDB("foo", { autoCompress: { sizeFactor: 0.9, }, }), ).toThrowError("sizeFactor"); }); it("minimumSize <= 0", () => { expect( () => ne...
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
() => { it("sizeFactor <= 1", () => { expect( () => new JsonlDB("foo", { autoCompress: { sizeFactor: 0.9, }, }), ).toThrowError("sizeFactor"); }); it("minimumSize <= 0", () => { expect( () => new JsonlDB("foo", { autoCompress: { siz...
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
() => { expect( () => new JsonlDB("foo", { autoCompress: { sizeFactor: 0.9, }, }), ).toThrowError("sizeFactor"); }
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
() => new JsonlDB("foo", { autoCompress: { sizeFactor: 0.9, }, })
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
() => { expect( () => new JsonlDB("foo", { autoCompress: { sizeFactorMinimumSize: -1, }, }), ).toThrowError("sizeFactorMinimumSize"); }
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
() => new JsonlDB("foo", { autoCompress: { sizeFactorMinimumSize: -1, }, })
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
() => { expect( () => new JsonlDB("foo", { autoCompress: { intervalMs: 9, }, }), ).toThrowError("intervalMs"); }
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
() => new JsonlDB("foo", { autoCompress: { intervalMs: 9, }, })
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
() => { expect( () => new JsonlDB("foo", { autoCompress: { intervalMinChanges: 0, }, }), ).toThrowError("intervalMinChanges"); }
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
() => new JsonlDB("foo", { autoCompress: { intervalMinChanges: 0, }, })
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
() => { it("intervalMs < 0", () => { expect( () => new JsonlDB("foo", { throttleFS: { intervalMs: -1, }, }), ).toThrowError("intervalMs"); }); it("maxBufferedCommands < 0", () => { expect( () => new JsonlDB("foo", { throttleFS: { in...
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
() => { expect( () => new JsonlDB("foo", { throttleFS: { intervalMs: -1, }, }), ).toThrowError("intervalMs"); }
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
() => new JsonlDB("foo", { throttleFS: { intervalMs: -1, }, })
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
() => { expect( () => new JsonlDB("foo", { throttleFS: { intervalMs: 0, maxBufferedCommands: -1, }, }), ).toThrowError("maxBufferedCommands"); }
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
() => new JsonlDB("foo", { throttleFS: { intervalMs: 0, maxBufferedCommands: -1, }, })
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
() => { let testFS: TestFS; let testFSRoot: string; beforeEach(async () => { testFS = new TestFS(); testFSRoot = await testFS.getRoot(); await testFS.create({ yes: // Final newline omitted on purpose '{"k":"key1","v":1}\n{"k":"key2","v":"2"}\n{"k":"key1"}', emptyLines: '\n{"k":"k...
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
async () => { testFS = new TestFS(); testFSRoot = await testFS.getRoot(); await testFS.create({ yes: // Final newline omitted on purpose '{"k":"key1","v":1}\n{"k":"key2","v":"2"}\n{"k":"key1"}', emptyLines: '\n{"k":"key1","v":1}\n\n\n{"k":"key2","v":"2"}\n\n', broken: `{"k":"key1",...
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
async () => { await testFS.remove(); }
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
async () => { const db = new JsonlDB(path.join(testFSRoot, "yes")); await db.open(); expect(db.isOpen).toBeTrue(); await db.close(); }
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
async () => { const db = new JsonlDB(path.join(testFSRoot, "no")); await db.open(); await db.close(); }
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
async () => { const db = new JsonlDB( path.join(testFSRoot, "this/path/does/not/exist"), ); await db.open(); await db.close(); }
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
async () => { const lockfileDirectory = path.join( testFSRoot, "this/path/does/not/exist/either", ); const db = new JsonlDB(path.join(testFSRoot, "lockfile"), { lockfileDirectory, }); await db.open(); await db.close(); await expect(fs.pathExists(lockfileDirectory)).resolves.toBeTrue()...
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
async () => { const db = new JsonlDB(path.join(testFSRoot, "yes")); await db.open(); await db.close(); }
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
async () => { const db1 = new JsonlDB(path.join(testFSRoot, "yes")); await db1.open(); const db2 = new JsonlDB(path.join(testFSRoot, "yes")); try { await db2.open(); throw new Error("it did not throw"); } catch (e: any) { expect(e.message).toMatch(/Failed to lock/i); } await db1.clos...
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
async () => { const db = new JsonlDB(path.join(testFSRoot, "yes")); await db.open(); expect(db.size).toBe(1); expect(db.has("key1")).toBeFalse(); expect(db.has("key2")).toBeTrue(); expect(db.get("key2")).toBe("2"); const spy = jest.fn(); db.forEach(spy); expect(spy).toBeCalledTimes(1); ...
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
async () => { const db = new JsonlDB(path.join(testFSRoot, "emptyLines")); await db.open(); expect(db.has("key1")).toBeTrue(); expect(db.get("key1")).toBe(1); expect(db.has("key2")).toBeTrue(); expect(db.get("key2")).toBe("2"); await db.close(); }
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
async () => { const db = new JsonlDB(path.join(testFSRoot, "broken")); try { await db.open(); throw new Error("it did not throw"); } catch (e: any) { expect(e.message).toMatch(/invalid data/i); expect(e.message).toMatch("line 2"); } }
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
async () => { const db = new JsonlDB(path.join(testFSRoot, "broken2")); try { await db.open(); throw new Error("it did not throw"); } catch (e: any) { expect(e.message).toMatch(/invalid data/i); expect(e.message).toMatch("line 2"); } }
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
async () => { const db = new JsonlDB(path.join(testFSRoot, "broken3")); try { await db.open(); throw new Error("it did not throw"); } catch (e: any) { expect(e.message).toMatch(/invalid data/i); expect(e.message).toMatch("line 1"); } }
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
async () => { const db = new JsonlDB(path.join(testFSRoot, "broken"), { ignoreReadErrors: true, }); await expect(db.open()).toResolve(); await db.close(); }
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
async () => { const db = new JsonlDB(path.join(testFSRoot, "broken2"), { ignoreReadErrors: true, }); await expect(db.open()).toResolve(); await db.close(); }
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
async () => { const reviver = jest.fn().mockReturnValue("eeee"); const db = new JsonlDB(path.join(testFSRoot, "reviver"), { reviver, }); await db.open(); expect(reviver).toBeCalledTimes(2); expect(reviver).toBeCalledWith("key2", "2"); expect(reviver).toBeCalledWith("key1", true); db.forEac...
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
(v) => { expect(v).toBe("eeee"); }
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
() => { const testFilename = "clear.jsonl"; let testFilenameFull: string; let db: JsonlDB; let testFS: TestFS; let testFSRoot: string; beforeEach(async () => { testFS = new TestFS(); testFSRoot = await testFS.getRoot(); testFilenameFull = path.join(testFSRoot, testFilename); await testFS.creat...
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
async () => { testFS = new TestFS(); testFSRoot = await testFS.getRoot(); testFilenameFull = path.join(testFSRoot, testFilename); await testFS.create({ [testFilename]: '{"k":"key1","v":1}\n{"k":"key2","v":"2"}\n{"k":"key1"}\n', }); db = new JsonlDB(testFilenameFull); await db.open(); }
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
async () => { await db.close(); expect(() => db.clear()).toThrowError("not open"); }
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
() => db.clear()
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
async () => { db.clear(); expect(db.size).toBe(0); expect(db.has("key1")).toBeFalse(); expect(db.has("key2")).toBeFalse(); // Force the stream to be flushed await db.close(); await expect(fs.stat(testFilenameFull)).resolves.toMatchObject({ size: 0, }); }
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
() => { const testFilename = "delete.jsonl"; let testFilenameFull: string; let db: JsonlDB; let testFS: TestFS; let testFSRoot: string; beforeEach(async () => { testFS = new TestFS(); testFSRoot = await testFS.getRoot(); testFilenameFull = path.join(testFSRoot, testFilename); await testFS.crea...
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
async () => { testFS = new TestFS(); testFSRoot = await testFS.getRoot(); testFilenameFull = path.join(testFSRoot, testFilename); await testFS.create({ [testFilename]: '{"k":"key1","v":1}\n{"k":"key2","v":"2"}\n', }); db = new JsonlDB(testFilenameFull); await db.open(); }
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
async () => { await db.close(); expect(() => db.delete("key1")).toThrowError("not open"); }
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
() => db.delete("key1")
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
async () => { expect(db.delete("key2")).toBeTrue(); expect(db.size).toBe(1); expect(db.has("key1")).toBeTrue(); expect(db.has("key2")).toBeFalse(); // Force the stream to be flushed await db.close(); await expect( fs.readFile(testFilenameFull, "utf8"), ).resolves.toEndWith(`{"k":"key2"}\n...
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
async () => { expect(db.delete("key2")).toBeTrue(); expect(db.delete("key1")).toBeTrue(); expect(db.size).toBe(0); expect(db.has("key1")).toBeFalse(); expect(db.has("key2")).toBeFalse(); // Force the stream to be flushed await db.close(); await expect( fs.readFile(testFilenameFull, "utf8"...
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
async () => { expect(db.delete("key2")).toBeTrue(); expect(db.delete("key2")).toBeFalse(); // Force the stream to be flushed await db.close(); await expect(fs.readFile(testFilenameFull, "utf8")).resolves.toBe( `{"k":"key1","v":1}\n{"k":"key2","v":"2"}\n{"k":"key2"}\n`, ); }
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
() => { const testFilename = "set.jsonl"; let testFilenameFull: string; let db: JsonlDB; let testFS: TestFS; let testFSRoot: string; beforeEach(async () => { testFS = new TestFS(); testFSRoot = await testFS.getRoot(); testFilenameFull = path.join(testFSRoot, testFilename); await testFS.create(...
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
async () => { testFS = new TestFS(); testFSRoot = await testFS.getRoot(); testFilenameFull = path.join(testFSRoot, testFilename); await testFS.create(); db = new JsonlDB(testFilenameFull); await db.open(); }
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
async () => { await db.close(); expect(() => db.set("foo", 1)).toThrowError("not open"); }
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
() => db.set("foo", 1)
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
async () => { db.set("key", true); expect(db.size).toBe(1); expect(db.has("key")).toBeTrue(); // Force the stream to be flushed await db.close(); await expect(fs.readFile(testFilenameFull, "utf8")).resolves.toBe( `{"k":"key","v":true}\n`, ); }
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
async () => { db.set("key2", true); db.set("key1", 1000); db.set("key3", ""); // Force the stream to be flushed await db.close(); await expect(fs.readFile(testFilenameFull, "utf8")).resolves.toBe( `{"k":"key2","v":true}\n{"k":"key1","v":1000}\n{"k":"key3","v":""}\n`, ); }
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
() => { const testFilename = "import.jsonl"; let testFilenameFull: string; let jsonFilenameFull: string; let db: JsonlDB; let testFS: TestFS; let testFSRoot: string; beforeEach(async () => { testFS = new TestFS(); testFSRoot = await testFS.getRoot(); testFilenameFull = path.join(testFSRoot, tes...
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
async () => { testFS = new TestFS(); testFSRoot = await testFS.getRoot(); testFilenameFull = path.join(testFSRoot, testFilename); jsonFilenameFull = path.join(testFSRoot, "jsonFile"); await testFS.create({ [testFilename]: '{"k":"key1","v":1}\n{"k":"key2","v":"2"}\n', jsonFile: '{"key3": 1, "key4...
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
async () => { await db.close(); expect(() => db.importJson({})).toThrowError("not open"); await expect(db.importJson("")).toReject(); }
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
() => db.importJson({})
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
async () => { db.importJson({ foo: "bar", baz: "inga", "1": 1, }); // Force the stream to be flushed await db.close(); // The order changes because Object.entries reads the entries in a different order await expect(fs.readFile(testFilenameFull, "utf8")).resolves.toBe( `{"k":"key1","v...
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
async () => { await db.importJson(jsonFilenameFull); // Force the stream to be flushed await db.close(); // The order changes because Object.entries reads the entries in a different order await expect(fs.readFile(testFilenameFull, "utf8")).resolves.toBe( `{"k":"key1","v":1} {"k":"key2","v":"2"} {"k...
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript
ArrowFunction
() => { const testFilename = "export.jsonl"; let testFilenameFull: string; let jsonFilenameFull: string; let db: JsonlDB; let testFS: TestFS; let testFSRoot: string; beforeEach(async () => { testFS = new TestFS(); testFSRoot = await testFS.getRoot(); testFilenameFull = path.join(testFSRoot, tes...
AlCalzone/jsonl-db
src/lib/db.test.ts
TypeScript