From 0dcd0aec0b31a86ea4d6490952176c22039a2dce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Corbi=C3=A8re?= Date: Sat, 15 Aug 2015 11:17:00 +0200 Subject: [PATCH] Add type definitions for gulp-cached --- gulp-cached/gulp-cached-tests.ts | 21 +++++++++++++++++ gulp-cached/gulp-cached.d.ts | 39 ++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 gulp-cached/gulp-cached-tests.ts create mode 100644 gulp-cached/gulp-cached.d.ts diff --git a/gulp-cached/gulp-cached-tests.ts b/gulp-cached/gulp-cached-tests.ts new file mode 100644 index 0000000000..42a6697388 --- /dev/null +++ b/gulp-cached/gulp-cached-tests.ts @@ -0,0 +1,21 @@ +/// +/// + +import * as gulp from "gulp"; +import cached = require("gulp-cached"); + +// Usage +gulp.src("*.ts") + .pipe(cached("ts-cache")); + +gulp.src("*.ts") + .pipe(cached("ts-cache", {})); + +gulp.src("*.ts") + .pipe(cached("ts-cache", { optimizeMemory: true })); + +// Clearing the whole cache +cached.caches = {}; + +// Clearing a specific cache entry +delete cached.caches["ts-cache"]; diff --git a/gulp-cached/gulp-cached.d.ts b/gulp-cached/gulp-cached.d.ts new file mode 100644 index 0000000000..eeb03997c1 --- /dev/null +++ b/gulp-cached/gulp-cached.d.ts @@ -0,0 +1,39 @@ +// Type definitions for gulp-cached +// Project: https://github.com/wearefractal/gulp-cached +// Definitions by: Thomas Corbière +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "gulp-cached" +{ + interface ICacheStore + { + [name: string]: {}; + } + + interface IOptions + { + /** + * Uses md5 instead of storing the whole file contents. + * @default false + */ + optimizeMemory?: boolean; + } + + interface IGulpCached + { + /** + * Creates a new cache hash or uses an existing one. + */ + (name: string, options?: IOptions): NodeJS.ReadWriteStream; + + /** + * Cache store. + */ + caches: ICacheStore; + } + + const cached: IGulpCached; + export = cached; +}