Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…yTyped into jquery/promise-compatibility
  • Loading branch information
leonard-thieu committed Sep 17, 2018
2 parents fec4350 + 428a996 commit 5dd33c0
Show file tree
Hide file tree
Showing 201 changed files with 6,599 additions and 856 deletions.
6 changes: 6 additions & 0 deletions notNeededPackages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1278,6 +1278,12 @@
"sourceRepoURL": "https://github.com/zalmoxisus/redux-devtools-extension",
"asOfVersion": "2.13.2"
},
{
"libraryName": "redux-little-router",
"typingsPackageName": "redux-little-router",
"sourceRepoURL": "https://github.com/FormidableLabs/redux-little-router",
"asOfVersion": "15.1.0"
},
{
"libraryName": "redux-persist",
"typingsPackageName": "redux-persist",
Expand Down
9 changes: 4 additions & 5 deletions types/angular-ui-sortable/angular-ui-sortable-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,8 @@ myApp.controller('sortableController', function ($scope: MySortableControllerSco
$scope.sortableOptions.tolerance = 'pointer';
$scope.sortableOptions.zIndex = 9999;

$scope.sortableOptions['ui-floating'] = undefined;
$scope.sortableOptions['ui-floating'] = null;
$scope.sortableOptions['ui-floating'] = false;
$scope.sortableOptions['ui-floating'] = true;
$scope.sortableOptions['ui-floating'] = "auto";
const sortableFloatingOption0: ng.ui.UISortableOptions<SortableModelInfo> = { 'ui-floating': undefined };
const sortableFloatingOption1: ng.ui.UISortableOptions<SortableModelInfo> = { 'ui-floating': false };
const sortableFloatingOption2: ng.ui.UISortableOptions<SortableModelInfo> = { 'ui-floating': true };
const sortableFloatingOption3: ng.ui.UISortableOptions<SortableModelInfo> = { 'ui-floating': 'auto' };
});
2 changes: 1 addition & 1 deletion types/angular-ui-sortable/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ declare module 'angular' {
export namespace ui {

interface UISortableOptions<T> extends SortableOptions<T> {
'ui-floating'?: string | boolean;
'ui-floating'?: 'auto' | boolean;
}

interface UISortableProperties<T> {
Expand Down
28 changes: 28 additions & 0 deletions types/bloom-filter/bloom-filter-tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import BloomFilter = require('bloom-filter');

const numElements = 3;
const falsePositiveRate = 0.01;
const filter = BloomFilter.create(numElements, falsePositiveRate);

// elements
const a = Buffer.from('99108ad8ed9bb6274d3980bab5a85c048f0950c8', 'hex');
const c = Buffer.from('b5a2c786d9ef4658287ced5914b37a1b4aa32eee', 'hex');

// insert elements
// $ExpectType void
filter.insert(a);

// $ExpectType boolean
!filter.contains(c);

// reinstantiate from an object
const serialized = filter.toObject();
const woahFilter = new BloomFilter(serialized);

// initialize directly
const newFilter = new BloomFilter({
vData: Buffer.from('123', 'hex'), // the data of the filter
nHashFuncs: 3, // the number of hash functions to use
nTweak: 2147483649, // the seed used for the hash fuctions
nFlags: 0 // flags used to update the filter when matched
});
38 changes: 38 additions & 0 deletions types/bloom-filter/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Type definitions for bloom-filter 0.2
// Project: https://github.com/bitpay/bloom-filter
// Definitions by: Daniel Byrne <https://github.com/danwbyrne>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

/// <reference types="node" />

declare class Filter {
constructor(options: Filter.FilterOptions);
static create(elements: number, falsePositiveRate: number, nTweak?: number, nFlags?: number): Filter;
toObject(): Filter.FilterOptions;
hash(nHashNum: number, vDataToHash: Buffer): number;
insert(data: Buffer): void;
contains(data: Buffer): boolean;
clear(): void;
inspect(): string;
BLOOM_UPDATE_NONE: number;
BLOOM_UPDATE_ALL: number;
BLOOM_UPDATE_P2PUBKEY_ONLY: number;
MAX_BLOOM_FILTER_SIZE: number;
MAX_HASH_FUNCS: number;
MIN_HASH_FUNCS: number;
LN2SQUARED: number;
LN2: number;
}

declare namespace Filter {
interface FilterOptions {
vData: Buffer;
nHashFuncs: number;
nTweak?: number;
nFlags?: number;
}

function MurmurHash3(seed: number, data: Buffer): number;
}

export = Filter;
19 changes: 19 additions & 0 deletions types/bloom-filter/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es6"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": ["../"],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"bloom-filter-tests.ts"
]
}
3 changes: 3 additions & 0 deletions types/bloom-filter/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}
2 changes: 2 additions & 0 deletions types/chart.js/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,8 @@ declare namespace Chart {
easing?: string;
onProgress?(chart: any): void;
onComplete?(chart: any): void;
animateRotate?: boolean;
animateScale?: boolean;
}

interface ChartElementsOptions {
Expand Down
4 changes: 2 additions & 2 deletions types/chroma-js/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ declare namespace chroma {
* Computes the eucledian distance between two colors in a given color space (default is 'lab').
* {@link https://en.wikipedia.org/wiki/Euclidean_distance#Three_dimensions}
*/
distance(color1: string | Color, color2: string | Color, colorSpace?: keyof ColorSpaces): Color;
distance(color1: string | Color, color2: string | Color, colorSpace?: keyof ColorSpaces): number;

/**
* Computes color difference {@link https://en.wikipedia.org/wiki/Color_difference#CMC_l:c_.281984.29} as
Expand All @@ -133,7 +133,7 @@ declare namespace chroma {
* {@link https://web.archive.org/web/20160306044036/http://www.brucelindbloom.com/javascript/ColorDiff.js}
* The parameters L (default 1) and C (default 1) are weighting factors for lightness and chromacity.
*/
deltaE(color1: string | Color, color2: string | Color, L?: number, C?: number): Color;
deltaE(color1: string | Color, color2: string | Color, L?: number, C?: number): number;

/**
* chroma.brewer is an map of ColorBrewer scales that are included in chroma.js for convenience.
Expand Down
1 change: 1 addition & 0 deletions types/dagre-d3/dagre-d3-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ graph.transition = (selection: d3.Selection<any>) => {
const render = new dagreD3.render();
const svg = d3.select("svg");
render.arrows()["arrowType"] = (parent: d3.Selection<any>, id: string, edge: dagre.Edge, type: string) => {};
render.shapes()["shapeName"] = (parent: d3.Selection<any>, bbox: any, node: dagre.Node) => {};
render(svg, graph);
2 changes: 2 additions & 0 deletions types/dagre-d3/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export as namespace dagreD3;

export * from "dagre";
export const render: { new(): Render };
export const intersect: { [shapeName: string]: (node: dagre.Node, points: Array<{}>, point: any) => void };

declare module "dagre" {
namespace graphlib {
Expand All @@ -32,4 +33,5 @@ export interface Render {
// see http://cpettitt.github.io/project/dagre-d3/latest/demo/user-defined.html for example usage
arrows(): { [arrowStyleName: string]: (parent: d3.Selection<any>, id: string, edge: dagre.Edge, type: string) => void };
(selection: d3.Selection<any>, g: dagre.graphlib.Graph): void;
shapes(): { [shapeStyleName: string]: (parent: d3.Selection<any>, bbox: any, node: dagre.Node) => void };
}
47 changes: 47 additions & 0 deletions types/elliptic/elliptic-tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import elliptic = require('elliptic');

const ec = new elliptic.ec('secp256k1');

// Generate keys
const key = ec.genKeyPair();

// Sign the message's hash (input must be an array, or a hex-string)
const msgHash = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
const signature = key.sign(msgHash);

// Export DER encoded signature in Array
const derSign = signature.toDER();

// Verify signature
console.log(key.verify(msgHash, derSign));

// CHECK WITH NO PRIVATE KEY

const pubPoint = key.getPublic();
const x = pubPoint.getX();
const y = pubPoint.getY();

// Public Key MUST be either:
// 1) '04' + hex string of x + hex string of y; or
// 2) object with two hex string properties (x and y); or
// 3) object with two buffer properties (x and y)
const pub = pubPoint.encode('hex'); // case 1
const aPub = { x: x.toString('hex'), y: y.toString('hex') }; // case 2
const bPub = { x: x.toBuffer(), y: y.toBuffer() }; // case 3
const cPub = { x: x.toArrayLike(Buffer), y: y.toArrayLike(Buffer) }; // case 3

// Import public key
const newKey = ec.keyFromPublic(pub, 'hex');

// Signature MUST be either:
// 1) DER-encoded signature as hex-string; or
// 2) DER-encoded signature as buffer; or
// 3) object with two hex-string properties (r and s); or
// 4) object with two buffer properties (r and s)

// const signature = '3046022100...'; // case 1
// const signature = new Buffer('...'); // case 2
// const signature = { r: 'b1fc...', s: '9c42...' }; // case 3

// Verify signature
console.log(key.verify(msgHash, signature));
158 changes: 158 additions & 0 deletions types/elliptic/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
// Type definitions for elliptic 6.4
// Project: https://github.com/indutny/elliptic
// Definitions by: Daniel Byrne <https://github.com/danwbyrne>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

import BN = require('bn.js');

// incomplete typings
export const utils: any;
export const rand: any;
export const eddsa: any;

export type BNInput = string | BN | number | Buffer | number[];

export const version: number;

export namespace curve {
class BaseCurve {
constructor(type: string, conf: BaseCurve.BaseCurveOptions)
p: BN;
type: string;
red: any; // ?
zero: any; // ?
one: any; // ?
two: any; // ?
n: BN | undefined | null;
g: any; // ?
redN: any; // ?
decodePoint(bytes: any, enc: string): any; // ?
}

namespace BaseCurve {
class BasePoint {
constructor(curve: any, type: string);
curve: any;
type: string;
precomputed: PrecomputedValues | null;
encode(enc: string, compact: boolean): BN;
encodeCompressed(enc: string): BN;
validate(): boolean;
precompute(power: number): BasePoint;
dblp(k: any): any; // ?
}

interface BaseCurveOptions {
p: number | string | number[] | Buffer | BN;
prime?: BN | string;
n?: number | BN | Buffer;
g?: any; // ?
gRed?: any; // ?
}

interface PrecomputedValues {
doubles: any; // ?
naf: any; // ?
beta: any; // ?
}
}
}

export namespace curves {
class PresetCurve {
constructor(options: PresetCurve.Options)
type: string;
g: any; // ?
n: BN | undefined | null;
hash: any; // ?
}

namespace PresetCurve {
interface Options {
type: string;
prime: string | null;
p: string;
a: string;
b: string;
n: string;
hash: any;
gRed: boolean;
g: any; // ?
beta?: string;
lambda?: string;
basis?: any; // ?
}
}
}

export class ec {
constructor(options: string | curves.PresetCurve)
curve: any;
n: BN | undefined | null;
nh: any;
g: any;
hash: any;

keyPair(options: ec.KeyPairOptions): ec.KeyPair;
keyFromPrivate(priv: Buffer | ec.KeyPair, enc?: string): ec.KeyPair;
keyFromPublic(pub: Buffer | ec.KeyPair, enc?: string): ec.KeyPair;
genKeyPair(options?: ec.GenKeyPairOptions): ec.KeyPair;
sign(msg: BNInput, key: Buffer | ec.KeyPair, enc: string, options?: ec.SignOptions): ec.Signature;
sign(msg: BNInput, key: Buffer | ec.KeyPair, options?: ec.SignOptions): ec.Signature;
verify(msg: BNInput, signature: ec.Signature | ec.SignatureOptions, key: Buffer | ec.KeyPair, enc?: string): boolean;
recoverPubKey(msg: BNInput, signature: ec.Signature | ec.SignatureOptions, j: number, enc?: string): any;
getKeyRecoveryParam(e: Error | undefined, signature: ec.Signature | ec.SignatureOptions, Q: BN, enc?: string): number;
}

export namespace ec {
interface GenKeyPairOptions {
pers: any;
entropy: any;
persEnc?: string;
entropyEnc?: string;
}

interface SignOptions {
pers: any;
persEnc?: string;
canonical?: boolean;
k?: BN;
}

class KeyPair {
static fromPublic(ec: ec, pub: Buffer | KeyPair, enc?: string): KeyPair;
static fromPrivate(ec: ec, priv: Buffer | KeyPair, enc?: string): KeyPair;
constructor(ec: ec, options: KeyPairOptions)
ec: ec;
validate(): { readonly result: boolean, readonly reason: string };
getPublic(compact: boolean, enc?: string): any; // ?
getPublic(enc?: string): any; // ?
getPrivate(enc?: 'hex'): Buffer | BN | string;
derive(pub: any): any; // ?
sign(msg: BNInput, enc: string, options?: SignOptions): Signature;
sign(msg: BNInput, options?: SignOptions): Signature;
verify(msg: BNInput, signature: Signature | SignatureOptions): boolean;
inspect(): string;
}

class Signature {
constructor(options: SignatureOptions | Signature, enc?: string)
r: BN;
s: BN;
recoveryParam: number | null;
toDER(enc?: string | null): any; // ?
}

interface SignatureOptions {
r: number;
s: number;
recoveryParam?: number;
}

interface KeyPairOptions {
priv?: Buffer;
privEnc?: string;
pub?: Buffer;
pubEnc?: string;
}
}
Loading

0 comments on commit 5dd33c0

Please sign in to comment.