+24
| sudo: false | ||
| language: node_js | ||
| node_js: | ||
| - "10" | ||
| cache: | ||
| directories: | ||
| - node_modules | ||
| before_script: | ||
| - npm run init | ||
| script: | ||
| - npm test | ||
| - npm audit | ||
| after_success: | ||
| - "cat coverage/lcov.info | ./node_modules/.bin/coveralls" | ||
| branches: | ||
| only: | ||
| - master |
| /** | ||
| * An example how to use webcheck | ||
| * @author Arne Schubert <atd.schubert@gmail.com> | ||
| */ | ||
| import * as url from "url"; | ||
| import { IResult, Webcheck } from "webcheck"; | ||
| import { CheerioPlugin } from "webcheck-cheerio"; | ||
| const webcheck = new Webcheck({ // Instantiate webcheck | ||
| concurrency: 1, | ||
| headers: { | ||
| "User-Agent": "Webcheck example crawler", | ||
| }, | ||
| }); | ||
| const cheerio = new CheerioPlugin(); | ||
| webcheck.addPlugin(cheerio); | ||
| cheerio.enable(); | ||
| /* | ||
| * Our own plugin | ||
| * | ||
| * It is much better to require a middleware as a module. | ||
| */ | ||
| const username = "atd-schubert"; | ||
| webcheck.on("result", (result: IResult) => { | ||
| const arr: string[] = []; | ||
| if (result.url.indexOf("https://github.com/" + username) === 0) { | ||
| if (!result.test) { | ||
| if (result.response.statusCode !== 200) { | ||
| // tslint:disable-next-line:no-console | ||
| return console.error("User does not exists!"); | ||
| } | ||
| if (typeof result.getCheerio === "function") { | ||
| result.getCheerio((err: Error | null, $: any) => { | ||
| if (err) { | ||
| // tslint:disable-next-line:no-console | ||
| return console.error(err); | ||
| } | ||
| $(".repo-list-item").each((i: number, elem: any) => { | ||
| const proof = {}; | ||
| webcheck.crawl({ | ||
| proof, | ||
| test: "license", | ||
| title: $(elem).find("h3").text().trim(), | ||
| url: url.resolve(result.url, $(elem).find("h3 a").attr("href")) + "/blob/master/LICENSE", | ||
| }); | ||
| webcheck.crawl({ | ||
| proof, | ||
| test: "readme", | ||
| title: $(elem).find("h3").text().trim(), | ||
| url: url.resolve(result.url, $(elem).find("h3 a").attr("href")) + "/blob/master/README.md", | ||
| }); | ||
| }); | ||
| }); | ||
| } | ||
| } else { | ||
| if (result.response.statusCode === 200) { | ||
| result.proof[result.test] = true; | ||
| } else { | ||
| result.proof[result.test] = false; | ||
| } | ||
| if (result.proof.hasOwnProperty("license") && result.proof.hasOwnProperty("readme")) { | ||
| arr.push("Repository " + result.title + " has"); | ||
| if (result.proof.license) { | ||
| arr.push("a license"); | ||
| } else { | ||
| arr.push("no license"); | ||
| } | ||
| arr.push("and"); | ||
| if (result.proof.readme) { | ||
| arr.push("a readme"); | ||
| } else { | ||
| arr.push("no readme"); | ||
| } | ||
| /* tslint:disable:no-console */ | ||
| console.log(arr.join(" ") + "."); | ||
| } | ||
| } | ||
| } | ||
| }); | ||
| webcheck.crawl({ | ||
| url: "https://github.com/" + username + "?tab=repositories", | ||
| }); | ||
| // Have fun |
+2
| export * from "./plugin"; | ||
| export * from "./webcheck"; |
| {"version":3,"file":"plugin.js","sourceRoot":"","sources":["plugin.ts"],"names":[],"mappings":";;AAcA;IAAA;QAEc,OAAE,GAAwB,EAAE,CAAC;QAC7B,SAAI,GAAwB,EAAE,CAAC;IAwD7C,CAAC;IApDU,uBAAM,GAAb;QAAc,cAAc;aAAd,UAAc,EAAd,qBAAc,EAAd,IAAc;YAAd,yBAAc;;QACxB,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YACd,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;SACxE;QAED,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;QACvC,KAAK,IAAM,IAAI,IAAI,IAAI,CAAC,EAAE,EAAE;YACxB,IAAI,IAAI,CAAC,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE;gBAC9B,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;aACvC;SACJ;QACD,KAAK,IAAM,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE;YAC1B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M,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC;SACvF;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IACM,yBAAQ,GAAf,UAAgB,MAAiB;QAC7B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;QACzC,OAAO,IAAI,CAAC;IAChB,CAAC;IACL,aAAC;AAAD,CAAC,AA3DD,IA2DC;AA3DqB,wBAAM"} |
+74
| import { IEmitterDictionary, IMiddleware, IWebcheck } from "./webcheck"; | ||
| export interface IPlugin { | ||
| enable(): this; | ||
| disable(): this; | ||
| register(handle: IWebcheck): this; | ||
| // protected handle?: IWebcheck; | ||
| // protected on?: IEmitterDictionary; | ||
| // protected once?: IEmitterDictionary; | ||
| // protected middleware?: IMiddleware; | ||
| // protected init?: Function; | ||
| } | ||
| export abstract class Plugin implements IPlugin { | ||
| protected handle?: IWebcheck; | ||
| protected on?: IEmitterDictionary = {}; | ||
| protected once?: IEmitterDictionary = {}; | ||
| protected middleware?: IMiddleware; | ||
| protected init?: () => void; | ||
| public enable(...args: any[]): this { | ||
| if (!this.handle) { | ||
| throw new Error("You have to register the plugin in Webcheck first"); | ||
| } | ||
| this.handle.emit("enablePlugin", this); | ||
| for (const hash in this.on) { | ||
| if (this.on.hasOwnProperty(hash)) { | ||
| this.handle.on(hash, this.on[hash]); | ||
| } | ||
| } | ||
| for (const hash in this.once) { | ||
| if (this.once.hasOwnProperty(hash)) { | ||
| this.handle.once(hash, this.once[hash]); | ||
| } | ||
| } | ||
| if (this.middleware) { | ||
| this.handle.middlewares.push(this.middleware); | ||
| } | ||
| if (typeof this.init === "function") { | ||
| this.init.apply(this, args as any); | ||
| } | ||
| return this; | ||
| } | ||
| public disable(): this { | ||
| if (!this.handle) { | ||
| throw new Error("You have to register the plugin in Webcheck first"); | ||
| } | ||
| this.handle.emit("disablePlugin", this); | ||
| for (const hash in this.on) { | ||
| if (this.on.hasOwnProperty(hash)) { | ||
| this.handle.removeListener(hash, this.on[hash]); | ||
| } | ||
| } | ||
| for (const hash in this.once) { | ||
| if (this.once.hasOwnProperty(hash)) { | ||
| this.handle.removeListener(hash, this.once[hash]); | ||
| } | ||
| } | ||
| if (this.middleware) { | ||
| this.handle.middlewares.splice(this.handle.middlewares.indexOf(this.middleware), 1); | ||
| } | ||
| return this; | ||
| } | ||
| public register(handle: IWebcheck): this { | ||
| this.handle = handle; | ||
| this.handle.emit("registerPlugin", this); | ||
| return this; | ||
| } | ||
| } |
+143
| "use strict"; | ||
| /** | ||
| * Webcheck core module | ||
| * @author Arne Schubert <atd.schubert@gmail.com> | ||
| * @module webcheck | ||
| */ | ||
| var __extends = (this && this.__extends) || (function () { | ||
| var extendStatics = function (d, b) { | ||
| extendStatics = Object.setPrototypeOf || | ||
| ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
| function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
| return extendStatics(d, b); | ||
| }; | ||
| return function (d, b) { | ||
| extendStatics(d, b); | ||
| function __() { this.constructor = d; } | ||
| d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
| }; | ||
| })(); | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var async_1 = require("async"); | ||
| var events_1 = require("events"); | ||
| var request = require("request"); | ||
| var pkg = require("./package.json"); | ||
| var Webcheck = /** @class */ (function (_super) { | ||
| __extends(Webcheck, _super); | ||
| function Webcheck(opts) { | ||
| if (opts === void 0) { opts = {}; } | ||
| var _this = _super.call(this) || this; | ||
| _this.concurrency = Webcheck.concurrency; | ||
| _this.middlewares = []; | ||
| _this.request = Webcheck.request; | ||
| _this.headers = Webcheck.headers; | ||
| _this.concurrency = opts.concurrency || Webcheck.concurrency; | ||
| _this.headers = opts.headers || Webcheck.headers; | ||
| /** | ||
| * Task runner for queue (async.queue) | ||
| * @private | ||
| * @fires Webcheck#request | ||
| */ | ||
| var taskRunner = function (task, callback) { | ||
| if (task.preventCrawl) { | ||
| return callback(); | ||
| } | ||
| /** | ||
| * @event Webcheck#request | ||
| * @type {ICrawlOptions} | ||
| */ | ||
| _this.emit("request", task); | ||
| if (task.preventCrawl) { | ||
| return callback(); | ||
| } | ||
| var req = _this.request(task) | ||
| .on("response", function (response) { | ||
| var done = false; | ||
| _this.emit("response", response); | ||
| var result = { | ||
| done: function (err) { | ||
| if (!done) { | ||
| done = true; | ||
| return callback(err); | ||
| } | ||
| _this.emit("warn", "done already triggered"); | ||
| }, | ||
| request: req, | ||
| response: response, | ||
| settings: task, | ||
| url: task.url, | ||
| }; | ||
| async_1.default.applyEachSeries(_this.middlewares, result, function (err) { | ||
| if (err) { | ||
| return callback(err); | ||
| } | ||
| delete result.done; | ||
| _this.emit("result", result); | ||
| if (!done) { | ||
| return callback(); | ||
| } | ||
| }); | ||
| }) | ||
| .on("error", function (err) { | ||
| return callback(err); | ||
| }); | ||
| _this.emit("requesting", req); | ||
| }; | ||
| _this.queue = async_1.default.queue(taskRunner, _this.concurrency); | ||
| _this.queue.drain = function () { return _this.emit("drain"); }; | ||
| return _this; | ||
| } | ||
| Webcheck.prototype.crawl = function (opts, cb) { | ||
| var _this = this; | ||
| if (cb === void 0) { cb = function () { }; } | ||
| if (typeof opts.url !== "string") { | ||
| throw new Error("No url specified!"); | ||
| } | ||
| opts.headers = opts.headers || this.headers; | ||
| opts.preventCrawl = false; | ||
| /** | ||
| * @event Webcheck#crawl | ||
| * @type {ICrawlOptions} | ||
| */ | ||
| this.emit("crawl", opts); | ||
| var caller = function () { | ||
| /** | ||
| * @event Webcheck#queue | ||
| * @type {ICrawlOptions} | ||
| */ | ||
| _this.emit("queue", opts); | ||
| if (opts.preventCrawl) { | ||
| return cb(); | ||
| } | ||
| if (opts.immediately) { | ||
| return _this.queue.unshift(opts, cb); | ||
| } | ||
| /** | ||
| * @callback Webcheck~queueCallback | ||
| * @param {null|error} error - Throws error if there was one | ||
| */ | ||
| _this.queue.push(opts, cb); | ||
| }; | ||
| if (typeof opts.wait === "number") { | ||
| this.emit("wait", opts); | ||
| setTimeout(caller, opts.wait); | ||
| } | ||
| else { | ||
| caller(); | ||
| } | ||
| return this; | ||
| }; | ||
| Webcheck.prototype.addPlugin = function (plugin) { | ||
| this.emit("addPlugin", plugin); | ||
| plugin.register(this); | ||
| return this; | ||
| }; | ||
| Webcheck.concurrency = 5; | ||
| Webcheck.headers = { | ||
| "User-Agent": pkg.name + " " + pkg.version, | ||
| }; | ||
| Webcheck.request = request; | ||
| return Webcheck; | ||
| }(events_1.EventEmitter)); | ||
| exports.Webcheck = Webcheck; | ||
| //# sourceMappingURL=webcheck.js.map |
| {"version":3,"file":"webcheck.js","sourceRoot":"","sources":["webcheck.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;AAEH,+BAA0C;AAC1C,iCAAsC;AAEtC,iCAAmC;AACnC,oCAAuC;AAyCvC;IAA8B,4BAAY;IAWtC,kBAAY,IAA2B;QAA3B,qBAAA,EAAA,SAA2B;QAAvC,YACI,iBAAO,SA0DV;QAhEM,iBAAW,GAAW,QAAQ,CAAC,WAAW,CAAC;QAClC,iBAAW,GAAkB,EAAE,CAAC;QAEzC,aAAO,GAAqF,QAAQ,CAAC,OAAO,CAAC;QAC7G,aAAO,GAAa,QAAQ,CAAC,OAAO,CAAC;QAGxC,KAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,IAAI,QAAQ,CAAC,WAAW,CAAC;QAC5D,KAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,QAAQ,CAAC,OAAO,CAAC;QAEhD;;;;WAIG;QACH,IAAM,UAAU,GAAG,UAAC,IAAmB,EAAE,QAAmB;YACxD,IAAI,IAAI,CAAC,YAAY,EAAE;gBACnB,OAAO,QAAQ,EAAE,CAAC;aACrB;YACD;;;eAGG;YACH,KAA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MAAM,EAAE,CAAC;SACZ;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,4BAAS,GAAhB,UAAiB,MAAe;QAC5B,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;QAC/B,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACtB,OAAO,IAAI,CAAC;IAChB,CAAC;IAtHa,oBAAW,GAAW,CAAC,CAAC;IACxB,gBAAO,GAAa;QAC9B,YAAY,EAAE,GAAG,CAAC,IAAI,GAAG,GAAG,GAAG,GAAG,CAAC,OAAO;KAC7C,CAAC;IACY,gBAAO,GAAqF,OAAO,CAAC;IAmHtH,eAAC;CAAA,AAxHD,CAA8B,qBAAY,GAwHzC;AAxHY,4BAAQ"} |
+172
| /** | ||
| * Webcheck core module | ||
| * @author Arne Schubert <atd.schubert@gmail.com> | ||
| * @module webcheck | ||
| */ | ||
| import async, { AsyncQueue } from "async"; | ||
| import { EventEmitter } from "events"; | ||
| import { Response } from "request"; | ||
| import * as request from "request"; | ||
| import pkg = require("./package.json"); | ||
| import { IPlugin } from "./plugin"; | ||
| export type ICallback = (err?: Error | null) => void; | ||
| export type IMiddleware = (result: IResult, next: ICallback) => void; | ||
| export interface IHeaders { | ||
| [name: string]: string; | ||
| } | ||
| export interface IEmitterDictionary { | ||
| // response?: (response: Response) => void; | ||
| [event: string]: (...args: any[]) => void; | ||
| } | ||
| export interface IWebcheckOptions { | ||
| request?: request.RequestAPI<request.Request, request.CoreOptions, request.RequiredUriUrl>; | ||
| headers?: IHeaders; | ||
| concurrency?: number; | ||
| } | ||
| export interface ICrawlOptions { | ||
| url: string; | ||
| headers?: IHeaders; | ||
| preventCrawl?: boolean; | ||
| immediately?: boolean; | ||
| wait?: number; | ||
| parameters?: { [name: string]: any}; | ||
| } | ||
| export interface IResult { | ||
| url: string; | ||
| settings: ICrawlOptions; | ||
| request: request.Request; | ||
| response: Response; | ||
| done?: ICallback; | ||
| } | ||
| export interface IWebcheck extends EventEmitter { | ||
| middlewares: IMiddleware[]; | ||
| queue: AsyncQueue<any>; | ||
| request: request.RequestAPI<request.Request, request.CoreOptions, request.RequiredUriUrl>; | ||
| headers: IHeaders; | ||
| addPlugin(plugin: IPlugin): this; | ||
| crawl(options: ICrawlOptions, callback?: ICallback): this; | ||
| } | ||
| export class Webcheck extends EventEmitter implements IWebcheck { | ||
| public static concurrency: number = 5; | ||
| public static headers: IHeaders = { | ||
| "User-Agent": pkg.name + " " + pkg.version, | ||
| }; | ||
| public static request: request.RequestAPI<request.Request, request.CoreOptions, request.RequiredUriUrl> = request; | ||
| public concurrency: number = Webcheck.concurrency; | ||
| public readonly middlewares: IMiddleware[] = []; | ||
| public queue: AsyncQueue<ICrawlOptions>; | ||
| public request: request.RequestAPI<request.Request, request.CoreOptions, request.RequiredUriUrl> = Webcheck.request; | ||
| public headers: IHeaders = Webcheck.headers; | ||
| constructor(opts: IWebcheckOptions = {}) { | ||
| super(); | ||
| this.concurrency = opts.concurrency || Webcheck.concurrency; | ||
| this.headers = opts.headers || Webcheck.headers; | ||
| /** | ||
| * Task runner for queue (async.queue) | ||
| * @private | ||
| * @fires Webcheck#request | ||
| */ | ||
| const taskRunner = (task: ICrawlOptions, callback: ICallback) => { | ||
| if (task.preventCrawl) { | ||
| return callback(); | ||
| } | ||
| /** | ||
| * @event Webcheck#request | ||
| * @type {ICrawlOptions} | ||
| */ | ||
| this.emit("request", task); | ||
| if (task.preventCrawl) { | ||
| return callback(); | ||
| } | ||
| const req = this.request(task) | ||
| .on("response", (response) => { | ||
| let done: boolean = false; | ||
| this.emit("response", response); | ||
| const result: IResult = { | ||
| done: (err?: Error | null) => { | ||
| if (!done) { | ||
| done = true; | ||
| return callback(err); | ||
| } | ||
| this.emit("warn", "done already triggered"); | ||
| }, | ||
| request: req, | ||
| response, | ||
| settings: task, | ||
| url: task.url, | ||
| }; | ||
| async.applyEachSeries(this.middlewares, result, (err?: Error) => { | ||
| if (err) { | ||
| return callback(err); | ||
| } | ||
| delete result.done; | ||
| this.emit("result", result); | ||
| if (!done) { | ||
| return callback(); | ||
| } | ||
| }); | ||
| }) | ||
| .on("error", (err: Error) => { | ||
| return callback(err); | ||
| }); | ||
| this.emit("requesting", req); | ||
| }; | ||
| this.queue = async.queue(taskRunner, this.concurrency); | ||
| this.queue.drain = () => this.emit("drain"); | ||
| } | ||
| public crawl(opts: ICrawlOptions, cb: ICallback = () => { /* do nothing */ }): this { | ||
| if (typeof opts.url !== "string") { | ||
| throw new Error("No url specified!"); | ||
| } | ||
| opts.headers = opts.headers || this.headers; | ||
| opts.preventCrawl = false; | ||
| /** | ||
| * @event Webcheck#crawl | ||
| * @type {ICrawlOptions} | ||
| */ | ||
| this.emit("crawl", opts); | ||
| const caller = () => { | ||
| /** | ||
| * @event Webcheck#queue | ||
| * @type {ICrawlOptions} | ||
| */ | ||
| this.emit("queue", opts); | ||
| if (opts.preventCrawl) { | ||
| return cb(); | ||
| } | ||
| if (opts.immediately) { | ||
| return this.queue.unshift(opts, cb); | ||
| } | ||
| /** | ||
| * @callback Webcheck~queueCallback | ||
| * @param {null|error} error - Throws error if there was one | ||
| */ | ||
| this.queue.push(opts, cb); | ||
| }; | ||
| if (typeof opts.wait === "number") { | ||
| this.emit("wait", opts); | ||
| setTimeout(caller, opts.wait); | ||
| } else { | ||
| caller(); | ||
| } | ||
| return this; | ||
| } | ||
| public addPlugin(plugin: IPlugin) { | ||
| this.emit("addPlugin", plugin); | ||
| plugin.register(this); | ||
| return this; | ||
| } | ||
| } |
@@ -16,3 +16,3 @@ { | ||
| "dependencies": { | ||
| "webcheck": "^1.0.0", | ||
| "webcheck": "^2.0.0", | ||
| "webcheck-cheerio": "^0.0.1" | ||
@@ -19,0 +19,0 @@ }, |
+7
-166
| "use strict"; | ||
| var __extends = (this && this.__extends) || function (d, b) { | ||
| for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; | ||
| function __() { this.constructor = d; } | ||
| d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
| }; | ||
| var async = require('async'); | ||
| var request = require('request'); | ||
| var events_1 = require('events'); | ||
| var pkg = require('./package.json'); | ||
| var Webcheck = (function (_super) { | ||
| __extends(Webcheck, _super); | ||
| function Webcheck(opts) { | ||
| var _this = this; | ||
| _super.call(this); | ||
| this.middlewares = []; | ||
| opts = opts || {}; | ||
| this.request = opts.request || Webcheck.request; | ||
| this.headers = opts.headers || Webcheck.headers; | ||
| opts.concurrency = opts.concurrency || Webcheck.concurrency; | ||
| var taskRunner = function (task, callback) { | ||
| var req; | ||
| if (task.preventCrawl) { | ||
| return callback(); | ||
| } | ||
| _this.emit('request', task); | ||
| if (task.preventCrawl) { | ||
| return callback(); | ||
| } | ||
| req = _this.request(task) | ||
| .on('response', function (response) { | ||
| var result, done; | ||
| _this.emit('response', response); | ||
| result = { | ||
| url: task.url, | ||
| settings: task, | ||
| request: req, | ||
| response: response, | ||
| done: function (err) { | ||
| if (!done) { | ||
| done = true; | ||
| return callback(err); | ||
| } | ||
| console.warn('done already triggered'); | ||
| } | ||
| }; | ||
| async.applyEachSeries(_this.middlewares, result, function (err) { | ||
| if (err) { | ||
| return callback(err); | ||
| } | ||
| delete result.done; | ||
| _this.emit('result', result); | ||
| if (!done) { | ||
| return callback(); | ||
| } | ||
| }); | ||
| }) | ||
| .on('error', function (err) { | ||
| return callback(err); | ||
| }); | ||
| }; | ||
| this.queue = async.queue(taskRunner, opts.concurrency); | ||
| this.queue.drain = function () { | ||
| _this.emit('drain'); | ||
| }; | ||
| } | ||
| Webcheck.prototype.crawl = function (opts, cb) { | ||
| var _this = this; | ||
| if (cb === void 0) { cb = function () { }; } | ||
| var caller; | ||
| opts = opts || {}; | ||
| if (typeof opts.url !== 'string') { | ||
| throw new Error('No url specified!'); | ||
| } | ||
| opts.headers = opts.headers || this.headers; | ||
| opts.preventCrawl = false; | ||
| this.emit('crawl', opts); | ||
| caller = function () { | ||
| _this.emit('queue', opts); | ||
| if (opts.preventCrawl) { | ||
| return cb(); | ||
| } | ||
| if (opts.immediately) { | ||
| return _this.queue.unshift(opts, cb); | ||
| } | ||
| _this.queue.push(opts, cb); | ||
| }; | ||
| if (typeof opts.wait === 'number') { | ||
| this.emit('wait', opts); | ||
| setTimeout(caller, opts.wait); | ||
| } | ||
| else { | ||
| caller(); | ||
| } | ||
| return this; | ||
| }; | ||
| Webcheck.prototype.addPlugin = function (plugin) { | ||
| this.emit('addPlugin', plugin); | ||
| plugin.register(this); | ||
| return this; | ||
| }; | ||
| Webcheck.concurrency = 5; | ||
| Webcheck.headers = { | ||
| 'User-Agent': pkg.name + ' ' + pkg.version | ||
| }; | ||
| Webcheck.request = request; | ||
| return Webcheck; | ||
| }(events_1.EventEmitter)); | ||
| exports.Webcheck = Webcheck; | ||
| var Plugin = (function () { | ||
| function Plugin() { | ||
| this.on = {}; | ||
| this.once = {}; | ||
| } | ||
| Plugin.prototype.enable = function () { | ||
| var hash; | ||
| this.handle.emit('enablePlugin', this); | ||
| for (hash in this.on) { | ||
| if (this.on.hasOwnProperty(hash)) { | ||
| this.handle.on(hash, this.on[hash]); | ||
| } | ||
| } | ||
| for (hash in this.once) { | ||
| if (this.once.hasOwnProperty(hash)) { | ||
| this.handle.once(hash, this.once[hash]); | ||
| } | ||
| } | ||
| if (this.middleware) { | ||
| this.handle.middlewares.push(this.middleware); | ||
| } | ||
| if (typeof this.init === 'function') { | ||
| this.init.apply(this, arguments); | ||
| } | ||
| return this; | ||
| }; | ||
| Plugin.prototype.disable = function () { | ||
| var hash; | ||
| this.handle.emit('disablePlugin', this); | ||
| for (hash in this.on) { | ||
| if (this.on.hasOwnProperty(hash)) { | ||
| this.handle.removeListener(hash, this.on[hash]); | ||
| } | ||
| } | ||
| for (hash in this.once) { | ||
| if (this.once.hasOwnProperty(hash)) { | ||
| this.handle.removeListener(hash, this.once[hash]); | ||
| } | ||
| } | ||
| if (this.middleware) { | ||
| this.handle.middlewares.splice(this.handle.middlewares.indexOf(this.middleware), 1); | ||
| } | ||
| return this; | ||
| }; | ||
| Plugin.prototype.register = function (handle) { | ||
| this.handle = handle; | ||
| this.handle.emit('registerPlugin', this); | ||
| return this; | ||
| }; | ||
| return Plugin; | ||
| }()); | ||
| exports.Plugin = Plugin; | ||
| //# sourceMappingURL=index.js.map | ||
| // Fallback to version 1.0.0 | ||
| module.exports = exports.Webcheck; | ||
| module.exports.Webcheck = exports.Webcheck; | ||
| module.exports.Plugin = exports.Plugin; | ||
| function __export(m) { | ||
| for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
| } | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| __export(require("./plugin")); | ||
| __export(require("./webcheck")); | ||
| //# sourceMappingURL=index.js.map |
+1
-1
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;;AAOA,IAAY,KAAK,WAAM,OAAO,CAAC,CAAA;AAE/B,IAAY,OAAO,WAAM,SAAS,CAAC,CAAA;AACnC,uBAA6B,QAAQ,CAAC,CAAA;AAEtC,IAAY,GAAG,WAAM,gBAAgB,CAAC,CAAA;AAmFtC;IAA8B,4BAAY;IAwCtC,kBAAY,IAAsB;QAxCtC,iBAgMC;QAvJO,iBAAO,CAAC;QAlBL,gBAAW,GAAkB,EAAE,CAAC;QAmBnC,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;QAClB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,QAAQ,CAAC,OAAO,CAAC;QAChD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,QAAQ,CAAC,OAAO,CAAC;QAEhD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,IAAI,QAAQ,CAAC,WAAW,CAAC;QAU5D,IAAI,UAAU,GAAgB,UAAC,IAAmB,EAAE,QAAmB;YACnE,IAAI,GAAoB,CAAC;YAEzB,EAAE,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC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AC,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;gBACjC,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;YACtD,CAAC;QACL,CAAC;QACD,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;YAClB,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC;QACxF,CAAC;QAED,MAAM,CAAC,IAAI,CAAC;IAChB,CAAC;IAOM,yBAAQ,GAAf,UAAgB,MAAgB;QAC5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;QACzC,MAAM,CAAC,IAAI,CAAC;IAChB,CAAC;IACL,aAAC;AAAD,CAAC,AA1FD,IA0FC;AA1FY,cAAM,SA0FlB,CAAA"} | ||
| {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;AAAA,8BAAyB;AACzB,gCAA2B"} |
+16
-6
| { | ||
| "name": "webcheck", | ||
| "version": "1.1.1", | ||
| "version": "2.0.0", | ||
| "description": "A module to analyse websites for SEO, validation and code-quality", | ||
| "main": "index.js", | ||
| "scripts": { | ||
| "test": "mocha" | ||
| "transpile": "tsc", | ||
| "lint": "tslint -p .", | ||
| "test": "npm run lint && npm run transpile && istanbul cover _mocha -- -- test/*.js" | ||
| }, | ||
@@ -30,9 +32,17 @@ "repository": { | ||
| "dependencies": { | ||
| "async": "^1.5.2", | ||
| "request": "^2.58.0" | ||
| "@types/async": "^2.0.50", | ||
| "@types/node": "^10.12.18", | ||
| "@types/request": "^2.48.1", | ||
| "async": "^2.6.1", | ||
| "request": "^2.88.0" | ||
| }, | ||
| "devDependencies": { | ||
| "mocha": "^2.2.5", | ||
| "typescript": "^1.8.10" | ||
| "@types/mocha": "^5.2.5", | ||
| "chai": "^4.2.0", | ||
| "coveralls": "^3.0.2", | ||
| "istanbul": "^0.4.5", | ||
| "mocha": "^5.2.0", | ||
| "tslint": "^5.12.0", | ||
| "typescript": "^3.2.2" | ||
| } | ||
| } |
+63
-1
@@ -1,1 +0,63 @@ | ||
| module.exports = require('./index').Plugin; | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var Plugin = /** @class */ (function () { | ||
| function Plugin() { | ||
| this.on = {}; | ||
| this.once = {}; | ||
| } | ||
| Plugin.prototype.enable = function () { | ||
| var args = []; | ||
| for (var _i = 0; _i < arguments.length; _i++) { | ||
| args[_i] = arguments[_i]; | ||
| } | ||
| if (!this.handle) { | ||
| throw new Error("You have to register the plugin in Webcheck first"); | ||
| } | ||
| this.handle.emit("enablePlugin", this); | ||
| for (var hash in this.on) { | ||
| if (this.on.hasOwnProperty(hash)) { | ||
| this.handle.on(hash, this.on[hash]); | ||
| } | ||
| } | ||
| for (var hash in this.once) { | ||
| if (this.once.hasOwnProperty(hash)) { | ||
| this.handle.once(hash, this.once[hash]); | ||
| } | ||
| } | ||
| if (this.middleware) { | ||
| this.handle.middlewares.push(this.middleware); | ||
| } | ||
| if (typeof this.init === "function") { | ||
| this.init.apply(this, args); | ||
| } | ||
| return this; | ||
| }; | ||
| Plugin.prototype.disable = function () { | ||
| if (!this.handle) { | ||
| throw new Error("You have to register the plugin in Webcheck first"); | ||
| } | ||
| this.handle.emit("disablePlugin", this); | ||
| for (var hash in this.on) { | ||
| if (this.on.hasOwnProperty(hash)) { | ||
| this.handle.removeListener(hash, this.on[hash]); | ||
| } | ||
| } | ||
| for (var hash in this.once) { | ||
| if (this.once.hasOwnProperty(hash)) { | ||
| this.handle.removeListener(hash, this.once[hash]); | ||
| } | ||
| } | ||
| if (this.middleware) { | ||
| this.handle.middlewares.splice(this.handle.middlewares.indexOf(this.middleware), 1); | ||
| } | ||
| return this; | ||
| }; | ||
| Plugin.prototype.register = function (handle) { | ||
| this.handle = handle; | ||
| this.handle.emit("registerPlugin", this); | ||
| return this; | ||
| }; | ||
| return Plugin; | ||
| }()); | ||
| exports.Plugin = Plugin; | ||
| //# sourceMappingURL=plugin.js.map |
+26
-43
@@ -22,3 +22,3 @@ ## Introduction | ||
| ```js | ||
| var Webcheck = require('webcheck').Webcheck; | ||
| var { Webcheck } = require('webcheck'); | ||
| var AnyPlugin = require('webcheck-any-plugin'); | ||
@@ -42,9 +42,6 @@ | ||
| ## Concept of this module | ||
| Since version 1.0.0 webcheck uses streams instead of callbacks. It is | ||
| not compatible to older versions! | ||
| Since version 1.0.0 webcheck uses streams instead of callbacks. It is not compatible to older versions! | ||
| Webcheck is small featured. You should extend your functionality with | ||
| plugins. Take a look at the | ||
| Webcheck is small featured. You should extend your functionality with plugins. Take a look at the | ||
| [list of plugins](https://github.com/atd-schubert/node-webcheck/blob/master/PLUGINS.md). | ||
@@ -54,4 +51,3 @@ | ||
| For further information about plugins in webcheck take a look at the | ||
| [plugin readme](PLUGINS.md). | ||
| For further information about plugins in webcheck take a look at the [plugin readme](PLUGINS.md). | ||
@@ -81,7 +77,5 @@ ## Webcheck Class | ||
| This is a instance of [request](https://github.com/request/request). | ||
| Webcheck use this as function to request a resource. If you want another | ||
| request function, for example to request resources from TOR with | ||
| [torrequest](https://github.com/atd-schubert/torrequest), you are able | ||
| *to swap this property. | ||
| This is a instance of [request](https://github.com/request/request). Webcheck use this as function to request a | ||
| resource. If you want another request function, for example to request resources from TOR with | ||
| [torrequest](https://github.com/atd-schubert/torrequest), you are able to swap this property. | ||
@@ -94,44 +88,33 @@ #### webcheck.middlewares | ||
| All events emitted on the webcheck object.` | ||
| All events emitted on the webcheck object. | ||
| ```js | ||
| var webcheck = new Webcheck(); | ||
| webcheck.on(event, fn); | ||
| ``` | ||
| var webcheck = new Webcheck(); | ||
| webcheck.on(event, fn); | ||
| Webcheck emits the following events: | ||
| * `crawl` (request-settings): Emitted directly after calling crawl method. | ||
| * `request` (request-settings): Emitted before request is executed. | ||
| * `result` ({url, request-settings, request, response}): Emitted after middleware are executed and document is fetched | ||
| * `drain`: Emitted on draining of queue | ||
| * `queue` (request-settings): Emitted before adding to queue | ||
| * `addPlugin` (plugin): Emitted when a plugin is added | ||
| * `enablePlugin` (plugin): Emitted when a added plugin gets enabled | ||
| * `disablePlugin` (plugin): Emitted when a added plugin gets disabled | ||
| - `crawl` (request-settings): Emitted directly after calling crawl method. | ||
| - `request` (request-settings): Emitted before request is executed. | ||
| - `result` ({url, request-settings, request, response}): Emitted after middleware are executed and document is fetched | ||
| - `drain`: Emitted on draining of queue | ||
| - `queue` (request-settings): Emitted before adding to queue | ||
| - `addPlugin` (plugin): Emitted when a plugin is added | ||
| - `enablePlugin` (plugin): Emitted when a added plugin gets enabled | ||
| - `disablePlugin` (plugin): Emitted when a added plugin gets disabled | ||
| ## Changes on version 1.1.0 and 2.0.0 | ||
| From now on Webcheck is a class within the module webcheck. | ||
| ## Changes on version 1.1.0 | ||
| Webcheck is (from now on) developed with | ||
| [TypeScript](http://www.typescriptlang.org/). In the older versions we | ||
| had exported Webcheck as module and not as class from a module. | ||
| That means Webcheck **must now** required over: | ||
| ```js | ||
| var Webcheck = require('webcheck'); | ||
| ```ts | ||
| import { Webcheck, Plugin } from 'webcheck'; | ||
| ``` | ||
| From now on Webcheck is a class within the module `webcheck`. | ||
| or in the classical way: | ||
| That means no changes for Plugin, but Webcheck should now required over: | ||
| ```js | ||
| var Webcheck = require('webcheck').Webcheck; | ||
| ``` | ||
| ``` | ||
| *For compatibility reasons it is still possible to require Webcheck the | ||
| old way... But the TypeScripts Typings would be incorrect!* | ||
| This way you should import this module within ES6 or TypeScript: | ||
| ```typescript | ||
| import { Webcheck, Plugin } from 'webcheck'; | ||
| ``` | ||
| It is no longer possible to require Webcheck the old way! That could also cause incompatibilities with older Plugins. |
+120
-94
| "use strict"; | ||
| var index_1 = require('../index'); | ||
| describe('Webcheck', function () { | ||
| describe('Basic functions and events', function () { | ||
| var webcheck, request, response, settings; | ||
| settings = { | ||
| url: 'http://unimportant.for/test' | ||
| var __extends = (this && this.__extends) || (function () { | ||
| var extendStatics = function (d, b) { | ||
| extendStatics = Object.setPrototypeOf || | ||
| ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
| function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
| return extendStatics(d, b); | ||
| }; | ||
| return function (d, b) { | ||
| extendStatics(d, b); | ||
| function __() { this.constructor = d; } | ||
| d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
| }; | ||
| })(); | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var __1 = require("../"); | ||
| var Plugin = /** @class */ (function (_super) { | ||
| __extends(Plugin, _super); | ||
| function Plugin() { | ||
| return _super !== null && _super.apply(this, arguments) || this; | ||
| } | ||
| return Plugin; | ||
| }(__1.Plugin)); // it is a abstract class... | ||
| describe("Webcheck", function () { | ||
| describe("statics", function () { | ||
| it("should have a request function", function () { | ||
| if (typeof __1.Webcheck.request !== "function") { | ||
| throw new Error("There is no request available"); | ||
| } | ||
| }); | ||
| }); | ||
| describe("Basic functions and events", function () { | ||
| // var webcheck, request, response, settings; | ||
| var webcheck = new __1.Webcheck(); | ||
| var settings = { | ||
| url: "http://unimportant.for/test", | ||
| }; | ||
| response = {}; | ||
| var response = {}; | ||
| before(function () { | ||
| var spoofedEventHandler = { | ||
| on: function (name, fn) { | ||
| if (name === 'response') { | ||
| if (name === "response") { | ||
| setTimeout(function () { | ||
@@ -22,15 +51,13 @@ fn(response); | ||
| return spoofedEventHandler; | ||
| } | ||
| }, | ||
| }; | ||
| webcheck = new index_1.Webcheck({}); | ||
| request = function () { | ||
| webcheck.request = (function () { | ||
| return spoofedEventHandler; | ||
| }; | ||
| webcheck.request = request; | ||
| }); | ||
| }); | ||
| it('should fire queue event', function (done) { | ||
| it("should fire queue event", function (done) { | ||
| var triggered; | ||
| webcheck.once('queue', function (s) { | ||
| webcheck.once("queue", function (s) { | ||
| if (s !== settings) { | ||
| return done(new Error('Wrong settings passed')); | ||
| return done(new Error("Wrong settings passed")); | ||
| } | ||
@@ -46,11 +73,11 @@ triggered = true; | ||
| } | ||
| return done(new Error('Event not triggered')); | ||
| return done(new Error("Event not triggered")); | ||
| }); | ||
| }); | ||
| it('should prevent request in event settings object', function (done) { | ||
| webcheck.once('queue', function (settings) { | ||
| settings.preventCrawl = true; | ||
| it("should prevent request in event settings object", function (done) { | ||
| webcheck.once("queue", function (receivedSettings) { | ||
| receivedSettings.preventCrawl = true; | ||
| }); | ||
| webcheck.once('request', function () { | ||
| done(new Error('Request started')); | ||
| webcheck.once("request", function () { | ||
| done(new Error("Request started")); | ||
| }); | ||
@@ -65,14 +92,15 @@ webcheck.crawl(settings, function (err) { | ||
| }); | ||
| it('should fire wait and queue event if waiting', function (done) { | ||
| var triggeredQueue, triggeredWait; | ||
| it("should fire wait and queue event if waiting", function (done) { | ||
| var triggeredQueue; | ||
| var triggeredWait; | ||
| settings.wait = 1; | ||
| webcheck.once('queue', function (s) { | ||
| webcheck.once("queue", function (s) { | ||
| if (s !== settings) { | ||
| return done(new Error('Wrong settings passed')); | ||
| return done(new Error("Wrong settings passed")); | ||
| } | ||
| triggeredQueue = true; | ||
| }); | ||
| webcheck.once('wait', function (s) { | ||
| webcheck.once("wait", function (s) { | ||
| if (s !== settings) { | ||
| return done(new Error('Wrong settings passed')); | ||
| return done(new Error("Wrong settings passed")); | ||
| } | ||
@@ -89,10 +117,10 @@ triggeredWait = true; | ||
| } | ||
| return done(new Error('Event not triggered')); | ||
| return done(new Error("Event not triggered")); | ||
| }); | ||
| }); | ||
| it('should fire response event and should replace replace function', function (done) { | ||
| it("should fire response event and should replace replace function", function (done) { | ||
| var triggered; | ||
| webcheck.once('response', function (r) { | ||
| webcheck.once("response", function (r) { | ||
| if (r !== response) { | ||
| return done(new Error('Wrong response returned')); | ||
| return done(new Error("Wrong response returned")); | ||
| } | ||
@@ -108,10 +136,10 @@ triggered = true; | ||
| } | ||
| return done(new Error('Event not triggered')); | ||
| return done(new Error("Event not triggered")); | ||
| }); | ||
| }); | ||
| it('should fire result event', function (done) { | ||
| it("should fire result event", function (done) { | ||
| var triggered; | ||
| webcheck.once('result', function (r) { | ||
| webcheck.once("result", function (r) { | ||
| if (r.response !== response) { | ||
| return done(new Error('Wrong response returned')); | ||
| return done(new Error("Wrong response returned")); | ||
| } | ||
@@ -127,13 +155,13 @@ triggered = true; | ||
| } | ||
| return done(new Error('Event not triggered')); | ||
| return done(new Error("Event not triggered")); | ||
| }); | ||
| }); | ||
| }); | ||
| describe('Middleware', function () { | ||
| var webcheck, request, response; | ||
| response = {}; | ||
| describe("Middleware", function () { | ||
| var webcheck = new __1.Webcheck(); | ||
| var response = {}; | ||
| before(function () { | ||
| var spoofedEventHandler = { | ||
| on: function (name, fn) { | ||
| if (name === 'response') { | ||
| if (name === "response") { | ||
| setTimeout(function () { | ||
@@ -147,22 +175,20 @@ fn(response); | ||
| return spoofedEventHandler; | ||
| } | ||
| }, | ||
| }; | ||
| webcheck = new index_1.Webcheck({}); | ||
| request = function () { | ||
| webcheck.request = (function () { | ||
| return spoofedEventHandler; | ||
| }; | ||
| webcheck.request = request; | ||
| }); | ||
| }); | ||
| it('should not fire result if middleware prevent execution', function (done) { | ||
| it("should not fire result if middleware prevent execution", function (done) { | ||
| webcheck.middlewares.push(function (result) { | ||
| result.done(); | ||
| }); | ||
| webcheck.once('result', function () { | ||
| return done(new Error('Event triggered')); | ||
| webcheck.once("result", function () { | ||
| return done(new Error("Event triggered")); | ||
| }); | ||
| webcheck.crawl({ | ||
| url: 'http://unimportant.url' | ||
| url: "http://unimportant.url", | ||
| }, function (err) { | ||
| webcheck.middlewares = []; | ||
| webcheck.removeAllListeners('result'); | ||
| webcheck.middlewares.length = 0; | ||
| webcheck.removeAllListeners("result"); | ||
| if (err) { | ||
@@ -174,3 +200,3 @@ return done(err); | ||
| }); | ||
| it('should fire result if middleware going next', function (done) { | ||
| it("should fire result if middleware going next", function (done) { | ||
| var triggered; | ||
@@ -180,9 +206,9 @@ webcheck.middlewares.push(function (result, next) { | ||
| }); | ||
| webcheck.once('result', function () { | ||
| webcheck.once("result", function () { | ||
| triggered = true; | ||
| }); | ||
| webcheck.crawl({ | ||
| url: 'http://unimportant.url' | ||
| url: "http://unimportant.url", | ||
| }, function (err) { | ||
| webcheck.middlewares = []; | ||
| webcheck.middlewares.length = 0; | ||
| if (err) { | ||
@@ -194,7 +220,7 @@ return done(err); | ||
| } | ||
| return done(new Error('Event not triggered')); | ||
| return done(new Error("Event not triggered")); | ||
| }); | ||
| }); | ||
| it('should stop middleware execution if middleware nexts error', function (done) { | ||
| var error = new Error('test'); | ||
| it("should stop middleware execution if middleware nexts error", function (done) { | ||
| var error = new Error("test"); | ||
| webcheck.middlewares.push(function (result, next) { | ||
@@ -204,5 +230,5 @@ next(error); | ||
| webcheck.crawl({ | ||
| url: 'http://unimportant.url' | ||
| url: "http://unimportant.url", | ||
| }, function (err) { | ||
| webcheck.middlewares = []; | ||
| webcheck.middlewares.length = 0; | ||
| if (err === error) { | ||
@@ -214,7 +240,8 @@ return done(); | ||
| } | ||
| return done(new Error('Error was not send')); | ||
| return done(new Error("Error was not send")); | ||
| }); | ||
| }); | ||
| it('should concat middleware in the right order', function (done) { | ||
| var triggeredFirst, triggeredSecond; | ||
| it("should concat middleware in the right order", function (done) { | ||
| var triggeredFirst; | ||
| var triggeredSecond; | ||
| webcheck.middlewares.push(function (result, next) { | ||
@@ -226,3 +253,3 @@ triggeredFirst = true; | ||
| if (!triggeredFirst) { | ||
| return next(new Error('first middleware was not executed')); | ||
| return next(new Error("first middleware was not executed")); | ||
| } | ||
@@ -233,3 +260,3 @@ triggeredSecond = true; | ||
| webcheck.crawl({ | ||
| url: 'http://unimportant.url' | ||
| url: "http://unimportant.url", | ||
| }, function (err) { | ||
@@ -242,16 +269,13 @@ if (err) { | ||
| } | ||
| return done(new Error('Nothing was triggered')); | ||
| return done(new Error("Nothing was triggered")); | ||
| }); | ||
| }); | ||
| }); | ||
| describe('Plugin', function () { | ||
| var webcheck; | ||
| before(function () { | ||
| webcheck = new index_1.Webcheck({}); | ||
| }); | ||
| it('should register plugin and trigger addPlugin event', function (done) { | ||
| var plugin = new index_1.Plugin(); | ||
| webcheck.once('addPlugin', function (p) { | ||
| describe("Plugin", function () { | ||
| var webcheck = new __1.Webcheck(); | ||
| it("should register plugin and trigger addPlugin event", function (done) { | ||
| var plugin = new Plugin(); | ||
| webcheck.once("addPlugin", function (p) { | ||
| if (p !== plugin) { | ||
| return done(new Error('Wrong')); | ||
| return done(new Error("Wrong")); | ||
| } | ||
@@ -262,7 +286,7 @@ return done(); | ||
| }); | ||
| it('should trigger enablePlugin event', function (done) { | ||
| var plugin = new index_1.Plugin(); | ||
| webcheck.once('enablePlugin', function (p) { | ||
| it("should trigger enablePlugin event", function (done) { | ||
| var plugin = new Plugin(); | ||
| webcheck.once("enablePlugin", function (p) { | ||
| if (p !== plugin) { | ||
| return done(new Error('Wrong plugin send in event')); | ||
| return done(new Error("Wrong plugin send in event")); | ||
| } | ||
@@ -274,7 +298,7 @@ return done(); | ||
| }); | ||
| it('should trigger disablePlugin event', function (done) { | ||
| var plugin = new index_1.Plugin(); | ||
| webcheck.once('disablePlugin', function (p) { | ||
| it("should trigger disablePlugin event", function (done) { | ||
| var plugin = new Plugin(); | ||
| webcheck.once("disablePlugin", function (p) { | ||
| if (p !== plugin) { | ||
| return done(new Error('Wrong plugin send in event')); | ||
| return done(new Error("Wrong plugin send in event")); | ||
| } | ||
@@ -287,7 +311,8 @@ return done(); | ||
| }); | ||
| it('should add a event on enablePlugin', function (done) { | ||
| var test = {}, plugin = new index_1.Plugin(); | ||
| plugin.once['test'] = function (t) { | ||
| it("should add a event on enablePlugin", function (done) { | ||
| var test = {}; | ||
| var plugin = new Plugin(); | ||
| plugin.once.test = function (t) { | ||
| if (test !== t) { | ||
| return done(new Error('Wrong parameter send on call')); | ||
| return done(new Error("Wrong parameter send on call")); | ||
| } | ||
@@ -298,9 +323,10 @@ return done(); | ||
| plugin.enable(); | ||
| webcheck.emit('test', test); | ||
| webcheck.emit("test", test); | ||
| }); | ||
| it('should remove added event on disablePlugin', function (done) { | ||
| var test = {}, plugin = new index_1.Plugin(); | ||
| plugin.once['test'] = function (t) { | ||
| it("should remove added event on disablePlugin", function (done) { | ||
| var test = {}; | ||
| var plugin = new Plugin(); | ||
| plugin.once.test = function (t) { | ||
| if (test !== t) { | ||
| return done(new Error('Wrong parameter send on call')); | ||
| return done(new Error("Wrong parameter send on call")); | ||
| } | ||
@@ -312,3 +338,3 @@ return done(); | ||
| plugin.disable(); | ||
| webcheck.emit('test', test); | ||
| webcheck.emit("test", test); | ||
| return done(); | ||
@@ -315,0 +341,0 @@ }); |
+1
-1
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":[],"mappings":";AAMA,sBAAqD,UAAU,CAAC,CAAA;AAEhE,QAAQ,CAAC,UAAU,EAAE;IAIjB,QAAQ,CAAC,4BAA4B,EAAE;QACnC,IAAI,QAAkB,EAAE,OAAY,EAAE,QAAQ,EAAE,QAAQ,CAAC;QACzD,QAAQ,GAAG;YACP,GAAG,EAAE,6BAA6B;SACrC,CAAC;QACF,QAAQ,GAAG,EAAE,CAAC;QAEd,MAAM,CAAC;YACH,IAAI,mBAAmB,GAAQ;gBAC3B,EAAE,EAAE,UAAC,IAAI,EAAE,EAAE;oBACT,EAAE,CAAC,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC;wBACtB,UAAU,CAAC;4BACP,EAAE,CAAC,QAAQ,CAAC,CAAC;wBACjB,CAAC,EAAE,CAAC,CAAC,CAAC;oBACV,CAAC;oBACD,MAAM,CAAC,mBAAmB,CAAC;gB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E,CAAC;QAClB,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"} |
+131
-139
@@ -1,25 +0,27 @@ | ||
| /*jslint node:true*/ | ||
| import { ICrawlOptions, Plugin as OriginalPlugin, Webcheck } from "../"; | ||
| /*global describe, it, before, after, beforeEach, afterEach*/ | ||
| class Plugin extends OriginalPlugin {} // it is a abstract class... | ||
| /// <reference path="../typings/main.d.ts"/> | ||
| describe("Webcheck", () => { | ||
| import { Webcheck, Plugin, IResult, ICallback } from '../index'; | ||
| describe('Webcheck', (): void => { | ||
| describe('Basic functions and events', (): void => { | ||
| var webcheck: Webcheck, request: any, response, settings; | ||
| settings = { | ||
| url: 'http://unimportant.for/test' | ||
| describe("statics", () => { | ||
| it("should have a request function", () => { | ||
| if (typeof Webcheck.request !== "function") { | ||
| throw new Error("There is no request available"); | ||
| } | ||
| }); | ||
| }); | ||
| describe("Basic functions and events", () => { | ||
| // var webcheck, request, response, settings; | ||
| const webcheck = new Webcheck(); | ||
| const settings: ICrawlOptions = { | ||
| url: "http://unimportant.for/test", | ||
| }; | ||
| response = {}; | ||
| const response = {}; | ||
| before((): void => { | ||
| var spoofedEventHandler: any = { | ||
| on: (name, fn): void => { | ||
| if (name === 'response') { | ||
| setTimeout((): void => { | ||
| before(() => { | ||
| const spoofedEventHandler = { | ||
| on(name: string, fn: (arg: any) => void) { | ||
| if (name === "response") { | ||
| setTimeout(() => { | ||
| fn(response); | ||
@@ -30,21 +32,19 @@ }, 1); | ||
| }, | ||
| once: (): void => { | ||
| once() { | ||
| return spoofedEventHandler; | ||
| } | ||
| }, | ||
| }; | ||
| webcheck = new Webcheck({}); | ||
| request = function () { | ||
| webcheck.request = (() => { | ||
| return spoofedEventHandler; | ||
| }; | ||
| webcheck.request = request; | ||
| }) as any; | ||
| }); | ||
| it('should fire queue event', (done: MochaDone): void => { | ||
| var triggered: boolean; | ||
| webcheck.once('queue', function (s) { | ||
| it("should fire queue event", (done) => { | ||
| let triggered: boolean; | ||
| webcheck.once("queue", (s) => { | ||
| if (s !== settings) { | ||
| return done(new Error('Wrong settings passed')); | ||
| return done(new Error("Wrong settings passed")); | ||
| } | ||
| triggered = true; | ||
| }); | ||
| webcheck.crawl(settings, function (err) { | ||
| webcheck.crawl(settings, (err) => { | ||
| if (err) { | ||
@@ -56,13 +56,13 @@ return done(err); | ||
| } | ||
| return done(new Error('Event not triggered')); | ||
| return done(new Error("Event not triggered")); | ||
| }); | ||
| }); | ||
| it('should prevent request in event settings object', (done: MochaDone): void => { | ||
| webcheck.once('queue', function (settings) { | ||
| settings.preventCrawl = true; | ||
| it("should prevent request in event settings object", (done: Mocha.Done) => { | ||
| webcheck.once("queue", (receivedSettings: ICrawlOptions) => { | ||
| receivedSettings.preventCrawl = true; | ||
| }); | ||
| webcheck.once('request', (): void => { | ||
| done(new Error('Request started')); | ||
| webcheck.once("request", () => { | ||
| done(new Error("Request started")); | ||
| }); | ||
| webcheck.crawl(settings, (err): void => { | ||
| webcheck.crawl(settings, (err) => { | ||
| webcheck.removeAllListeners(); | ||
@@ -75,19 +75,20 @@ if (err) { | ||
| }); | ||
| it('should fire wait and queue event if waiting', (done: MochaDone): void => { | ||
| var triggeredQueue, | ||
| triggeredWait; | ||
| it("should fire wait and queue event if waiting", (done: Mocha.Done) => { | ||
| let triggeredQueue: boolean; | ||
| let triggeredWait: boolean; | ||
| settings.wait = 1; | ||
| webcheck.once('queue', (s): void => { | ||
| webcheck.once("queue", (s: ICrawlOptions) => { | ||
| if (s !== settings) { | ||
| return done(new Error('Wrong settings passed')); | ||
| return done(new Error("Wrong settings passed")); | ||
| } | ||
| triggeredQueue = true; | ||
| }); | ||
| webcheck.once('wait', (s): void => { | ||
| webcheck.once("wait", (s: ICrawlOptions) => { | ||
| if (s !== settings) { | ||
| return done(new Error('Wrong settings passed')); | ||
| return done(new Error("Wrong settings passed")); | ||
| } | ||
| triggeredWait = true; | ||
| }); | ||
| webcheck.crawl(settings, (err): void => { | ||
| webcheck.crawl(settings, (err?: Error | null) => { | ||
| if (err) { | ||
@@ -101,14 +102,14 @@ return done(err); | ||
| } | ||
| return done(new Error('Event not triggered')); | ||
| return done(new Error("Event not triggered")); | ||
| }); | ||
| }); | ||
| it('should fire response event and should replace replace function', (done): void => { | ||
| var triggered; | ||
| webcheck.once('response', (r): void => { | ||
| it("should fire response event and should replace replace function", (done: Mocha.Done) => { | ||
| let triggered: boolean; | ||
| webcheck.once("response", (r) => { | ||
| if (r !== response) { | ||
| return done(new Error('Wrong response returned')); | ||
| return done(new Error("Wrong response returned")); | ||
| } | ||
| triggered = true; | ||
| }); | ||
| webcheck.crawl(settings, (err): void => { | ||
| webcheck.crawl(settings, (err) => { | ||
| if (err) { | ||
@@ -120,14 +121,14 @@ return done(err); | ||
| } | ||
| return done(new Error('Event not triggered')); | ||
| return done(new Error("Event not triggered")); | ||
| }); | ||
| }); | ||
| it('should fire result event', (done: MochaDone): void => { | ||
| var triggered; | ||
| webcheck.once('result', (r): void => { | ||
| it("should fire result event", (done) => { | ||
| let triggered: boolean; | ||
| webcheck.once("result", (r) => { | ||
| if (r.response !== response) { | ||
| return done(new Error('Wrong response returned')); | ||
| return done(new Error("Wrong response returned")); | ||
| } | ||
| triggered = true; | ||
| }); | ||
| webcheck.crawl(settings, (err: Error): void => { | ||
| webcheck.crawl(settings, (err) => { | ||
| if (err) { | ||
@@ -139,3 +140,3 @@ return done(err); | ||
| } | ||
| return done(new Error('Event not triggered')); | ||
| return done(new Error("Event not triggered")); | ||
| }); | ||
@@ -145,13 +146,10 @@ }); | ||
| describe('Middleware', (): void => { | ||
| var webcheck: Webcheck, | ||
| request: any, | ||
| response: any; | ||
| response = {}; | ||
| before((): void => { | ||
| var spoofedEventHandler = { | ||
| on: (name, fn): any => { | ||
| if (name === 'response') { | ||
| setTimeout((): void => { | ||
| describe("Middleware", () => { | ||
| const webcheck = new Webcheck(); | ||
| const response = {}; | ||
| before(() => { | ||
| const spoofedEventHandler = { | ||
| on(name: string, fn: (arg: any) => void) { | ||
| if (name === "response") { | ||
| setTimeout(() => { | ||
| fn(response); | ||
@@ -162,25 +160,23 @@ }, 1); | ||
| }, | ||
| once: (): any => { | ||
| once() { | ||
| return spoofedEventHandler; | ||
| } | ||
| }, | ||
| }; | ||
| webcheck = new Webcheck({}); | ||
| request = (): any => { | ||
| webcheck.request = (() => { | ||
| return spoofedEventHandler; | ||
| }; | ||
| webcheck.request = request; | ||
| }) as any; | ||
| }); | ||
| it('should not fire result if middleware prevent execution', (done: MochaDone): void => { | ||
| webcheck.middlewares.push((result: IResult): void => { | ||
| result.done(); | ||
| it("should not fire result if middleware prevent execution", (done: Mocha.Done) => { | ||
| webcheck.middlewares.push((result) => { | ||
| result.done!(); | ||
| }); | ||
| webcheck.once('result', (): void => { | ||
| return done(new Error('Event triggered')); | ||
| webcheck.once("result", () => { | ||
| return done(new Error("Event triggered")); | ||
| }); | ||
| webcheck.crawl({ | ||
| url: 'http://unimportant.url' | ||
| }, (err: Error): void => { | ||
| webcheck.middlewares = []; | ||
| webcheck.removeAllListeners('result'); | ||
| url: "http://unimportant.url", | ||
| }, (err?: Error | null) => { | ||
| webcheck.middlewares.length = 0; | ||
| webcheck.removeAllListeners("result"); | ||
| if (err) { | ||
@@ -192,14 +188,14 @@ return done(err); | ||
| }); | ||
| it('should fire result if middleware going next', (done: MochaDone): void => { | ||
| var triggered; | ||
| webcheck.middlewares.push((result: IResult, next: ICallback): void => { | ||
| it("should fire result if middleware going next", (done: Mocha.Done) => { | ||
| let triggered: boolean; | ||
| webcheck.middlewares.push((result, next) => { | ||
| next(); | ||
| }); | ||
| webcheck.once('result', (): void => { | ||
| webcheck.once("result", () => { | ||
| triggered = true; | ||
| }); | ||
| webcheck.crawl({ | ||
| url: 'http://unimportant.url' | ||
| }, (err: Error): void => { | ||
| webcheck.middlewares = []; | ||
| url: "http://unimportant.url", | ||
| }, (err?: Error | null) => { | ||
| webcheck.middlewares.length = 0; | ||
| if (err) { | ||
@@ -211,14 +207,14 @@ return done(err); | ||
| } | ||
| return done(new Error('Event not triggered')); | ||
| return done(new Error("Event not triggered")); | ||
| }); | ||
| }); | ||
| it('should stop middleware execution if middleware nexts error', (done: MochaDone): void => { | ||
| var error = new Error('test'); | ||
| webcheck.middlewares.push((result: IResult, next: ICallback): void => { | ||
| it("should stop middleware execution if middleware nexts error", (done) => { | ||
| const error = new Error("test"); | ||
| webcheck.middlewares.push((result, next) => { | ||
| next(error); | ||
| }); | ||
| webcheck.crawl({ | ||
| url: 'http://unimportant.url' | ||
| }, (err: Error): void => { | ||
| webcheck.middlewares = []; | ||
| url: "http://unimportant.url", | ||
| }, (err) => { | ||
| webcheck.middlewares.length = 0; | ||
| if (err === error) { | ||
@@ -230,16 +226,15 @@ return done(); | ||
| } | ||
| return done(new Error('Error was not send')); | ||
| return done(new Error("Error was not send")); | ||
| }); | ||
| }); | ||
| it('should concat middleware in the right order', (done: MochaDone): void => { | ||
| var triggeredFirst: boolean, | ||
| triggeredSecond: boolean; | ||
| webcheck.middlewares.push((result: IResult, next: ICallback): void => { | ||
| it("should concat middleware in the right order", (done) => { | ||
| let triggeredFirst: boolean; | ||
| let triggeredSecond: boolean; | ||
| webcheck.middlewares.push((result, next) => { | ||
| triggeredFirst = true; | ||
| next(); | ||
| }); | ||
| webcheck.middlewares.push((result: IResult, next): void => { | ||
| webcheck.middlewares.push((result, next) => { | ||
| if (!triggeredFirst) { | ||
| return next(new Error('first middleware was not executed')); | ||
| return next(new Error("first middleware was not executed")); | ||
| } | ||
@@ -250,4 +245,4 @@ triggeredSecond = true; | ||
| webcheck.crawl({ | ||
| url: 'http://unimportant.url' | ||
| }, (err: Error): void => { | ||
| url: "http://unimportant.url", | ||
| }, (err) => { | ||
| if (err) { | ||
@@ -259,3 +254,3 @@ return done(err); | ||
| } | ||
| return done(new Error('Nothing was triggered')); | ||
| return done(new Error("Nothing was triggered")); | ||
| }); | ||
@@ -265,14 +260,11 @@ }); | ||
| describe('Plugin', (): void => { | ||
| var webcheck: Webcheck; | ||
| before((): void => { | ||
| webcheck = new Webcheck({}); | ||
| }); | ||
| describe("Plugin", () => { | ||
| const webcheck = new Webcheck(); | ||
| it('should register plugin and trigger addPlugin event', (done: MochaDone): void => { | ||
| var plugin: Plugin = new Plugin(); | ||
| it("should register plugin and trigger addPlugin event", (done: Mocha.Done) => { | ||
| const plugin = new Plugin(); | ||
| webcheck.once('addPlugin', (p: Plugin): void => { | ||
| webcheck.once("addPlugin", (p) => { | ||
| if (p !== plugin) { | ||
| return done(new Error('Wrong')); | ||
| return done(new Error("Wrong")); | ||
| } | ||
@@ -284,8 +276,8 @@ return done(); | ||
| }); | ||
| it('should trigger enablePlugin event', (done: MochaDone): void => { | ||
| var plugin: Plugin = new Plugin(); | ||
| it("should trigger enablePlugin event", (done: Mocha.Done) => { | ||
| const plugin = new Plugin(); | ||
| webcheck.once('enablePlugin', (p: Plugin): void => { | ||
| webcheck.once("enablePlugin", (p) => { | ||
| if (p !== plugin) { | ||
| return done(new Error('Wrong plugin send in event')); | ||
| return done(new Error("Wrong plugin send in event")); | ||
| } | ||
@@ -298,8 +290,8 @@ return done(); | ||
| }); | ||
| it('should trigger disablePlugin event', (done: MochaDone): void => { | ||
| var plugin: Plugin = new Plugin(); | ||
| it("should trigger disablePlugin event", (done: Mocha.Done) => { | ||
| const plugin = new Plugin(); | ||
| webcheck.once('disablePlugin', (p: Plugin): void => { | ||
| webcheck.once("disablePlugin", (p) => { | ||
| if (p !== plugin) { | ||
| return done(new Error('Wrong plugin send in event')); | ||
| return done(new Error("Wrong plugin send in event")); | ||
| } | ||
@@ -313,9 +305,9 @@ return done(); | ||
| }); | ||
| it('should add a event on enablePlugin', (done: MochaDone): void => { | ||
| var test: any = {}, | ||
| plugin: Plugin = new Plugin(); | ||
| it("should add a event on enablePlugin", (done: Mocha.Done) => { | ||
| const test = {}; | ||
| const plugin = new Plugin(); | ||
| plugin.once['test'] = (t: any): void => { | ||
| (plugin as any).once.test = (t: any) => { | ||
| if (test !== t) { | ||
| return done(new Error('Wrong parameter send on call')); | ||
| return done(new Error("Wrong parameter send on call")); | ||
| } | ||
@@ -327,11 +319,11 @@ return done(); | ||
| plugin.enable(); | ||
| webcheck.emit('test', test); | ||
| webcheck.emit("test", test); | ||
| }); | ||
| it('should remove added event on disablePlugin', (done: MochaDone): void => { | ||
| var test = {}, | ||
| plugin: Plugin = new Plugin(); | ||
| it("should remove added event on disablePlugin", (done: Mocha.Done) => { | ||
| const test = {}; | ||
| const plugin = new Plugin(); | ||
| plugin.once['test'] = (t: any): void => { | ||
| (plugin as any).once.test = (t: any) => { | ||
| if (test !== t) { | ||
| return done(new Error('Wrong parameter send on call')); | ||
| return done(new Error("Wrong parameter send on call")); | ||
| } | ||
@@ -344,6 +336,6 @@ return done(); | ||
| plugin.disable(); | ||
| webcheck.emit('test', test); | ||
| webcheck.emit("test", test); | ||
| return done(); | ||
| }); | ||
| }); | ||
| }); | ||
| }); |
+13
-15
| { | ||
| "compilerOptions": { | ||
| "target": "es5", | ||
| "module": "commonjs", | ||
| "moduleResolution": "node", | ||
| "noImplicitAny": false, | ||
| "removeComments": true, | ||
| "preserveConstEnums": true, | ||
| "declaration": true, | ||
| "sourceMap": true, | ||
| "outDir": "." | ||
| }, | ||
| "exclude": [ | ||
| "node_modules", | ||
| "typings" | ||
| ] | ||
| "compilerOptions": { | ||
| "module": "commonjs", | ||
| "target": "es5", | ||
| "strict": true, | ||
| "sourceMap": true, | ||
| "resolveJsonModule": true, | ||
| "outDir": ".", | ||
| "allowSyntheticDefaultImports": true | ||
| }, | ||
| "exclude": [ | ||
| "node_modules", | ||
| "example" | ||
| ] | ||
| } |
+10
-134
| { | ||
| "rules": { | ||
| "align": [ | ||
| true, | ||
| "parameters", | ||
| "arguments", | ||
| "statements" | ||
| "defaultSeverity": "error", | ||
| "extends": [ | ||
| "tslint:recommended" | ||
| ], | ||
| "ban": false, | ||
| "class-name": true, | ||
| "comment-format": [ | ||
| true, | ||
| "check-space" | ||
| ], | ||
| "curly": true, | ||
| "eofline": true, | ||
| "forin": true, | ||
| "indent": [ | ||
| true, | ||
| "spaces" | ||
| ], | ||
| "interface-name": true, | ||
| "jsdoc-format": true, | ||
| "label-position": true, | ||
| "label-undefined": true, | ||
| "max-line-length": [ | ||
| true, | ||
| 140 | ||
| ], | ||
| "member-access": false, | ||
| "member-ordering": [ | ||
| true, | ||
| "public-before-private", | ||
| "static-before-instance", | ||
| "variables-before-functions" | ||
| ], | ||
| "no-any": false, | ||
| "no-arg": true, | ||
| "no-bitwise": true, | ||
| "no-conditional-assignment": true, | ||
| "no-consecutive-blank-lines": false, | ||
| "no-console": [ | ||
| true, | ||
| "debug", | ||
| "info", | ||
| "time", | ||
| "timeEnd", | ||
| "trace" | ||
| ], | ||
| "no-construct": true, | ||
| "no-constructor-vars": true, | ||
| "no-debugger": true, | ||
| "no-duplicate-key": true, | ||
| "no-duplicate-variable": true, | ||
| "no-empty": true, | ||
| "no-eval": true, | ||
| "no-inferrable-types": false, | ||
| "no-internal-module": false, | ||
| "no-null-keyword": true, | ||
| "no-require-imports": true, | ||
| "no-shadowed-variable": true, | ||
| "no-string-literal": true, | ||
| "no-switch-case-fall-through": true, | ||
| "no-trailing-whitespace": true, | ||
| "no-unreachable": true, | ||
| "no-unused-expression": true, | ||
| "no-unused-variable": true, | ||
| "no-use-before-declare": true, | ||
| "no-var-keyword": false, | ||
| "no-var-requires": false, | ||
| "object-literal-sort-keys": true, | ||
| "one-line": [ | ||
| true, | ||
| "check-open-brace", | ||
| "check-catch", | ||
| "check-else", | ||
| "check-whitespace" | ||
| ], | ||
| "quotemark": [ | ||
| true, | ||
| "single", | ||
| "avoid-escape" | ||
| ], | ||
| "radix": true, | ||
| "semicolon": true, | ||
| "switch-default": true, | ||
| "trailing-comma": [ | ||
| true, | ||
| { | ||
| "multiline": "never", | ||
| "singleline": "never" | ||
| } | ||
| ], | ||
| "triple-equals": [ | ||
| true, | ||
| "allow-null-check" | ||
| ], | ||
| "typedef": [ | ||
| true, | ||
| "call-signature", | ||
| "parameter", | ||
| "property-declaration", | ||
| "variable-declaration", | ||
| "member-variable-declaration" | ||
| ], | ||
| "typedef-whitespace": [ | ||
| true, | ||
| { | ||
| "call-signature": "nospace", | ||
| "index-signature": "nospace", | ||
| "parameter": "nospace", | ||
| "property-declaration": "nospace", | ||
| "variable-declaration": "nospace" | ||
| } | ||
| ], | ||
| "use-strict": [ | ||
| true, | ||
| "check-module", | ||
| "check-function" | ||
| ], | ||
| "variable-name": [ | ||
| true, | ||
| "check-format", | ||
| "allow-leading-underscore", | ||
| "ban-keywords" | ||
| ], | ||
| "whitespace": [ | ||
| true, | ||
| "check-branch", | ||
| "check-decl", | ||
| "check-operator", | ||
| "check-separator", | ||
| "check-type" | ||
| ] | ||
| } | ||
| } | ||
| "jsRules": {}, | ||
| "rules": {}, | ||
| "rulesDirectory": [], | ||
| "linterOptions": { | ||
| "exclude": ["*.json"] | ||
| } | ||
| } |
Sorry, the diff of this file is not supported yet
| /*jslint node:true*/ | ||
| /** | ||
| * An example how to use webcheck | ||
| * @author Arne Schubert <atd.schubert@gmail.com> | ||
| */ | ||
| 'use strict'; | ||
| var Webcheck = require('webcheck').Webcheck; | ||
| var CheerioPlugin = require('webcheck-cheerio'); | ||
| var webcheck = new Webcheck(); | ||
| var cheerio = new CheerioPlugin(); | ||
| webcheck.addPlugin(cheerio); | ||
| cheerio.enable(); | ||
| var url = require('url'); // <- We need this module to parse sub-urls | ||
| var webcheck = new Webcheck({ // Instantiate webcheck | ||
| headers: { | ||
| 'User-Agent': 'Webcheck example crawler' | ||
| }, | ||
| concurrency: 1 | ||
| }); | ||
| /* | ||
| * Our own plugin | ||
| * | ||
| * It is much better to require a middleware as a module. | ||
| */ | ||
| var username = 'atd-schubert'; | ||
| webcheck.on('result', function (result) { | ||
| var arr = []; | ||
| if (result.url.indexOf('https://github.com/' + username) === 0) { | ||
| if (!result.test) { | ||
| if (result.response.statusCode !== 200) { | ||
| return console.error('User does not exists!'); | ||
| } | ||
| if (typeof result.getCheerio === 'function') { | ||
| result.getCheerio(function (err, $) { | ||
| if (err) { | ||
| return console.error(err); | ||
| } | ||
| $('.repo-list-item').each(function (i, elem) { | ||
| var proof = {}; | ||
| webcheck.crawl({ | ||
| url: url.resolve(result.url, $(elem).find('h3 a').attr('href')) + '/blob/master/LICENSE', | ||
| title: $(elem).find('h3').text().trim(), | ||
| proof: proof, | ||
| test: 'license' | ||
| }); | ||
| webcheck.crawl({ | ||
| url: url.resolve(result.url, $(elem).find('h3 a').attr('href')) + '/blob/master/README.md', | ||
| title: $(elem).find('h3').text().trim(), | ||
| proof: proof, | ||
| test: 'readme' | ||
| }); | ||
| }); | ||
| }); | ||
| } | ||
| } else { | ||
| if (result.response.statusCode === 200) { | ||
| result.proof[result.test] = true; | ||
| } else { | ||
| result.proof[result.test] = false; | ||
| } | ||
| if (result.proof.hasOwnProperty('license') && result.proof.hasOwnProperty('readme')) { | ||
| arr.push('Repository ' + result.title + ' has'); | ||
| if (result.proof.license) { | ||
| arr.push('a license'); | ||
| } else { | ||
| arr.push('no license'); | ||
| } | ||
| arr.push('and'); | ||
| if (result.proof.readme) { | ||
| arr.push('a readme'); | ||
| } else { | ||
| arr.push('no readme'); | ||
| } | ||
| console.log(arr.join(' ') + '.'); | ||
| } | ||
| } | ||
| } | ||
| }); | ||
| webcheck.crawl({ | ||
| url: 'https://github.com/' + username + '?tab=repositories' | ||
| }); | ||
| // Have fun |
Sorry, the diff of this file is not supported yet
-76
| // [ts-npm-lint] disabled triple slash reference to 'typings/main.d.ts' | ||
| import * as http from 'http'; | ||
| import * as request from 'request'; | ||
| import { EventEmitter } from 'events'; | ||
| export interface ICallback { | ||
| (err?: Error): void; | ||
| } | ||
| export interface IMiddleware { | ||
| (result: IResult, next: ICallback): void; | ||
| } | ||
| export interface IHeaders { | ||
| [name: string]: string; | ||
| } | ||
| export interface IEmitterDictionary { | ||
| response?: (response) => void; | ||
| [event: string]: (...args) => void; | ||
| } | ||
| export interface IPlugin { | ||
| handle: Webcheck; | ||
| on: IEmitterDictionary; | ||
| once: IEmitterDictionary; | ||
| middleware?: IMiddleware; | ||
| init?: Function; | ||
| enable(): IPlugin; | ||
| disable(): IPlugin; | ||
| register(handle: IWebcheck): IPlugin; | ||
| } | ||
| export interface IWebcheckOptions { | ||
| request?: request.RequestAPI<request.Request, request.CoreOptions, request.RequiredUriUrl>; | ||
| headers?: IHeaders; | ||
| concurrency?: number; | ||
| } | ||
| export interface ICrawlOptions { | ||
| url: string; | ||
| headers?: IHeaders; | ||
| preventCrawl?: boolean; | ||
| immediately?: boolean; | ||
| wait?: number; | ||
| } | ||
| export interface IResult { | ||
| url: string; | ||
| settings: ICrawlOptions; | ||
| request: request.Request; | ||
| response: http.ClientResponse; | ||
| done?: ICallback; | ||
| } | ||
| export interface IWebcheck { | ||
| middlewares: IMiddleware[]; | ||
| queue: AsyncQueue<any>; | ||
| request: request.RequestAPI<request.Request, request.CoreOptions, request.RequiredUriUrl>; | ||
| headers: IHeaders; | ||
| addPlugin(plugin: Plugin): IWebcheck; | ||
| crawl(options: ICrawlOptions, callback: ICallback): IWebcheck; | ||
| } | ||
| export declare class Webcheck extends EventEmitter implements IWebcheck { | ||
| static concurrency: number; | ||
| static headers: IHeaders; | ||
| static request: request.RequestAPI<request.Request, request.CoreOptions, request.RequiredUriUrl>; | ||
| middlewares: IMiddleware[]; | ||
| queue: AsyncQueue<ICrawlOptions>; | ||
| request: request.RequestAPI<request.Request, request.CoreOptions, request.RequiredUriUrl>; | ||
| headers: IHeaders; | ||
| constructor(opts: IWebcheckOptions); | ||
| crawl(opts: ICrawlOptions, cb?: ICallback): this; | ||
| addPlugin(plugin: Plugin): Webcheck; | ||
| } | ||
| export declare class Plugin implements IPlugin { | ||
| handle: Webcheck; | ||
| on: IEmitterDictionary; | ||
| once: IEmitterDictionary; | ||
| middleware: IMiddleware; | ||
| init: Function; | ||
| enable(): Plugin; | ||
| disable(): Plugin; | ||
| register(handle: Webcheck): Plugin; | ||
| } |
| // [ts-npm-lint] disabled triple slash reference to '../typings/main.d.ts' |
-11
| { | ||
| "ambientDependencies": { | ||
| "async": "registry:dt/async#1.4.2+20160316155526", | ||
| "form-data": "registry:dt/form-data#0.0.0+20160316155526", | ||
| "node": "registry:dt/node#4.0.0+20160423143914", | ||
| "request": "registry:dt/request#0.0.0+20160316155526" | ||
| }, | ||
| "ambientDevDependencies": { | ||
| "mocha": "registry:dt/mocha#2.2.5+20160317120654" | ||
| } | ||
| } |
| /// <reference path="browser/ambient/async/index.d.ts" /> | ||
| /// <reference path="browser/ambient/form-data/index.d.ts" /> | ||
| /// <reference path="browser/ambient/mocha/index.d.ts" /> | ||
| /// <reference path="browser/ambient/node/index.d.ts" /> | ||
| /// <reference path="browser/ambient/request/index.d.ts" /> |
| // Generated by typings | ||
| // Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/56295f5058cac7ae458540423c50ac2dcf9fc711/async/async.d.ts | ||
| // Type definitions for Async 1.4.2 | ||
| // Project: https://github.com/caolan/async | ||
| // Definitions by: Boris Yankov <https://github.com/borisyankov/>, Arseniy Maximov <https://github.com/kern0>, Joe Herman <https://github.com/Penryn> | ||
| // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
| interface Dictionary<T> { [key: string]: T; } | ||
| interface ErrorCallback { (err?: Error): void; } | ||
| interface AsyncResultCallback<T> { (err: Error, result: T): void; } | ||
| interface AsyncResultArrayCallback<T> { (err: Error, results: T[]): void; } | ||
| interface AsyncResultObjectCallback<T> { (err: Error, results: Dictionary<T>): void; } | ||
| interface AsyncFunction<T> { (callback: (err?: Error, result?: T) => void): void; } | ||
| interface AsyncIterator<T> { (item: T, callback: ErrorCallback): void; } | ||
| interface AsyncForEachOfIterator<T> { (item: T, key: number, callback: ErrorCallback): void; } | ||
| interface AsyncResultIterator<T, R> { (item: T, callback: AsyncResultCallback<R>): void; } | ||
| interface AsyncMemoIterator<T, R> { (memo: R, item: T, callback: AsyncResultCallback<R>): void; } | ||
| interface AsyncBooleanIterator<T> { (item: T, callback: (truthValue: boolean) => void): void; } | ||
| interface AsyncWorker<T> { (task: T, callback: ErrorCallback): void; } | ||
| interface AsyncVoidFunction { (callback: ErrorCallback): void; } | ||
| interface AsyncQueue<T> { | ||
| length(): number; | ||
| started: boolean; | ||
| running(): number; | ||
| idle(): boolean; | ||
| concurrency: number; | ||
| push(task: T, callback?: ErrorCallback): void; | ||
| push(task: T[], callback?: ErrorCallback): void; | ||
| unshift(task: T, callback?: ErrorCallback): void; | ||
| unshift(task: T[], callback?: ErrorCallback): void; | ||
| saturated: () => any; | ||
| empty: () => any; | ||
| drain: () => any; | ||
| paused: boolean; | ||
| pause(): void | ||
| resume(): void; | ||
| kill(): void; | ||
| } | ||
| interface AsyncPriorityQueue<T> { | ||
| length(): number; | ||
| concurrency: number; | ||
| started: boolean; | ||
| paused: boolean; | ||
| push(task: T, priority: number, callback?: AsyncResultArrayCallback<T>): void; | ||
| push(task: T[], priority: number, callback?: AsyncResultArrayCallback<T>): void; | ||
| saturated: () => any; | ||
| empty: () => any; | ||
| drain: () => any; | ||
| running(): number; | ||
| idle(): boolean; | ||
| pause(): void; | ||
| resume(): void; | ||
| kill(): void; | ||
| } | ||
| interface AsyncCargo { | ||
| length(): number; | ||
| payload: number; | ||
| push(task: any, callback? : Function): void; | ||
| push(task: any[], callback? : Function): void; | ||
| saturated(): void; | ||
| empty(): void; | ||
| drain(): void; | ||
| idle(): boolean; | ||
| pause(): void; | ||
| resume(): void; | ||
| kill(): void; | ||
| } | ||
| interface Async { | ||
| // Collections | ||
| each<T>(arr: T[], iterator: AsyncIterator<T>, callback?: ErrorCallback): void; | ||
| eachSeries<T>(arr: T[], iterator: AsyncIterator<T>, callback?: ErrorCallback): void; | ||
| eachLimit<T>(arr: T[], limit: number, iterator: AsyncIterator<T>, callback?: ErrorCallback): void; | ||
| forEachOf(obj: any, iterator: (item: any, key: string|number, callback?: ErrorCallback) => void, callback: ErrorCallback): void; | ||
| forEachOf<T>(obj: T[], iterator: AsyncForEachOfIterator<T>, callback?: ErrorCallback): void; | ||
| forEachOfSeries(obj: any, iterator: (item: any, key: string|number, callback?: ErrorCallback) => void, callback: ErrorCallback): void; | ||
| forEachOfSeries<T>(obj: T[], iterator: AsyncForEachOfIterator<T>, callback?: ErrorCallback): void; | ||
| forEachOfLimit(obj: any, limit: number, iterator: (item: any, key: string|number, callback?: ErrorCallback) => void, callback: ErrorCallback): void; | ||
| forEachOfLimit<T>(obj: T[], limit: number, iterator: AsyncForEachOfIterator<T>, callback?: ErrorCallback): void; | ||
| map<T, R>(arr: T[], iterator: AsyncResultIterator<T, R>, callback?: AsyncResultArrayCallback<R>): any; | ||
| mapSeries<T, R>(arr: T[], iterator: AsyncResultIterator<T, R>, callback?: AsyncResultArrayCallback<R>): any; | ||
| mapLimit<T, R>(arr: T[], limit: number, iterator: AsyncResultIterator<T, R>, callback?: AsyncResultArrayCallback<R>): any; | ||
| filter<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: (results: T[]) => any): any; | ||
| select<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: (results: T[]) => any): any; | ||
| filterSeries<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: (results: T[]) => any): any; | ||
| selectSeries<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: (results: T[]) => any): any; | ||
| filterLimit<T>(arr: T[], limit: number, iterator: AsyncBooleanIterator<T>, callback?: (results: T[]) => any): any; | ||
| selectLimit<T>(arr: T[], limit: number, iterator: AsyncBooleanIterator<T>, callback?: (results: T[]) => any): any; | ||
| reject<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: (results: T[]) => any): any; | ||
| rejectSeries<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: (results: T[]) => any): any; | ||
| rejectLimit<T>(arr: T[], limit: number, iterator: AsyncBooleanIterator<T>, callback?: (results: T[]) => any): any; | ||
| reduce<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback?: AsyncResultCallback<R>): any; | ||
| inject<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback?: AsyncResultCallback<R>): any; | ||
| foldl<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback?: AsyncResultCallback<R>): any; | ||
| reduceRight<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback: AsyncResultCallback<R>): any; | ||
| foldr<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback: AsyncResultCallback<R>): any; | ||
| detect<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: (result: T) => void): any; | ||
| detectSeries<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: (result: T) => void): any; | ||
| detectLimit<T>(arr: T[], limit: number, iterator: AsyncBooleanIterator<T>, callback?: (result: T) => void): any; | ||
| sortBy<T, V>(arr: T[], iterator: AsyncResultIterator<T, V>, callback?: AsyncResultArrayCallback<T>): any; | ||
| some<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: (result: boolean) => void): any; | ||
| someLimit<T>(arr: T[], limit: number, iterator: AsyncBooleanIterator<T>, callback?: (result: boolean) => void): any; | ||
| any<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: (result: boolean) => void): any; | ||
| every<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: (result: boolean) => any): any; | ||
| everyLimit<T>(arr: T[], limit: number, iterator: AsyncBooleanIterator<T>, callback?: (result: boolean) => any): any; | ||
| all<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: (result: boolean) => any): any; | ||
| concat<T, R>(arr: T[], iterator: AsyncResultIterator<T, R[]>, callback?: AsyncResultArrayCallback<R>): any; | ||
| concatSeries<T, R>(arr: T[], iterator: AsyncResultIterator<T, R[]>, callback?: AsyncResultArrayCallback<R>): any; | ||
| // Control Flow | ||
| series<T>(tasks: AsyncFunction<T>[], callback?: AsyncResultArrayCallback<T>): void; | ||
| series<T>(tasks: Dictionary<AsyncFunction<T>>, callback?: AsyncResultObjectCallback<T>): void; | ||
| parallel<T>(tasks: Array<AsyncFunction<T>>, callback?: AsyncResultArrayCallback<T>): void; | ||
| parallel<T>(tasks: Dictionary<AsyncFunction<T>>, callback?: AsyncResultObjectCallback<T>): void; | ||
| parallelLimit<T>(tasks: Array<AsyncFunction<T>>, limit: number, callback?: AsyncResultArrayCallback<T>): void; | ||
| parallelLimit<T>(tasks: Dictionary<AsyncFunction<T>>, limit: number, callback?: AsyncResultObjectCallback<T>): void; | ||
| whilst(test: () => boolean, fn: AsyncVoidFunction, callback: (err: any) => void): void; | ||
| doWhilst(fn: AsyncVoidFunction, test: () => boolean, callback: (err: any) => void): void; | ||
| until(test: () => boolean, fn: AsyncVoidFunction, callback: (err: any) => void): void; | ||
| doUntil(fn: AsyncVoidFunction, test: () => boolean, callback: (err: any) => void): void; | ||
| during(test: (testCallback : (error: Error, truth: boolean) => void) => void, fn: AsyncVoidFunction, callback: (err: any) => void): void; | ||
| doDuring(fn: AsyncVoidFunction, test: (testCallback: (error: Error, truth: boolean) => void) => void, callback: (err: any) => void): void; | ||
| forever(next: (errCallback : (err: Error) => void) => void, errBack: (err: Error) => void) : void; | ||
| waterfall(tasks: Function[], callback?: (err: Error, results?: any) => void): void; | ||
| compose(...fns: Function[]): Function; | ||
| seq(...fns: Function[]): Function; | ||
| applyEach(fns: Function[], argsAndCallback: any[]): void; // applyEach(fns, args..., callback). TS does not support ... for a middle argument. Callback is optional. | ||
| applyEachSeries(fns: Function[], argsAndCallback: any[]): void; // applyEachSeries(fns, args..., callback). TS does not support ... for a middle argument. Callback is optional. | ||
| queue<T>(worker: AsyncWorker<T>, concurrency?: number): AsyncQueue<T>; | ||
| priorityQueue<T>(worker: AsyncWorker<T>, concurrency: number): AsyncPriorityQueue<T>; | ||
| cargo(worker : (tasks: any[], callback : ErrorCallback) => void, payload? : number) : AsyncCargo; | ||
| auto(tasks: any, callback?: (error: Error, results: any) => void): void; | ||
| retry<T>(opts: number, task: (callback : AsyncResultCallback<T>, results: any) => void, callback: (error: Error, results: any) => void): void; | ||
| retry<T>(opts: { times: number, interval: number }, task: (callback: AsyncResultCallback<T>, results : any) => void, callback: (error: Error, results: any) => void): void; | ||
| iterator(tasks: Function[]): Function; | ||
| apply(fn: Function, ...arguments: any[]): AsyncFunction<any>; | ||
| nextTick(callback: Function): void; | ||
| setImmediate(callback: Function): void; | ||
| times<T> (n: number, iterator: AsyncResultIterator<number, T>, callback: AsyncResultArrayCallback<T>): void; | ||
| timesSeries<T>(n: number, iterator: AsyncResultIterator<number, T>, callback: AsyncResultArrayCallback<T>): void; | ||
| timesLimit<T>(n: number, limit: number, iterator: AsyncResultIterator<number, T>, callback: AsyncResultArrayCallback<T>): void; | ||
| // Utils | ||
| memoize(fn: Function, hasher?: Function): Function; | ||
| unmemoize(fn: Function): Function; | ||
| ensureAsync(fn: (... argsAndCallback: any[]) => void): Function; | ||
| constant(...values: any[]): Function; | ||
| asyncify(fn: Function): Function; | ||
| wrapSync(fn: Function): Function; | ||
| log(fn: Function, ...arguments: any[]): void; | ||
| dir(fn: Function, ...arguments: any[]): void; | ||
| noConflict(): Async; | ||
| } | ||
| declare var async: Async; | ||
| declare module "async" { | ||
| export = async; | ||
| } |
| // Generated by typings | ||
| // Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/56295f5058cac7ae458540423c50ac2dcf9fc711/form-data/form-data.d.ts | ||
| // Type definitions for form-data | ||
| // Project: https://github.com/felixge/node-form-data | ||
| // Definitions by: Carlos Ballesteros Velasco <https://github.com/soywiz> | ||
| // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
| // Imported from: https://github.com/soywiz/typescript-node-definitions/form-data.d.ts | ||
| declare module "form-data" { | ||
| export class FormData { | ||
| append(key: string, value: any, options?: any): FormData; | ||
| getHeaders(): Object; | ||
| // TODO expand pipe | ||
| pipe(to: any): any; | ||
| submit(params: string|Object, callback: (error: any, response: any) => void): any; | ||
| } | ||
| } |
| // Generated by typings | ||
| // Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/7de6c3dd94feaeb21f20054b9f30d5dabc5efabd/mocha/mocha.d.ts | ||
| // Type definitions for mocha 2.2.5 | ||
| // Project: http://mochajs.org/ | ||
| // Definitions by: Kazi Manzur Rashid <https://github.com/kazimanzurrashid/>, otiai10 <https://github.com/otiai10>, jt000 <https://github.com/jt000>, Vadim Macagon <https://github.com/enlight> | ||
| // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
| interface MochaSetupOptions { | ||
| //milliseconds to wait before considering a test slow | ||
| slow?: number; | ||
| // timeout in milliseconds | ||
| timeout?: number; | ||
| // ui name "bdd", "tdd", "exports" etc | ||
| ui?: string; | ||
| //array of accepted globals | ||
| globals?: any[]; | ||
| // reporter instance (function or string), defaults to `mocha.reporters.Spec` | ||
| reporter?: any; | ||
| // bail on the first test failure | ||
| bail?: boolean; | ||
| // ignore global leaks | ||
| ignoreLeaks?: boolean; | ||
| // grep string or regexp to filter tests with | ||
| grep?: any; | ||
| } | ||
| interface MochaDone { | ||
| (error?: Error): void; | ||
| } | ||
| declare var mocha: Mocha; | ||
| declare var describe: Mocha.IContextDefinition; | ||
| declare var xdescribe: Mocha.IContextDefinition; | ||
| // alias for `describe` | ||
| declare var context: Mocha.IContextDefinition; | ||
| // alias for `describe` | ||
| declare var suite: Mocha.IContextDefinition; | ||
| declare var it: Mocha.ITestDefinition; | ||
| declare var xit: Mocha.ITestDefinition; | ||
| // alias for `it` | ||
| declare var test: Mocha.ITestDefinition; | ||
| declare function before(action: () => void): void; | ||
| declare function before(action: (done: MochaDone) => void): void; | ||
| declare function before(description: string, action: () => void): void; | ||
| declare function before(description: string, action: (done: MochaDone) => void): void; | ||
| declare function setup(action: () => void): void; | ||
| declare function setup(action: (done: MochaDone) => void): void; | ||
| declare function after(action: () => void): void; | ||
| declare function after(action: (done: MochaDone) => void): void; | ||
| declare function after(description: string, action: () => void): void; | ||
| declare function after(description: string, action: (done: MochaDone) => void): void; | ||
| declare function teardown(action: () => void): void; | ||
| declare function teardown(action: (done: MochaDone) => void): void; | ||
| declare function beforeEach(action: () => void): void; | ||
| declare function beforeEach(action: (done: MochaDone) => void): void; | ||
| declare function beforeEach(description: string, action: () => void): void; | ||
| declare function beforeEach(description: string, action: (done: MochaDone) => void): void; | ||
| declare function suiteSetup(action: () => void): void; | ||
| declare function suiteSetup(action: (done: MochaDone) => void): void; | ||
| declare function afterEach(action: () => void): void; | ||
| declare function afterEach(action: (done: MochaDone) => void): void; | ||
| declare function afterEach(description: string, action: () => void): void; | ||
| declare function afterEach(description: string, action: (done: MochaDone) => void): void; | ||
| declare function suiteTeardown(action: () => void): void; | ||
| declare function suiteTeardown(action: (done: MochaDone) => void): void; | ||
| declare class Mocha { | ||
| constructor(options?: { | ||
| grep?: RegExp; | ||
| ui?: string; | ||
| reporter?: string; | ||
| timeout?: number; | ||
| bail?: boolean; | ||
| }); | ||
| /** Setup mocha with the given options. */ | ||
| setup(options: MochaSetupOptions): Mocha; | ||
| bail(value?: boolean): Mocha; | ||
| addFile(file: string): Mocha; | ||
| /** Sets reporter by name, defaults to "spec". */ | ||
| reporter(name: string): Mocha; | ||
| /** Sets reporter constructor, defaults to mocha.reporters.Spec. */ | ||
| reporter(reporter: (runner: Mocha.IRunner, options: any) => any): Mocha; | ||
| ui(value: string): Mocha; | ||
| grep(value: string): Mocha; | ||
| grep(value: RegExp): Mocha; | ||
| invert(): Mocha; | ||
| ignoreLeaks(value: boolean): Mocha; | ||
| checkLeaks(): Mocha; | ||
| /** | ||
| * Function to allow assertion libraries to throw errors directly into mocha. | ||
| * This is useful when running tests in a browser because window.onerror will | ||
| * only receive the 'message' attribute of the Error. | ||
| */ | ||
| throwError(error: Error): void; | ||
| /** Enables growl support. */ | ||
| growl(): Mocha; | ||
| globals(value: string): Mocha; | ||
| globals(values: string[]): Mocha; | ||
| useColors(value: boolean): Mocha; | ||
| useInlineDiffs(value: boolean): Mocha; | ||
| timeout(value: number): Mocha; | ||
| slow(value: number): Mocha; | ||
| enableTimeouts(value: boolean): Mocha; | ||
| asyncOnly(value: boolean): Mocha; | ||
| noHighlighting(value: boolean): Mocha; | ||
| /** Runs tests and invokes `onComplete()` when finished. */ | ||
| run(onComplete?: (failures: number) => void): Mocha.IRunner; | ||
| } | ||
| // merge the Mocha class declaration with a module | ||
| declare namespace Mocha { | ||
| /** Partial interface for Mocha's `Runnable` class. */ | ||
| interface IRunnable { | ||
| title: string; | ||
| fn: Function; | ||
| async: boolean; | ||
| sync: boolean; | ||
| timedOut: boolean; | ||
| } | ||
| /** Partial interface for Mocha's `Suite` class. */ | ||
| interface ISuite { | ||
| parent: ISuite; | ||
| title: string; | ||
| fullTitle(): string; | ||
| } | ||
| /** Partial interface for Mocha's `Test` class. */ | ||
| interface ITest extends IRunnable { | ||
| parent: ISuite; | ||
| pending: boolean; | ||
| fullTitle(): string; | ||
| } | ||
| /** Partial interface for Mocha's `Runner` class. */ | ||
| interface IRunner {} | ||
| interface IContextDefinition { | ||
| (description: string, spec: () => void): ISuite; | ||
| only(description: string, spec: () => void): ISuite; | ||
| skip(description: string, spec: () => void): void; | ||
| timeout(ms: number): void; | ||
| } | ||
| interface ITestDefinition { | ||
| (expectation: string, assertion?: () => void): ITest; | ||
| (expectation: string, assertion?: (done: MochaDone) => void): ITest; | ||
| only(expectation: string, assertion?: () => void): ITest; | ||
| only(expectation: string, assertion?: (done: MochaDone) => void): ITest; | ||
| skip(expectation: string, assertion?: () => void): void; | ||
| skip(expectation: string, assertion?: (done: MochaDone) => void): void; | ||
| timeout(ms: number): void; | ||
| } | ||
| export module reporters { | ||
| export class Base { | ||
| stats: { | ||
| suites: number; | ||
| tests: number; | ||
| passes: number; | ||
| pending: number; | ||
| failures: number; | ||
| }; | ||
| constructor(runner: IRunner); | ||
| } | ||
| export class Doc extends Base {} | ||
| export class Dot extends Base {} | ||
| export class HTML extends Base {} | ||
| export class HTMLCov extends Base {} | ||
| export class JSON extends Base {} | ||
| export class JSONCov extends Base {} | ||
| export class JSONStream extends Base {} | ||
| export class Landing extends Base {} | ||
| export class List extends Base {} | ||
| export class Markdown extends Base {} | ||
| export class Min extends Base {} | ||
| export class Nyan extends Base {} | ||
| export class Progress extends Base { | ||
| /** | ||
| * @param options.open String used to indicate the start of the progress bar. | ||
| * @param options.complete String used to indicate a complete test on the progress bar. | ||
| * @param options.incomplete String used to indicate an incomplete test on the progress bar. | ||
| * @param options.close String used to indicate the end of the progress bar. | ||
| */ | ||
| constructor(runner: IRunner, options?: { | ||
| open?: string; | ||
| complete?: string; | ||
| incomplete?: string; | ||
| close?: string; | ||
| }); | ||
| } | ||
| export class Spec extends Base {} | ||
| export class TAP extends Base {} | ||
| export class XUnit extends Base { | ||
| constructor(runner: IRunner, options?: any); | ||
| } | ||
| } | ||
| } | ||
| declare module "mocha" { | ||
| export = Mocha; | ||
| } |
Sorry, the diff of this file is too big to display
| // Generated by typings | ||
| // Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/56295f5058cac7ae458540423c50ac2dcf9fc711/request/request.d.ts | ||
| // Type definitions for request | ||
| // Project: https://github.com/mikeal/request | ||
| // Definitions by: Carlos Ballesteros Velasco <https://github.com/soywiz>, bonnici <https://github.com/bonnici>, Bart van der Schoor <https://github.com/Bartvds>, Joe Skeen <http://github.com/joeskeen>, Christopher Currens <https://github.com/ccurrens> | ||
| // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
| // Imported from: https://github.com/soywiz/typescript-node-definitions/d.ts | ||
| declare module 'request' { | ||
| import stream = require('stream'); | ||
| import http = require('http'); | ||
| import https = require('https'); | ||
| import FormData = require('form-data'); | ||
| import url = require('url'); | ||
| import fs = require('fs'); | ||
| namespace request { | ||
| export interface RequestAPI<TRequest extends Request, | ||
| TOptions extends CoreOptions, | ||
| TUriUrlOptions> { | ||
| defaults(options: TOptions): RequestAPI<TRequest, TOptions, RequiredUriUrl>; | ||
| defaults(options: RequiredUriUrl & TOptions): DefaultUriUrlRequestApi<TRequest, TOptions, OptionalUriUrl>; | ||
| (uri: string, options?: TOptions, callback?: RequestCallback): TRequest; | ||
| (uri: string, callback?: RequestCallback): TRequest; | ||
| (options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest; | ||
| get(uri: string, options?: TOptions, callback?: RequestCallback): TRequest; | ||
| get(uri: string, callback?: RequestCallback): TRequest; | ||
| get(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest; | ||
| post(uri: string, options?: TOptions, callback?: RequestCallback): TRequest; | ||
| post(uri: string, callback?: RequestCallback): TRequest; | ||
| post(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest; | ||
| put(uri: string, options?: TOptions, callback?: RequestCallback): TRequest; | ||
| put(uri: string, callback?: RequestCallback): TRequest; | ||
| put(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest; | ||
| head(uri: string, options?: TOptions, callback?: RequestCallback): TRequest; | ||
| head(uri: string, callback?: RequestCallback): TRequest; | ||
| head(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest; | ||
| patch(uri: string, options?: TOptions, callback?: RequestCallback): TRequest; | ||
| patch(uri: string, callback?: RequestCallback): TRequest; | ||
| patch(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest; | ||
| del(uri: string, options?: TOptions, callback?: RequestCallback): TRequest; | ||
| del(uri: string, callback?: RequestCallback): TRequest; | ||
| del(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest; | ||
| forever(agentOptions: any, optionsArg: any): TRequest; | ||
| jar(): CookieJar; | ||
| cookie(str: string): Cookie; | ||
| initParams: any; | ||
| debug: boolean; | ||
| } | ||
| interface DefaultUriUrlRequestApi<TRequest extends Request, | ||
| TOptions extends CoreOptions, | ||
| TUriUrlOptions> extends RequestAPI<TRequest, TOptions, TUriUrlOptions> { | ||
| defaults(options: TOptions): DefaultUriUrlRequestApi<TRequest, TOptions, OptionalUriUrl>; | ||
| (): TRequest; | ||
| get(): TRequest; | ||
| post(): TRequest; | ||
| put(): TRequest; | ||
| head(): TRequest; | ||
| patch(): TRequest; | ||
| del(): TRequest; | ||
| } | ||
| interface CoreOptions { | ||
| baseUrl?: string; | ||
| callback?: (error: any, response: http.IncomingMessage, body: any) => void; | ||
| jar?: any; // CookieJar | ||
| formData?: any; // Object | ||
| form?: any; // Object or string | ||
| auth?: AuthOptions; | ||
| oauth?: OAuthOptions; | ||
| aws?: AWSOptions; | ||
| hawk?: HawkOptions; | ||
| qs?: any; | ||
| json?: any; | ||
| multipart?: RequestPart[] | Multipart; | ||
| agent?: http.Agent | https.Agent; | ||
| agentOptions?: any; | ||
| agentClass?: any; | ||
| forever?: any; | ||
| host?: string; | ||
| port?: number; | ||
| method?: string; | ||
| headers?: Headers; | ||
| body?: any; | ||
| followRedirect?: boolean | ((response: http.IncomingMessage) => boolean); | ||
| followAllRedirects?: boolean; | ||
| maxRedirects?: number; | ||
| encoding?: string; | ||
| pool?: any; | ||
| timeout?: number; | ||
| proxy?: any; | ||
| strictSSL?: boolean; | ||
| gzip?: boolean; | ||
| preambleCRLF?: boolean; | ||
| postambleCRLF?: boolean; | ||
| key?: Buffer; | ||
| cert?: Buffer; | ||
| passphrase?: string; | ||
| ca?: Buffer; | ||
| har?: HttpArchiveRequest; | ||
| useQuerystring?: boolean; | ||
| } | ||
| interface UriOptions { | ||
| uri: string; | ||
| } | ||
| interface UrlOptions { | ||
| url: string; | ||
| } | ||
| export type RequiredUriUrl = UriOptions | UrlOptions; | ||
| interface OptionalUriUrl { | ||
| uri?: string; | ||
| url?: string; | ||
| } | ||
| export type OptionsWithUri = UriOptions & CoreOptions; | ||
| export type OptionsWithUrl = UrlOptions & CoreOptions; | ||
| export type Options = OptionsWithUri | OptionsWithUrl; | ||
| export interface RequestCallback { | ||
| (error: any, response: http.IncomingMessage, body: any): void; | ||
| } | ||
| export interface HttpArchiveRequest { | ||
| url?: string; | ||
| method?: string; | ||
| headers?: NameValuePair[]; | ||
| postData?: { | ||
| mimeType?: string; | ||
| params?: NameValuePair[]; | ||
| } | ||
| } | ||
| export interface NameValuePair { | ||
| name: string; | ||
| value: string; | ||
| } | ||
| export interface Multipart { | ||
| chunked?: boolean; | ||
| data?: { | ||
| 'content-type'?: string, | ||
| body: string | ||
| }[]; | ||
| } | ||
| export interface RequestPart { | ||
| headers?: Headers; | ||
| body: any; | ||
| } | ||
| export interface Request extends stream.Stream { | ||
| readable: boolean; | ||
| writable: boolean; | ||
| getAgent(): http.Agent; | ||
| //start(): void; | ||
| //abort(): void; | ||
| pipeDest(dest: any): void; | ||
| setHeader(name: string, value: string, clobber?: boolean): Request; | ||
| setHeaders(headers: Headers): Request; | ||
| qs(q: Object, clobber?: boolean): Request; | ||
| form(): FormData.FormData; | ||
| form(form: any): Request; | ||
| multipart(multipart: RequestPart[]): Request; | ||
| json(val: any): Request; | ||
| aws(opts: AWSOptions, now?: boolean): Request; | ||
| auth(username: string, password: string, sendInmediately?: boolean, bearer?: string): Request; | ||
| oauth(oauth: OAuthOptions): Request; | ||
| jar(jar: CookieJar): Request; | ||
| on(event: string, listener: Function): this; | ||
| on(event: 'request', listener: (req: http.ClientRequest) => void): this; | ||
| on(event: 'response', listener: (resp: http.IncomingMessage) => void): this; | ||
| on(event: 'data', listener: (data: Buffer | string) => void): this; | ||
| on(event: 'error', listener: (e: Error) => void): this; | ||
| on(event: 'complete', listener: (resp: http.IncomingMessage, body?: string | Buffer) => void): this; | ||
| write(buffer: Buffer, cb?: Function): boolean; | ||
| write(str: string, cb?: Function): boolean; | ||
| write(str: string, encoding: string, cb?: Function): boolean; | ||
| write(str: string, encoding?: string, fd?: string): boolean; | ||
| end(): void; | ||
| end(chunk: Buffer, cb?: Function): void; | ||
| end(chunk: string, cb?: Function): void; | ||
| end(chunk: string, encoding: string, cb?: Function): void; | ||
| pause(): void; | ||
| resume(): void; | ||
| abort(): void; | ||
| destroy(): void; | ||
| toJSON(): Object; | ||
| } | ||
| export interface Headers { | ||
| [key: string]: any; | ||
| } | ||
| export interface AuthOptions { | ||
| user?: string; | ||
| username?: string; | ||
| pass?: string; | ||
| password?: string; | ||
| sendImmediately?: boolean; | ||
| bearer?: string; | ||
| } | ||
| export interface OAuthOptions { | ||
| callback?: string; | ||
| consumer_key?: string; | ||
| consumer_secret?: string; | ||
| token?: string; | ||
| token_secret?: string; | ||
| verifier?: string; | ||
| } | ||
| export interface HawkOptions { | ||
| credentials: any; | ||
| } | ||
| export interface AWSOptions { | ||
| secret: string; | ||
| bucket?: string; | ||
| } | ||
| export interface CookieJar { | ||
| setCookie(cookie: Cookie, uri: string | url.Url, options?: any): void | ||
| getCookieString(uri: string | url.Url): string | ||
| getCookies(uri: string | url.Url): Cookie[] | ||
| } | ||
| export interface CookieValue { | ||
| name: string; | ||
| value: any; | ||
| httpOnly: boolean; | ||
| } | ||
| export interface Cookie extends Array<CookieValue> { | ||
| constructor(name: string, req: Request): void; | ||
| str: string; | ||
| expires: Date; | ||
| path: string; | ||
| toString(): string; | ||
| } | ||
| } | ||
| var request: request.RequestAPI<request.Request, request.CoreOptions, request.RequiredUriUrl>; | ||
| export = request; | ||
| } |
| /// <reference path="main/ambient/async/index.d.ts" /> | ||
| /// <reference path="main/ambient/form-data/index.d.ts" /> | ||
| /// <reference path="main/ambient/mocha/index.d.ts" /> | ||
| /// <reference path="main/ambient/node/index.d.ts" /> | ||
| /// <reference path="main/ambient/request/index.d.ts" /> |
| // Generated by typings | ||
| // Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/56295f5058cac7ae458540423c50ac2dcf9fc711/async/async.d.ts | ||
| // Type definitions for Async 1.4.2 | ||
| // Project: https://github.com/caolan/async | ||
| // Definitions by: Boris Yankov <https://github.com/borisyankov/>, Arseniy Maximov <https://github.com/kern0>, Joe Herman <https://github.com/Penryn> | ||
| // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
| interface Dictionary<T> { [key: string]: T; } | ||
| interface ErrorCallback { (err?: Error): void; } | ||
| interface AsyncResultCallback<T> { (err: Error, result: T): void; } | ||
| interface AsyncResultArrayCallback<T> { (err: Error, results: T[]): void; } | ||
| interface AsyncResultObjectCallback<T> { (err: Error, results: Dictionary<T>): void; } | ||
| interface AsyncFunction<T> { (callback: (err?: Error, result?: T) => void): void; } | ||
| interface AsyncIterator<T> { (item: T, callback: ErrorCallback): void; } | ||
| interface AsyncForEachOfIterator<T> { (item: T, key: number, callback: ErrorCallback): void; } | ||
| interface AsyncResultIterator<T, R> { (item: T, callback: AsyncResultCallback<R>): void; } | ||
| interface AsyncMemoIterator<T, R> { (memo: R, item: T, callback: AsyncResultCallback<R>): void; } | ||
| interface AsyncBooleanIterator<T> { (item: T, callback: (truthValue: boolean) => void): void; } | ||
| interface AsyncWorker<T> { (task: T, callback: ErrorCallback): void; } | ||
| interface AsyncVoidFunction { (callback: ErrorCallback): void; } | ||
| interface AsyncQueue<T> { | ||
| length(): number; | ||
| started: boolean; | ||
| running(): number; | ||
| idle(): boolean; | ||
| concurrency: number; | ||
| push(task: T, callback?: ErrorCallback): void; | ||
| push(task: T[], callback?: ErrorCallback): void; | ||
| unshift(task: T, callback?: ErrorCallback): void; | ||
| unshift(task: T[], callback?: ErrorCallback): void; | ||
| saturated: () => any; | ||
| empty: () => any; | ||
| drain: () => any; | ||
| paused: boolean; | ||
| pause(): void | ||
| resume(): void; | ||
| kill(): void; | ||
| } | ||
| interface AsyncPriorityQueue<T> { | ||
| length(): number; | ||
| concurrency: number; | ||
| started: boolean; | ||
| paused: boolean; | ||
| push(task: T, priority: number, callback?: AsyncResultArrayCallback<T>): void; | ||
| push(task: T[], priority: number, callback?: AsyncResultArrayCallback<T>): void; | ||
| saturated: () => any; | ||
| empty: () => any; | ||
| drain: () => any; | ||
| running(): number; | ||
| idle(): boolean; | ||
| pause(): void; | ||
| resume(): void; | ||
| kill(): void; | ||
| } | ||
| interface AsyncCargo { | ||
| length(): number; | ||
| payload: number; | ||
| push(task: any, callback? : Function): void; | ||
| push(task: any[], callback? : Function): void; | ||
| saturated(): void; | ||
| empty(): void; | ||
| drain(): void; | ||
| idle(): boolean; | ||
| pause(): void; | ||
| resume(): void; | ||
| kill(): void; | ||
| } | ||
| interface Async { | ||
| // Collections | ||
| each<T>(arr: T[], iterator: AsyncIterator<T>, callback?: ErrorCallback): void; | ||
| eachSeries<T>(arr: T[], iterator: AsyncIterator<T>, callback?: ErrorCallback): void; | ||
| eachLimit<T>(arr: T[], limit: number, iterator: AsyncIterator<T>, callback?: ErrorCallback): void; | ||
| forEachOf(obj: any, iterator: (item: any, key: string|number, callback?: ErrorCallback) => void, callback: ErrorCallback): void; | ||
| forEachOf<T>(obj: T[], iterator: AsyncForEachOfIterator<T>, callback?: ErrorCallback): void; | ||
| forEachOfSeries(obj: any, iterator: (item: any, key: string|number, callback?: ErrorCallback) => void, callback: ErrorCallback): void; | ||
| forEachOfSeries<T>(obj: T[], iterator: AsyncForEachOfIterator<T>, callback?: ErrorCallback): void; | ||
| forEachOfLimit(obj: any, limit: number, iterator: (item: any, key: string|number, callback?: ErrorCallback) => void, callback: ErrorCallback): void; | ||
| forEachOfLimit<T>(obj: T[], limit: number, iterator: AsyncForEachOfIterator<T>, callback?: ErrorCallback): void; | ||
| map<T, R>(arr: T[], iterator: AsyncResultIterator<T, R>, callback?: AsyncResultArrayCallback<R>): any; | ||
| mapSeries<T, R>(arr: T[], iterator: AsyncResultIterator<T, R>, callback?: AsyncResultArrayCallback<R>): any; | ||
| mapLimit<T, R>(arr: T[], limit: number, iterator: AsyncResultIterator<T, R>, callback?: AsyncResultArrayCallback<R>): any; | ||
| filter<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: (results: T[]) => any): any; | ||
| select<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: (results: T[]) => any): any; | ||
| filterSeries<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: (results: T[]) => any): any; | ||
| selectSeries<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: (results: T[]) => any): any; | ||
| filterLimit<T>(arr: T[], limit: number, iterator: AsyncBooleanIterator<T>, callback?: (results: T[]) => any): any; | ||
| selectLimit<T>(arr: T[], limit: number, iterator: AsyncBooleanIterator<T>, callback?: (results: T[]) => any): any; | ||
| reject<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: (results: T[]) => any): any; | ||
| rejectSeries<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: (results: T[]) => any): any; | ||
| rejectLimit<T>(arr: T[], limit: number, iterator: AsyncBooleanIterator<T>, callback?: (results: T[]) => any): any; | ||
| reduce<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback?: AsyncResultCallback<R>): any; | ||
| inject<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback?: AsyncResultCallback<R>): any; | ||
| foldl<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback?: AsyncResultCallback<R>): any; | ||
| reduceRight<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback: AsyncResultCallback<R>): any; | ||
| foldr<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback: AsyncResultCallback<R>): any; | ||
| detect<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: (result: T) => void): any; | ||
| detectSeries<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: (result: T) => void): any; | ||
| detectLimit<T>(arr: T[], limit: number, iterator: AsyncBooleanIterator<T>, callback?: (result: T) => void): any; | ||
| sortBy<T, V>(arr: T[], iterator: AsyncResultIterator<T, V>, callback?: AsyncResultArrayCallback<T>): any; | ||
| some<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: (result: boolean) => void): any; | ||
| someLimit<T>(arr: T[], limit: number, iterator: AsyncBooleanIterator<T>, callback?: (result: boolean) => void): any; | ||
| any<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: (result: boolean) => void): any; | ||
| every<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: (result: boolean) => any): any; | ||
| everyLimit<T>(arr: T[], limit: number, iterator: AsyncBooleanIterator<T>, callback?: (result: boolean) => any): any; | ||
| all<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: (result: boolean) => any): any; | ||
| concat<T, R>(arr: T[], iterator: AsyncResultIterator<T, R[]>, callback?: AsyncResultArrayCallback<R>): any; | ||
| concatSeries<T, R>(arr: T[], iterator: AsyncResultIterator<T, R[]>, callback?: AsyncResultArrayCallback<R>): any; | ||
| // Control Flow | ||
| series<T>(tasks: AsyncFunction<T>[], callback?: AsyncResultArrayCallback<T>): void; | ||
| series<T>(tasks: Dictionary<AsyncFunction<T>>, callback?: AsyncResultObjectCallback<T>): void; | ||
| parallel<T>(tasks: Array<AsyncFunction<T>>, callback?: AsyncResultArrayCallback<T>): void; | ||
| parallel<T>(tasks: Dictionary<AsyncFunction<T>>, callback?: AsyncResultObjectCallback<T>): void; | ||
| parallelLimit<T>(tasks: Array<AsyncFunction<T>>, limit: number, callback?: AsyncResultArrayCallback<T>): void; | ||
| parallelLimit<T>(tasks: Dictionary<AsyncFunction<T>>, limit: number, callback?: AsyncResultObjectCallback<T>): void; | ||
| whilst(test: () => boolean, fn: AsyncVoidFunction, callback: (err: any) => void): void; | ||
| doWhilst(fn: AsyncVoidFunction, test: () => boolean, callback: (err: any) => void): void; | ||
| until(test: () => boolean, fn: AsyncVoidFunction, callback: (err: any) => void): void; | ||
| doUntil(fn: AsyncVoidFunction, test: () => boolean, callback: (err: any) => void): void; | ||
| during(test: (testCallback : (error: Error, truth: boolean) => void) => void, fn: AsyncVoidFunction, callback: (err: any) => void): void; | ||
| doDuring(fn: AsyncVoidFunction, test: (testCallback: (error: Error, truth: boolean) => void) => void, callback: (err: any) => void): void; | ||
| forever(next: (errCallback : (err: Error) => void) => void, errBack: (err: Error) => void) : void; | ||
| waterfall(tasks: Function[], callback?: (err: Error, results?: any) => void): void; | ||
| compose(...fns: Function[]): Function; | ||
| seq(...fns: Function[]): Function; | ||
| applyEach(fns: Function[], argsAndCallback: any[]): void; // applyEach(fns, args..., callback). TS does not support ... for a middle argument. Callback is optional. | ||
| applyEachSeries(fns: Function[], argsAndCallback: any[]): void; // applyEachSeries(fns, args..., callback). TS does not support ... for a middle argument. Callback is optional. | ||
| queue<T>(worker: AsyncWorker<T>, concurrency?: number): AsyncQueue<T>; | ||
| priorityQueue<T>(worker: AsyncWorker<T>, concurrency: number): AsyncPriorityQueue<T>; | ||
| cargo(worker : (tasks: any[], callback : ErrorCallback) => void, payload? : number) : AsyncCargo; | ||
| auto(tasks: any, callback?: (error: Error, results: any) => void): void; | ||
| retry<T>(opts: number, task: (callback : AsyncResultCallback<T>, results: any) => void, callback: (error: Error, results: any) => void): void; | ||
| retry<T>(opts: { times: number, interval: number }, task: (callback: AsyncResultCallback<T>, results : any) => void, callback: (error: Error, results: any) => void): void; | ||
| iterator(tasks: Function[]): Function; | ||
| apply(fn: Function, ...arguments: any[]): AsyncFunction<any>; | ||
| nextTick(callback: Function): void; | ||
| setImmediate(callback: Function): void; | ||
| times<T> (n: number, iterator: AsyncResultIterator<number, T>, callback: AsyncResultArrayCallback<T>): void; | ||
| timesSeries<T>(n: number, iterator: AsyncResultIterator<number, T>, callback: AsyncResultArrayCallback<T>): void; | ||
| timesLimit<T>(n: number, limit: number, iterator: AsyncResultIterator<number, T>, callback: AsyncResultArrayCallback<T>): void; | ||
| // Utils | ||
| memoize(fn: Function, hasher?: Function): Function; | ||
| unmemoize(fn: Function): Function; | ||
| ensureAsync(fn: (... argsAndCallback: any[]) => void): Function; | ||
| constant(...values: any[]): Function; | ||
| asyncify(fn: Function): Function; | ||
| wrapSync(fn: Function): Function; | ||
| log(fn: Function, ...arguments: any[]): void; | ||
| dir(fn: Function, ...arguments: any[]): void; | ||
| noConflict(): Async; | ||
| } | ||
| declare var async: Async; | ||
| declare module "async" { | ||
| export = async; | ||
| } |
| // Generated by typings | ||
| // Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/56295f5058cac7ae458540423c50ac2dcf9fc711/form-data/form-data.d.ts | ||
| // Type definitions for form-data | ||
| // Project: https://github.com/felixge/node-form-data | ||
| // Definitions by: Carlos Ballesteros Velasco <https://github.com/soywiz> | ||
| // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
| // Imported from: https://github.com/soywiz/typescript-node-definitions/form-data.d.ts | ||
| declare module "form-data" { | ||
| export class FormData { | ||
| append(key: string, value: any, options?: any): FormData; | ||
| getHeaders(): Object; | ||
| // TODO expand pipe | ||
| pipe(to: any): any; | ||
| submit(params: string|Object, callback: (error: any, response: any) => void): any; | ||
| } | ||
| } |
| // Generated by typings | ||
| // Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/7de6c3dd94feaeb21f20054b9f30d5dabc5efabd/mocha/mocha.d.ts | ||
| // Type definitions for mocha 2.2.5 | ||
| // Project: http://mochajs.org/ | ||
| // Definitions by: Kazi Manzur Rashid <https://github.com/kazimanzurrashid/>, otiai10 <https://github.com/otiai10>, jt000 <https://github.com/jt000>, Vadim Macagon <https://github.com/enlight> | ||
| // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
| interface MochaSetupOptions { | ||
| //milliseconds to wait before considering a test slow | ||
| slow?: number; | ||
| // timeout in milliseconds | ||
| timeout?: number; | ||
| // ui name "bdd", "tdd", "exports" etc | ||
| ui?: string; | ||
| //array of accepted globals | ||
| globals?: any[]; | ||
| // reporter instance (function or string), defaults to `mocha.reporters.Spec` | ||
| reporter?: any; | ||
| // bail on the first test failure | ||
| bail?: boolean; | ||
| // ignore global leaks | ||
| ignoreLeaks?: boolean; | ||
| // grep string or regexp to filter tests with | ||
| grep?: any; | ||
| } | ||
| interface MochaDone { | ||
| (error?: Error): void; | ||
| } | ||
| declare var mocha: Mocha; | ||
| declare var describe: Mocha.IContextDefinition; | ||
| declare var xdescribe: Mocha.IContextDefinition; | ||
| // alias for `describe` | ||
| declare var context: Mocha.IContextDefinition; | ||
| // alias for `describe` | ||
| declare var suite: Mocha.IContextDefinition; | ||
| declare var it: Mocha.ITestDefinition; | ||
| declare var xit: Mocha.ITestDefinition; | ||
| // alias for `it` | ||
| declare var test: Mocha.ITestDefinition; | ||
| declare function before(action: () => void): void; | ||
| declare function before(action: (done: MochaDone) => void): void; | ||
| declare function before(description: string, action: () => void): void; | ||
| declare function before(description: string, action: (done: MochaDone) => void): void; | ||
| declare function setup(action: () => void): void; | ||
| declare function setup(action: (done: MochaDone) => void): void; | ||
| declare function after(action: () => void): void; | ||
| declare function after(action: (done: MochaDone) => void): void; | ||
| declare function after(description: string, action: () => void): void; | ||
| declare function after(description: string, action: (done: MochaDone) => void): void; | ||
| declare function teardown(action: () => void): void; | ||
| declare function teardown(action: (done: MochaDone) => void): void; | ||
| declare function beforeEach(action: () => void): void; | ||
| declare function beforeEach(action: (done: MochaDone) => void): void; | ||
| declare function beforeEach(description: string, action: () => void): void; | ||
| declare function beforeEach(description: string, action: (done: MochaDone) => void): void; | ||
| declare function suiteSetup(action: () => void): void; | ||
| declare function suiteSetup(action: (done: MochaDone) => void): void; | ||
| declare function afterEach(action: () => void): void; | ||
| declare function afterEach(action: (done: MochaDone) => void): void; | ||
| declare function afterEach(description: string, action: () => void): void; | ||
| declare function afterEach(description: string, action: (done: MochaDone) => void): void; | ||
| declare function suiteTeardown(action: () => void): void; | ||
| declare function suiteTeardown(action: (done: MochaDone) => void): void; | ||
| declare class Mocha { | ||
| constructor(options?: { | ||
| grep?: RegExp; | ||
| ui?: string; | ||
| reporter?: string; | ||
| timeout?: number; | ||
| bail?: boolean; | ||
| }); | ||
| /** Setup mocha with the given options. */ | ||
| setup(options: MochaSetupOptions): Mocha; | ||
| bail(value?: boolean): Mocha; | ||
| addFile(file: string): Mocha; | ||
| /** Sets reporter by name, defaults to "spec". */ | ||
| reporter(name: string): Mocha; | ||
| /** Sets reporter constructor, defaults to mocha.reporters.Spec. */ | ||
| reporter(reporter: (runner: Mocha.IRunner, options: any) => any): Mocha; | ||
| ui(value: string): Mocha; | ||
| grep(value: string): Mocha; | ||
| grep(value: RegExp): Mocha; | ||
| invert(): Mocha; | ||
| ignoreLeaks(value: boolean): Mocha; | ||
| checkLeaks(): Mocha; | ||
| /** | ||
| * Function to allow assertion libraries to throw errors directly into mocha. | ||
| * This is useful when running tests in a browser because window.onerror will | ||
| * only receive the 'message' attribute of the Error. | ||
| */ | ||
| throwError(error: Error): void; | ||
| /** Enables growl support. */ | ||
| growl(): Mocha; | ||
| globals(value: string): Mocha; | ||
| globals(values: string[]): Mocha; | ||
| useColors(value: boolean): Mocha; | ||
| useInlineDiffs(value: boolean): Mocha; | ||
| timeout(value: number): Mocha; | ||
| slow(value: number): Mocha; | ||
| enableTimeouts(value: boolean): Mocha; | ||
| asyncOnly(value: boolean): Mocha; | ||
| noHighlighting(value: boolean): Mocha; | ||
| /** Runs tests and invokes `onComplete()` when finished. */ | ||
| run(onComplete?: (failures: number) => void): Mocha.IRunner; | ||
| } | ||
| // merge the Mocha class declaration with a module | ||
| declare namespace Mocha { | ||
| /** Partial interface for Mocha's `Runnable` class. */ | ||
| interface IRunnable { | ||
| title: string; | ||
| fn: Function; | ||
| async: boolean; | ||
| sync: boolean; | ||
| timedOut: boolean; | ||
| } | ||
| /** Partial interface for Mocha's `Suite` class. */ | ||
| interface ISuite { | ||
| parent: ISuite; | ||
| title: string; | ||
| fullTitle(): string; | ||
| } | ||
| /** Partial interface for Mocha's `Test` class. */ | ||
| interface ITest extends IRunnable { | ||
| parent: ISuite; | ||
| pending: boolean; | ||
| fullTitle(): string; | ||
| } | ||
| /** Partial interface for Mocha's `Runner` class. */ | ||
| interface IRunner {} | ||
| interface IContextDefinition { | ||
| (description: string, spec: () => void): ISuite; | ||
| only(description: string, spec: () => void): ISuite; | ||
| skip(description: string, spec: () => void): void; | ||
| timeout(ms: number): void; | ||
| } | ||
| interface ITestDefinition { | ||
| (expectation: string, assertion?: () => void): ITest; | ||
| (expectation: string, assertion?: (done: MochaDone) => void): ITest; | ||
| only(expectation: string, assertion?: () => void): ITest; | ||
| only(expectation: string, assertion?: (done: MochaDone) => void): ITest; | ||
| skip(expectation: string, assertion?: () => void): void; | ||
| skip(expectation: string, assertion?: (done: MochaDone) => void): void; | ||
| timeout(ms: number): void; | ||
| } | ||
| export module reporters { | ||
| export class Base { | ||
| stats: { | ||
| suites: number; | ||
| tests: number; | ||
| passes: number; | ||
| pending: number; | ||
| failures: number; | ||
| }; | ||
| constructor(runner: IRunner); | ||
| } | ||
| export class Doc extends Base {} | ||
| export class Dot extends Base {} | ||
| export class HTML extends Base {} | ||
| export class HTMLCov extends Base {} | ||
| export class JSON extends Base {} | ||
| export class JSONCov extends Base {} | ||
| export class JSONStream extends Base {} | ||
| export class Landing extends Base {} | ||
| export class List extends Base {} | ||
| export class Markdown extends Base {} | ||
| export class Min extends Base {} | ||
| export class Nyan extends Base {} | ||
| export class Progress extends Base { | ||
| /** | ||
| * @param options.open String used to indicate the start of the progress bar. | ||
| * @param options.complete String used to indicate a complete test on the progress bar. | ||
| * @param options.incomplete String used to indicate an incomplete test on the progress bar. | ||
| * @param options.close String used to indicate the end of the progress bar. | ||
| */ | ||
| constructor(runner: IRunner, options?: { | ||
| open?: string; | ||
| complete?: string; | ||
| incomplete?: string; | ||
| close?: string; | ||
| }); | ||
| } | ||
| export class Spec extends Base {} | ||
| export class TAP extends Base {} | ||
| export class XUnit extends Base { | ||
| constructor(runner: IRunner, options?: any); | ||
| } | ||
| } | ||
| } | ||
| declare module "mocha" { | ||
| export = Mocha; | ||
| } |
Sorry, the diff of this file is too big to display
| // Generated by typings | ||
| // Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/56295f5058cac7ae458540423c50ac2dcf9fc711/request/request.d.ts | ||
| // Type definitions for request | ||
| // Project: https://github.com/mikeal/request | ||
| // Definitions by: Carlos Ballesteros Velasco <https://github.com/soywiz>, bonnici <https://github.com/bonnici>, Bart van der Schoor <https://github.com/Bartvds>, Joe Skeen <http://github.com/joeskeen>, Christopher Currens <https://github.com/ccurrens> | ||
| // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
| // Imported from: https://github.com/soywiz/typescript-node-definitions/d.ts | ||
| declare module 'request' { | ||
| import stream = require('stream'); | ||
| import http = require('http'); | ||
| import https = require('https'); | ||
| import FormData = require('form-data'); | ||
| import url = require('url'); | ||
| import fs = require('fs'); | ||
| namespace request { | ||
| export interface RequestAPI<TRequest extends Request, | ||
| TOptions extends CoreOptions, | ||
| TUriUrlOptions> { | ||
| defaults(options: TOptions): RequestAPI<TRequest, TOptions, RequiredUriUrl>; | ||
| defaults(options: RequiredUriUrl & TOptions): DefaultUriUrlRequestApi<TRequest, TOptions, OptionalUriUrl>; | ||
| (uri: string, options?: TOptions, callback?: RequestCallback): TRequest; | ||
| (uri: string, callback?: RequestCallback): TRequest; | ||
| (options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest; | ||
| get(uri: string, options?: TOptions, callback?: RequestCallback): TRequest; | ||
| get(uri: string, callback?: RequestCallback): TRequest; | ||
| get(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest; | ||
| post(uri: string, options?: TOptions, callback?: RequestCallback): TRequest; | ||
| post(uri: string, callback?: RequestCallback): TRequest; | ||
| post(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest; | ||
| put(uri: string, options?: TOptions, callback?: RequestCallback): TRequest; | ||
| put(uri: string, callback?: RequestCallback): TRequest; | ||
| put(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest; | ||
| head(uri: string, options?: TOptions, callback?: RequestCallback): TRequest; | ||
| head(uri: string, callback?: RequestCallback): TRequest; | ||
| head(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest; | ||
| patch(uri: string, options?: TOptions, callback?: RequestCallback): TRequest; | ||
| patch(uri: string, callback?: RequestCallback): TRequest; | ||
| patch(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest; | ||
| del(uri: string, options?: TOptions, callback?: RequestCallback): TRequest; | ||
| del(uri: string, callback?: RequestCallback): TRequest; | ||
| del(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest; | ||
| forever(agentOptions: any, optionsArg: any): TRequest; | ||
| jar(): CookieJar; | ||
| cookie(str: string): Cookie; | ||
| initParams: any; | ||
| debug: boolean; | ||
| } | ||
| interface DefaultUriUrlRequestApi<TRequest extends Request, | ||
| TOptions extends CoreOptions, | ||
| TUriUrlOptions> extends RequestAPI<TRequest, TOptions, TUriUrlOptions> { | ||
| defaults(options: TOptions): DefaultUriUrlRequestApi<TRequest, TOptions, OptionalUriUrl>; | ||
| (): TRequest; | ||
| get(): TRequest; | ||
| post(): TRequest; | ||
| put(): TRequest; | ||
| head(): TRequest; | ||
| patch(): TRequest; | ||
| del(): TRequest; | ||
| } | ||
| interface CoreOptions { | ||
| baseUrl?: string; | ||
| callback?: (error: any, response: http.IncomingMessage, body: any) => void; | ||
| jar?: any; // CookieJar | ||
| formData?: any; // Object | ||
| form?: any; // Object or string | ||
| auth?: AuthOptions; | ||
| oauth?: OAuthOptions; | ||
| aws?: AWSOptions; | ||
| hawk?: HawkOptions; | ||
| qs?: any; | ||
| json?: any; | ||
| multipart?: RequestPart[] | Multipart; | ||
| agent?: http.Agent | https.Agent; | ||
| agentOptions?: any; | ||
| agentClass?: any; | ||
| forever?: any; | ||
| host?: string; | ||
| port?: number; | ||
| method?: string; | ||
| headers?: Headers; | ||
| body?: any; | ||
| followRedirect?: boolean | ((response: http.IncomingMessage) => boolean); | ||
| followAllRedirects?: boolean; | ||
| maxRedirects?: number; | ||
| encoding?: string; | ||
| pool?: any; | ||
| timeout?: number; | ||
| proxy?: any; | ||
| strictSSL?: boolean; | ||
| gzip?: boolean; | ||
| preambleCRLF?: boolean; | ||
| postambleCRLF?: boolean; | ||
| key?: Buffer; | ||
| cert?: Buffer; | ||
| passphrase?: string; | ||
| ca?: Buffer; | ||
| har?: HttpArchiveRequest; | ||
| useQuerystring?: boolean; | ||
| } | ||
| interface UriOptions { | ||
| uri: string; | ||
| } | ||
| interface UrlOptions { | ||
| url: string; | ||
| } | ||
| export type RequiredUriUrl = UriOptions | UrlOptions; | ||
| interface OptionalUriUrl { | ||
| uri?: string; | ||
| url?: string; | ||
| } | ||
| export type OptionsWithUri = UriOptions & CoreOptions; | ||
| export type OptionsWithUrl = UrlOptions & CoreOptions; | ||
| export type Options = OptionsWithUri | OptionsWithUrl; | ||
| export interface RequestCallback { | ||
| (error: any, response: http.IncomingMessage, body: any): void; | ||
| } | ||
| export interface HttpArchiveRequest { | ||
| url?: string; | ||
| method?: string; | ||
| headers?: NameValuePair[]; | ||
| postData?: { | ||
| mimeType?: string; | ||
| params?: NameValuePair[]; | ||
| } | ||
| } | ||
| export interface NameValuePair { | ||
| name: string; | ||
| value: string; | ||
| } | ||
| export interface Multipart { | ||
| chunked?: boolean; | ||
| data?: { | ||
| 'content-type'?: string, | ||
| body: string | ||
| }[]; | ||
| } | ||
| export interface RequestPart { | ||
| headers?: Headers; | ||
| body: any; | ||
| } | ||
| export interface Request extends stream.Stream { | ||
| readable: boolean; | ||
| writable: boolean; | ||
| getAgent(): http.Agent; | ||
| //start(): void; | ||
| //abort(): void; | ||
| pipeDest(dest: any): void; | ||
| setHeader(name: string, value: string, clobber?: boolean): Request; | ||
| setHeaders(headers: Headers): Request; | ||
| qs(q: Object, clobber?: boolean): Request; | ||
| form(): FormData.FormData; | ||
| form(form: any): Request; | ||
| multipart(multipart: RequestPart[]): Request; | ||
| json(val: any): Request; | ||
| aws(opts: AWSOptions, now?: boolean): Request; | ||
| auth(username: string, password: string, sendInmediately?: boolean, bearer?: string): Request; | ||
| oauth(oauth: OAuthOptions): Request; | ||
| jar(jar: CookieJar): Request; | ||
| on(event: string, listener: Function): this; | ||
| on(event: 'request', listener: (req: http.ClientRequest) => void): this; | ||
| on(event: 'response', listener: (resp: http.IncomingMessage) => void): this; | ||
| on(event: 'data', listener: (data: Buffer | string) => void): this; | ||
| on(event: 'error', listener: (e: Error) => void): this; | ||
| on(event: 'complete', listener: (resp: http.IncomingMessage, body?: string | Buffer) => void): this; | ||
| write(buffer: Buffer, cb?: Function): boolean; | ||
| write(str: string, cb?: Function): boolean; | ||
| write(str: string, encoding: string, cb?: Function): boolean; | ||
| write(str: string, encoding?: string, fd?: string): boolean; | ||
| end(): void; | ||
| end(chunk: Buffer, cb?: Function): void; | ||
| end(chunk: string, cb?: Function): void; | ||
| end(chunk: string, encoding: string, cb?: Function): void; | ||
| pause(): void; | ||
| resume(): void; | ||
| abort(): void; | ||
| destroy(): void; | ||
| toJSON(): Object; | ||
| } | ||
| export interface Headers { | ||
| [key: string]: any; | ||
| } | ||
| export interface AuthOptions { | ||
| user?: string; | ||
| username?: string; | ||
| pass?: string; | ||
| password?: string; | ||
| sendImmediately?: boolean; | ||
| bearer?: string; | ||
| } | ||
| export interface OAuthOptions { | ||
| callback?: string; | ||
| consumer_key?: string; | ||
| consumer_secret?: string; | ||
| token?: string; | ||
| token_secret?: string; | ||
| verifier?: string; | ||
| } | ||
| export interface HawkOptions { | ||
| credentials: any; | ||
| } | ||
| export interface AWSOptions { | ||
| secret: string; | ||
| bucket?: string; | ||
| } | ||
| export interface CookieJar { | ||
| setCookie(cookie: Cookie, uri: string | url.Url, options?: any): void | ||
| getCookieString(uri: string | url.Url): string | ||
| getCookies(uri: string | url.Url): Cookie[] | ||
| } | ||
| export interface CookieValue { | ||
| name: string; | ||
| value: any; | ||
| httpOnly: boolean; | ||
| } | ||
| export interface Cookie extends Array<CookieValue> { | ||
| constructor(name: string, req: Request): void; | ||
| str: string; | ||
| expires: Date; | ||
| path: string; | ||
| toString(): string; | ||
| } | ||
| } | ||
| var request: request.RequestAPI<request.Request, request.CoreOptions, request.RequiredUriUrl>; | ||
| export = request; | ||
| } |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 4 instances in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
1
-88.89%1
-94.12%64144
-79.67%5
150%7
250%21
-32.26%1171
-82.39%116
-12.78%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
Updated
Updated