diff --git a/types/mem-fs/index.d.ts b/types/mem-fs/index.d.ts new file mode 100644 index 0000000000..0cece1da38 --- /dev/null +++ b/types/mem-fs/index.d.ts @@ -0,0 +1,21 @@ +// Type definitions for mem-fs 1.1 +// Project: https://github.com/sboudrias/mem-fs +// Definitions by: My Food Bag +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +import { EventEmitter } from 'events'; +import { Transform } from 'stream'; +import * as File from 'vinyl'; + +export function create(...args: any[]): memFs.Store; + +export namespace memFs { + interface Store extends EventEmitter { + add: (file: File, content: string) => void; + each: (callback: (file: File, index: number) => void) => void; + get: (filepath: string) => File; + stream: () => Transform; + } +} diff --git a/types/mem-fs/mem-fs-tests.ts b/types/mem-fs/mem-fs-tests.ts new file mode 100644 index 0000000000..ada05c22c7 --- /dev/null +++ b/types/mem-fs/mem-fs-tests.ts @@ -0,0 +1,8 @@ +import * as fs from 'mem-fs'; + +const store = fs.create(); +const file = store.get('hello'); + +store.add(file, 'hahahahah'); + +store.each(file => console.dir(store.get(file.path))); diff --git a/types/mem-fs/tsconfig.json b/types/mem-fs/tsconfig.json new file mode 100644 index 0000000000..23cb94acb6 --- /dev/null +++ b/types/mem-fs/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "mem-fs-tests.ts" + ] +} diff --git a/types/mem-fs/tslint.json b/types/mem-fs/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/mem-fs/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +}