mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 23:07:06 +00:00
Merged branch master into master
This commit is contained in:
@@ -180,6 +180,8 @@ function test_collection() {
|
||||
|
||||
var alphabetical = books.sortBy((book: Book): number => null);
|
||||
|
||||
var copy = books.clone();
|
||||
|
||||
let one: Book;
|
||||
let models: Book[];
|
||||
let bool: boolean;
|
||||
|
||||
Vendored
+1
@@ -235,6 +235,7 @@ declare namespace Backbone {
|
||||
**/
|
||||
get(id: number|string|Model): TModel;
|
||||
has(key: number|string|Model): boolean;
|
||||
clone(): this;
|
||||
create(attributes: any, options?: ModelSaveOptions): TModel;
|
||||
pluck(attribute: string): any[];
|
||||
push(model: TModel, options?: AddOptions): TModel;
|
||||
|
||||
Vendored
+4
-4
@@ -54,22 +54,22 @@ export interface CommonWrapper<P = {}, S = {}> {
|
||||
/**
|
||||
* Returns whether or not the current wrapper has a node anywhere in it's render tree that looks like the one passed in.
|
||||
*/
|
||||
contains(node: ReactElement<any> | string): boolean;
|
||||
contains(node: ReactElement<any> | Array<ReactElement<any>> | string): boolean;
|
||||
|
||||
/**
|
||||
* Returns whether or not a given react element exists in the shallow render tree.
|
||||
*/
|
||||
containsMatchingElement(node: ReactElement<any>): boolean;
|
||||
containsMatchingElement(node: ReactElement<any> | Array<ReactElement<any>>): boolean;
|
||||
|
||||
/**
|
||||
* Returns whether or not all the given react elements exists in the shallow render tree
|
||||
*/
|
||||
containsAllMatchingElements(nodes: Array<ReactElement<any>>): boolean;
|
||||
containsAllMatchingElements(nodes: Array<ReactElement<any>> | Array<Array<ReactElement<any>>>): boolean;
|
||||
|
||||
/**
|
||||
* Returns whether or not one of the given react elements exists in the shallow render tree.
|
||||
*/
|
||||
containsAnyMatchingElements(nodes: Array<ReactElement<any>>): boolean;
|
||||
containsAnyMatchingElements(nodes: Array<ReactElement<any>> | Array<Array<ReactElement<any>>>): boolean;
|
||||
|
||||
/**
|
||||
* Returns whether or not the current render tree is equal to the given node, based on the expected value.
|
||||
|
||||
@@ -3,7 +3,12 @@ import expform = require("express-formidable");
|
||||
|
||||
const app = express();
|
||||
|
||||
app.use("/form1", expform());
|
||||
app.use("/form1", expform(), (req, res, next) => {
|
||||
console.log(req.fields);
|
||||
console.log(req.files);
|
||||
next();
|
||||
});
|
||||
|
||||
app.use("/form2", expform({
|
||||
encoding: "utf-8",
|
||||
uploadDir: "./uploads",
|
||||
|
||||
Vendored
+17
-4
@@ -1,10 +1,21 @@
|
||||
// Type definitions for express-formidable 1.0.0
|
||||
// Type definitions for express-formidable 1.0
|
||||
// Project: https://github.com/noraesae/express-formidable
|
||||
// Definitions by: Torkild Dyvik Olsen <https://github.com/tdolsen>
|
||||
// Definitions by: Torkild Dyvik Olsen <https://github.com/tdolsen>, Evan Shortiss <https://github.com/evanshortiss>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
import { RequestHandler } from "express";
|
||||
import * as express from "express";
|
||||
import { Fields, Files } from "formidable";
|
||||
|
||||
// Extend the express request object with attached formidable files and fields
|
||||
declare global {
|
||||
namespace Express {
|
||||
interface Request {
|
||||
fields?: Fields;
|
||||
files?: Files;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
interface ExpressFormidableOptions {
|
||||
encoding?: string;
|
||||
@@ -17,6 +28,8 @@ interface ExpressFormidableOptions {
|
||||
multiples?: boolean;
|
||||
}
|
||||
|
||||
declare function ExpressFormidable(options?: ExpressFormidableOptions): RequestHandler;
|
||||
declare function ExpressFormidable(options?: ExpressFormidableOptions): express.RequestHandler;
|
||||
|
||||
declare namespace ExpressFormidable {}
|
||||
|
||||
export = ExpressFormidable;
|
||||
|
||||
@@ -20,4 +20,4 @@
|
||||
"index.d.ts",
|
||||
"express-formidable-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,79 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"adjacent-overload-signatures": false,
|
||||
"array-type": false,
|
||||
"arrow-return-shorthand": false,
|
||||
"ban-types": false,
|
||||
"callable-types": false,
|
||||
"comment-format": false,
|
||||
"dt-header": false,
|
||||
"eofline": false,
|
||||
"export-just-namespace": false,
|
||||
"import-spacing": false,
|
||||
"interface-name": false,
|
||||
"interface-over-type-literal": false,
|
||||
"jsdoc-format": false,
|
||||
"max-line-length": false,
|
||||
"member-access": false,
|
||||
"new-parens": false,
|
||||
"no-any-union": false,
|
||||
"no-boolean-literal-compare": false,
|
||||
"no-conditional-assignment": false,
|
||||
"no-consecutive-blank-lines": false,
|
||||
"no-construct": false,
|
||||
"no-declare-current-package": false,
|
||||
"no-duplicate-imports": false,
|
||||
"no-duplicate-variable": false,
|
||||
"no-empty-interface": false,
|
||||
"no-for-in-array": false,
|
||||
"no-inferrable-types": false,
|
||||
"no-internal-module": false,
|
||||
"no-irregular-whitespace": false,
|
||||
"no-mergeable-namespace": false,
|
||||
"no-misused-new": false,
|
||||
"no-namespace": false,
|
||||
"no-object-literal-type-assertion": false,
|
||||
"no-padding": false,
|
||||
"no-redundant-jsdoc": false,
|
||||
"no-redundant-jsdoc-2": false,
|
||||
"no-redundant-undefined": false,
|
||||
"no-reference-import": false,
|
||||
"no-relative-import-in-test": false,
|
||||
"no-self-import": false,
|
||||
"no-single-declare-module": false,
|
||||
"no-string-throw": false,
|
||||
"no-unnecessary-callback-wrapper": false,
|
||||
"no-unnecessary-class": false,
|
||||
"no-unnecessary-generics": false,
|
||||
"no-unnecessary-qualifier": false,
|
||||
"no-unnecessary-type-assertion": false,
|
||||
"no-useless-files": false,
|
||||
"no-var-keyword": false,
|
||||
"no-var-requires": false,
|
||||
"no-void-expression": false,
|
||||
"no-trailing-whitespace": false,
|
||||
"object-literal-key-quotes": false,
|
||||
"object-literal-shorthand": false,
|
||||
"one-line": false,
|
||||
"one-variable-per-declaration": false,
|
||||
"only-arrow-functions": false,
|
||||
"prefer-conditional-expression": false,
|
||||
"prefer-const": false,
|
||||
"prefer-declare-function": false,
|
||||
"prefer-for-of": false,
|
||||
"prefer-method-signature": false,
|
||||
"prefer-template": false,
|
||||
"radix": false,
|
||||
"semicolon": false,
|
||||
"space-before-function-paren": false,
|
||||
"space-within-parens": false,
|
||||
"strict-export-declare-modifiers": false,
|
||||
"trim-file": false,
|
||||
"triple-equals": false,
|
||||
"typedef-whitespace": false,
|
||||
"unified-signatures": false,
|
||||
"void-return": false,
|
||||
"whitespace": false
|
||||
}
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
import * as find from "find";
|
||||
|
||||
const stringPattern = ".d.ts";
|
||||
const regexPattern = /ts(config|lint)\.json/;
|
||||
const rootDir = ".";
|
||||
|
||||
const emptyCb = (): void => { };
|
||||
const errorCb = (err: Error): void => { };
|
||||
const stringArrayCallback = (paths: string[]): void => { };
|
||||
const singleStringCb = (paths: string): void => { };
|
||||
|
||||
find.file(rootDir, (dirs: string[]): void => { }).error(emptyCb); // $ExpectType void
|
||||
find.file(rootDir, (dirs: string[]): void => { }).error(errorCb); // $ExpectType void
|
||||
find.file(stringPattern, rootDir, (dirs: string[]): void => { }).error(errorCb); // $ExpectType void
|
||||
find.file(regexPattern, rootDir, (dirs: string[]): void => { }).error(errorCb); // $ExpectType void
|
||||
find.fileSync(rootDir); // $ExpectType string[]
|
||||
find.fileSync(stringPattern, rootDir); // $ExpectType string[]
|
||||
find.fileSync(regexPattern, rootDir); // $ExpectType string[]
|
||||
find.eachFile(rootDir, singleStringCb).end(emptyCb).error(errorCb).end(emptyCb); // $ExpectType FindEachStream
|
||||
find.eachFile(stringPattern, rootDir, singleStringCb).end(emptyCb).error(errorCb).end(emptyCb); // $ExpectType FindEachStream
|
||||
find.eachFile(regexPattern, rootDir, singleStringCb).end(emptyCb).error(errorCb).end(emptyCb); // $ExpectType FindEachStream
|
||||
|
||||
find.dir(stringPattern, rootDir, (dirs: string[]): void => { }).error(emptyCb); // $ExpectType void
|
||||
find.dir(stringPattern, rootDir, (dirs: string[]): void => { }).error(errorCb); // $ExpectType void
|
||||
find.dir(regexPattern, rootDir, (dirs: string[]): void => { }).error(errorCb); // $ExpectType void
|
||||
find.dir(rootDir, (dirs: string[]): void => { }).error(errorCb); // $ExpectType void
|
||||
find.dirSync(rootDir); // $ExpectType string[]
|
||||
find.dirSync(stringPattern, rootDir); // $ExpectType string[]
|
||||
find.dirSync(regexPattern, rootDir); // $ExpectType string[]
|
||||
find.eachDir(rootDir, singleStringCb).end(emptyCb).error(errorCb).end(emptyCb); // $ExpectType FindEachStream
|
||||
find.eachDir(stringPattern, rootDir, singleStringCb).end(emptyCb).error(errorCb).end(emptyCb); // $ExpectType FindEachStream
|
||||
find.eachDir(regexPattern, rootDir, singleStringCb).end(emptyCb).error(errorCb).end(emptyCb); // $ExpectType FindEachStream
|
||||
Vendored
+116
@@ -0,0 +1,116 @@
|
||||
// Type definitions for find 0.2
|
||||
// Project: https://github.com/yuanchuan/find#readme
|
||||
// Definitions by: Andrey Lalev <https://github.com/andypyrope>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export interface AsyncFindStream {
|
||||
/**
|
||||
* Handling errors in asynchronous interfaces.
|
||||
* @param callback The callback that is called upon an error
|
||||
*/
|
||||
error(callback: (() => void) | ((err: Error) => void)): void;
|
||||
}
|
||||
|
||||
export interface FindEachStream {
|
||||
/**
|
||||
* Handling errors in asynchronous interfaces.
|
||||
* @param callback The callback that is called upon an error
|
||||
*/
|
||||
error(callback: (() => void) | ((err: Error) => void)): FindEachStream;
|
||||
|
||||
/**
|
||||
* Detect end in find.eachfile and find.eachdir.
|
||||
* @param callback The callback called at the end of find.eachfile and find.eachdir
|
||||
*/
|
||||
end(callback: () => void): FindEachStream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find all files in a given directory asynchronously.
|
||||
* @param root The root directory
|
||||
* @param callback A callback that accepts an array of the found files
|
||||
*/
|
||||
export function file(root: string, callback: (files: string[]) => void): AsyncFindStream;
|
||||
|
||||
/**
|
||||
* Find all files that match a glob pattern in a given directory asynchronously.
|
||||
* @param pattern The pattern to filter the files with
|
||||
* @param root The root directory
|
||||
* @param callback A callback that accepts an array of the found files
|
||||
*/
|
||||
export function file(pattern: string | RegExp, root: string, callback: (files: string[]) => void): AsyncFindStream;
|
||||
|
||||
/**
|
||||
* Find all files in a given directory asynchronously.
|
||||
* @param root The root directory
|
||||
* @param callback A callback that accepts each file separately
|
||||
*/
|
||||
export function eachFile(root: string, callback: (file: string) => void): FindEachStream;
|
||||
|
||||
/**
|
||||
* Find all files that match a glob pattern in a given directory asynchronously.
|
||||
* @param pattern The pattern to filter the files with
|
||||
* @param root The root directory
|
||||
* @param callback A callback that accepts an array of the found files
|
||||
*/
|
||||
export function eachFile(pattern: string | RegExp, root: string, callback: (file: string) => void): FindEachStream;
|
||||
|
||||
/**
|
||||
* Find all files in a given directory synchronously.
|
||||
* @param root The root directory
|
||||
* @returns The files that have been found
|
||||
*/
|
||||
export function fileSync(root: string): string[];
|
||||
|
||||
/**
|
||||
* Find all files that match a glob pattern in a given directory synchronously.
|
||||
* @param pattern The pattern to filter the files with
|
||||
* @param root The root directory
|
||||
* @returns The files that have been found
|
||||
*/
|
||||
export function fileSync(pattern: string | RegExp, root: string): string[];
|
||||
|
||||
/**
|
||||
* Find all directories in a given directory asynchronously.
|
||||
* @param root The root directory
|
||||
* @param callback A callback that accepts an array of the found directories
|
||||
*/
|
||||
export function dir(root: string, callback: (directories: string[]) => void): AsyncFindStream;
|
||||
|
||||
/**
|
||||
* Find all directories that match a glob pattern in a given directory asynchronously.
|
||||
* @param pattern The pattern to filter the directories with
|
||||
* @param root The root directory
|
||||
* @param callback A callback that accepts an array of the found directories
|
||||
*/
|
||||
export function dir(pattern: RegExp | string, root: string, callback: (directories: string[]) => void): AsyncFindStream;
|
||||
|
||||
/**
|
||||
* Find all directories in a given directory synchronously.
|
||||
* @param root The root directory
|
||||
* @returns The directories that have been found
|
||||
*/
|
||||
export function dirSync(root: string): string[];
|
||||
|
||||
/**
|
||||
* Find all directories that match a glob pattern in a given directory synchronously.
|
||||
* @param pattern The pattern to filter the directories with
|
||||
* @param root The root directory
|
||||
* @returns The directories that have been found
|
||||
*/
|
||||
export function dirSync(pattern: string | RegExp, root: string): string[];
|
||||
|
||||
/**
|
||||
* Find all directories in a given directory asynchronously.
|
||||
* @param root The root directory
|
||||
* @param callback A callback that accepts each of the found directories separately
|
||||
*/
|
||||
export function eachDir(root: string, callback: (directory: string) => void): FindEachStream;
|
||||
|
||||
/**
|
||||
* Find all directories that match a glob pattern in a given directory asynchronously.
|
||||
* @param pattern The pattern to filter the directories with
|
||||
* @param root The root directory
|
||||
* @param callback A callback that accepts each of the found directories separately
|
||||
*/
|
||||
export function eachDir(pattern: string | RegExp, root: string, callback: (directory: string) => void): FindEachStream;
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"find-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+3
-1
@@ -28,11 +28,13 @@ export interface ExecutionContext {
|
||||
|
||||
/**
|
||||
* The result of execution. `data` is the result of executing the
|
||||
* query, `errors` is null if no errors occurred, and is a
|
||||
* query, `extensions` represents additional metadata, `errors` is
|
||||
* null if no errors occurred, and is a
|
||||
* non-empty array if an error occurred.
|
||||
*/
|
||||
export interface ExecutionResult {
|
||||
data?: { [key: string]: any };
|
||||
extensions?: { [key: string]: any };
|
||||
errors?: GraphQLError[];
|
||||
}
|
||||
|
||||
|
||||
Vendored
+1
@@ -8,6 +8,7 @@
|
||||
// Mikhail Novikov <https://github.com/freiksenet>
|
||||
// Ivan Goncharov <https://github.com/IvanGoncharov>
|
||||
// Hagai Cohen <https://github.com/DxCx>
|
||||
// Ricardo Portugal <https://github.com/rportugal>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import cleanDest = require("gulp-clean-dest");
|
||||
|
||||
const someDir = ".";
|
||||
|
||||
// $ExpectType ReadWriteStream
|
||||
cleanDest(someDir);
|
||||
cleanDest(someDir, {});
|
||||
cleanDest(someDir, { cwd: someDir });
|
||||
cleanDest(someDir, { extension: ".ts" });
|
||||
cleanDest(someDir, { cwd: someDir, extension: ".ts" });
|
||||
Vendored
+29
@@ -0,0 +1,29 @@
|
||||
// Type definitions for gulp-clean-dest 0.2
|
||||
// Project: https://github.com/clark800/gulp-clean-dest
|
||||
// Definitions by: Andrey Lalev <https://github.com/andypyrope>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
declare namespace gulpCleanDest {
|
||||
interface Options {
|
||||
/**
|
||||
* The working directory the folder is relative to.
|
||||
*/
|
||||
cwd?: string;
|
||||
|
||||
/**
|
||||
* Extension of the destination files. Useful if it differs from the original.
|
||||
*/
|
||||
extension?: string;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes files from the dest directory prior to building.
|
||||
* @param destination The name of the dest directory
|
||||
* @param options Options for the cleaning process
|
||||
*/
|
||||
declare function gulpCleanDest(destination: string, options?: gulpCleanDest.Options): NodeJS.ReadWriteStream;
|
||||
|
||||
export = gulpCleanDest;
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"gulp-clean-dest-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+585
-311
File diff suppressed because it is too large
Load Diff
+791
-89
File diff suppressed because it is too large
Load Diff
Vendored
+43
@@ -364,6 +364,49 @@ declare module "mongoose" {
|
||||
pass?: string;
|
||||
/** options for authentication (see http://mongodb.github.com/node-mongodb-native/api-generated/db.html#authenticate) */
|
||||
auth?: any;
|
||||
/** Use ssl connection (needs to have a mongod server with ssl support) (default: true) */
|
||||
ssl?: boolean;
|
||||
/** Number of connections in the connection pool for each server instance, set to 5 as default for legacy reasons. */
|
||||
sslValidate?: object;
|
||||
/** Reconnect on error (default: true) */
|
||||
poolSize?: number;
|
||||
/** Validate mongod server certificate against ca (needs to have a mongod server with ssl support, 2.4 or higher) */
|
||||
autoReconnect?: boolean;
|
||||
/** TCP KeepAlive on the socket with a X ms delay before start (default: 0). */
|
||||
keepAlive?: number;
|
||||
/** TCP Connection timeout setting (default: 0) */
|
||||
connectTimeoutMS?: number;
|
||||
/** TCP Socket timeout setting (default: 0) */
|
||||
socketTimeoutMS?: number;
|
||||
/** If the database authentication is dependent on another databaseName. */
|
||||
authSource?: string;
|
||||
/** Attempt to reconnect #times (default: 30) */
|
||||
retries?: number;
|
||||
/** Will wait # milliseconds between retries (default: 1000) */
|
||||
reconnectWait?: number;
|
||||
/** The name of the replicaset to connect to. */
|
||||
replicaSet?: string;
|
||||
/** The current value of the parameter native_parser */
|
||||
nativeParser?: boolean;
|
||||
/** Auth mechanism */
|
||||
authMechanism?: any;
|
||||
/** Specify a journal write concern (default: false). */
|
||||
journal?: boolean;
|
||||
/** The write concern */
|
||||
w?: number|string;
|
||||
/** The write concern timeout. */
|
||||
wTimeoutMS?: number;
|
||||
/** The ReadPreference mode as listed here: http://mongodb.github.io/node-mongodb-native/2.1/api/ReadPreference.html */
|
||||
readPreference?: string;
|
||||
/** An object representing read preference tags, see: http://mongodb.github.io/node-mongodb-native/2.1/api/ReadPreference.html */
|
||||
readPreferencetags?: object;
|
||||
|
||||
// TODO
|
||||
safe?: any;
|
||||
fsync?: any;
|
||||
rs_name?: any;
|
||||
slaveOk?: any;
|
||||
authdb?: any;
|
||||
}
|
||||
|
||||
/** See the node-mongodb-native driver instance for options that it understands. */
|
||||
|
||||
Vendored
+4
-4
@@ -981,8 +981,8 @@ declare namespace R {
|
||||
/**
|
||||
* Returns the larger of its two arguments.
|
||||
*/
|
||||
max(a: Ord, b: Ord): Ord;
|
||||
max(a: Ord): (b: Ord) => Ord;
|
||||
max<T extends Ord>(a: T, b: T): T;
|
||||
max<T extends Ord>(a: T): (b: T) => T;
|
||||
|
||||
/**
|
||||
* Takes a function and two values, and returns whichever value produces
|
||||
@@ -1084,8 +1084,8 @@ declare namespace R {
|
||||
/**
|
||||
* Returns the smaller of its two arguments.
|
||||
*/
|
||||
min(a: Ord, b: Ord): Ord;
|
||||
min(a: Ord): (b: Ord) => Ord;
|
||||
min<T extends Ord>(a: T, b: T): T;
|
||||
min<T extends Ord>(a: T): (b: T) => T;
|
||||
|
||||
/**
|
||||
* Takes a function and two values, and returns whichever value produces
|
||||
|
||||
@@ -1986,8 +1986,8 @@ class Rectangle {
|
||||
};
|
||||
|
||||
() => {
|
||||
const x: R.Ord = R.max(7, 3); // => 7
|
||||
const y: R.Ord = R.max("a", "z"); // => 'z'
|
||||
const x: number = R.max(7, 3); // => 7
|
||||
const y: string = R.max("a", "z"); // => 'z'
|
||||
};
|
||||
|
||||
() => {
|
||||
@@ -2017,8 +2017,8 @@ class Rectangle {
|
||||
};
|
||||
|
||||
() => {
|
||||
const x: R.Ord = R.min(9, 3); // => 3
|
||||
const y: R.Ord = R.min("a", "z"); // => 'a'
|
||||
const x: number = R.min(9, 3); // => 3
|
||||
const y: string = R.min("a", "z"); // => 'a'
|
||||
};
|
||||
|
||||
() => {
|
||||
|
||||
Vendored
+20
-21
@@ -1,6 +1,11 @@
|
||||
// Type definitions for request 2.0
|
||||
// Project: https://github.com/request/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 <https://github.com/joeskeen>, Christopher Currens <https://github.com/ccurrens>, Jon Stevens <https://github.com/lookfirst>
|
||||
// Definitions by: Carlos Ballesteros Velasco <https://github.com/soywiz>,
|
||||
// bonnici <https://github.com/bonnici>,
|
||||
// Bart van der Schoor <https://github.com/Bartvds>,
|
||||
// Joe Skeen <https://github.com/joeskeen>,
|
||||
// Christopher Currens <https://github.com/ccurrens>,
|
||||
// Jon Stevens <https://github.com/lookfirst>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
@@ -17,10 +22,7 @@ import FormData = require('form-data');
|
||||
import { Url } from 'url';
|
||||
|
||||
declare namespace request {
|
||||
export interface RequestAPI<TRequest extends Request,
|
||||
TOptions extends CoreOptions,
|
||||
TUriUrlOptions> {
|
||||
|
||||
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>;
|
||||
|
||||
@@ -65,9 +67,8 @@ declare namespace request {
|
||||
}
|
||||
|
||||
interface DefaultUriUrlRequestApi<TRequest extends Request,
|
||||
TOptions extends CoreOptions,
|
||||
TUriUrlOptions> extends RequestAPI<TRequest, TOptions, TUriUrlOptions> {
|
||||
|
||||
TOptions extends CoreOptions,
|
||||
TUriUrlOptions> extends RequestAPI<TRequest, TOptions, TUriUrlOptions> {
|
||||
defaults(options: TOptions): DefaultUriUrlRequestApi<TRequest, TOptions, OptionalUriUrl>;
|
||||
(callback?: RequestCallback): TRequest;
|
||||
|
||||
@@ -173,13 +174,11 @@ declare namespace request {
|
||||
export type OptionsWithUrl = UrlOptions & CoreOptions;
|
||||
export type Options = OptionsWithUri | OptionsWithUrl;
|
||||
|
||||
export interface RequestCallback {
|
||||
(error: any, response: RequestResponse, body: any): void;
|
||||
}
|
||||
export type RequestCallback = (error: any, response: RequestResponse, body: any) => void;
|
||||
|
||||
export type ResponseRequest = CoreOptions & {
|
||||
uri: Url;
|
||||
}
|
||||
};
|
||||
|
||||
export interface RequestResponse extends http.IncomingMessage {
|
||||
request: ResponseRequest;
|
||||
@@ -209,7 +208,7 @@ declare namespace request {
|
||||
postData?: {
|
||||
mimeType?: string;
|
||||
params?: NameValuePair[];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export interface NameValuePair {
|
||||
@@ -219,10 +218,10 @@ declare namespace request {
|
||||
|
||||
export interface Multipart {
|
||||
chunked?: boolean;
|
||||
data?: {
|
||||
data?: Array<{
|
||||
'content-type'?: string,
|
||||
body: string
|
||||
}[];
|
||||
}>;
|
||||
}
|
||||
|
||||
export interface RequestPart {
|
||||
@@ -235,8 +234,8 @@ declare namespace request {
|
||||
writable: boolean;
|
||||
|
||||
getAgent(): http.Agent;
|
||||
//start(): void;
|
||||
//abort(): void;
|
||||
// start(): void;
|
||||
// abort(): void;
|
||||
pipeDest(dest: any): void;
|
||||
setHeader(name: string, value: string, clobber?: boolean): Request;
|
||||
setHeaders(headers: Headers): Request;
|
||||
@@ -293,7 +292,7 @@ declare namespace request {
|
||||
token_secret?: string;
|
||||
transport_method?: 'body' | 'header' | 'query';
|
||||
verifier?: string;
|
||||
body_hash?: true | string
|
||||
body_hash?: true | string;
|
||||
}
|
||||
|
||||
export interface HawkOptions {
|
||||
@@ -306,9 +305,9 @@ declare namespace request {
|
||||
}
|
||||
|
||||
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[]
|
||||
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 {
|
||||
|
||||
+126
-131
@@ -1,10 +1,10 @@
|
||||
|
||||
import request = require('request');
|
||||
import http = require('http');
|
||||
import stream = require('stream');
|
||||
import urlModule = require('url');
|
||||
import fs = require('fs');
|
||||
import FormData = require('form-data');
|
||||
import path = require('path');
|
||||
|
||||
var value: any;
|
||||
var str: string;
|
||||
@@ -33,12 +33,12 @@ var bodyArr: request.RequestPart[] = [{
|
||||
body: value
|
||||
}];
|
||||
|
||||
//Defaults tests
|
||||
// Defaults tests
|
||||
(() => {
|
||||
const githubUrl = 'https://github.com';
|
||||
const defaultJarRequest = request.defaults({ jar: true });
|
||||
defaultJarRequest.get(githubUrl);
|
||||
//defaultJarRequest(); //this line doesn't compile (and shouldn't)
|
||||
// defaultJarRequest(); //this line doesn't compile (and shouldn't)
|
||||
const defaultUrlRequest = request.defaults({ url: githubUrl });
|
||||
defaultUrlRequest();
|
||||
defaultUrlRequest.get();
|
||||
@@ -48,7 +48,6 @@ var bodyArr: request.RequestPart[] = [{
|
||||
defaultBodyRequest.put();
|
||||
})();
|
||||
|
||||
|
||||
// --- --- --- --- --- --- --- --- --- --- --- ---
|
||||
|
||||
obj = req.toJSON();
|
||||
@@ -90,21 +89,15 @@ strOrTrueOrUndef = oauth.body_hash;
|
||||
var options: request.Options = {
|
||||
url: str,
|
||||
uri: str,
|
||||
callback: (error: any, response: any, body: any) => {
|
||||
|
||||
},
|
||||
callback: (error: any, response: any, body: any) => {},
|
||||
jar: value,
|
||||
form: obj,
|
||||
oauth: value,
|
||||
aws: aws,
|
||||
qs: obj,
|
||||
json: value,
|
||||
jsonReviver: (key: string, value: any) => {
|
||||
|
||||
},
|
||||
jsonReplacer: (key: string, value: any) => {
|
||||
|
||||
},
|
||||
jsonReviver: (key: string, value: any) => {},
|
||||
jsonReplacer: (key: string, value: any) => {},
|
||||
multipart: value,
|
||||
agent: new http.Agent(),
|
||||
agentOptions: value,
|
||||
@@ -139,8 +132,8 @@ opt.uri = str;
|
||||
// --- --- --- --- --- --- --- --- --- --- --- ---
|
||||
|
||||
agent = req.getAgent();
|
||||
//req.start();
|
||||
//req.abort();
|
||||
// req.start();
|
||||
// req.abort();
|
||||
req.pipeDest(dest);
|
||||
req = req.setHeader(str, str);
|
||||
req = req.setHeader(str, str, bool);
|
||||
@@ -241,14 +234,14 @@ r.post(options);
|
||||
|
||||
request
|
||||
.get('http://example.com/example.png')
|
||||
.on('response', function(response: any) {
|
||||
.on('response', (response: any) => {
|
||||
// check response
|
||||
})
|
||||
.pipe(request.put('http://another.com/another.png'));
|
||||
|
||||
//The following examples from https://github.com/request/request
|
||||
request('http://www.google.com', function (error, response, body) {
|
||||
if (!error && response.statusCode == 200) {
|
||||
// The following examples from https://github.com/request/request
|
||||
request('http://www.google.com', (error, response, body) => {
|
||||
if (!error && response.statusCode === 200) {
|
||||
console.log(body); // Show the HTML for the Google homepage.
|
||||
}
|
||||
});
|
||||
@@ -261,7 +254,7 @@ request.get('http://google.com/img.png').pipe(request.put('http://mysite.com/img
|
||||
|
||||
request
|
||||
.get('http://google.com/img.png')
|
||||
.on('response', function(response: any) {
|
||||
.on('response', (response: any) => {
|
||||
console.log(response.statusCode); // 200
|
||||
console.log(response.headers['content-type']); // 'image/png'
|
||||
})
|
||||
@@ -269,22 +262,25 @@ request
|
||||
|
||||
request
|
||||
.get('http://mysite.com/doodle.png')
|
||||
.on('error', function(err: any) {
|
||||
.on('error', (err: any) => {
|
||||
console.log(err);
|
||||
})
|
||||
.pipe(fs.createWriteStream('doodle.png'));
|
||||
|
||||
http.createServer(function (req, resp) {
|
||||
http.createServer((req, resp) => {
|
||||
if (req.url === '/doodle.png') {
|
||||
if (req.method === 'PUT') {
|
||||
req.pipe(request.put('http://mysite.com/doodle.png'));
|
||||
} else if (req.method === 'GET' || req.method === 'HEAD') {
|
||||
request.get('http://mysite.com/doodle.png').pipe(resp);
|
||||
switch (req.method) {
|
||||
case 'PUT':
|
||||
req.pipe(request.put('http://mysite.com/doodle.png'));
|
||||
break;
|
||||
case 'GET':
|
||||
case 'HEAD':
|
||||
request.get('http://mysite.com/doodle.png').pipe(resp);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
http.createServer(function (req, resp) {
|
||||
http.createServer((req, resp) => {
|
||||
if (req.url === '/doodle.png') {
|
||||
var x = request('http://mysite.com/doodle.png');
|
||||
req.pipe(x);
|
||||
@@ -292,21 +288,21 @@ http.createServer(function (req, resp) {
|
||||
}
|
||||
});
|
||||
|
||||
http.createServer(function (req, resp) {
|
||||
http.createServer((req, resp) => {
|
||||
req.pipe(request('http://mysite.com/doodle.png')).pipe(resp);
|
||||
});
|
||||
|
||||
http.createServer(function (req, resp) {
|
||||
http.createServer((req, resp) => {
|
||||
if (req.url === '/doodle.png') {
|
||||
r.get('http://google.com/doodle.png').pipe(resp);
|
||||
}
|
||||
});
|
||||
|
||||
request.post('http://service.com/upload', {form:{key:'value'}});
|
||||
request.post('http://service.com/upload', {form: {key: 'value'}});
|
||||
// or
|
||||
request.post('http://service.com/upload').form({key:'value'});
|
||||
request.post('http://service.com/upload').form({key: 'value'});
|
||||
// or
|
||||
request.post({url:'http://service.com/upload', form: {key:'value'}}, function(err,httpResponse,body){ /* ... */ });
|
||||
request.post({url: 'http://service.com/upload', form: {key: 'value'}}, (err, httpResponse, body) => { /* ... */ });
|
||||
|
||||
var data = {
|
||||
// Pass a simple key-value pair
|
||||
@@ -331,9 +327,10 @@ var data = {
|
||||
}
|
||||
}
|
||||
};
|
||||
request.post({url:'http://service.com/upload', formData: data}, function optionalCallback(err, httpResponse, body) {
|
||||
request.post({url: 'http://service.com/upload', formData: data}, function optionalCallback(err, httpResponse, body) {
|
||||
if (err) {
|
||||
return console.error('upload failed:', err);
|
||||
console.error('upload failed:', err);
|
||||
return;
|
||||
}
|
||||
console.log('Upload successful! Server responded with:', body);
|
||||
});
|
||||
@@ -354,15 +351,16 @@ request({
|
||||
data: [
|
||||
{
|
||||
'content-type': 'application/json',
|
||||
body: JSON.stringify({foo: 'bar', _attachments: {'message.txt': {follows: true, length: 18, 'content_type': 'text/plain' }}})
|
||||
body: JSON.stringify({foo: 'bar', _attachments: {'message.txt': {follows: true, length: 18, content_type: 'text/plain' }}})
|
||||
},
|
||||
{ body: 'I am an attachment' }
|
||||
]
|
||||
}
|
||||
},
|
||||
function (error, response, body) {
|
||||
(error, response, body) => {
|
||||
if (error) {
|
||||
return console.error('upload failed:', error);
|
||||
console.error('upload failed:', error);
|
||||
return;
|
||||
}
|
||||
console.log('Upload successful! Server responded with:', body);
|
||||
});
|
||||
@@ -374,15 +372,16 @@ request({
|
||||
multipart: [
|
||||
{
|
||||
headers: { 'content-type': 'application/json' },
|
||||
body: JSON.stringify({foo: 'bar', _attachments: {'message.txt': {follows: true, length: 18, 'content_type': 'text/plain' }}})
|
||||
body: JSON.stringify({foo: 'bar', _attachments: {'message.txt': {follows: true, length: 18, content_type: 'text/plain' }}})
|
||||
},
|
||||
{ body: 'I am an attachment' },
|
||||
{ body: fs.createReadStream('image.png') }
|
||||
]
|
||||
},
|
||||
function (error, response, body) {
|
||||
(error, response, body) => {
|
||||
if (error) {
|
||||
return console.error('upload failed:', error);
|
||||
console.error('upload failed:', error);
|
||||
return;
|
||||
}
|
||||
console.log('Upload successful! Server responded with:', body);
|
||||
});
|
||||
@@ -390,32 +389,32 @@ request({
|
||||
request.get('http://some.server.com/').auth('username', 'password', false);
|
||||
// or
|
||||
request.get('http://some.server.com/', {
|
||||
'auth': {
|
||||
'user': 'username',
|
||||
'pass': 'password',
|
||||
'sendImmediately': false
|
||||
auth: {
|
||||
user: 'username',
|
||||
pass: 'password',
|
||||
sendImmediately: false
|
||||
}
|
||||
});
|
||||
// or
|
||||
request.get('http://some.server.com/').auth('foo', 'bar', true, 'bearerToken');
|
||||
// or
|
||||
request.get('http://some.server.com/', {
|
||||
'auth': {
|
||||
'bearer': 'bearerToken'
|
||||
auth: {
|
||||
bearer: 'bearerToken'
|
||||
}
|
||||
});
|
||||
// or
|
||||
request.get('http://some.server.com/', {
|
||||
'auth': {
|
||||
'bearer': () => 'bearerToken'
|
||||
auth: {
|
||||
bearer: () => 'bearerToken'
|
||||
}
|
||||
});
|
||||
|
||||
var username = 'username',
|
||||
password = 'password',
|
||||
url = 'http://' + username + ':' + password + '@some.server.com';
|
||||
let username = 'username';
|
||||
let password = 'password';
|
||||
var url = `http://'${username}:${password}'@some.server.com`;
|
||||
|
||||
request({url: url}, function (error, response, body) {
|
||||
request({url: url}, (error, response, body) => {
|
||||
// Do more stuff with 'body' here
|
||||
});
|
||||
|
||||
@@ -427,7 +426,7 @@ options = {
|
||||
};
|
||||
|
||||
function callback(error: any, response: http.IncomingMessage, body: string) {
|
||||
if (!error && response.statusCode == 200) {
|
||||
if (!error && response.statusCode === 200) {
|
||||
var info = JSON.parse(body);
|
||||
console.log(info.stargazers_count + " Stars");
|
||||
console.log(info.forks_count + " Forks");
|
||||
@@ -441,15 +440,15 @@ request(options, callback);
|
||||
import qs = require('querystring');
|
||||
const CONSUMER_KEY = 'key';
|
||||
const CONSUMER_SECRET = 'secret';
|
||||
oauth =
|
||||
{ callback: 'http://mysite.com/callback/'
|
||||
, consumer_key: CONSUMER_KEY
|
||||
, consumer_secret: CONSUMER_SECRET
|
||||
, transport_method: 'header'
|
||||
}
|
||||
, url = 'https://api.twitter.com/oauth/request_token'
|
||||
;
|
||||
request.post({url:url, oauth:oauth}, function (e, r, body) {
|
||||
oauth = {
|
||||
callback: 'http://mysite.com/callback/',
|
||||
consumer_key: CONSUMER_KEY,
|
||||
consumer_secret: CONSUMER_SECRET,
|
||||
transport_method: 'header'
|
||||
};
|
||||
url = 'https://api.twitter.com/oauth/request_token';
|
||||
|
||||
request.post({url: url, oauth: oauth}, (e, r, body) => {
|
||||
// Ideally, you would take the body in the response
|
||||
// and construct a URL that a user clicks on (like a sign in button).
|
||||
// The verifier is only available in the response after a user has
|
||||
@@ -457,46 +456,44 @@ request.post({url:url, oauth:oauth}, function (e, r, body) {
|
||||
|
||||
// step 2
|
||||
var req_data = qs.parse(body);
|
||||
var uri = 'https://api.twitter.com/oauth/authenticate'
|
||||
+ '?' + qs.stringify({oauth_token: req_data.oauth_token});
|
||||
var uri = `https://api.twitter.com/oauth/authenticate?${qs.stringify({oauth_token: req_data.oauth_token})}`;
|
||||
// redirect the user to the authorize uri
|
||||
|
||||
// step 3
|
||||
// after the user is redirected back to your server
|
||||
var auth_data: any = qs.parse(body)
|
||||
, oauth =
|
||||
{ consumer_key: CONSUMER_KEY
|
||||
, consumer_secret: CONSUMER_SECRET
|
||||
, token: auth_data.oauth_token
|
||||
, token_secret: req_data.oauth_token_secret as string
|
||||
, verifier: auth_data.oauth_verifier
|
||||
}
|
||||
, url = 'https://api.twitter.com/oauth/access_token'
|
||||
;
|
||||
request.post({url:url, oauth:oauth}, function (e, r, body) {
|
||||
var auth_data: any = qs.parse(body);
|
||||
var oauth = {
|
||||
consumer_key: CONSUMER_KEY,
|
||||
consumer_secret: CONSUMER_SECRET,
|
||||
token: auth_data.oauth_token,
|
||||
token_secret: req_data.oauth_token_secret as string,
|
||||
verifier: auth_data.oauth_verifier
|
||||
};
|
||||
var url = 'https://api.twitter.com/oauth/access_token';
|
||||
|
||||
request.post({url: url, oauth: oauth}, (e, r, body) => {
|
||||
// ready to make signed requests on behalf of the user
|
||||
var perm_data: any = qs.parse(body);
|
||||
var oauth =
|
||||
{ consumer_key: CONSUMER_KEY
|
||||
, consumer_secret: CONSUMER_SECRET
|
||||
, token: perm_data.oauth_token
|
||||
, token_secret: perm_data.oauth_token_secret
|
||||
};
|
||||
var oauth = {
|
||||
consumer_key: CONSUMER_KEY,
|
||||
consumer_secret: CONSUMER_SECRET,
|
||||
token: perm_data.oauth_token,
|
||||
token_secret: perm_data.oauth_token_secret
|
||||
};
|
||||
var url = 'https://api.twitter.com/1.1/users/show.json';
|
||||
var query = {
|
||||
screen_name: perm_data.screen_name,
|
||||
user_id: perm_data.user_id
|
||||
};
|
||||
request.get({url:url, oauth:oauth, qs:query, json:true}, function (e, r, user) {
|
||||
request.get({url: url, oauth: oauth, qs: query, json: true}, (e, r, user) => {
|
||||
console.log(user);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
var path = require('path')
|
||||
, certFile = path.resolve(__dirname, 'ssl/client.crt')
|
||||
, keyFile = path.resolve(__dirname, 'ssl/client.key')
|
||||
, caFile = path.resolve(__dirname, 'ssl/ca.cert.pem');
|
||||
var certFile = path.resolve(__dirname, 'ssl/client.crt');
|
||||
var keyFile = path.resolve(__dirname, 'ssl/client.key');
|
||||
var caFile = path.resolve(__dirname, 'ssl/ca.cert.pem');
|
||||
|
||||
options = {
|
||||
url: 'https://api.some-server.com/',
|
||||
@@ -508,9 +505,8 @@ options = {
|
||||
|
||||
request.get(options);
|
||||
|
||||
var path = require('path')
|
||||
, certFile = path.resolve(__dirname, 'ssl/client.crt')
|
||||
, keyFile = path.resolve(__dirname, 'ssl/client.key');
|
||||
var certFile = path.resolve(__dirname, 'ssl/client.crt');
|
||||
var keyFile = path.resolve(__dirname, 'ssl/client.key');
|
||||
|
||||
options = {
|
||||
url: 'https://api.some-server.com/',
|
||||
@@ -540,7 +536,6 @@ request.get({
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
request({
|
||||
// will be ignored
|
||||
method: 'GET',
|
||||
@@ -572,19 +567,19 @@ request({
|
||||
}
|
||||
});
|
||||
|
||||
//requests using baseRequest() will set the 'x-token' header
|
||||
// requests using baseRequest() will set the 'x-token' header
|
||||
var baseRequest = request.defaults({
|
||||
headers: {'x-token': 'my-token'}
|
||||
});
|
||||
|
||||
//requests using specialRequest() will include the 'x-token' header set in
|
||||
//baseRequest and will also include the 'special' header
|
||||
// requests using specialRequest() will include the 'x-token' header set in
|
||||
// baseRequest and will also include the 'special' header
|
||||
var specialRequest = baseRequest.defaults({
|
||||
headers: {special: 'special value'}
|
||||
});
|
||||
|
||||
const urlRequest = specialRequest.defaults({url: 'https://github.com'});
|
||||
urlRequest({}, function(error, response, body) {console.log(body);});
|
||||
urlRequest({}, (error, response, body) => { console.log(body); });
|
||||
|
||||
request.put(url);
|
||||
request.patch(url);
|
||||
@@ -597,7 +592,7 @@ request.cookie('key1=value1');
|
||||
request.jar();
|
||||
request.debug = true;
|
||||
|
||||
request.get('http://10.255.255.1', {timeout: 1500}, function(err) {
|
||||
request.get('http://10.255.255.1', {timeout: 1500}, (err) => {
|
||||
console.log(err.code === 'ETIMEDOUT');
|
||||
// Set to `true` if the timeout was a connection timeout, `false` or
|
||||
// `undefined` otherwise.
|
||||
@@ -605,23 +600,23 @@ request.get('http://10.255.255.1', {timeout: 1500}, function(err) {
|
||||
process.exit(0);
|
||||
});
|
||||
|
||||
var rand = Math.floor(Math.random()*100000000).toString();
|
||||
var rand = Math.floor(Math.random() * 100000000).toString();
|
||||
request(
|
||||
{ method: 'PUT'
|
||||
, uri: 'http://mikeal.iriscouch.com/testjs/' + rand
|
||||
, multipart:
|
||||
[ { headers: { 'content-type': 'application/json' }
|
||||
, body: JSON.stringify({foo: 'bar', _attachments: {'message.txt': {follows: true, length: 18, 'content_type': 'text/plain' }}})
|
||||
, body: JSON.stringify({foo: 'bar', _attachments: {'message.txt': {follows: true, length: 18, content_type: 'text/plain' }}})
|
||||
}
|
||||
, { body: 'I am an attachment' }
|
||||
]
|
||||
}
|
||||
, function (error, response, body) {
|
||||
if(response.statusCode == 201){
|
||||
console.log('document saved as: http://mikeal.iriscouch.com/testjs/'+ rand)
|
||||
, (error, response, body) => {
|
||||
if (response.statusCode === 201) {
|
||||
console.log('document saved as: http://mikeal.iriscouch.com/testjs/' + rand);
|
||||
} else {
|
||||
console.log('error: '+ response.statusCode)
|
||||
console.log(body)
|
||||
console.log('error: ' + response.statusCode);
|
||||
console.log(body);
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -631,31 +626,31 @@ request(
|
||||
, uri: 'http://www.google.com'
|
||||
, gzip: true
|
||||
}
|
||||
, function (error, response, body) {
|
||||
, (error, response, body) => {
|
||||
// body is the decompressed response body
|
||||
console.log('server encoded the data as: ' + (response.headers['content-encoding'] || 'identity'))
|
||||
console.log('the decoded data is: ' + body)
|
||||
console.log('server encoded the data as: ' + (response.headers['content-encoding'] || 'identity'));
|
||||
console.log('the decoded data is: ' + body);
|
||||
}
|
||||
).on('data', function(data: any) {
|
||||
).on('data', (data: any) => {
|
||||
// decompressed data as it is received
|
||||
console.log('decoded chunk: ' + data)
|
||||
console.log('decoded chunk: ' + data);
|
||||
})
|
||||
.on('response', function(response: http.IncomingMessage) {
|
||||
.on('response', (response: http.IncomingMessage) => {
|
||||
// unmodified http.IncomingMessage object
|
||||
response.on('data', function(data: any[]) {
|
||||
response.on('data', (data: any[]) => {
|
||||
// compressed data as it is received
|
||||
console.log('received ' + data.length + ' bytes of compressed data')
|
||||
})
|
||||
console.log(`received ${data.length} bytes of compressed data`);
|
||||
});
|
||||
});
|
||||
|
||||
var requestWithJar = request.defaults({jar: true})
|
||||
requestWithJar('http://www.google.com', function () {
|
||||
var requestWithJar = request.defaults({jar: true});
|
||||
requestWithJar('http://www.google.com', () => {
|
||||
requestWithJar('http://images.google.com');
|
||||
});
|
||||
|
||||
var j = request.jar()
|
||||
requestWithJar = request.defaults({jar:j})
|
||||
requestWithJar('http://www.google.com', function () {
|
||||
var j = request.jar();
|
||||
requestWithJar = request.defaults({jar: j});
|
||||
requestWithJar('http://www.google.com', () => {
|
||||
requestWithJar('http://images.google.com');
|
||||
});
|
||||
|
||||
@@ -663,21 +658,21 @@ var j = request.jar();
|
||||
cookie = request.cookie('key1=value1');
|
||||
var url = 'http://www.google.com';
|
||||
j.setCookie(cookie, url);
|
||||
request({url: url, jar: j}, function () {
|
||||
request({url: url, jar: j}, () => {
|
||||
request('http://images.google.com');
|
||||
});
|
||||
|
||||
//TODO: add definitions for tough-cookie-filestore
|
||||
//var FileCookieStore = require('tough-cookie-filestore');
|
||||
// TODO: add definitions for tough-cookie-filestore
|
||||
// var FileCookieStore = require('tough-cookie-filestore');
|
||||
// NOTE - currently the 'cookies.json' file must already exist!
|
||||
//var j = request.jar(new FileCookieStore('cookies.json'));
|
||||
requestWithJar = request.defaults({ jar : j })
|
||||
request('http://www.google.com', function() {
|
||||
// var j = request.jar(new FileCookieStore('cookies.json'));
|
||||
requestWithJar = request.defaults({ jar : j });
|
||||
request('http://www.google.com', () => {
|
||||
request('http://images.google.com');
|
||||
});
|
||||
|
||||
var j = request.jar()
|
||||
request({url: 'http://www.google.com', jar: j}, function () {
|
||||
var j = request.jar();
|
||||
request({url: 'http://www.google.com', jar: j}, () => {
|
||||
var cookie_string = j.getCookieString(url); // "key1=value1; key2=value2; ..."
|
||||
var cookies = j.getCookies(url);
|
||||
// [{key: 'key1', value: 'value1', domain: "www.google.com", ...}, ...]
|
||||
@@ -689,11 +684,11 @@ request(
|
||||
, gzip: true
|
||||
}
|
||||
)
|
||||
.on('request', function(req: http.ClientRequest) { })
|
||||
.on('response', function(resp: http.IncomingMessage) { })
|
||||
.on('data', function(data: Buffer | string) { })
|
||||
.on('error', function(e: Error) { })
|
||||
.on('complete', function(resp: http.IncomingMessage, body?: string | Buffer) { });
|
||||
.on('request', (req: http.ClientRequest) => { })
|
||||
.on('response', (resp: http.IncomingMessage) => { })
|
||||
.on('data', (data: Buffer | string) => { })
|
||||
.on('error', (e: Error) => { })
|
||||
.on('complete', (resp: http.IncomingMessage, body?: string | Buffer) => { });
|
||||
|
||||
// options.url / options.uri can be the Url object
|
||||
request.get({
|
||||
@@ -720,11 +715,11 @@ requestWithOptionalUri({ url: urlModule.parse('http://example.com') });
|
||||
|
||||
requestWithOptionalUri('http://example.com');
|
||||
|
||||
requestWithOptionalUri(function() {});
|
||||
requestWithOptionalUri(() => {});
|
||||
|
||||
requestWithOptionalUri.get();
|
||||
|
||||
requestWithOptionalUri.get(function() {});
|
||||
requestWithOptionalUri.get(() => {});
|
||||
|
||||
requestWithOptionalUri.get('http://example.com');
|
||||
|
||||
|
||||
@@ -1,81 +1,14 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"adjacent-overload-signatures": false,
|
||||
"array-type": false,
|
||||
"arrow-return-shorthand": false,
|
||||
"ban-comma-operator": false,
|
||||
"ban-types": false,
|
||||
"callable-types": false,
|
||||
"comment-format": false,
|
||||
"dt-header": false,
|
||||
"eofline": false,
|
||||
"export-just-namespace": false,
|
||||
"import-spacing": false,
|
||||
"interface-name": false,
|
||||
"interface-over-type-literal": false,
|
||||
"jsdoc-format": false,
|
||||
"max-line-length": false,
|
||||
"member-access": false,
|
||||
"new-parens": false,
|
||||
"no-any-union": false,
|
||||
"no-boolean-literal-compare": false,
|
||||
"no-conditional-assignment": false,
|
||||
"no-consecutive-blank-lines": false,
|
||||
"no-construct": false,
|
||||
"no-declare-current-package": false,
|
||||
"no-duplicate-imports": false,
|
||||
"no-duplicate-variable": false,
|
||||
"no-empty-interface": false,
|
||||
"no-for-in-array": false,
|
||||
"no-inferrable-types": false,
|
||||
"no-internal-module": false,
|
||||
"no-irregular-whitespace": false,
|
||||
"no-mergeable-namespace": false,
|
||||
"no-misused-new": false,
|
||||
"no-namespace": false,
|
||||
"no-object-literal-type-assertion": false,
|
||||
"no-padding": false,
|
||||
"no-redundant-jsdoc": false,
|
||||
"no-redundant-jsdoc-2": false,
|
||||
"no-redundant-undefined": false,
|
||||
"no-reference-import": false,
|
||||
"no-relative-import-in-test": false,
|
||||
"no-self-import": false,
|
||||
"no-single-declare-module": false,
|
||||
"no-string-throw": false,
|
||||
"no-unnecessary-callback-wrapper": false,
|
||||
"no-unnecessary-class": false,
|
||||
"no-unnecessary-generics": false,
|
||||
"no-unnecessary-qualifier": false,
|
||||
"no-unnecessary-type-assertion": false,
|
||||
"no-useless-files": false,
|
||||
"no-var-keyword": false,
|
||||
"no-var-requires": false,
|
||||
"no-void-expression": false,
|
||||
"no-trailing-whitespace": false,
|
||||
"object-literal-key-quotes": false,
|
||||
"object-literal-shorthand": false,
|
||||
"one-line": false,
|
||||
"one-variable-per-declaration": false,
|
||||
"only-arrow-functions": false,
|
||||
"prefer-conditional-expression": false,
|
||||
"prefer-const": false,
|
||||
"prefer-declare-function": false,
|
||||
"prefer-for-of": false,
|
||||
"prefer-method-signature": false,
|
||||
"prefer-switch": false,
|
||||
"prefer-template": false,
|
||||
"radix": false,
|
||||
"semicolon": false,
|
||||
"space-before-function-paren": false,
|
||||
"space-within-parens": false,
|
||||
"strict-export-declare-modifiers": false,
|
||||
"trim-file": false,
|
||||
"triple-equals": false,
|
||||
"typedef-whitespace": false,
|
||||
"unified-signatures": false,
|
||||
"void-return": false,
|
||||
"whitespace": false
|
||||
"unified-signatures": false
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -244,7 +244,7 @@ declare module "rethinkdb" {
|
||||
insert(obj: any[], options?: InsertOptions): Operation<WriteResult>;
|
||||
insert(obj: any, options?: InsertOptions): Operation<WriteResult>;
|
||||
|
||||
get<TObjectType extends object>(key: string): Operation<TObjectType | null>;
|
||||
get<TObjectType extends object>(key: string): Operation<TObjectType | null> & Writeable;
|
||||
getAll(key: string, index?: Index): Sequence; // without index defaults to primary key
|
||||
getAll(...keys: string[]): Sequence;
|
||||
wait(WaitOptions?: WaitOptions): WaitResult;
|
||||
|
||||
Vendored
+4
-1
@@ -1058,12 +1058,15 @@ declare module _ {
|
||||
* @param list The sorted list.
|
||||
* @param value The value to determine its index within `list`.
|
||||
* @param iterator Iterator to compute the sort ranking of each value, optional.
|
||||
* @param context `this` object in `iterator`, optional.
|
||||
* @return The index where `value` should be inserted into `list`.
|
||||
**/
|
||||
sortedIndex<T, TSort>(
|
||||
list: _.List<T>,
|
||||
value: T,
|
||||
iterator?: (x: T) => TSort, context?: any): number;
|
||||
iterator?: ((x: T) => TSort) | string,
|
||||
context?: any
|
||||
): number;
|
||||
|
||||
/**
|
||||
* A function to create flexibly-numbered lists of integers, handy for each and map loops. start, if omitted,
|
||||
|
||||
@@ -21,4 +21,4 @@
|
||||
"index.d.ts",
|
||||
"underscore-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user