Merge remote-tracking branch 'upstream/master' into office-js-outlook-sep-updates

This commit is contained in:
Elizabeth Samuel
2018-09-19 08:31:27 -07:00
125 changed files with 7352 additions and 5784 deletions
+4952 -4869
View File
File diff suppressed because it is too large Load Diff
+6
View File
@@ -174,6 +174,12 @@
"sourceRepoURL": "https://github.com/Microsoft/Bing-Maps-V8-TypeScript-Definitions",
"asOfVersion": "2.0.15"
},
{
"libraryName": "bitwise",
"typingsPackageName": "bitwise",
"sourceRepoURL": "https://github.com/dodekeract/bitwise",
"asOfVersion": "2.0.0"
},
{
"libraryName": "botvs",
"typingsPackageName": "botvs",
+1 -1
View File
@@ -1316,7 +1316,7 @@ declare namespace angular {
*
* @param key the key of the data to be retrieved
*/
get<T>(key: string): T;
get<T>(key: string): T | undefined;
/**
* Removes an entry from the Cache object.
@@ -27,3 +27,6 @@ const mockContext = {
};
awsServerlessExpress.proxy(server, mockEvent, mockContext);
awsServerlessExpress.proxy(server, mockEvent, mockContext, 'CALLBACK', () => {});
awsServerlessExpress.proxy(server, mockEvent, mockContext, 'CONTEXT_SUCCEED');
awsServerlessExpress.proxy(server, mockEvent, mockContext, 'PROMISE').promise.then((response: awsServerlessExpress.Response) => {}).catch(err => {});
+34 -2
View File
@@ -1,4 +1,4 @@
// Type definitions for aws-serverless-express 3.0
// Type definitions for aws-serverless-express 3.3
// Project: https://github.com/awslabs/aws-serverless-express
// Definitions by: Ben Speakman <https://github.com/threesquared>
// Josh Caffey <https://github.com/jcaffey>
@@ -11,6 +11,16 @@
import * as http from 'http';
import * as lambda from 'aws-lambda';
export interface Response {
statusCode: number;
body: string;
headers: {};
}
export interface ProxyResult {
promise: Promise<Response>;
}
export function createServer(
requestListener: (request: http.IncomingMessage, response: http.ServerResponse) => void,
serverListenCallback?: () => any,
@@ -20,5 +30,27 @@ export function createServer(
export function proxy(
server: http.Server,
event: any,
context: lambda.Context
context: lambda.Context,
): http.Server;
export function proxy(
server: http.Server,
event: any,
context: lambda.Context,
resolutionMode: 'CONTEXT_SUCCEED',
): void;
export function proxy(
server: http.Server,
event: any,
context: lambda.Context,
resolutionMode: 'PROMISE'
): ProxyResult;
export function proxy(
server: http.Server,
event: any,
context: lambda.Context,
resolutionMode: 'CALLBACK',
callback?: (error: any, response: Response) => void
): void;
-4
View File
@@ -1,4 +0,0 @@
export default function and(
bits1: ReadonlyArray<number>,
bits2: ReadonlyArray<number>
): ReadonlyArray<number>;
-33
View File
@@ -1,33 +0,0 @@
import bitsAnd from './and';
import bitsNor from './nor';
import bitsNot from './not';
import bitsOr from './or';
import bitsReduceAnd from './reduce-and';
import bitsReduceNand from './reduce-nand';
import bitsReduceNor from './reduce-nor';
import bitsReduceOr from './reduce-or';
import bitsReduceXnor from './reduce-xnor';
import bitsReduceXor from './reduce-xor';
import bitsToBoolean from './to-boolean';
import bitsToString from './to-string';
import bitsXnor from './xnor';
import bitsXor from './xor';
declare namespace bits {
const and: typeof bitsAnd;
const nor: typeof bitsNor;
const not: typeof bitsNot;
const or: typeof bitsOr;
const reduceAnd: typeof bitsReduceAnd;
const reduceNand: typeof bitsReduceNand;
const reduceNor: typeof bitsReduceNor;
const reduceOr: typeof bitsReduceOr;
const reduceXnor: typeof bitsReduceXnor;
const reduceXor: typeof bitsReduceXor;
const toBoolean: typeof bitsToBoolean;
const toString: typeof bitsToString;
const xnor: typeof bitsXnor;
const xor: typeof bitsXor;
}
export default bits;
-4
View File
@@ -1,4 +0,0 @@
export default function nand(
bits1: ReadonlyArray<number>,
bits2: ReadonlyArray<number>
): ReadonlyArray<number>;
-4
View File
@@ -1,4 +0,0 @@
export default function nor(
bits1: ReadonlyArray<number>,
bits2: ReadonlyArray<number>
): ReadonlyArray<number>;
-4
View File
@@ -1,4 +0,0 @@
export default function not(
bits1: ReadonlyArray<number>,
bits2: ReadonlyArray<number>
): ReadonlyArray<number>;
-4
View File
@@ -1,4 +0,0 @@
export default function or(
bits1: ReadonlyArray<number>,
bits2: ReadonlyArray<number>
): ReadonlyArray<number>;
-1
View File
@@ -1 +0,0 @@
export default function reduceAnd(bits: ReadonlyArray<number>): number;
-1
View File
@@ -1 +0,0 @@
export default function reduceNand(bits: ReadonlyArray<number>): number;
-1
View File
@@ -1 +0,0 @@
export default function reduceNor(bits: ReadonlyArray<number>): number;
-1
View File
@@ -1 +0,0 @@
export default function reduceOr(bits: ReadonlyArray<number>): number;
-1
View File
@@ -1 +0,0 @@
export default function reduceXnor(bits: ReadonlyArray<number>): number;
-1
View File
@@ -1 +0,0 @@
export default function reduceXor(bits: ReadonlyArray<number>): number;
-3
View File
@@ -1,3 +0,0 @@
export default function toBoolean(
bits: ReadonlyArray<number>
): ReadonlyArray<boolean>;
-5
View File
@@ -1,5 +0,0 @@
export default function toString(
bit: ReadonlyArray<number>,
spacing?: number,
spacer?: string
): string;
-4
View File
@@ -1,4 +0,0 @@
export default function xnor(
bits1: ReadonlyArray<number>,
bits2: ReadonlyArray<number>
): ReadonlyArray<number>;
-4
View File
@@ -1,4 +0,0 @@
export default function xor(
bits1: ReadonlyArray<number>,
bits2: ReadonlyArray<number>
): ReadonlyArray<number>;
-56
View File
@@ -1,56 +0,0 @@
// Demonstrating cherry-picking
import bitwise from 'bitwise';
import bits from 'bitwise/bits';
import toBoolean from 'bitwise/bits/to-boolean';
import buffer from 'bitwise/buffer';
import create from 'bitwise/buffer/create';
import byte from 'bitwise/byte';
import read from 'bitwise/byte/read';
import integer from 'bitwise/integer';
import setBit from 'bitwise/integer/set-bit';
import nibble from 'bitwise/nibble';
import nibbleRead from 'bitwise/nibble/read';
import string from 'bitwise/string';
import toBits from 'bitwise/string/to-bits';
// Testing basic functions
const testBits = [0, 1, 1, 0, 1];
// $ExpectType string
bitwise.bits.toString(testBits);
// $ExpectType ReadonlyArray<boolean>
bits.toBoolean(testBits);
// $ExpectType ReadonlyArray<boolean>
toBoolean(testBits);
// $ExpectType ReadonlyArray<number>
byte.read(12);
// $ExpectType ReadonlyArray<number>
read(12);
// $ExpectType Buffer
buffer.create(testBits);
// $ExpectType Buffer
create(testBits);
// $ExpectType ReadonlyArray<number>
integer.setBit(12, 1, 0);
// $ExpectType ReadonlyArray<number>
setBit(12, 1, 0);
// $ExpectType ReadonlyArray<number>
nibble.read(15);
// $ExpectType ReadonlyArray<number>
nibbleRead(15);
// $ExpectType ReadonlyArray<number>
string.toBits('10 10 12$%_.0');
// $ExpectType ReadonlyArray<number>
toBits('10 10 12$%_.0');
-7
View File
@@ -1,7 +0,0 @@
/// <reference types= "node" />
export default function and(
buffer1: Buffer,
buffer2: Buffer,
isLooping?: boolean
): Buffer;
-3
View File
@@ -1,3 +0,0 @@
/// <reference types= "node" />
export default function create(bits: ReadonlyArray<number>): Buffer;
-31
View File
@@ -1,31 +0,0 @@
import bufferAnd from './and';
import bufferCreate from './create';
import bufferModify from './modify';
import bufferNand from './nand';
import bufferNor from './nor';
import bufferNot from './not';
import bufferOr from './or';
import bufferRead from './read';
import bufferReadCInt from './read-c-int';
import bufferReadInt from './read-int';
import bufferReadUInt from './read-u-int';
import bufferXnor from './xnor';
import bufferXor from './xor';
declare namespace buffer {
const and: typeof bufferAnd;
const create: typeof bufferCreate;
const modify: typeof bufferModify;
const nand: typeof bufferNand;
const nor: typeof bufferNor;
const not: typeof bufferNot;
const or: typeof bufferOr;
const read: typeof bufferRead;
const readCInt: typeof bufferReadCInt;
const readInt: typeof bufferReadInt;
const readUInt: typeof bufferReadUInt;
const xnor: typeof bufferXnor;
const xor: typeof bufferXor;
}
export default buffer;
-7
View File
@@ -1,7 +0,0 @@
/// <reference types= "node" />
export default function modify(
buffer: Buffer,
newBits: ReadonlyArray<number>,
bitOffset?: number
): void;
-7
View File
@@ -1,7 +0,0 @@
/// <reference types= "node" />
export default function nand(
buffer1: Buffer,
buffer2: Buffer,
isLooping?: boolean
): Buffer;
-7
View File
@@ -1,7 +0,0 @@
/// <reference types= "node" />
export default function nor(
buffer1: Buffer,
buffer2: Buffer,
isLooping: boolean
): Buffer;
-3
View File
@@ -1,3 +0,0 @@
/// <reference types= "node" />
export default function not(buffer: Buffer): Buffer;
-7
View File
@@ -1,7 +0,0 @@
/// <reference types= "node" />
export default function or(
buffer1: Buffer,
buffer2: Buffer,
isLooping?: boolean
): Buffer;
-7
View File
@@ -1,7 +0,0 @@
/// <reference types= "node" />
export default function readCInt(
buffer: Buffer,
bitOffset?: number,
bitLength?: number
): number;
-7
View File
@@ -1,7 +0,0 @@
/// <reference types= "node" />
export default function readInt(
buffer: Buffer,
bitOffset?: number,
bitLength?: number
): number;
-7
View File
@@ -1,7 +0,0 @@
/// <reference types= "node" />
export default function readUInt(
buffer: Buffer,
bitOffset?: number,
bitLength?: number
): number;
-7
View File
@@ -1,7 +0,0 @@
/// <reference types= "node" />
export default function read(
buffer: Buffer,
bitOffset?: number,
bitLength?: number
): ReadonlyArray<number>;
-7
View File
@@ -1,7 +0,0 @@
/// <reference types= "node" />
export default function xnor(
buffer1: Buffer,
buffer2: Buffer,
isLooping?: boolean
): Buffer;
-7
View File
@@ -1,7 +0,0 @@
/// <reference types= "node" />
export default function xor(
buffer1: Buffer,
buffer2: Buffer,
isLooping?: boolean
): Buffer;
-9
View File
@@ -1,9 +0,0 @@
import byteRead from './read';
import byteWrite from './write';
declare namespace byte {
const read: typeof byteRead;
const write: typeof byteWrite;
}
export default byte;
-1
View File
@@ -1 +0,0 @@
export default function read(byte: number): ReadonlyArray<number>;
-1
View File
@@ -1 +0,0 @@
export default function write(bits: ReadonlyArray<number>): number;
-22
View File
@@ -1,22 +0,0 @@
// Type definitions for bitwise 1.5
// Project: https://github.com/dodekeract/bitwise
// Definitions by: Daniel Byrne <https://github.com/danwbyrne>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import bitwiseBits from './bits';
import bitwiseBuffer from './buffer';
import bitwiseByte from './byte';
import bitwiseInteger from './integer';
import bitwiseNibble from './nibble';
import bitwiseString from './string';
declare namespace bitwise {
const bits: typeof bitwiseBits;
const buffer: typeof bitwiseBuffer;
const byte: typeof bitwiseByte;
const integer: typeof bitwiseInteger;
const nibble: typeof bitwiseNibble;
const string: typeof bitwiseString;
}
export default bitwise;
-1
View File
@@ -1 +0,0 @@
export default function getBit(number: number, position: number): number;
-11
View File
@@ -1,11 +0,0 @@
import integerGetBit from './get-bit';
import integerSetBit from './set-bit';
import integerToggleBit from './toggle-bit';
declare namespace integer {
const getBit: typeof integerGetBit;
const setBit: typeof integerSetBit;
const toggleBit: typeof integerToggleBit;
}
export default integer;
-5
View File
@@ -1,5 +0,0 @@
export default function setBit(
number: number,
position: number,
value: number
): ReadonlyArray<number>;
-4
View File
@@ -1,4 +0,0 @@
export default function toggleBit(
number: number,
position: number
): ReadonlyArray<number>;
-9
View File
@@ -1,9 +0,0 @@
import nibbleRead from './read';
import nibbleWrite from './write';
declare namespace nibble {
const read: typeof nibbleRead;
const write: typeof nibbleWrite;
}
export default nibble;
-1
View File
@@ -1 +0,0 @@
export default function read(nibble: number): ReadonlyArray<number>;
-1
View File
@@ -1 +0,0 @@
export default function write(nibble: ReadonlyArray<number>): number;
-7
View File
@@ -1,7 +0,0 @@
import stringToBits from './to-bits';
declare namespace string {
const toBits: typeof stringToBits;
}
export default string;
-1
View File
@@ -1 +0,0 @@
export default function toBits(string: string): ReadonlyArray<number>;
-60
View File
@@ -1,60 +0,0 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es6"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": ["../"],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"bitwise-tests.ts",
"bits/and.d.ts",
"bits/index.d.ts",
"bits/nand.d.ts",
"bits/nor.d.ts",
"bits/not.d.ts",
"bits/or.d.ts",
"bits/reduce-and.d.ts",
"bits/reduce-nand.d.ts",
"bits/reduce-nor.d.ts",
"bits/reduce-or.d.ts",
"bits/reduce-xnor.d.ts",
"bits/reduce-xor.d.ts",
"bits/to-boolean.d.ts",
"bits/to-string.d.ts",
"bits/xnor.d.ts",
"bits/xor.d.ts",
"buffer/and.d.ts",
"buffer/create.d.ts",
"buffer/modify.d.ts",
"buffer/nand.d.ts",
"buffer/nor.d.ts",
"buffer/not.d.ts",
"buffer/or.d.ts",
"buffer/read-c-int.d.ts",
"buffer/read-int.d.ts",
"buffer/read-u-int.d.ts",
"buffer/read.d.ts",
"buffer/xnor.d.ts",
"buffer/xor.d.ts",
"byte/index.d.ts",
"byte/read.d.ts",
"byte/write.d.ts",
"integer/get-bit.d.ts",
"integer/index.d.ts",
"integer/set-bit.d.ts",
"integer/toggle-bit.d.ts",
"nibble/index.d.ts",
"nibble/read.d.ts",
"nibble/write.d.ts",
"string/index.d.ts",
"string/to-bits.d.ts"
]
}
-3
View File
@@ -1,3 +0,0 @@
{
"extends": "dtslint/dt.json"
}
+10
View File
@@ -0,0 +1,10 @@
import bytewise = require('bytewise');
// $ExpectType Buffer
bytewise.encode([1, 2, 3]);
// $ExpectType any
bytewise.decode(bytewise.encode([1, 2 , 3]));
// $ExpectType Buffer
bytewise.encode(bytewise.sorts.array.bound.lower(['123', -1, 0x123, Buffer.from('test')]));
+16
View File
@@ -0,0 +1,16 @@
// Type definitions for bytewise 1.1
// Project: https://github.com/deanlandolt/bytewise
// Definitions by: Daniel Byrne <https://github.com/danwbyrne>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
/// <reference types= "node" />
interface Bytewise {
encode: (value: any) => Buffer;
decode: (value: Buffer) => any;
[k: string]: any;
}
declare const bytewise: Bytewise;
export = bytewise;
+23
View File
@@ -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",
"bytewise-tests.ts"
]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}
+1
View File
@@ -186,6 +186,7 @@ declare namespace Chai {
property: Property;
members: Members;
ordered: Ordered;
nested: Nested;
}
interface Ordered {
@@ -0,0 +1,33 @@
/* Note that this is a sample function for the purpose of running the below CustomFunctionsMappings test */
function ADD10(n: number) {
return n + 10;
}
CustomFunctionMappings = {
addTen: ADD10
};
async function getStockValues(ticker: string, handler: CustomFunctions.StreamingHandler<number>) {
const dollars = await (await fetch(`myService.com/prices/${ticker}`)).json();
handler.setResult(dollars);
}
async function getStockValuesOneTime(ticker: string, handler: CustomFunctions.CancelableHandler) {
let shouldStop = false;
handler.onCanceled = () => shouldStop = true;
await pause(1000);
if (shouldStop) {
return null;
}
const dollars = await (await fetch(`myService.com/prices/${ticker}`)).json();
return dollars;
}
async function getStockValuesNowWithNoCancelling(ticker: string) {
const dollars = await (await fetch(`myService.com/prices/${ticker}`)).json();
return dollars;
}
declare function pause(ms: number): Promise<void>;
+30
View File
@@ -0,0 +1,30 @@
// Type definitions for Custom Functions 1.4
// Project: http://dev.office.com
// Definitions by: OfficeDev <https://github.com/OfficeDev>, Michael Zlatkovsky <https://github.com/Zlatkovsky>, Michelle Scharlock <https://github.com/mscharlock>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.4
/*
office-js
Copyright (c) Microsoft Corporation
*/
declare let CustomFunctionMappings: { [key: string]: Function };
declare namespace CustomFunctions {
interface StreamingHandler<T> extends CancelableHandler {
/*
* Sets the returned result for a streaming custom function.
* @beta
*/
setResult: (value: T) => void;
}
interface CancelableHandler {
/*
* Handles what should occur when a custom function is canceled.
* @beta
*/
onCanceled: () => void;
}
}
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": ["../"],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"target": "es6"
},
"files": [
"index.d.ts",
"custom-functions-runtime-tests.ts"
]
}
@@ -0,0 +1,6 @@
{
"extends": "dtslint/dt.json",
"rules": {
"ban-types": false
}
}
@@ -0,0 +1,13 @@
import { AbstractLevelDOWN } from 'abstract-leveldown';
import EncodingDOWN from 'encoding-down';
const test = (encoding: EncodingDOWN) => {
encoding.put("key", "value", (err?: Error) => { });
encoding.put(1, "value", { something: true }, (err?: Error) => { });
encoding.get("key", (err?: Error) => { });
encoding.get(1, { something: true }, (err: Error | undefined, value: any) => { });
};
// $ExpectType void
test(new EncodingDOWN(new AbstractLevelDOWN("here")));
+59
View File
@@ -0,0 +1,59 @@
// Type definitions for encoding-down 5.0
// Project: https://github.com/Level/encoding-down
// Definitions by: Meirion Hughes <https://github.com/MeirionHughes>
// Daniel Byrne <https://github.com/danwbyrne>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
import {
AbstractLevelDOWN,
AbstractIteratorOptions,
AbstractIterator,
AbstractOpenOptions,
AbstractGetOptions,
ErrorCallback,
ErrorValueCallback,
AbstractChainedBatch,
AbstractBatch,
AbstractOptions
} from 'abstract-leveldown';
import { CodecOptions, CodecEncoder } from 'level-codec';
interface EncodingDown<K = any, V = any> extends AbstractLevelDOWN<K, V> {
get(key: K, cb: ErrorValueCallback<V>): void;
get(key: K, options: EncodingDown.GetOptions, cb: ErrorValueCallback<V>): void;
put(key: K, value: V, cb: ErrorCallback): void;
put(key: K, value: V, options: EncodingDown.PutOptions, cb: ErrorCallback): void;
del(key: K, cb: ErrorCallback): void;
del(key: K, options: EncodingDown.DelOptions, cb: ErrorCallback): void;
batch(): EncodingDown.ChainedBatch;
batch(array: AbstractBatch[], cb: ErrorCallback): EncodingDown.ChainedBatch;
batch(array: AbstractBatch[], options: EncodingDown.BatchOptions, cb: ErrorCallback): EncodingDown.ChainedBatch;
iterator(options?: EncodingDown.IteratorOptions): AbstractIterator<any, any>;
}
declare namespace EncodingDown {
interface GetOptions extends AbstractGetOptions, CodecOptions {}
interface PutOptions extends AbstractOptions, CodecOptions {}
interface DelOptions extends AbstractOptions, CodecOptions {}
interface BatchOptions extends AbstractOptions, CodecOptions {}
interface IteratorOptions extends AbstractIteratorOptions, CodecOptions {}
interface ChainedBatch<K = any, V = any> extends AbstractChainedBatch<K, V> {
write(cb: any): any;
write(options: CodecOptions & AbstractOptions, cb: any): any;
}
interface Constructor {
// tslint:disable-next-line:no-unnecessary-generics
<K = any, V = any>(db: AbstractLevelDOWN, options?: CodecOptions): EncodingDown<K, V>;
// tslint:disable-next-line:no-unnecessary-generics
new <K = any, V = any>(db: AbstractLevelDOWN, options?: CodecOptions): EncodingDown<K, V>;
}
}
declare const EncodingDown: EncodingDown.Constructor;
export default EncodingDown;
+23
View File
@@ -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",
"encoding-down-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+4 -1
View File
@@ -5,7 +5,7 @@ const Glob = glob.Glob;
const pattern = "test/a/**/[cg]/../[cg]";
console.log(pattern);
const mg = new Glob(pattern, {mark: true, sync: true}, (er, matches) => {
const mg = new Glob(pattern, {mark: true, sync: true, symlinks: {"test/a/foo": true}}, (er, matches) => {
if (er) {
console.error(er);
return;
@@ -28,3 +28,6 @@ const Glob = glob.Glob;
});
console.log("after");
})();
glob.sync('/foo/*', {realpath: true, realpathCache: {'/foo/bar': '/bar'}, ignore: '/foo/baz'});
glob.sync('/*', {nodir: true, cache: {'/': ['bar', 'baz']}, statCache: {'/foo/bar': false, '/foo/baz': {isDirectory() { return true; }}}});
+10 -35
View File
@@ -1,13 +1,13 @@
// Type definitions for Glob 5.0
// Type definitions for Glob 7.1
// Project: https://github.com/isaacs/node-glob
// Definitions by: vvakame <https://github.com/vvakame>
// voy <https://github.com/voy>
// Klaus Meinhardt <https://github.com/ajafff>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
import events = require("events");
import fs = require('fs');
import minimatch = require("minimatch");
declare function G(pattern: string, cb: (err: Error | null, matches: string[]) => void): void;
@@ -33,9 +33,10 @@ declare namespace G {
stat?: boolean;
silent?: boolean;
strict?: boolean;
cache?: { [path: string]: any /* boolean | string | string[] */ };
statCache?: { [path: string]: fs.Stats };
symlinks?: any;
cache?: { [path: string]: boolean | 'DIR' | 'FILE' | string[] };
statCache?: { [path: string]: false | { isDirectory(): boolean} | undefined };
symlinks?: { [path: string]: boolean | undefined };
realpathCache?: { [path: string]: string };
sync?: boolean;
nounique?: boolean;
nonull?: boolean;
@@ -46,15 +47,12 @@ declare namespace G {
nocase?: boolean;
matchBase?: any;
nodir?: boolean;
ignore?: any; /* string | string[] */
ignore?: string | string[];
follow?: boolean;
realpath?: boolean;
nonegate?: boolean;
nocomment?: boolean;
absolute?: boolean;
/** Deprecated. */
globDebug?: boolean;
}
interface IGlobStatic extends events.EventEmitter {
@@ -72,9 +70,9 @@ declare namespace G {
minimatch: minimatch.IMinimatch;
options: IOptions;
aborted: boolean;
cache: { [path: string]: any /* boolean | string | string[] */ };
statCache: { [path: string]: fs.Stats };
symlinks: { [path: string]: boolean };
cache: { [path: string]: boolean | 'DIR' | 'FILE' | string[] };
statCache: { [path: string]: false | { isDirectory(): boolean; } | undefined };
symlinks: { [path: string]: boolean | undefined };
realpathCache: { [path: string]: string };
found: string[];
}
@@ -83,29 +81,6 @@ declare namespace G {
pause(): void;
resume(): void;
abort(): void;
/** Deprecated. */
EOF: any;
/** Deprecated. */
paused: boolean;
/** Deprecated. */
maxDepth: number;
/** Deprecated. */
maxLength: number;
/** Deprecated. */
changedCwd: boolean;
/** Deprecated. */
cwd: string;
/** Deprecated. */
root: string;
/** Deprecated. */
error: any;
/** Deprecated. */
matches: string[];
/** Deprecated. */
log(...args: any[]): void;
/** Deprecated. */
emitMatch(m: any): void;
}
}
+30
View File
@@ -0,0 +1,30 @@
import glob = require("glob");
const Glob = glob.Glob;
(() => {
const pattern = "test/a/**/[cg]/../[cg]";
console.log(pattern);
const mg = new Glob(pattern, {mark: true, sync: true}, (er, matches) => {
if (er) {
console.error(er);
return;
}
console.log("matches", matches);
});
console.log("after");
})();
(() => {
const pattern = "{./*/*,/*,/usr/local/*}";
console.log(pattern);
const mg = new Glob(pattern, {mark: true}, (er, matches) => {
if (er) {
console.error(er);
return;
}
console.log("matches", matches);
});
console.log("after");
})();
+112
View File
@@ -0,0 +1,112 @@
// Type definitions for Glob 5.0
// Project: https://github.com/isaacs/node-glob
// Definitions by: vvakame <https://github.com/vvakame>
// voy <https://github.com/voy>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
import events = require("events");
import fs = require('fs');
import minimatch = require("minimatch");
declare function G(pattern: string, cb: (err: Error | null, matches: string[]) => void): void;
declare function G(pattern: string, options: G.IOptions, cb: (err: Error | null, matches: string[]) => void): void;
declare namespace G {
function __promisify__(pattern: string, options?: IOptions): Promise<string[]>;
function sync(pattern: string, options?: IOptions): string[];
function hasMagic(pattern: string, options?: IOptions): boolean;
let Glob: IGlobStatic;
let GlobSync: IGlobSyncStatic;
interface IOptions extends minimatch.IOptions {
cwd?: string;
root?: string;
dot?: boolean;
nomount?: boolean;
mark?: boolean;
nosort?: boolean;
stat?: boolean;
silent?: boolean;
strict?: boolean;
cache?: { [path: string]: any /* boolean | string | string[] */ };
statCache?: { [path: string]: fs.Stats };
symlinks?: any;
sync?: boolean;
nounique?: boolean;
nonull?: boolean;
debug?: boolean;
nobrace?: boolean;
noglobstar?: boolean;
noext?: boolean;
nocase?: boolean;
matchBase?: any;
nodir?: boolean;
ignore?: any; /* string | string[] */
follow?: boolean;
realpath?: boolean;
nonegate?: boolean;
nocomment?: boolean;
absolute?: boolean;
/** Deprecated. */
globDebug?: boolean;
}
interface IGlobStatic extends events.EventEmitter {
new (pattern: string, cb?: (err: Error | null, matches: string[]) => void): IGlob;
new (pattern: string, options: IOptions, cb?: (err: Error | null, matches: string[]) => void): IGlob;
prototype: IGlob;
}
interface IGlobSyncStatic {
new (pattern: string, options?: IOptions): IGlobBase;
prototype: IGlobBase;
}
interface IGlobBase {
minimatch: minimatch.IMinimatch;
options: IOptions;
aborted: boolean;
cache: { [path: string]: any /* boolean | string | string[] */ };
statCache: { [path: string]: fs.Stats };
symlinks: { [path: string]: boolean };
realpathCache: { [path: string]: string };
found: string[];
}
interface IGlob extends IGlobBase, events.EventEmitter {
pause(): void;
resume(): void;
abort(): void;
/** Deprecated. */
EOF: any;
/** Deprecated. */
paused: boolean;
/** Deprecated. */
maxDepth: number;
/** Deprecated. */
maxLength: number;
/** Deprecated. */
changedCwd: boolean;
/** Deprecated. */
cwd: string;
/** Deprecated. */
root: string;
/** Deprecated. */
error: any;
/** Deprecated. */
matches: string[];
/** Deprecated. */
log(...args: any[]): void;
/** Deprecated. */
emitMatch(m: any): void;
}
}
export = G;
+28
View File
@@ -0,0 +1,28 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictFunctionTypes": true,
"baseUrl": "../../",
"typeRoots": [
"../../"
],
"paths": {
"glob": [
"glob/v5"
]
},
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"glob-tests.ts"
]
}
+6
View File
@@ -0,0 +1,6 @@
{
"extends": "dtslint/dt.json",
"rules": {
"interface-name": false
}
}
+30
View File
@@ -0,0 +1,30 @@
export type OutputEncoding = 'hex' | 'base64';
export function hmac(algorithm: string, secret: string, data: string, outputEncoding: OutputEncoding): string;
export function md4(input: string, outputEncoding: OutputEncoding): string;
export function md5(input: string, outputEncoding: OutputEncoding): string;
export function sha1(input: string, outputEncoding: OutputEncoding): string;
export function sha256(input: string, outputEncoding: OutputEncoding): string;
export function sha384(input: string, outputEncoding: OutputEncoding): string;
export function sha512(input: string, outputEncoding: OutputEncoding): string;
export function sha512_224(input: string, outputEncoding: OutputEncoding): string;
export function sha512_256(input: string, outputEncoding: OutputEncoding): string;
export function ripemd160(input: string, outputEncoding: OutputEncoding): string;
export function createHash(algorithm: string): Hasher;
export function createHMAC(algorithm: string, secret: string): Hasher;
export interface Hasher {
update: (input: string) => void;
digest: (outputEncoding: OutputEncoding) => string;
}
+96
View File
@@ -0,0 +1,96 @@
import { bytes } from '.';
export function batch(requests: ReadonlyArray<Request>): { [key: string]: Response };
export function batch(requests: ReadonlyArray<Request>): Response[];
export function del(url: string, body?: string | object, params?: RequestParams): Response;
export function get(url: string, params?: RequestParams): Response;
export function options(url: string, body?: string | object, params?: RequestParams): Response;
export function patch(url: string, body?: string | object, params?: RequestParams): Response;
export function post(url: string, body?: string | object, params?: RequestParams): Response;
export function put(url: string, body?: string | object, params?: RequestParams): Response;
export function request(method: string, url: string, body?: string | object, params?: RequestParams): Response;
export interface RequestParams {
auth?: string;
cookies?: object;
headers?: object;
jar?: object;
redirects?: number;
tags?: object;
timeout?: number;
}
export type Request = string | RequestObj;
export interface RequestObj {
url: string;
method?: string;
body?: string | object;
params?: RequestParams;
}
export interface Response {
body: string;
cookies: object;
error: string;
headers: { [key: string]: string };
ocsp: {
produced_at: number,
this_update: number,
next_update: number,
revocation_reason: string,
revoked_at: number,
status: string
};
proto: string;
remote_ip: string;
remote_port: number;
request: {
body: string,
cookies: object,
headers: object,
method: string,
url: string
};
status: number;
timings: {
blocked: number,
looking_up: number,
connecting: number,
tls_handshaking: number,
sending: number,
waiting: number,
receiving: number,
duration: number
};
tls_cipher_suite: string;
tls_version: string;
url: string;
clickLink: (params?: {
selector?: string,
params?: RequestParams
}) => Response;
html: (selector?: string) => any;
json: () => any;
submitForm: (params?: {
formSelector?: string,
fields?: object,
submitSelector?: string,
params?: RequestParams
}) => Response;
}
export function file(data: string | bytes, filename?: string, contentType?: string): FileData;
export interface FileData {
data: string | bytes;
filename?: string;
content_type?: string;
}
+20
View File
@@ -0,0 +1,20 @@
// Type definitions for k6 0.0
// Project: https://github.com/loadimpact/k6#readme
// Definitions by: My Self <https://github.com/MajorBreakfast>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
export type bytes = any;
declare global {
function open(filePath: string): string;
function open(filePath: string, mode: 'b'): bytes;
}
export function check<T>(val: T, sets: { [key: string]: (val: T) => boolean }, tags?: object): boolean;
export function fail(err?: string): undefined;
export function group<T>(name: string, fn: () => T): T;
export function sleep(t: number): void;
+205
View File
@@ -0,0 +1,205 @@
import http from "k6/http";
import { check, sleep, fail, group } from "k6";
const users = JSON.parse(open("./users.json"));
const __VU = 1;
function test1() {
const user = users[__VU - 1];
console.log(`${user.username}, ${user.password}`);
sleep(3);
}
const binFile1 = open("/path/to/file.bin", "b");
export default function test2() {
const data = {
field: "this is a standard form field",
file: http.file(binFile1, "test.bin")
};
const res = http.post("https://example.com/upload", data);
sleep(3);
}
function test3() {
const res = http.get("http://httpbin.org");
check(res, {
"response code was 200": (res) => res.status === 200,
"body size was 1234 bytes": (res) => res.body.length === 1234,
});
}
function test4() {
const res = http.get("https://loadimpact.com");
check(res, {
"status code MUST be 200": (res) => res.status === 200,
}) || fail("status code was *not* 200");
}
function test5() {
group("my user scenario", () => {
group("front page", () => {
const res = http.get("https://loadimpact.com");
check(res, {
"status code is 200": (res) => res.status === 200,
});
});
group("features page", () => {
const res = http.get("https://loadimpact.com/features");
check(res, {
"status code is 200": (res) => res.status === 200,
"h1 message is correct": (res) => res.html("h1").text().startsWith("Simple yet realistic load testing"),
});
});
});
}
function test6() {
http.get("https://loadimpact.com");
sleep(Math.random() * 30);
http.get("https://loadimpact.com/features");
}
function httpTest1() {
const responses = http.batch([
"http://test.loadimpact.com",
"http://test.loadimpact.com/style.css",
"http://test.loadimpact.com/images/logo.png",
]);
check(responses[0], {
"main page status was 200": res => res.status === 200,
});
}
function httpTest2() {
const req1 = {
method: "GET",
url: "http://httpbin.org/get",
};
const req2 = {
method: "GET",
url: "http://test.loadimpact.com",
};
const req3 = {
method: "POST",
url: "http://httpbin.org/post",
body: {
hello: "world!",
},
params: { headers: { "Content-Type": "application/x-www-form-urlencoded" } }
};
const responses = http.batch([req1, req2, req3]);
// httpbin.org should return our POST data in the response body, so
// we check the third response object to see that the POST worked.
check(responses[2], {
"form data OK": (res) => JSON.parse(res.body)["form"]["hello"] === "world!",
});
}
const binFile = open("/path/to/file.bin", "b");
function httpTest3() {
const data = {
field: "this is a standard form field",
file: http.file(binFile, "test.bin")
};
const res = http.post("https://example.com/upload", data);
sleep(3);
}
function httpTest4() {
return http.get("https://loadimpact.com");
}
function httpTest5() {
const options = { maxRedirects: 10 };
const baseURL = "https://dev-li-david.pantheonsite.io";
// Fetch the login page, with the login HTML form
const res1 = http.get(baseURL + "/user/login");
// Extract hidden value needed to POST form
const formBuildID = (res1.body.match('name="form_build_id" value="(.*)"') || [])[1];
// Create an Object containing the form data
const formdata = {
name: "testuser1",
pass: "testuser1",
form_build_id: formBuildID,
form_id: "user_login",
op: "Log in",
};
const headers = { "Content-Type": "application/x-www-form-urlencoded" };
// Send login request
const res2 = http.post(baseURL + "/user/login", formdata, { headers });
// Verify that we ended up on the user page
check(res2, {
"login succeeded": (res2) => res2.url === `${baseURL}/users/testuser1`,
}) || fail("login failed");
}
function httpTest6() {
const params = {
cookies: { my_cookie: "value" },
headers: { "X-MyHeader": "k6test" },
redirects: 5,
tags: { k6test: "yes" }
};
http.get("https://loadimpact.com", params);
}
function httpTest7() {
const url1 = "https://api.loadimpact.com/v3/account/me";
const url2 = "http://httpbin.org/get";
const apiToken = "f232831bda15dd233c53b9c548732c0197619a3d3c451134d9abded7eb5bb195";
const requestHeaders = {
"User-Agent": "k6",
Authorization: "Token " + apiToken
};
http.batch([
{ method: "GET", url: url1, params: { headers: requestHeaders } },
{ method: "GET", url: url2 }
]);
}
function httpTest8() {
// Passing username and password as part of URL plus the auth option will authenticate using HTTP Digest authentication
const res = http.get("http://user:passwd@httpbin.org/digest-auth/auth/user/passwd", {auth: "digest"});
// Verify response
check(res, {
"status is 200": (r) => r.status === 200,
"is authenticated": (r) => r.json().authenticated === true,
"is correct user": (r) => r.json().user === "user"
});
}
function httpTest9() {
const res = http.get("https://loadimpact.com");
for (const p in res.headers) {
if (res.headers.hasOwnProperty(p)) {
console.log(`${p} : ${res.headers[p]}`);
}
}
check(res, {
"status is 200": (r) => r.status === 200,
"caption is correct": (r) => r.html("h1").text() === "Example Domain",
});
}
function httpTest10() {
// Request page with links
let res = http.get("https://httpbin.org/links/10/0");
// Now, click the 4th link on the page
res = res.clickLink({ selector: 'a:nth-child(4)' });
}
function httpTest11() {
// Request page containing a form
let res = http.get("https://httpbin.org/forms/post");
// Now, submit form setting/overriding some fields of the form
res = res.submitForm({ fields: { custname: "test", extradata: "test2" }, submitSelector: "mySubmit" });
}
+26
View File
@@ -0,0 +1,26 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es2015", "dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"allowSyntheticDefaultImports": true
},
"files": [
"index.d.ts",
"http.d.ts",
"crypto.d.ts",
"k6-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+9 -1
View File
@@ -13,6 +13,14 @@
"../"
],
"types": [],
"paths": {
"levelup": [
"levelup/v1"
],
"leveldown": [
"leveldown/v1"
]
},
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
@@ -20,4 +28,4 @@
"index.d.ts",
"level-sublevel-tests.ts"
]
}
}
+70 -123
View File
@@ -1,148 +1,95 @@
// Type definitions for LevelDown 1.7
// Project: https://github.com/level/leveldown
// Definitions by: Thiago de Arruda <https://github.com/tarruda>
// Linus Unnebäck <https://github.com/LinusU>
// Type definitions for leveldown 4.0
// Project: https://github.com/Level/leveldown
// Definitions by: Meirion Hughes <https://github.com/MeirionHughes>
// Daniel Byrne <https://github.com/danwbyrne>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
/// <reference types="node" />
export = leveldown;
import {
AbstractLevelDOWN,
AbstractIteratorOptions,
AbstractIterator,
AbstractOpenOptions,
AbstractGetOptions,
ErrorCallback,
ErrorValueCallback,
AbstractChainedBatch,
AbstractBatch,
AbstractOptions
} from 'abstract-leveldown';
declare var leveldown: leveldown.Constructor;
export type Bytes = string | Buffer;
export type ErrorSizeCallback = (err: Error | undefined, size: number) => void;
declare namespace leveldown {
type Bytes = string | Buffer;
type ErrCallback = (error: any) => void;
type ErrNumberCallback = (error: any, value: number) => void;
type ErrBufferCallback = (error: any, value: Buffer) => void;
type ErrStringCallback = (error: any, value: string) => void;
type KeyAsStringCallback = (error: any, key: string, value: Buffer) => void;
type ValueAsStringCallback = (error: any, key: Buffer, value: string) => void;
type KeyAndValueAsStringCallback = (error: any, key: string, value: string) => void;
type KeyAndValueAsBufferCallback = (error: any, key: Buffer, value: Buffer) => void;
export interface LevelDown extends AbstractLevelDOWN<Bytes, Bytes> {
open(cb: ErrorCallback): void;
open(options: LevelDownOpenOptions, cb: ErrorCallback): void;
interface PutBatch {
type: "put";
key: Bytes;
value: Bytes;
get(key: Bytes, cb: ErrorValueCallback<Bytes>): void;
get(key: Bytes, options: LevelDownGetOptions, cb: ErrorValueCallback<Bytes>): void;
put(key: Bytes, value: Bytes, cb: ErrorCallback): void;
put(key: Bytes, value: Bytes, options: LevelDownPutOptions, cb: ErrorCallback): void;
del(key: Bytes, cb: ErrorCallback): void;
del(key: Bytes, options: LevelDownDelOptions, cb: ErrorCallback): void;
batch(): AbstractChainedBatch<Bytes, Bytes>;
batch(array: AbstractBatch[], cb: ErrorCallback): AbstractChainedBatch<Bytes, Bytes>;
batch(array: AbstractBatch[], options: LevelDownBatchOptions, cb: ErrorCallback): AbstractChainedBatch<Bytes, Bytes>;
approximateSize(start: Bytes, end: Bytes, cb: ErrorSizeCallback): void;
compactRange(start: Bytes, end: Bytes, cb: ErrorCallback): void;
getProperty(property: string): string;
destroy(location: string, cb: ErrorCallback): void;
repair(location: string, cb: ErrorCallback): void;
iterator(options?: LevelDownIteratorOptions): LevelDownIterator;
}
interface DelBatch {
type: "del";
key: Bytes;
interface LevelDownConstructor {
new(location: string): LevelDown;
(location: string): LevelDown;
}
type Batch = PutBatch | DelBatch;
interface OpenOptions {
createIfMissing?: boolean;
errorIfExists?: boolean;
compression?: boolean;
cacheSize?: number;
export interface LevelDownOpenOptions extends AbstractOpenOptions {
compression?: boolean;
cacheSize?: number;
writeBufferSize?: number;
blockSize?: number;
maxOpenFiles?: number;
blockRestartInterval?: number;
maxFileSize?: number;
}
interface OpenAdvancedOptions extends OpenOptions {
writeBufferSize?: number;
blockSize?: number;
maxOpenFiles?: number;
blockRestartInterval?: number;
maxFileSize?: number;
export interface LevelDownGetOptions extends AbstractGetOptions {
fillCache?: boolean;
}
interface WriteOptions {
sync?: boolean;
export interface LevelDownPutOptions extends AbstractOptions {
sync?: boolean;
}
interface ReadOptions {
fillCache?: boolean;
export interface LevelDownDelOptions extends AbstractOptions {
sync?: boolean;
}
interface BufferReadOptions extends ReadOptions {
asBuffer?: true;
export interface LevelDownBatchOptions extends AbstractOptions {
sync?: boolean;
}
interface StringReadOptions extends ReadOptions {
asBuffer: false;
export interface LevelDownIteratorOptions extends AbstractIteratorOptions<Bytes> {
fillCache?: boolean;
}
interface IteratorOptions {
gt?: Bytes;
lt?: Bytes;
gte?: Bytes;
lte?: Bytes;
reverse?: boolean;
keys?: boolean;
values?: boolean;
limit?: number;
fillCache?: boolean;
export interface LevelDownIterator extends AbstractIterator<Bytes, Bytes> {
seek(key: Bytes): void;
binding: any;
cache: any;
finished: any;
fastFuture: any;
}
interface KeyAsStringIteratorOptions extends IteratorOptions {
keyAsBuffer: false;
valueAsBuffer?: true;
}
interface ValueAsStringIteratorOptions extends IteratorOptions {
keyAsBuffer?: true;
valueAsBuffer: false;
}
interface KeyAndValueAsStringIteratorOptions extends IteratorOptions {
keyAsBuffer: false;
valueAsBuffer: false;
}
interface KeyAndValueAsBufferIteratorOptions extends IteratorOptions {
keyAsBuffer?: true;
valueAsBuffer?: true;
}
interface Iterator {
seek(key: Bytes): void;
end(callback: ErrCallback): void;
}
interface KeyAsStringIterator extends Iterator {
next(callback: KeyAsStringCallback): void;
}
interface ValueAsStringIterator extends Iterator {
next(callback: ValueAsStringCallback): void;
}
interface KeyAndValueAsStringIterator extends Iterator {
next(callback: KeyAndValueAsStringCallback): void;
}
interface KeyAndValueAsBufferIterator extends Iterator {
next(callback: KeyAndValueAsBufferCallback): void;
}
interface LevelDown {
open(callback: ErrCallback): void;
open(options: OpenOptions, callback: ErrCallback): void;
close(callback?: ErrCallback): void;
put(key: Bytes, value: Bytes, callback: ErrCallback): void;
put(key: Bytes, value: Bytes, options: WriteOptions, callback: ErrCallback): void;
get(key: Bytes, callback: ErrBufferCallback): void;
get(key: Bytes, options: BufferReadOptions, callback: ErrBufferCallback): void;
get(key: Bytes, options: StringReadOptions, callback: ErrStringCallback): void;
del(key: Bytes, callback?: ErrCallback): void;
del(key: Bytes, options: WriteOptions, callback?: ErrCallback): void;
batch(operations: Batch[], callback?: ErrCallback): void;
batch(operations: Batch[], options?: WriteOptions, callback?: ErrCallback): void;
approximateSize(start: Bytes, end: Bytes, callback: ErrNumberCallback): void;
compactRange(start: Bytes, end: Bytes, callback: ErrCallback): void;
getProperty(property: string): string;
iterator(options?: KeyAsStringIteratorOptions): KeyAsStringIterator;
iterator(options?: ValueAsStringIteratorOptions): ValueAsStringIterator;
iterator(options?: KeyAndValueAsStringIteratorOptions): KeyAndValueAsStringIterator;
iterator(options?: KeyAndValueAsBufferIteratorOptions): KeyAndValueAsBufferIterator;
}
interface Constructor {
(location: string): LevelDown;
destroy(location: string, callback: ErrCallback): void;
repair(location: string, callback: ErrCallback): void;
}
}
declare const LevelDOWN: LevelDownConstructor;
export default LevelDOWN;
+14 -81
View File
@@ -1,86 +1,19 @@
import leveldown = require("leveldown");
import LevelDOWN from 'leveldown';
const db = leveldown("db1");
// can use new, or not.
const a = new LevelDOWN("./tmp/leveldown");
const b = LevelDOWN("./tmp/leveldown");
db.open((err) => {});
db.open({createIfMissing: true}, (err) => {});
const down = new LevelDOWN("./tmp/leveldown");
db.put("key", "value", (err) => {});
db.put(Buffer.from("key"), Buffer.from("value"), (err) => {});
db.put("key", "value", {sync: true}, (err) => {});
down.open(() => {
down.put("key", "value", (err?) => { });
down.put(Buffer.from([1]), "value", { something: true }, (err?) => { });
db.get("key", {asBuffer: false}, (error, val) => {
console.log(val.toUpperCase());
down.get("key", (err?) => { });
down.get(Buffer.from([1]), { something: true }, (err: Error | undefined, value: any) => { });
down.close(() => {
// do nothing
});
});
db.get("key", {fillCache: true}, (error, val) => {
console.log(val.readUInt32BE(0));
});
db.get("key", (error, val) => {
console.log(val.readUInt32BE(0));
});
db.del("key");
db.del("key", (error) => {});
db.del("key", {sync: true}, (error) => {});
db.batch([{
type: "put", key: "k", value: "v"
}, {
type: "del", key: "k"
}], (error) => {});
const keyAsStringIterator = db.iterator({keyAsBuffer: false});
keyAsStringIterator.next((err, k, v) => {
console.log(k.toUpperCase());
console.log(v.readUInt32BE(0));
});
const valueAsStringIterator = db.iterator({valueAsBuffer: false});
valueAsStringIterator.next((err, k, v) => {
console.log(k.readUInt32BE(0));
console.log(v.toUpperCase());
});
const keyAndValueAsStringIterator = db.iterator({keyAsBuffer: false, valueAsBuffer: false});
keyAndValueAsStringIterator.next((err, k, v) => {
console.log(k.toUpperCase());
console.log(v.toUpperCase());
});
const keyAndValueAsBufferIterator1 = db.iterator({keyAsBuffer: true, valueAsBuffer: true});
keyAndValueAsBufferIterator1.next((err, k, v) => {
console.log(k.readUInt32BE(0));
console.log(v.readUInt32BE(0));
});
const keyAndValueAsBufferIterator2 = db.iterator({keyAsBuffer: true});
keyAndValueAsBufferIterator2.next((err, k, v) => {
console.log(k.readUInt32BE(0));
console.log(v.readUInt32BE(0));
});
const keyAndValueAsBufferIterator3 = db.iterator({valueAsBuffer: true});
keyAndValueAsBufferIterator3.next((err, k, v) => {
console.log(k.readUInt32BE(0));
console.log(v.readUInt32BE(0));
});
const keyAndValueAsBufferIterator4 = db.iterator({});
keyAndValueAsBufferIterator4.next((err, k, v) => {
console.log(k.readUInt32BE(0));
console.log(v.readUInt32BE(0));
});
keyAndValueAsBufferIterator4.seek("k");
keyAndValueAsBufferIterator4.end((err) => {});
const s: string = db.getProperty("leveldb.stats");
db.approximateSize("k1", "k2", (err, size) => {
console.log(size.toExponential());
});
db.compactRange("k1", "k2", (err) => {});
leveldown.destroy("/path/to/db", (err) => {});
leveldown.repair("/path/to/db", (err) => {});
+1 -1
View File
@@ -20,4 +20,4 @@
"index.d.ts",
"leveldown-tests.ts"
]
}
}
+3 -1
View File
@@ -1 +1,3 @@
{ "extends": "dtslint/dt.json" }
{
"extends": "dtslint/dt.json"
}
+148
View File
@@ -0,0 +1,148 @@
// Type definitions for leveldown 1.7
// Project: https://github.com/level/leveldown
// Definitions by: Thiago de Arruda <https://github.com/tarruda>
// Linus Unnebäck <https://github.com/LinusU>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
export = leveldown;
declare var leveldown: leveldown.Constructor;
declare namespace leveldown {
type Bytes = string | Buffer;
type ErrCallback = (error: any) => void;
type ErrNumberCallback = (error: any, value: number) => void;
type ErrBufferCallback = (error: any, value: Buffer) => void;
type ErrStringCallback = (error: any, value: string) => void;
type KeyAsStringCallback = (error: any, key: string, value: Buffer) => void;
type ValueAsStringCallback = (error: any, key: Buffer, value: string) => void;
type KeyAndValueAsStringCallback = (error: any, key: string, value: string) => void;
type KeyAndValueAsBufferCallback = (error: any, key: Buffer, value: Buffer) => void;
interface PutBatch {
type: "put";
key: Bytes;
value: Bytes;
}
interface DelBatch {
type: "del";
key: Bytes;
}
type Batch = PutBatch | DelBatch;
interface OpenOptions {
createIfMissing?: boolean;
errorIfExists?: boolean;
compression?: boolean;
cacheSize?: number;
}
interface OpenAdvancedOptions extends OpenOptions {
writeBufferSize?: number;
blockSize?: number;
maxOpenFiles?: number;
blockRestartInterval?: number;
maxFileSize?: number;
}
interface WriteOptions {
sync?: boolean;
}
interface ReadOptions {
fillCache?: boolean;
}
interface BufferReadOptions extends ReadOptions {
asBuffer?: true;
}
interface StringReadOptions extends ReadOptions {
asBuffer: false;
}
interface IteratorOptions {
gt?: Bytes;
lt?: Bytes;
gte?: Bytes;
lte?: Bytes;
reverse?: boolean;
keys?: boolean;
values?: boolean;
limit?: number;
fillCache?: boolean;
}
interface KeyAsStringIteratorOptions extends IteratorOptions {
keyAsBuffer: false;
valueAsBuffer?: true;
}
interface ValueAsStringIteratorOptions extends IteratorOptions {
keyAsBuffer?: true;
valueAsBuffer: false;
}
interface KeyAndValueAsStringIteratorOptions extends IteratorOptions {
keyAsBuffer: false;
valueAsBuffer: false;
}
interface KeyAndValueAsBufferIteratorOptions extends IteratorOptions {
keyAsBuffer?: true;
valueAsBuffer?: true;
}
interface Iterator {
seek(key: Bytes): void;
end(callback: ErrCallback): void;
}
interface KeyAsStringIterator extends Iterator {
next(callback: KeyAsStringCallback): void;
}
interface ValueAsStringIterator extends Iterator {
next(callback: ValueAsStringCallback): void;
}
interface KeyAndValueAsStringIterator extends Iterator {
next(callback: KeyAndValueAsStringCallback): void;
}
interface KeyAndValueAsBufferIterator extends Iterator {
next(callback: KeyAndValueAsBufferCallback): void;
}
interface LevelDown {
open(callback: ErrCallback): void;
open(options: OpenOptions, callback: ErrCallback): void;
close(callback?: ErrCallback): void;
put(key: Bytes, value: Bytes, callback: ErrCallback): void;
put(key: Bytes, value: Bytes, options: WriteOptions, callback: ErrCallback): void;
get(key: Bytes, callback: ErrBufferCallback): void;
get(key: Bytes, options: BufferReadOptions, callback: ErrBufferCallback): void;
get(key: Bytes, options: StringReadOptions, callback: ErrStringCallback): void;
del(key: Bytes, callback?: ErrCallback): void;
del(key: Bytes, options: WriteOptions, callback?: ErrCallback): void;
batch(operations: Batch[], callback?: ErrCallback): void;
batch(operations: Batch[], options?: WriteOptions, callback?: ErrCallback): void;
approximateSize(start: Bytes, end: Bytes, callback: ErrNumberCallback): void;
compactRange(start: Bytes, end: Bytes, callback: ErrCallback): void;
getProperty(property: string): string;
iterator(options?: KeyAsStringIteratorOptions): KeyAsStringIterator;
iterator(options?: ValueAsStringIteratorOptions): ValueAsStringIterator;
iterator(options?: KeyAndValueAsStringIteratorOptions): KeyAndValueAsStringIterator;
iterator(options?: KeyAndValueAsBufferIteratorOptions): KeyAndValueAsBufferIterator;
}
interface Constructor {
(location: string): LevelDown;
destroy(location: string, callback: ErrCallback): void;
repair(location: string, callback: ErrCallback): void;
}
}
+86
View File
@@ -0,0 +1,86 @@
import leveldown = require("leveldown");
const db = leveldown("db1");
db.open((err) => {});
db.open({createIfMissing: true}, (err) => {});
db.put("key", "value", (err) => {});
db.put(Buffer.from("key"), Buffer.from("value"), (err) => {});
db.put("key", "value", {sync: true}, (err) => {});
db.get("key", {asBuffer: false}, (error, val) => {
console.log(val.toUpperCase());
});
db.get("key", {fillCache: true}, (error, val) => {
console.log(val.readUInt32BE(0));
});
db.get("key", (error, val) => {
console.log(val.readUInt32BE(0));
});
db.del("key");
db.del("key", (error) => {});
db.del("key", {sync: true}, (error) => {});
db.batch([{
type: "put", key: "k", value: "v"
}, {
type: "del", key: "k"
}], (error) => {});
const keyAsStringIterator = db.iterator({keyAsBuffer: false});
keyAsStringIterator.next((err, k, v) => {
console.log(k.toUpperCase());
console.log(v.readUInt32BE(0));
});
const valueAsStringIterator = db.iterator({valueAsBuffer: false});
valueAsStringIterator.next((err, k, v) => {
console.log(k.readUInt32BE(0));
console.log(v.toUpperCase());
});
const keyAndValueAsStringIterator = db.iterator({keyAsBuffer: false, valueAsBuffer: false});
keyAndValueAsStringIterator.next((err, k, v) => {
console.log(k.toUpperCase());
console.log(v.toUpperCase());
});
const keyAndValueAsBufferIterator1 = db.iterator({keyAsBuffer: true, valueAsBuffer: true});
keyAndValueAsBufferIterator1.next((err, k, v) => {
console.log(k.readUInt32BE(0));
console.log(v.readUInt32BE(0));
});
const keyAndValueAsBufferIterator2 = db.iterator({keyAsBuffer: true});
keyAndValueAsBufferIterator2.next((err, k, v) => {
console.log(k.readUInt32BE(0));
console.log(v.readUInt32BE(0));
});
const keyAndValueAsBufferIterator3 = db.iterator({valueAsBuffer: true});
keyAndValueAsBufferIterator3.next((err, k, v) => {
console.log(k.readUInt32BE(0));
console.log(v.readUInt32BE(0));
});
const keyAndValueAsBufferIterator4 = db.iterator({});
keyAndValueAsBufferIterator4.next((err, k, v) => {
console.log(k.readUInt32BE(0));
console.log(v.readUInt32BE(0));
});
keyAndValueAsBufferIterator4.seek("k");
keyAndValueAsBufferIterator4.end((err) => {});
const s: string = db.getProperty("leveldb.stats");
db.approximateSize("k1", "k2", (err, size) => {
console.log(size.toExponential());
});
db.compactRange("k1", "k2", (err) => {});
leveldown.destroy("/path/to/db", (err) => {});
leveldown.repair("/path/to/db", (err) => {});
+31
View File
@@ -0,0 +1,31 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../../",
"typeRoots": [
"../../"
],
"types": [],
"paths": {
"leveldown": [
"leveldown/v1"
],
"leveldown/*": [
"leveldown/v1/*"
]
},
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"leveldown-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+100 -59
View File
@@ -1,82 +1,123 @@
// Type definitions for LevelUp
// Type definitions for levelup 3.1
// Project: https://github.com/Level/levelup
// Definitions by: Bret Little <https://github.com/blittle>, Thiago de Arruda <https://github.com/tarruda>
// Definitions by: Meirion Hughes <https://github.com/MeirionHughes>
// Daniel Byrne <https://github.com/danwbyrne>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
/// <reference types="node" />
import * as leveldown from "leveldown";
import { EventEmitter } from 'events';
import { AbstractLevelDOWN, AbstractIteratorOptions, AbstractBatch, ErrorCallback, AbstractOptions, ErrorValueCallback, AbstractGetOptions } from 'abstract-leveldown';
export = levelup;
type LevelUpPut<K, V, O> =
((key: K, value: V, callback: ErrorCallback) => void) &
((key: K, value: V, options: O, callback: ErrorCallback) => void) &
((key: K, value: V, options?: O) => Promise<void>);
declare var levelup: levelup.LevelUpConstructor;
type LevelUpGet<K, V, O> =
((key: K, callback: ErrorValueCallback<V>) => void) &
((key: K, options: O, callback: ErrorValueCallback<V>) => void) &
((key: K, options?: O) => Promise<V>);
declare namespace levelup {
type LevelUpDel<K, O> =
((key: K, callback: ErrorCallback) => void) &
((key: K, options: O, callback: ErrorCallback) => void) &
((key: K, options?: O) => Promise<void>);
interface CustomEncoding {
encode(val: any): Buffer| string;
decode(val: Buffer | string): any;
buffer: boolean;
type: string;
}
type LevelUpBatch<K, O> =
((key: K, callback: ErrorCallback) => void) &
((key: K, options: O, callback: ErrorCallback) => void) &
((key: K, options?: O) => Promise<void>);
type Encoding = string | CustomEncoding;
type InferDBPut<DB> =
DB extends { put: (key: infer K, value: infer V, options: infer O, cb: any) => void } ?
LevelUpPut<K, V, O> :
LevelUpPut<any, any, AbstractOptions>;
interface Batch {
type: string;
key: any;
value?: any;
keyEncoding?: Encoding;
valueEncoding?: Encoding;
}
type InferDBGet<DB> =
DB extends { get: (key: infer K, options: infer O, callback: ErrorValueCallback<infer V>) => void } ?
LevelUpGet<K, V, O> :
LevelUpGet<any, any, AbstractGetOptions>;
interface LevelUpBase<BatchType extends Batch> {
open(callback ?: (error : any) => any): void;
close(callback ?: (error : any) => any): void;
put(key: any, value: any, callback ?: (error: any) => any): void;
put(key: any, value: any, options?: { sync?: boolean }, callback ?: (error: any) => any): void;
get(key: any, callback ?: (error: any, value: any) => any): void;
type InferDBDel<DB> =
DB extends { del: (key: infer K, options: infer O, callback: ErrorCallback) => void } ?
LevelUpDel<K, O> :
LevelUpDel<any, AbstractOptions>;
get(key: any, options ?: { keyEncoding?: Encoding; fillCache?: boolean }, callback ?: (error: any, value: any) => any): void;
del(key: any, callback ?: (error: any) => any): void;
del(key: any, options ?: { keyEncoding?: Encoding; sync?: boolean }, callback ?: (error: any) => any): void;
export interface LevelUp<DB = AbstractLevelDOWN> extends EventEmitter {
open(): Promise<void>;
open(callback?: ErrorCallback): void;
close(): Promise<void>;
close(callback?: ErrorCallback): void;
put: InferDBPut<DB>;
get: InferDBGet<DB>;
del: InferDBDel<DB>;
batch(array: BatchType[], options?: { keyEncoding?: Encoding; valueEncoding?: Encoding; sync?: boolean }, callback?: (error?: any)=>any): void;
batch(array: BatchType[], callback?: (error?: any)=>any): void;
batch():LevelUpChain;
isOpen():boolean;
isClosed():boolean;
createReadStream(options?: any): any;
createKeyStream(options?: any): any;
createValueStream(options?: any): any;
createWriteStream(options?: any): any;
destroy(location: string, callback?: Function): void;
repair(location: string, callback?: Function): void;
}
batch(array: AbstractBatch[], options?: any): Promise<void>;
batch(array: AbstractBatch[], options: any, callback: (err?: any) => any): void;
batch(array: AbstractBatch[], callback: (err?: any) => any): void;
type LevelUp = LevelUpBase<Batch>
batch(): LevelUpChain;
interface LevelUpChain {
put(key: any, value: any): LevelUpChain;
put(key: any, value: any, options?: { sync?: boolean }): LevelUpChain;
del(key: any): LevelUpChain;
del(key: any, options ?: { keyEncoding?: Encoding; sync?: boolean }): LevelUpChain;
clear(): LevelUpChain;
write(callback?: (error?: any)=>any) : LevelUpChain;
}
isOpen(): boolean;
isClosed(): boolean;
interface levelupOptions {
createIfMissing?: boolean;
errorIfExists?: boolean;
compression?: boolean;
cacheSize?: number;
keyEncoding?: Encoding;
valueEncoding?: Encoding;
db?: leveldown.Constructor;
createReadStream(options?: AbstractIteratorOptions): NodeJS.ReadableStream;
createKeyStream(options?: AbstractIteratorOptions): NodeJS.ReadableStream;
createValueStream(options?: AbstractIteratorOptions): NodeJS.ReadableStream;
/*
emitted when a new value is 'put'
*/
on(event: 'put', cb: (key: any, value: any) => void): this;
/*
emitted when a value is deleted
*/
on(event: 'del', cb: (key: any) => void): this;
/*
emitted when a batch operation has executed
*/
on(event: 'batch', cb: (ary: any[]) => void): this;
/*
emitted on given event
*/
on(event: 'open' | 'ready' | 'closed' | 'opening' | 'closing', cb: () => void): this;
}
interface LevelUpConstructor {
(hostname: string, options?: levelupOptions): LevelUp;
<DB extends AbstractLevelDOWN = AbstractLevelDOWN>(
db: DB,
options: any,
cb?: ErrorCallback): LevelUp<DB>;
<DB extends AbstractLevelDOWN = AbstractLevelDOWN>(
db: DB,
cb?: ErrorCallback): LevelUp<DB>;
new <DB extends AbstractLevelDOWN = AbstractLevelDOWN>(
db: DB,
options: any,
cb?: ErrorCallback): LevelUp<DB>;
new <DB extends AbstractLevelDOWN = AbstractLevelDOWN>(
db: DB,
cb?: ErrorCallback): LevelUp<DB>;
errors: /*typeof levelerrors*/ any; // ? level-errors is not in DT
}
export interface LevelUpChain<K = any, V = any> {
readonly length: number;
put(key: K, value: V): this;
del(key: K): this;
clear(): this;
write(callback: ErrorCallback): this;
write(): Promise<this>;
}
export const errors: /*typeof levelerrors*/ any; // ? level-errors is not in DT
declare const LevelUp: LevelUpConstructor;
export default LevelUp;
+26 -40
View File
@@ -1,11 +1,5 @@
import levelup = require("levelup");
interface BufferEncoding {
encode(val: any): Buffer;
decode(val: Buffer): any;
buffer: boolean;
type: string;
}
import levelup from 'levelup';
import { AbstractLevelDOWN } from 'abstract-leveldown';
interface StringEncoding {
encode(val: any): string;
@@ -14,50 +8,39 @@ interface StringEncoding {
type: string;
}
declare const bufferEncoding: BufferEncoding;
declare const stringEncoding: StringEncoding;
var db1 = levelup("db1", {
keyEncoding: bufferEncoding,
valueEncoding: bufferEncoding
});
var db2 = levelup("db2", {
const db = levelup(new AbstractLevelDOWN('here'), {
keyEncoding: stringEncoding,
valueEncoding: stringEncoding
});
var db = levelup('./mydb')
db.open();
db.close();
db.open((error)=> {
db.open((error) => {
});
db.close((error)=> {
db.close((error) => {
});
db.put("key", {});
db.put("key", {}, (error)=>{});
db.put("key", {}, { sync: true}, (error)=>{});
db.put("key", {}, (error) => {});
db.put("key", {}, { sync: true}, (error) => {});
db.get("key", {keyEncoding: "json"}, (error, val) => {});
db.get("key", {fillCache: true}, (error, val) => {});
db.get("key", (error, val) => {});
db.del("key");
db.del("key", (error)=>{});
db.del("key", {keyEncoding: "json"}, (error)=>{});
db.del("key", {sync: true}, (error)=>{});
db.del("key", (error) => {});
db.del("key", {keyEncoding: "json"}, (error) => {});
db.del("key", {sync: true}, (error) => {});
db.batch([{
type : 'put'
, key : ([1, 2, 3])
, value : { some: 'json' }
, keyEncoding : 'binary'
, valueEncoding : 'json'
}], (error)=> {});
}], (error: Error | undefined) => {});
db.batch()
.del('father')
@@ -65,20 +48,23 @@ db.batch()
.put('dob', '16 February 1941')
.put('spouse', 'Kim Young-sook')
.put('occupation', 'Clown')
.write(function () { console.log('Done!') })
.write(() => { console.log('Done!'); });
// $ExpectType boolean
db.isOpen();
// $ExpectType boolean
db.isClosed();
var open:boolean = db.isOpen();
var closed:boolean = db.isClosed();
db.createReadStream()
.on('data', function (data: any) {
console.log(data.key, '=', data.value)
.on('data', (data: any) => {
console.log(data.key, '=', data.value);
})
.on('error', function (err: any) {
console.log('Oh my!', err)
.on('error', (err: any) => {
console.log('Oh my!', err);
})
.on('close', function () {
console.log('Stream closed')
})
.on('end', function () {
console.log('Stream closed')
.on('close', () => {
console.log('Stream closed');
})
.on('end', () => {
console.log('Stream closed');
});
+2 -2
View File
@@ -6,7 +6,7 @@
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
@@ -20,4 +20,4 @@
"index.d.ts",
"levelup-tests.ts"
]
}
}
+1 -77
View File
@@ -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"
}
+82
View File
@@ -0,0 +1,82 @@
// Type definitions for levelup 1.0
// Project: https://github.com/Level/levelup
// Definitions by: Bret Little <https://github.com/blittle>, Thiago de Arruda <https://github.com/tarruda>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
import * as leveldown from "leveldown";
export = levelup;
declare var levelup: levelup.LevelUpConstructor;
declare namespace levelup {
interface CustomEncoding {
encode(val: any): Buffer| string;
decode(val: Buffer | string): any;
buffer: boolean;
type: string;
}
type Encoding = string | CustomEncoding;
interface Batch {
type: string;
key: any;
value?: any;
keyEncoding?: Encoding;
valueEncoding?: Encoding;
}
interface LevelUpBase<BatchType extends Batch> {
open(callback ?: (error : any) => any): void;
close(callback ?: (error : any) => any): void;
put(key: any, value: any, callback ?: (error: any) => any): void;
put(key: any, value: any, options?: { sync?: boolean }, callback ?: (error: any) => any): void;
get(key: any, callback ?: (error: any, value: any) => any): void;
get(key: any, options ?: { keyEncoding?: Encoding; fillCache?: boolean }, callback ?: (error: any, value: any) => any): void;
del(key: any, callback ?: (error: any) => any): void;
del(key: any, options ?: { keyEncoding?: Encoding; sync?: boolean }, callback ?: (error: any) => any): void;
batch(array: BatchType[], options?: { keyEncoding?: Encoding; valueEncoding?: Encoding; sync?: boolean }, callback?: (error?: any)=>any): void;
batch(array: BatchType[], callback?: (error?: any)=>any): void;
batch():LevelUpChain;
isOpen():boolean;
isClosed():boolean;
createReadStream(options?: any): any;
createKeyStream(options?: any): any;
createValueStream(options?: any): any;
createWriteStream(options?: any): any;
destroy(location: string, callback?: Function): void;
repair(location: string, callback?: Function): void;
}
type LevelUp = LevelUpBase<Batch>
interface LevelUpChain {
put(key: any, value: any): LevelUpChain;
put(key: any, value: any, options?: { sync?: boolean }): LevelUpChain;
del(key: any): LevelUpChain;
del(key: any, options ?: { keyEncoding?: Encoding; sync?: boolean }): LevelUpChain;
clear(): LevelUpChain;
write(callback?: (error?: any)=>any) : LevelUpChain;
}
interface levelupOptions {
createIfMissing?: boolean;
errorIfExists?: boolean;
compression?: boolean;
cacheSize?: number;
keyEncoding?: Encoding;
valueEncoding?: Encoding;
db?: leveldown.Constructor;
}
interface LevelUpConstructor {
(hostname: string, options?: levelupOptions): LevelUp;
}
}
+84
View File
@@ -0,0 +1,84 @@
import levelup = require("levelup");
interface BufferEncoding {
encode(val: any): Buffer;
decode(val: Buffer): any;
buffer: boolean;
type: string;
}
interface StringEncoding {
encode(val: any): string;
decode(val: string): any;
buffer: boolean;
type: string;
}
declare const bufferEncoding: BufferEncoding;
declare const stringEncoding: StringEncoding;
var db1 = levelup("db1", {
keyEncoding: bufferEncoding,
valueEncoding: bufferEncoding
});
var db2 = levelup("db2", {
keyEncoding: stringEncoding,
valueEncoding: stringEncoding
});
var db = levelup('./mydb')
db.open();
db.close();
db.open((error) => {
});
db.close((error) => {
});
db.put("key", {});
db.put("key", {}, (error) => { });
db.put("key", {}, { sync: true }, (error) => { });
db.get("key", { keyEncoding: "json" }, (error, val) => { });
db.get("key", { fillCache: true }, (error, val) => { });
db.get("key", (error, val) => { });
db.del("key");
db.del("key", (error) => { });
db.del("key", { keyEncoding: "json" }, (error) => { });
db.del("key", { sync: true }, (error) => { });
db.batch([{
type: 'put'
, key: ([1, 2, 3])
, value: { some: 'json' }
, keyEncoding: 'binary'
, valueEncoding: 'json'
}], (error) => { });
db.batch()
.del('father')
.put('name', 'Yuri Irsenovich Kim')
.put('dob', '16 February 1941')
.put('spouse', 'Kim Young-sook')
.put('occupation', 'Clown')
.write(function () { console.log('Done!') })
var open: boolean = db.isOpen();
var closed: boolean = db.isClosed();
db.createReadStream()
.on('data', function (data: any) {
console.log(data.key, '=', data.value)
})
.on('error', function (err: any) {
console.log('Oh my!', err)
})
.on('close', function () {
console.log('Stream closed')
})
.on('end', function () {
console.log('Stream closed')
})
+34
View File
@@ -0,0 +1,34 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictFunctionTypes": true,
"baseUrl": "../../",
"typeRoots": [
"../../"
],
"types": [],
"paths": {
"levelup": [
"levelup/v1"
],
"levelup/*": [
"levelup/v1/*"
],
"leveldown": [
"leveldown/v1"
]
},
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"levelup-tests.ts"
]
}
+79
View File
@@ -0,0 +1,79 @@
{
"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
}
}
+15 -12
View File
@@ -2,6 +2,7 @@
// Project: https://github.com/webpack/memory-fs
// Definitions by: e-cloud <https://github.com/e-cloud>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
/// <reference types="node" />
@@ -38,7 +39,7 @@ declare class MemoryFileSystem {
unlinkSync(_path: string): void;
readlinkSync(_path: string): void;
readlinkSync(_path: string): string;
writeFileSync(_path: string, content: string | Buffer, encoding?: string): void;
@@ -51,11 +52,11 @@ declare class MemoryFileSystem {
createWriteStream(path: string, options?: any): any;
exists(path: string, callback: (isExist: boolean) => any): any;
exists(path: string, callback: (isExist: boolean) => void): void;
writeFile(path: string, content: string | Buffer, callback: (err?: Error) => any): any;
writeFile(path: string, content: string | Buffer, callback: (err: Error | undefined) => void): void;
writeFile(path: string, content: string | Buffer, encoding: string, callback: (err?: Error) => any): any;
writeFile(path: string, content: string | Buffer, encoding: string, callback: (err: Error | undefined) => void): void;
join(path: string, request: string): string;
@@ -63,21 +64,23 @@ declare class MemoryFileSystem {
normalize(path: string): string;
stat(path: string, callback: (err?: Error, result?: any) => any): void;
stat(path: string, callback: (err: Error | null, result?: any) => void): void;
readdir(path: string, callback: (err?: Error, result?: any) => any): void;
readdir(path: string, callback: (err: Error | null, result?: any) => void): void;
mkdirp(path: string, callback: (err?: Error, result?: any) => any): void;
mkdirp(path: string, callback: (err: Error | null, result?: any) => void): void;
rmdir(path: string, callback: (err?: Error, result?: any) => any): void;
rmdir(path: string, callback: (err: Error | null, result?: any) => void): void;
unlink(path: string, callback: (err?: Error, result?: any) => any): void;
unlink(path: string, callback: (err: Error | null, result?: any) => void): void;
readlink(path: string, callback: (err?: Error, result?: any) => any): void;
readlink(path: string, callback: (err: Error | null, result?: any) => void): void;
mkdir(path: string, optArg: {}, callback: (err?: Error, result?: any) => any): void;
mkdir(path: string, callback: (err: Error | null) => void): void;
mkdir(path: string, optArg: {}, callback: (err: Error | null, result?: any) => void): void;
readFile(path: string, optArg: {}, callback: (err?: Error, result?: any) => any): void;
readFile(path: string, callback: (err: Error | null, result?: any) => void): void;
readFile(path: string, optArg: {}, callback: (err: Error | null, result?: any) => void): void;
}
export = MemoryFileSystem;
+7
View File
@@ -0,0 +1,7 @@
import MemoryFileSystem = require('memory-fs')
import webpack = require('webpack')
// integration with webpack
const compiler = webpack()
compiler.inputFileSystem = new MemoryFileSystem()
compiler.outputFileSystem = new MemoryFileSystem()
+2 -1
View File
@@ -22,6 +22,7 @@
"lib/normalize.d.ts",
"test/index.ts",
"test/join.ts",
"test/normalize.ts"
"test/normalize.ts",
"test/webpack.ts"
]
}
+11 -8
View File
@@ -982,7 +982,7 @@ declare namespace Office {
*
* This method is available in the DialogApi requirement set for Word, Excel, or PowerPoint add-ins, and in the Mailbox requirement set 1.4
* for Outlook. For more on how to specify a requirement set in your manifest, see
* {@link https://docs.microsoft.com/en-us/office/dev/add-ins/develop/specify-office-hosts-and-api-requirements | Specify Office hosts and API requirements}.
* {@link https://docs.microsoft.com/office/dev/add-ins/develop/specify-office-hosts-and-api-requirements | Specify Office hosts and API requirements}.
*
* The initial page must be on the same domain as the parent page (the startAddress parameter). After the initial page loads, you can go to
* other domains.
@@ -4818,7 +4818,7 @@ declare namespace Office {
* Clears formatting on the bound table.
*
* @remarks
* See {@link https://docs.microsoft.com/en-us/office/dev/add-ins/excel/excel-add-ins-tables#format-a-table | Format tables in add-ins for Excel} for more information.
* See {@link https://docs.microsoft.com/office/dev/add-ins/excel/excel-add-ins-tables#format-a-table | Format tables in add-ins for Excel} for more information.
*
* **Support details**
*
@@ -5111,7 +5111,7 @@ declare namespace Office {
}
/**
* Specifies enumerated values for the `cells` property in the cellFormat parameter of
* {@link https://docs.microsoft.com/en-us/office/dev/add-ins/excel/excel-add-ins-tables#format-a-table | table formatting methods}.
* {@link https://docs.microsoft.com/office/dev/add-ins/excel/excel-add-ins-tables#format-a-table | table formatting methods}.
*
* @remarks
*
@@ -17246,9 +17246,12 @@ declare namespace OfficeExtension {
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
////////////////////// Begin OfficeCore ////////////////////////
////////////////////////////////////////////////////////////////
@@ -54984,7 +54987,7 @@ declare namespace OneNote {
*
* @param left The left position of the top, left corner of the Outline.
* @param top The top position of the top, left corner of the Outline.
* @param html An HTML string that describes the visual presentation of the Outline. See {@link https://docs.microsoft.com/en-us/office/dev/add-ins/onenote/onenote-add-ins-page-content#supported-html | Supported HTML} for the OneNote add-ins JavaScript API.
* @param html An HTML string that describes the visual presentation of the Outline. See {@link https://docs.microsoft.com/office/dev/add-ins/onenote/onenote-add-ins-page-content#supported-html | Supported HTML} for the OneNote add-ins JavaScript API.
*/
addOutline(left: number, top: number, html: string): OneNote.Outline;
/**
@@ -55366,7 +55369,7 @@ declare namespace OneNote {
*
* [Api set: OneNoteApi 1.1]
*
* @param html The HTML string to append. See {@link https://docs.microsoft.com/en-us/office/dev/add-ins/onenote/onenote-add-ins-page-content#supported-html | Supported HTML} for the OneNote add-ins JavaScript API.
* @param html The HTML string to append. See {@link https://docs.microsoft.com/office/dev/add-ins/onenote/onenote-add-ins-page-content#supported-html | Supported HTML} for the OneNote add-ins JavaScript API.
*/
appendHtml(html: string): void;
/**
@@ -55584,7 +55587,7 @@ declare namespace OneNote {
* [Api set: OneNoteApi 1.1]
*
* @param insertLocation The location of new contents relative to the current Paragraph.
* @param html An HTML string that describes the visual presentation of the content. See {@link https://docs.microsoft.com/en-us/office/dev/add-ins/onenote/onenote-add-ins-page-content#supported-html | Supported HTML} for the OneNote add-ins JavaScript API.
* @param html An HTML string that describes the visual presentation of the content. See {@link https://docs.microsoft.com/office/dev/add-ins/onenote/onenote-add-ins-page-content#supported-html | Supported HTML} for the OneNote add-ins JavaScript API.
*/
insertHtmlAsSibling(insertLocation: OneNote.InsertLocation, html: string): void;
/**
@@ -55594,7 +55597,7 @@ declare namespace OneNote {
* [Api set: OneNoteApi 1.1]
*
* @param insertLocation The location of new contents relative to the current Paragraph.
* @param html An HTML string that describes the visual presentation of the content. See {@link https://docs.microsoft.com/en-us/office/dev/add-ins/onenote/onenote-add-ins-page-content#supported-html | Supported HTML} for the OneNote add-ins JavaScript API.
* @param html An HTML string that describes the visual presentation of the content. See {@link https://docs.microsoft.com/office/dev/add-ins/onenote/onenote-add-ins-page-content#supported-html | Supported HTML} for the OneNote add-ins JavaScript API.
*/
insertHtmlAsSibling(insertLocation: "Before" | "After", html: string): void;
/**
@@ -56403,7 +56406,7 @@ declare namespace OneNote {
*
* [Api set: OneNoteApi 1.1]
*
* @param html The HTML string to append. See {@link https://docs.microsoft.com/en-us/office/dev/add-ins/onenote/onenote-add-ins-page-content#supported-html | Supported HTML} for the OneNote add-ins JavaScript API.
* @param html The HTML string to append. See {@link https://docs.microsoft.com/office/dev/add-ins/onenote/onenote-add-ins-page-content#supported-html | Supported HTML} for the OneNote add-ins JavaScript API.
*/
appendHtml(html: string): void;
/**
+117
View File
@@ -0,0 +1,117 @@
// Type definitions for office-runtime 1.0
// Project: http://dev.office.com/
// Definitions by: Michael Zlatskovsky <https://github.com/Zlatkovsky>, Michelle Scharlock <https://github.com/mscharlock>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// Typescript Version: 2.4
/*
office-runtime
Copyright (c) Microsoft Corporation
*/
declare namespace OfficeRuntime {
function displayWebDialog(url: string, options: DisplayWebDialogOptions): Promise<Dialog>;
const AsyncStorage: AsyncStorage;
// tslint:disable-next-line:interface-name
/*
* Asynchronous, global, and persistent key-value storage that can be used by Excel Custom Functions.
* @beta
*
* @remarks
* Each add-in instance has its own storage partition, unique to a user and their device.
*
* The default amount of total storage allowed per add-in is 5MB.
*
* Each method listed below returns a Promise object.
*
*/
interface AsyncStorage {
/*
* @beta
* Retrieves an object based on a key and invokes a callback when finished. Returns a Promise.
*/
getItem(key: string, callback?: (error?: Error, result?: string) => void): Promise<string>;
/*
* @beta
* Assigns the value for a key-value pair and invokes a callback when finished. Returns a Promise.
*/
setItem(key: string, value: string, callback?: (error?: Error) => void): Promise<void>;
/*
* @beta
* Removes an item for specified key and invokes a callback when finished. Returns a Promise.
*/
removeItem(key: string, callback?: (error?: Error) => void): Promise<void>;
/*
* @beta
* Erases all AsyncStorage. Returns a Promise.
*/
clear(callback?: (error?: Error) => void): Promise<void>;
/*
* @beta
* Returns a Promise with all keys.
*/
getAllKeys(callback?: (error?: Error, keys?: string[]) => void): Promise<string[]>;
/*
* @beta
* Stores multiple key-value pairs in one batch. Returns a Promise. When a key doesn't exist, returns null.
*/
multiSet(keyValuePairs: string[][], callback?: (errors?: Error[]) => void): Promise<void>;
/*
* @beta
* Deletes a batch of keys, specified in the `keys` array.
*/
multiRemove(keys: string[], callback?: (errors?: Error[]) => void): Promise<void>;
/*
* @beta
* Fetches a batch of keys, specified in the `keys` array. When a key doesn't exist, returns null.
*/
multiGet(keys: string[], callback?: (errors?: Error[], result?: string[][]) => void): Promise<string[][]>;
}
/*
* @beta
* Object representing the dialog box.
*/
interface Dialog {
/*
* @beta
* Method that closes a dialog box.
*/
close(): Promise<void>;
}
/*
* Provides options for how a dialog is displayed.
*/
interface DisplayWebDialogOptions {
/*
* @beta
* Determines whether the dialog box displays as a popup (false) or within an IFrame (true). This setting is only applicable to custom functions running on Excel Online.
*/
displayInIFrame?: boolean;
/*
* @beta
* Defines the height of the dialog box as a percentage of the current display.
*/
height?: string;
/*
* @beta
* Defines the width of the dialog box as a percentage of the current display.
*/
width?: string;
/*
* @beta
* True if title is hidden from the dialog box.
*/
hideTitle?: boolean;
/*
* @beta
* Callback that is run when the dialog box is closed.
*/
onClose?: () => void;
/*
* @beta
* Callback that is run when the dialog box sends an error.
*/
onMessage?(message: string, dialog?: Dialog): void;
}
}
@@ -0,0 +1,61 @@
/*
office-runtime
Copyright (c) Microsoft Corporation
*/
OfficeRuntime.AsyncStorage.getItem("foo", () => {
// perform an action
});
OfficeRuntime.AsyncStorage.getItem("foo").then(value => console.log(value));
OfficeRuntime.AsyncStorage.setItem("foo", "bar");
OfficeRuntime.AsyncStorage.setItem("foo", "bar").then(error => console.log(error));
OfficeRuntime.AsyncStorage.removeItem("foo");
OfficeRuntime.AsyncStorage.removeItem("foo", () => {
// perform an action
});
OfficeRuntime.AsyncStorage.clear();
OfficeRuntime.AsyncStorage.clear(() => {
// perform an action
});
OfficeRuntime.AsyncStorage.getAllKeys().then(keys => {
keys.forEach(item => console.log(item));
});
OfficeRuntime.AsyncStorage.getAllKeys((error, keys) => {
if (error) {
console.error(error);
} else {
keys.forEach(item => console.log(item));
}
});
OfficeRuntime.AsyncStorage.multiSet(
[["username", "foo"], ["yearOfBirth", "2001"]],
errors => {
errors.filter(error => error != null).forEach(error => console.log(error));
}
);
OfficeRuntime.AsyncStorage.multiRemove(["foo", "bar"]);
OfficeRuntime.AsyncStorage.multiRemove(["foo", "bar"]).then(value => console.log(value));
OfficeRuntime.AsyncStorage.multiGet(["username", "yearOfBirth"]).then(
values => {
console.log(values[0][1]);
console.log(values[1][1]);
}
);
OfficeRuntime.displayWebDialog("https://localhost:3000", {
displayInIFrame: false
});
OfficeRuntime.displayWebDialog("https://localhost:3000", {
onClose: () => {
console.log("closed");
}
});
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": ["../"],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"target": "es6"
},
"files": [
"index.d.ts",
"office-runtime-tests.ts"
]
}

Some files were not shown because too many files have changed in this diff Show More