From 461a6b2fb8b2436561d1ea95fb3fbc391c7f45ca Mon Sep 17 00:00:00 2001 From: Christian Friedow Date: Mon, 6 Aug 2018 11:41:35 +0200 Subject: [PATCH] Added typings for tough-cookie-filestore --- types/tough-cookie-filestore/index.d.ts | 42 +++++++++++++++++++ .../tough-cookie-filestore-tests.ts | 3 ++ types/tough-cookie-filestore/tsconfig.json | 23 ++++++++++ types/tough-cookie-filestore/tslint.json | 1 + 4 files changed, 69 insertions(+) create mode 100644 types/tough-cookie-filestore/index.d.ts create mode 100644 types/tough-cookie-filestore/tough-cookie-filestore-tests.ts create mode 100644 types/tough-cookie-filestore/tsconfig.json create mode 100644 types/tough-cookie-filestore/tslint.json diff --git a/types/tough-cookie-filestore/index.d.ts b/types/tough-cookie-filestore/index.d.ts new file mode 100644 index 0000000000..1b0c68d820 --- /dev/null +++ b/types/tough-cookie-filestore/index.d.ts @@ -0,0 +1,42 @@ +// Type definitions for tough-cookie-filestore 0.0 +// Project: https://github.com/mitsuru/tough-cookie-filestore +// Definitions by: Christian Friedow +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export interface Cookie { + domain: string; + path: string; + key: string; +} + +export default class FileCookieStore { + idx: { + [domain: string]: { + [path: string]: { + [key: string]: Cookie, + }, + }, + }; + filePath: string; + synchronous: boolean; + + constructor(filePath: string); + + inspect(): string; + + findCookie(domain: string, path: string, key: string, cb: (whatever: null, cookie: Cookie | null | undefined) => void): void; + + findCookies(domain: string, path: string, cb: (whatever: null, cookies: Cookie[]) => void): void; + + putCookie(cookie: Cookie, path: string, key: string, cb: (whatever: null) => void): void; + + updateCookie(oldCookie: Cookie, newCookie: Cookie, cb: (whatever: null) => void): void; + + removeCookie(domain: string, path: string, key: string, cb: (whatever: null) => void): void; + + removeCookies(domain: string, path: string, cb: (whatever: null) => void): void; + + saveToFile(filePath: string, data: any, cb: () => void): void; + + loadFromFile(filePath: string, cb: (data: any) => void): void; +} diff --git a/types/tough-cookie-filestore/tough-cookie-filestore-tests.ts b/types/tough-cookie-filestore/tough-cookie-filestore-tests.ts new file mode 100644 index 0000000000..7ac696ba21 --- /dev/null +++ b/types/tough-cookie-filestore/tough-cookie-filestore-tests.ts @@ -0,0 +1,3 @@ +import FileCookieStore from 'tough-cookie-filestore'; + +const cookiestore = new FileCookieStore('cookies.json'); diff --git a/types/tough-cookie-filestore/tsconfig.json b/types/tough-cookie-filestore/tsconfig.json new file mode 100644 index 0000000000..a00ed9cfa4 --- /dev/null +++ b/types/tough-cookie-filestore/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "tough-cookie-filestore-tests.ts" + ] +} diff --git a/types/tough-cookie-filestore/tslint.json b/types/tough-cookie-filestore/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/tough-cookie-filestore/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }