Merge pull request #2052 from vvakame/add-glob

added glob/glob.d.ts
This commit is contained in:
Masahiro Wakame
2014-04-18 08:56:03 +09:00
5 changed files with 155 additions and 0 deletions
+2
View File
@@ -100,6 +100,7 @@ List of Definitions
* [Gamepad](http://www.w3.org/TR/gamepad/) (by [Kon](http://phyzkit.net/))
* [Giraffe](https://github.com/barc/backbone.giraffe) (by [Matt McCray](https://github.com/darthapo))
* [glDatePicker](http://glad.github.com/glDatePicker/) (by [Dániel Tar](https://github.com/qcz))
* [Glob](https://github.com/isaacs/node-glob) (by [vvakame](https://github.com/vvakame))
* [GoJS](http://gojs.net/) (by [Barbara Duckworth](https://github.com/barbara42))
* [Greasemonkey](http://www.greasespot.net/) (by [Kota Saito](https://github.com/kotas))
* [GreenSock Animation Platform (GSAP)](http://www.greensock.com/get-started-js/) (by [Robert S.](https://github.com/codeBelt))
@@ -211,6 +212,7 @@ List of Definitions
* [mCustomScrollbar](https://github.com/malihu/malihu-custom-scrollbar-plugin) (by [Sarah Williams](https://github.com/flurg))
* [Meteor](https://www.meteor.com) (by [Dave Allen](https://github.com/fullflavedave))
* [Microsoft Live Connect](http://msdn.microsoft.com/en-us/library/live/hh243643.aspx) (by [John Vilk](https://github.com/jvilk))
* [Minimatch](https://github.com/isaacs/minimatch) (by [vvakame](https://github.com/vvakame))
* [minimist](https://github.com/substack/minimist) (by [Bart van der Schoor](https://github.com/Bartvds))
* [mixto](https://github.com/atom/mixto) (by [vvakame](https://github.com/vvakame))
* [Modernizr](http://modernizr.com/) (by [Boris Yankov](https://github.com/borisyankov) and [Theodore Brown](https://github.com/theodorejb/))
+24
View File
@@ -0,0 +1,24 @@
/// <reference path="./glob.d.ts" />
import glob = require("glob");
var Glob = glob.Glob;
(()=> {
var pattern = "test/a/**/[cg]/../[cg]";
console.log(pattern);
var mg = new Glob(pattern, {mark: true, sync: true}, function (er, matches) {
console.log("matches", matches)
});
console.log("after")
})();
(()=> {
var pattern = "{./*/*,/*,/usr/local/*}";
console.log(pattern);
var mg = new Glob(pattern, {mark: true}, function (er, matches) {
console.log("matches", matches)
});
console.log("after")
})();
+70
View File
@@ -0,0 +1,70 @@
// Type definitions for Glob
// Project: https://github.com/isaacs/node-glob
// Definitions by: vvakame <https://github.com/vvakame/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../node/node.d.ts" />
/// <reference path="../minimatch/minimatch.d.ts" />
declare module "glob" {
import events = require("events");
import minimatch = require("minimatch");
function G(pattern:string, cb:(err:Error, matches:string[])=>void):void;
function G(pattern:string, options:G.IOptions, cb:(err:Error, matches:string[])=>void):void;
module G {
function sync(pattern:string, options?:IOptions):string[];
var Glob:IGlobStatic;
interface IOptions extends minimatch.IOptions {
sync?: boolean;
nomount?: boolean;
matchBase?:any;
noglobstar?:any;
strict?: boolean;
dot?:boolean;
mark?:boolean;
nounique?:boolean;
nonull?:boolean;
nosort?:boolean;
nocase?:boolean;
stat?:boolean;
debug?:boolean;
globDebug?:boolean;
silent?:boolean;
}
interface IGlobStatic extends events.EventEmitter {
new (pattern:string, cb?:(err:Error, matches:string[])=>void):IGlob;
new (pattern:string, options:any, cb?:(err:Error, matches:string[])=>void):IGlob;
}
interface IGlob {
EOF:any;
paused:boolean;
maxDepth:number;
maxLength:number;
cache:any;
statCache:any;
changedCwd:boolean;
cwd: string;
root: string;
error: any;
aborted: boolean;
minimatch: minimatch.IMinimatch;
matches:string[];
log(...args:any[]):void;
abort():void;
pause():void;
resume():void;
emitMatch(m:any):void;
}
}
export = G;
}
+13
View File
@@ -0,0 +1,13 @@
/// <reference path="./minimatch.d.ts" />
import mm = require("minimatch");
var pattern = "**/*.ts";
var options = {
debug: true
};
var m = new mm.Minimatch(pattern, options);
var r = m.makeRe();
var f = "test.ts";
mm.match(f, pattern, options);
+46
View File
@@ -0,0 +1,46 @@
// Type definitions for Minimatch
// Project: https://github.com/isaacs/minimatch
// Definitions by: vvakame <https://github.com/vvakame/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module "minimatch" {
function M(target:string, pattern:string, options?:M.IOptions):void;
module M {
function match(filename:string, pattern:string, options:IOptions):boolean;
var Minimatch:IMinimatchStatic;
interface IOptions {
debug?:boolean;
nobrace?:boolean;
noglobstar?:boolean;
dot?:boolean;
noext?:boolean;
nocase?:boolean;
nonull?:boolean;
matchBase?:boolean;
nocomment?:boolean;
nonegate?:boolean;
flipNegate?:boolean;
}
interface IMinimatchStatic {
new (pattern:string, options:IOptions):IMinimatch;
}
interface IMinimatch {
debug():void;
make():void;
parseNegate():void;
braceExpand(pattern:string, options:IOptions):void;
parse(pattern:string, isSub?:boolean):void;
makeRe():any; // regexp or boolean
match(file:string, pattern:string, options:IOptions):boolean;
matchOne(file:string, pattern:string, partial:any):boolean;
}
}
export = M;
}