mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 06:47:03 +00:00
Merge branch 'master' into jest-type-inference
This commit is contained in:
+305
-266
File diff suppressed because it is too large
Load Diff
@@ -255,12 +255,30 @@ Here are the [currently requested definitions](https://github.com/DefinitelyType
|
||||
|
||||
If types are part of a web standard, they should be contributed to [TSJS-lib-generator](https://github.com/Microsoft/TSJS-lib-generator) so that they can become part of the default `lib.dom.d.ts`.
|
||||
|
||||
#### Should I add an empty namespace to a package that doesn't export a module to use ES6 style imports?
|
||||
|
||||
Some packages, like [chai-http](https://github.com/chaijs/chai-http), export a function.
|
||||
|
||||
Importing this module with an ES6 style import in the form `import * as foo from "foo";` leads to the error:
|
||||
|
||||
> error TS2497: Module 'foo' resolves to a non-module entity and cannot be imported using this construct
|
||||
|
||||
This error can be suppressed by merging the function declaration with an empty namespace of the same name, but this practice is discouraged.
|
||||
This is a commonly cited [Stack Overflow answer](https://stackoverflow.com/questions/39415661/what-does-resolves-to-a-non-module-entity-and-cannot-be-imported-using-this) regarding this matter.
|
||||
|
||||
It is more appropriate to import the module using the `import foo = require("foo");` syntax.
|
||||
Nevertheless, if you want to use a default import like `import foo from "foo";` you have two options:
|
||||
- you can use the [`--allowSyntheticDefaultImports` compiler option](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-1-8.html#support-for-default-import-interop-with-systemjs) if your module runtime supports an interop scheme for non-ECMAScript modules, i.e. if default imports work in your environment (e.g. Webpack, SystemJS, esm).
|
||||
- you can use the [`--esModuleInterop` compiler option](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-7.html#support-for-import-d-from-cjs-form-commonjs-modules-with---esmoduleinterop) if you want TypeScript to take care of non-ECMAScript interop (since Typescript 2.7).
|
||||
|
||||
#### A package uses `export =`, but I prefer to use default imports. Can I change `export =` to `export default`?
|
||||
|
||||
If you are using TypeScript 2.7 or later, use `--esModuleInterop` in your project.
|
||||
Otherwise, if default imports work in your environment (e.g. Webpack, SystemJS, esm), consider turning on the [`--allowSyntheticDefaultImports`](http://www.typescriptlang.org/docs/handbook/compiler-options.html) compiler option.
|
||||
Like in the previous question, refer to using either the [`--allowSyntheticDefaultImports`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-1-8.html#support-for-default-import-interop-with-systemjs)
|
||||
or [`--esModuleInterop`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-7.html#support-for-import-d-from-cjs-form-commonjs-modules-with---esmoduleinterop)
|
||||
compiler options.
|
||||
|
||||
Do not change the type definition if it is accurate.
|
||||
For an NPM package, `export =` is accurate if `node -p 'require("foo")'` is the export, and `export default` is accurate if `node -p 'require("foo").default'` is the export.
|
||||
For an NPM package, `export =` is accurate if `node -p 'require("foo")'` works to import a module, and `export default` is accurate if `node -p 'require("foo").default'` works to import a module.
|
||||
|
||||
#### I want to use features from TypeScript 2.1 or above.
|
||||
|
||||
@@ -268,8 +286,9 @@ Then you will have to add a comment to the last line of your definition header (
|
||||
|
||||
#### I want to use features from TypeScript 3.1 or above.
|
||||
|
||||
You will need to use the `typesVersions` feature of TypeScript 3.1 and above. You can find a detailed explanation
|
||||
of this feature in the [official TypeScript documentation](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-1.html#version-selection-with-typesversions).
|
||||
You can use the same `// TypeScript Version: 3.1` comment as above.
|
||||
However, if your project needs to maintain types that are compatible with 3.1 and above *at the same time as* types that are compatible with 3.0 or below, you will need to use the `typesVersions` feature, which is available in TypeScript 3.1 and above.
|
||||
You can find a detailed explanation of this feature in the [official TypeScript documentation](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-1.html#version-selection-with-typesversions).
|
||||
|
||||
Here's a short explanation to get you started:
|
||||
|
||||
@@ -368,19 +387,6 @@ When `dts-gen` is used to scaffold a scoped package, the `paths` property has to
|
||||
|
||||
GitHub doesn't [support](http://stackoverflow.com/questions/5646174/how-to-make-github-follow-directory-history-after-renames) file history for renamed files. Use [`git log --follow`](https://www.git-scm.com/docs/git-log) instead.
|
||||
|
||||
#### Should I add an empty namespace to a package that doesn't export a module to use ES6 style imports?
|
||||
|
||||
Some packages, like [chai-http](https://github.com/chaijs/chai-http), export a function.
|
||||
|
||||
Importing this module with an ES6 style import in the form `import * as foo from "foo";` leads to the error:
|
||||
|
||||
> error TS2497: Module 'foo' resolves to a non-module entity and cannot be imported using this construct
|
||||
|
||||
This error can be suppressed by merging the function declaration with an empty namespace of the same name, but this practice is discouraged.
|
||||
This is a commonly cited [Stack Overflow answer](https://stackoverflow.com/questions/39415661/what-does-resolves-to-a-non-module-entity-and-cannot-be-imported-using-this) regarding this matter.
|
||||
|
||||
It is more appropriate to import the module using the `import foo = require("foo");` syntax, or to use a default import like `import foo from "foo";` if using the `--allowSyntheticDefaultImports` flag if your module runtime supports an interop scheme for non-ECMAScript modules as such.
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the MIT license.
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
import { Ber, BerReader, BerWriter } from 'asn1';
|
||||
|
||||
let buf: Buffer = Buffer.alloc(0);
|
||||
let bool = false;
|
||||
let str = '';
|
||||
let num = 0;
|
||||
let numOrNull: number | null = 0;
|
||||
const roStrArray: ReadonlyArray<string> = [str];
|
||||
|
||||
const reader = new BerReader(buf);
|
||||
numOrNull = reader.peek();
|
||||
bool = reader.readBoolean();
|
||||
numOrNull = reader.readByte(bool);
|
||||
num = reader.readEnumeration();
|
||||
num = reader.readInt();
|
||||
num = reader.readLength();
|
||||
num = reader.readLength(num);
|
||||
str = reader.readOID();
|
||||
str = reader.readOID(num);
|
||||
numOrNull = reader.readSequence();
|
||||
numOrNull = reader.readSequence(num);
|
||||
str = reader.readString();
|
||||
str = reader.readString(num);
|
||||
buf = reader.readString(num, bool);
|
||||
num = reader._readTag();
|
||||
num = reader._readTag(num);
|
||||
|
||||
let writer = new BerWriter();
|
||||
writer = new BerWriter({
|
||||
size: num,
|
||||
growthFactor: num,
|
||||
});
|
||||
|
||||
buf = writer.buffer;
|
||||
buf = writer._buf;
|
||||
num = writer._size;
|
||||
num = writer._offset;
|
||||
|
||||
writer.endSequence();
|
||||
writer.startSequence();
|
||||
writer.startSequence(num);
|
||||
writer.writeBoolean(bool);
|
||||
writer.writeBoolean(bool, num);
|
||||
writer.writeBuffer(buf, num);
|
||||
writer.writeByte(num);
|
||||
writer.writeEnumeration(num);
|
||||
writer.writeEnumeration(num, num);
|
||||
writer.writeInt(num);
|
||||
writer.writeInt(num, num);
|
||||
writer.writeLength(num);
|
||||
writer.writeNull();
|
||||
writer.writeOID(str, num);
|
||||
writer.writeString(str);
|
||||
writer.writeString(str, num);
|
||||
writer.writeStringArray(roStrArray);
|
||||
writer._ensure(num);
|
||||
|
||||
num = Ber.BMPString;
|
||||
num = Ber.BitString;
|
||||
num = Ber.Boolean;
|
||||
num = Ber.CharacterString;
|
||||
num = Ber.Constructor;
|
||||
num = Ber.Context;
|
||||
num = Ber.EOC;
|
||||
num = Ber.Enumeration;
|
||||
num = Ber.External;
|
||||
num = Ber.GeneralString;
|
||||
num = Ber.GeneralizedTime;
|
||||
num = Ber.GraphicString;
|
||||
num = Ber.IA5String;
|
||||
num = Ber.Integer;
|
||||
num = Ber.Null;
|
||||
num = Ber.NumericString;
|
||||
num = Ber.OID;
|
||||
num = Ber.ObjectDescriptor;
|
||||
num = Ber.OctetString;
|
||||
num = Ber.PDV;
|
||||
num = Ber.PrintableString;
|
||||
num = Ber.Real;
|
||||
num = Ber.RelativeOID;
|
||||
num = Ber.Sequence;
|
||||
num = Ber.Set;
|
||||
num = Ber.T61String;
|
||||
num = Ber.UTCTime;
|
||||
num = Ber.UniversalString;
|
||||
num = Ber.Utf8String;
|
||||
num = Ber.VideotexString;
|
||||
num = Ber.VisibleString;
|
||||
Vendored
+126
@@ -0,0 +1,126 @@
|
||||
// Type definitions for asn1 0.2
|
||||
// Project: https://github.com/joyent/node-asn1
|
||||
// Definitions by: Jim Geurts <https://github.com/jgeurts>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
/// <reference types="node" />
|
||||
|
||||
export class BerReader {
|
||||
readonly buffer: Buffer;
|
||||
readonly offset: number;
|
||||
readonly length: number;
|
||||
readonly remain: number;
|
||||
readonly _buf: Buffer;
|
||||
_size: number;
|
||||
_offset: number;
|
||||
|
||||
constructor(data: Buffer);
|
||||
|
||||
peek(): number | null;
|
||||
readBoolean(): boolean;
|
||||
readByte(peek: boolean): number | null;
|
||||
readEnumeration(): number;
|
||||
readInt(): number;
|
||||
readLength(offset?: number): number;
|
||||
readOID(tag?: number): string;
|
||||
readSequence(tag?: number): number | null;
|
||||
readString(tag?: number): string;
|
||||
readString(tag: number, retbuf: boolean): Buffer;
|
||||
_readTag(tag?: number): number;
|
||||
}
|
||||
|
||||
export class BerWriter {
|
||||
readonly buffer: Buffer;
|
||||
readonly _buf: Buffer;
|
||||
readonly _size: number;
|
||||
_offset: number;
|
||||
|
||||
constructor(options?: {
|
||||
size: number;
|
||||
growthFactor: number;
|
||||
});
|
||||
|
||||
endSequence(): void;
|
||||
startSequence(tag?: number): void;
|
||||
writeBoolean(b: boolean, tag?: number): void;
|
||||
writeBuffer(buf: Buffer, tag: number): void;
|
||||
writeByte(b: number): void;
|
||||
writeEnumeration(i: number, tag?: number): void;
|
||||
writeInt(i: number, tag?: number): void;
|
||||
writeLength(len: number): void;
|
||||
writeNull(): void;
|
||||
writeOID(s: string, tag: number): void;
|
||||
writeString(s: string, tag?: number): void;
|
||||
writeStringArray(strings: ReadonlyArray<string>): void;
|
||||
_ensure(length: number): void;
|
||||
}
|
||||
|
||||
export namespace Ber {
|
||||
const BMPString: number;
|
||||
const BitString: number;
|
||||
const Boolean: number;
|
||||
const CharacterString: number;
|
||||
const Constructor: number;
|
||||
const Context: number;
|
||||
const EOC: number;
|
||||
const Enumeration: number;
|
||||
const External: number;
|
||||
const GeneralString: number;
|
||||
const GeneralizedTime: number;
|
||||
const GraphicString: number;
|
||||
const IA5String: number;
|
||||
const Integer: number;
|
||||
const Null: number;
|
||||
const NumericString: number;
|
||||
const OID: number;
|
||||
const ObjectDescriptor: number;
|
||||
const OctetString: number;
|
||||
const PDV: number;
|
||||
const PrintableString: number;
|
||||
const Real: number;
|
||||
const RelativeOID: number;
|
||||
const Sequence: number;
|
||||
const Set: number;
|
||||
const T61String: number;
|
||||
const UTCTime: number;
|
||||
const UniversalString: number;
|
||||
const Utf8String: number;
|
||||
const VideotexString: number;
|
||||
const VisibleString: number;
|
||||
}
|
||||
/*
|
||||
declare enum BerType {
|
||||
EOC = 0,
|
||||
Boolean = 1,
|
||||
Integer = 2,
|
||||
BitString = 3,
|
||||
OctetString = 4,
|
||||
Null = 5,
|
||||
OID = 6,
|
||||
ObjectDescriptor = 7,
|
||||
External = 8,
|
||||
Real = 9, // float
|
||||
Enumeration = 10,
|
||||
PDV = 11,
|
||||
Utf8String = 12,
|
||||
RelativeOID = 13,
|
||||
Sequence = 16,
|
||||
Set = 17,
|
||||
NumericString = 18,
|
||||
PrintableString = 19,
|
||||
T61String = 20,
|
||||
VideotexString = 21,
|
||||
IA5String = 22,
|
||||
UTCTime = 23,
|
||||
GeneralizedTime = 24,
|
||||
GraphicString = 25,
|
||||
VisibleString = 26,
|
||||
GeneralString = 28,
|
||||
UniversalString = 29,
|
||||
CharacterString = 30,
|
||||
BMPString = 31,
|
||||
Constructor = 32,
|
||||
Context = 128,
|
||||
}
|
||||
|
||||
*/
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"noUnusedParameters": true,
|
||||
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"asn1-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Vendored
+10
@@ -569,6 +569,14 @@ export type SpecErrorCodes =
|
||||
export interface Auth0Error {
|
||||
error: LibErrorCodes | SpecErrorCodes | string;
|
||||
errorDescription: string;
|
||||
// Need to include non-intuitive error fields that Auth0 uses
|
||||
code?: string;
|
||||
description?: string;
|
||||
name?: string;
|
||||
policy?: string;
|
||||
original?: any;
|
||||
statusCode?: number;
|
||||
statusText?: string;
|
||||
}
|
||||
|
||||
export type Auth0ParseHashError = Auth0Error & {
|
||||
@@ -812,6 +820,8 @@ export interface AuthorizeOptions {
|
||||
login_hint?: string;
|
||||
prompt?: string;
|
||||
mode?: "login" | "signUp";
|
||||
accessType?: string;
|
||||
approvalPrompt?: string;
|
||||
}
|
||||
|
||||
export interface CheckSessionOptions extends AuthorizeOptions {
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
import axios from "axios";
|
||||
import applyConverters from "axios-case-converter";
|
||||
|
||||
applyConverters(); // $ExpectError
|
||||
|
||||
applyConverters(axios.create()); // $ExpectType AxiosInstance
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// Type definitions for axios-case-converter 0.3
|
||||
// Project: https://github.com/mpyw/axios-case-converter
|
||||
// Definitions by: Derek Kniffin <https://github.com/dkniffin>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
import { AxiosInstance } from "axios";
|
||||
|
||||
export default function applyConverters(axios: AxiosInstance): AxiosInstance;
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"axios": "^0.16.1"
|
||||
}
|
||||
}
|
||||
@@ -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",
|
||||
"axios-case-converter-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -0,0 +1,77 @@
|
||||
$(() => {
|
||||
$('#cp1').colorpicker();
|
||||
|
||||
$('#cp2').colorpicker();
|
||||
|
||||
$('#cp3').colorpicker({
|
||||
color: '#AA3399',
|
||||
format: 'rgb'
|
||||
});
|
||||
|
||||
$('#cp4').colorpicker().on('changeColor', (e) => {
|
||||
$('body')[0].style.backgroundColor = e.color.toString('rgba');
|
||||
});
|
||||
|
||||
$('#cp5').colorpicker({
|
||||
color: "transparent",
|
||||
format: "hex"
|
||||
});
|
||||
|
||||
$('#cp6').colorpicker({
|
||||
color: "#88cc33",
|
||||
horizontal: true
|
||||
});
|
||||
|
||||
$('#cp7').colorpicker({
|
||||
color: '#ffaa00',
|
||||
container: true,
|
||||
inline: true
|
||||
});
|
||||
|
||||
$('#cp8').colorpicker({
|
||||
colorSelectors: {
|
||||
black: '#000000',
|
||||
white: '#ffffff',
|
||||
red: '#FF0000',
|
||||
default: '#777777',
|
||||
primary: '#337ab7',
|
||||
success: '#5cb85c',
|
||||
info: '#5bc0de',
|
||||
warning: '#f0ad4e',
|
||||
danger: '#d9534f'
|
||||
}
|
||||
});
|
||||
|
||||
$('#cp9').colorpicker({
|
||||
customClass: 'colorpicker-2x',
|
||||
sliders: {
|
||||
saturation: {
|
||||
maxLeft: 200,
|
||||
maxTop: 200
|
||||
},
|
||||
hue: {
|
||||
maxTop: 200
|
||||
},
|
||||
alpha: {
|
||||
maxTop: 200
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$('.disable-button').click((e) => {
|
||||
e.preventDefault();
|
||||
|
||||
$('#cp10').colorpicker('disable');
|
||||
});
|
||||
|
||||
$('.enable-button').click((e) => {
|
||||
e.preventDefault();
|
||||
|
||||
$('#cp10').colorpicker('enable');
|
||||
});
|
||||
|
||||
$('#cp10').colorpicker();
|
||||
|
||||
|
||||
$('#cp11').colorpicker();
|
||||
});
|
||||
+270
@@ -0,0 +1,270 @@
|
||||
// Type definitions for bootstrap-colorpicker 2.5
|
||||
// Project: https://github.com/farbelous/bootstrap-colorpicker/tree/v2.x
|
||||
// Definitions by: Aleksandar Manukov <https://github.com/aleksandar-manukov>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
/// <reference types="jquery" />
|
||||
|
||||
type ColorFormat = 'hex' | 'rgb' | 'rgba';
|
||||
|
||||
type ColorPickerAlignOptions = 'right' | 'left';
|
||||
|
||||
type ColorPickerEvents = 'create' |
|
||||
'showPicker' |
|
||||
'hidePicker' |
|
||||
'changeColor' |
|
||||
'disable' |
|
||||
'enable' |
|
||||
'destroy';
|
||||
|
||||
/**
|
||||
* You can set colorpicker options either as a plugin parameter or data-* attributes
|
||||
*/
|
||||
interface ColorPickerOptions {
|
||||
/**
|
||||
* If not false, forces the color format to be hex, rgb or rgba, otherwise the format is automatically detected.
|
||||
*
|
||||
* Default: false
|
||||
*/
|
||||
format?: ColorFormat;
|
||||
|
||||
/**
|
||||
* If not false, sets the color to this value.
|
||||
*
|
||||
* Default: false
|
||||
*/
|
||||
color?: string;
|
||||
|
||||
/**
|
||||
* If not false, the picker will be contained inside this element, otherwise it will be appended to the document body.
|
||||
*
|
||||
* Default: false
|
||||
*/
|
||||
container?: boolean;
|
||||
|
||||
/**
|
||||
* Children selector for the component or element that trigger the colorpicker and which background color will change (needs an inner <i> element).
|
||||
*
|
||||
* Default: '.add-on, .input-group-addon'
|
||||
*/
|
||||
component?: string | JQuery;
|
||||
|
||||
/**
|
||||
* Children selector for the input that will store the picker selected value.
|
||||
*
|
||||
* Default: 'input'
|
||||
*/
|
||||
input?: string | JQuery;
|
||||
|
||||
/**
|
||||
* If true, put a '#' (number sign) before hex strings.
|
||||
*
|
||||
* Default: true
|
||||
*/
|
||||
hexNumberSignPrefix?: boolean;
|
||||
|
||||
/**
|
||||
* If true, the hue and alpha channel bars will be rendered horizontally, above the saturation selector.
|
||||
*
|
||||
* Default: false
|
||||
*/
|
||||
horizontal?: boolean;
|
||||
|
||||
/**
|
||||
* If true, forces to show the colorpicker as an inline element.
|
||||
*
|
||||
* Default: false
|
||||
*/
|
||||
inline?: boolean;
|
||||
|
||||
/**
|
||||
* Vertical sliders configuration (read source code if you really need to tweak this).
|
||||
*/
|
||||
sliders?: object;
|
||||
|
||||
/**
|
||||
* Horizontal sliders configuration (read source code if you really need to tweak this).
|
||||
*/
|
||||
slidersHorz?: object;
|
||||
|
||||
/**
|
||||
* Customizes the default colorpicker HTML template.
|
||||
*/
|
||||
template?: string;
|
||||
|
||||
/**
|
||||
* By default, the colorpicker is aligned to the right of the input. If you need to switch it to the left, set align to 'left'.
|
||||
*
|
||||
* Default: 'right'
|
||||
*/
|
||||
align?: ColorPickerAlignOptions;
|
||||
|
||||
/**
|
||||
* Adds this class to the colorpicker widget.
|
||||
*
|
||||
* Default: null
|
||||
*/
|
||||
customClass?: string;
|
||||
|
||||
/**
|
||||
* List of pre selected colors (hex format). If you choose one of these colors, the alias is returned instead of the hex code.
|
||||
*
|
||||
* Default: null
|
||||
*/
|
||||
colorSelectors?: object;
|
||||
|
||||
/**
|
||||
* Fallback color string that will be applied when the color failed to be parsed. If null, it will keep the current color if any.
|
||||
*
|
||||
* Default: null
|
||||
*/
|
||||
fallbackColor?: string;
|
||||
|
||||
/**
|
||||
* Fallback color format (e.g. when not specified or for alias mode, when selecting non aliased colors)
|
||||
*
|
||||
* Default: hex
|
||||
*/
|
||||
fallbackFormat?: string;
|
||||
}
|
||||
|
||||
interface Color {
|
||||
colors: {};
|
||||
fallbackFormat: string;
|
||||
fallbackValue: string;
|
||||
hexNumberSignPrefix: boolean;
|
||||
origFormat: string;
|
||||
predefinedColors: {};
|
||||
value: {
|
||||
h: number;
|
||||
s: number;
|
||||
b: number;
|
||||
a: number;
|
||||
};
|
||||
|
||||
/**
|
||||
* Set a new color. The value is parsed and tries to do a quess on the format.
|
||||
*/
|
||||
setColor(value: string): void;
|
||||
|
||||
/**
|
||||
* Set the HUE with a value between 0 and 1.
|
||||
*/
|
||||
setHue(value: number): void;
|
||||
|
||||
/**
|
||||
* Set the saturation with a value between 0 and 1.
|
||||
*/
|
||||
setSaturation(value: number): void;
|
||||
|
||||
/**
|
||||
* Set the brightness with a value between 0 and 1.
|
||||
*/
|
||||
setBrightness(value: number): void;
|
||||
|
||||
/**
|
||||
* Set the transparency with a value between 0 and 1.
|
||||
*/
|
||||
setAlpha(value: number): void;
|
||||
|
||||
/**
|
||||
* Returns a hash with red, green, blue and alpha.
|
||||
*/
|
||||
toRGB(): string;
|
||||
|
||||
/**
|
||||
* Returns a string with HEX format for the current color.
|
||||
*/
|
||||
toHex(): string;
|
||||
|
||||
/**
|
||||
* Returns a hash with HSLA values.
|
||||
*/
|
||||
toHSL(): string;
|
||||
|
||||
/**
|
||||
* Returns current color as string in specified format.
|
||||
*/
|
||||
toString(format: ColorFormat): string;
|
||||
}
|
||||
|
||||
interface ColorPicker {
|
||||
color: Color;
|
||||
component: boolean;
|
||||
container: boolean;
|
||||
disabled: boolean;
|
||||
element: JQuery;
|
||||
format: string;
|
||||
input: JQuery;
|
||||
options: ColorPickerOptions;
|
||||
picker: JQuery;
|
||||
}
|
||||
|
||||
interface ColorPickerEventObject extends JQueryEventObject {
|
||||
color: Color;
|
||||
}
|
||||
|
||||
interface JQuery {
|
||||
/**
|
||||
* Initializes an colorpicker.
|
||||
*/
|
||||
colorpicker(options?: ColorPickerOptions): JQuery;
|
||||
|
||||
/**
|
||||
* Gets the value from the input or the data attribute (if has no input), otherwise returns the default value, which defaults to #000000 if not specified.
|
||||
*/
|
||||
colorpicker(methodName: 'getValue', defaultValue: string): string;
|
||||
|
||||
/**
|
||||
* Set a new value for the color picker (also updates everything). Triggers 'changeColor' event.
|
||||
*/
|
||||
colorpicker(methodName: 'setValue', value: any): any;
|
||||
|
||||
/**
|
||||
* Show the color picker
|
||||
*/
|
||||
colorpicker(methodName: 'show'): void;
|
||||
|
||||
/**
|
||||
* Hide the color picker
|
||||
*/
|
||||
colorpicker(methodName: 'hide'): void;
|
||||
|
||||
/**
|
||||
* Updates the color picker's position relative to the element
|
||||
*/
|
||||
colorpicker(methodName: 'reposition'): void;
|
||||
|
||||
/**
|
||||
* Refreshes the widget colors (this is done automatically)
|
||||
*/
|
||||
colorpicker(methodName: 'update'): void;
|
||||
|
||||
/**
|
||||
* Enable the color picker.
|
||||
*/
|
||||
colorpicker(methodName: 'enable'): void;
|
||||
|
||||
/**
|
||||
* Disable the color picker.
|
||||
*/
|
||||
colorpicker(methodName: 'disable'): void;
|
||||
|
||||
/**
|
||||
* Destroys the colorpicker widget and unbind all .colorpicker events from the element and component
|
||||
*/
|
||||
colorpicker(methodName: 'destroy'): void;
|
||||
|
||||
/**
|
||||
* Access to the colorpicker API directly
|
||||
*/
|
||||
data(methodName: 'colorpicker'): ColorPicker;
|
||||
|
||||
off(events: ColorPickerEvents, selector?: string, handler?: (event: ColorPickerEventObject) => any): JQuery;
|
||||
off(events: ColorPickerEvents, handler: (event: ColorPickerEventObject) => any): JQuery;
|
||||
|
||||
on(events: ColorPickerEvents, selector: string, data: any, handler?: (event: ColorPickerEventObject) => any): JQuery;
|
||||
on(events: ColorPickerEvents, selector: string, handler: (event: ColorPickerEventObject) => any): JQuery;
|
||||
on(events: ColorPickerEvents, handler: (event: ColorPickerEventObject) => any): JQuery;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"bootstrap-colorpicker-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"no-consecutive-blank-lines": false,
|
||||
"eofline": false,
|
||||
"unified-signatures": false,
|
||||
"no-trailing-whitespace": [true, "ignore-comments"]
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,21 @@
|
||||
declare let aHtmlElement: HTMLElement;
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// jQuery backward compatibility
|
||||
// --------------------------------------------------------------------------------------
|
||||
|
||||
$(".dropdown").on("affixed.bs.affix", (e) => {
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// Modal
|
||||
// --------------------------------------------------------------------------------------
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$(".modal").modal();
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$(".modal").modal("show");
|
||||
|
||||
$(".modal").modal("toggle");
|
||||
@@ -27,8 +37,10 @@ $(".modal").modal({
|
||||
// Dropdown
|
||||
// --------------------------------------------------------------------------------------
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$(".dropdown").dropdown();
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$(".dropdown").dropdown("toggle");
|
||||
|
||||
$(".dropdown").on("show.bs.dropdown", (e) => {
|
||||
@@ -39,8 +51,10 @@ $(".dropdown").on("show.bs.dropdown", (e) => {
|
||||
// Scrollspy
|
||||
// --------------------------------------------------------------------------------------
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$(".navbar").scrollspy();
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$(".navbar").scrollspy("refresh");
|
||||
|
||||
$(".navbar").scrollspy({
|
||||
@@ -48,7 +62,7 @@ $(".navbar").scrollspy({
|
||||
offset: 10,
|
||||
});
|
||||
|
||||
$('.navbar').on("activate.bs.scrollspy", () => {
|
||||
$(".navbar").on("activate.bs.scrollspy", () => {
|
||||
// do something...
|
||||
});
|
||||
|
||||
@@ -56,8 +70,10 @@ $('.navbar').on("activate.bs.scrollspy", () => {
|
||||
// Togglable tabs
|
||||
// --------------------------------------------------------------------------------------
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$(".tab").tab();
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$(".tab").tab("show");
|
||||
|
||||
$(".tab").on("shown.bs.tab", (e) => {
|
||||
@@ -69,8 +85,10 @@ $(".tab").on("shown.bs.tab", (e) => {
|
||||
// Tooltip
|
||||
// --------------------------------------------------------------------------------------
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$(".tooltip").tooltip();
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$(".tooltip").tooltip("show");
|
||||
|
||||
$(".tooltip").tooltip({
|
||||
@@ -129,8 +147,10 @@ $(".tooltip").on("hidden.bs.tooltip", () => {
|
||||
// Popover
|
||||
// --------------------------------------------------------------------------------------
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$(".popover").popover();
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$(".popover").popover("show");
|
||||
|
||||
$(".popover").popover({
|
||||
@@ -186,8 +206,10 @@ $(".popover").on("hidden.bs.popover", () => {
|
||||
// Alert
|
||||
// --------------------------------------------------------------------------------------
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$(".alert").alert();
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$(".alert").alert("close");
|
||||
|
||||
$(".alert").on("closed.bs.alert", () => {
|
||||
@@ -198,6 +220,7 @@ $(".alert").on("closed.bs.alert", () => {
|
||||
// Button
|
||||
// --------------------------------------------------------------------------------------
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$(".btn").button("toggle");
|
||||
|
||||
$(".btn").button("reset");
|
||||
@@ -208,8 +231,10 @@ $(".btn").button("Swaps text to any data defined text state.");
|
||||
// Collapse
|
||||
// --------------------------------------------------------------------------------------
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$(".collapse").collapse();
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$(".collapse").collapse("toggle");
|
||||
|
||||
$(".collapse").collapse({
|
||||
@@ -225,8 +250,10 @@ $(".collapse").on("hidden.bs.collapse", () => {
|
||||
// Carousel
|
||||
// --------------------------------------------------------------------------------------
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$(".carousel").carousel();
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$(".carousel").carousel("cycle");
|
||||
|
||||
$(".carousel").carousel(200);
|
||||
@@ -246,7 +273,7 @@ $(".carousel").carousel({
|
||||
pause: null,
|
||||
});
|
||||
|
||||
$('#myCarousel').on('slide.bs.carousel', (e) => {
|
||||
$("#myCarousel").on("slide.bs.carousel", (e) => {
|
||||
const dir: "left" | "right" = e.direction;
|
||||
aHtmlElement = e.relatedTarget;
|
||||
});
|
||||
@@ -255,8 +282,10 @@ $('#myCarousel').on('slide.bs.carousel', (e) => {
|
||||
// Affix
|
||||
// --------------------------------------------------------------------------------------
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$(".affix").affix();
|
||||
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$(".affix").affix("checkPosition");
|
||||
|
||||
$(".affix").affix({
|
||||
|
||||
Vendored
+40
-33
@@ -7,6 +7,16 @@
|
||||
|
||||
/// <reference types="jquery"/>
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// For jQuery v1 and v2 backward compatibility
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Same as jQuery v3 `JQuery.EventHandlerBase`.
|
||||
*/
|
||||
type JQueryEventHandlerBase<TContext, T> =
|
||||
(this: TContext, t: T, ...args: any[]) => void | false;
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Some Types and Interfaces
|
||||
// --------------------------------------------------------------------------
|
||||
@@ -265,7 +275,7 @@ interface AffixOptions {
|
||||
// Events
|
||||
// --------------------------------------------------------------------------------------
|
||||
|
||||
interface CarouselEventHandler<TElement> extends JQuery.TriggeredEvent<TElement, undefined, HTMLElement, HTMLElement> {
|
||||
interface CarouselEventHandler extends JQueryEventObject {
|
||||
/**
|
||||
* The direction in which the carousel is sliding.
|
||||
*/
|
||||
@@ -277,14 +287,14 @@ interface CarouselEventHandler<TElement> extends JQuery.TriggeredEvent<TElement,
|
||||
relatedTarget: HTMLElement;
|
||||
}
|
||||
|
||||
interface DropdownsEventHandler<TElement> extends JQuery.TriggeredEvent<TElement, undefined, HTMLElement, HTMLElement> {
|
||||
interface DropdownsEventHandler extends JQueryEventObject {
|
||||
/**
|
||||
* The toggling anchor element.
|
||||
*/
|
||||
relatedTarget: HTMLElement;
|
||||
}
|
||||
|
||||
interface TapEventHandler<TElement> extends JQuery.TriggeredEvent<TElement, undefined, HTMLElement, HTMLElement> {
|
||||
interface TapEventHandler extends JQueryEventObject {
|
||||
/**
|
||||
* * For `show.bs.tab` and `shown.bs.tab`, is the new active tab.
|
||||
* * For `hide.bs.tab`, is the current active tab.
|
||||
@@ -314,7 +324,7 @@ type TooltipEvent = "show.bs.tooltip" | "shown.bs.tooltip" | "hide.bs.tooltip" |
|
||||
// jQuery
|
||||
// --------------------------------------------------------------------------------------
|
||||
|
||||
interface JQuery {
|
||||
interface JQuery<TElement = HTMLElement> {
|
||||
/**
|
||||
* Call a method on the modal element:
|
||||
* * `toggle` – Manually toggles a modal.
|
||||
@@ -325,22 +335,19 @@ interface JQuery {
|
||||
*
|
||||
* Returns to the caller before the modal has actually been shown or hidden (i.e. before the `shown.bs.modal` or `hidden.bs.modal` event occurs).
|
||||
*/
|
||||
modal(action: "toggle" | "show" | "hide" | "handleUpdate"): JQuery;
|
||||
modal(action: "toggle" | "show" | "hide" | "handleUpdate"): this;
|
||||
/**
|
||||
* Activates a content as a modal.
|
||||
*/
|
||||
modal(options?: ModalOptions): JQuery;
|
||||
modal(options?: ModalOptions): this;
|
||||
|
||||
/**
|
||||
* Toggles the dropdown menu of a given navbar or tabbed navigation.
|
||||
*/
|
||||
dropdown(action: "toggle"): JQuery;
|
||||
/**
|
||||
* Toggle contextual overlays for displaying lists of links.
|
||||
*
|
||||
* If no _method_ is specified, toggle contextual overlays for displaying lists of links.
|
||||
* The data-api, `data-toggle="dropdown"` is always required to be present on the dropdown's trigger element.
|
||||
*
|
||||
* When _method_ `toggle` is specified, toggles the dropdown menu of a given navbar or tabbed navigation.
|
||||
*/
|
||||
dropdown(): this;
|
||||
dropdown(action?: "toggle"): this;
|
||||
|
||||
// tslint:disable:jsdoc-format
|
||||
/**
|
||||
@@ -353,11 +360,11 @@ $('[data-spy="scroll"]').each(function () {
|
||||
```
|
||||
*/
|
||||
// tslint:enable:jsdoc-format
|
||||
scrollspy(action: "refresh"): JQuery;
|
||||
scrollspy(action: "refresh"): this;
|
||||
/**
|
||||
* Add scrollspy behavior to a topbar navigation.
|
||||
*/
|
||||
scrollspy(options?: ScrollSpyOptions): JQuery;
|
||||
scrollspy(options?: ScrollSpyOptions): this;
|
||||
|
||||
/**
|
||||
* If no _method_ is specified, activates a tab element and content container. Tab should have either a `data-target` or an `href` targeting a container node in the DOM.
|
||||
@@ -367,7 +374,7 @@ $('[data-spy="scroll"]').each(function () {
|
||||
*
|
||||
* Returns to the caller before the tab pane has actually been shown (i.e. before the `shown.bs.tab` event occurs).
|
||||
*/
|
||||
tab(action?: "show"): JQuery;
|
||||
tab(action?: "show"): this;
|
||||
|
||||
/**
|
||||
* Call a method on the tooltip element:
|
||||
@@ -380,11 +387,11 @@ $('[data-spy="scroll"]').each(function () {
|
||||
* Returns to the caller before the tooltip has actually been shown or hidden (i.e. before the `shown.bs.tooltip` or `hidden.bs.tooltip` event occurs).
|
||||
* This is considered a "manual" triggering of the tooltip.
|
||||
*/
|
||||
tooltip(action: "show" | "hide" | "toggle" | "destroy"): JQuery;
|
||||
tooltip(action: "show" | "hide" | "toggle" | "destroy"): this;
|
||||
/**
|
||||
* Attaches a tooltip handler to an element collection.
|
||||
*/
|
||||
tooltip(options?: TooltipOptions): JQuery;
|
||||
tooltip(options?: TooltipOptions): this;
|
||||
|
||||
/**
|
||||
* Call a method on the popover element:
|
||||
@@ -397,11 +404,11 @@ $('[data-spy="scroll"]').each(function () {
|
||||
* Returns to the caller before the popover has actually been shown or hidden (i.e. before the `shown.bs.popover` or `hidden.bs.popover` event occurs).
|
||||
* This is considered a "manual" triggering of the popover.
|
||||
*/
|
||||
popover(action: "show" | "hide" | "toggle" | "destroy"): JQuery;
|
||||
popover(action: "show" | "hide" | "toggle" | "destroy"): this;
|
||||
/**
|
||||
* Initializes popovers for an element collection.
|
||||
*/
|
||||
popover(options?: PopoverOptions): JQuery;
|
||||
popover(options?: PopoverOptions): this;
|
||||
|
||||
/**
|
||||
* If no _method_ is specified, makes an alert listen for click events on descendant elements which have the `data-dismiss="alert"` attribute.
|
||||
@@ -410,7 +417,7 @@ $('[data-spy="scroll"]').each(function () {
|
||||
* When _method_ `close` is specified, closes an alert by removing it from the DOM. If the `.fade` and `.in` classes are present on the element,
|
||||
* the alert will fade out before it is removed.
|
||||
*/
|
||||
alert(action?: "close"): JQuery;
|
||||
alert(action?: "close"): this;
|
||||
|
||||
/**
|
||||
* Call a method on the button element:
|
||||
@@ -418,7 +425,7 @@ $('[data-spy="scroll"]').each(function () {
|
||||
* * `reset` – Resets button state: swaps text to original text. This method is asynchronous and returns before the resetting has actually completed.
|
||||
* * _string_ – Swaps text to any data defined text state.
|
||||
*/
|
||||
button(action: "toggle" | "reset" | string): JQuery;
|
||||
button(action: "toggle" | "reset" | string): this;
|
||||
|
||||
/**
|
||||
* Call a method on the collapsible element:
|
||||
@@ -428,11 +435,11 @@ $('[data-spy="scroll"]').each(function () {
|
||||
*
|
||||
* Returns to the caller before the collapsible element has actually been shown or hidden (i.e. before the `shown.bs.collapse` or `hidden.bs.collapse` event occurs).
|
||||
*/
|
||||
collapse(action: "toggle" | "show" | "hide"): JQuery;
|
||||
collapse(action: "toggle" | "show" | "hide"): this;
|
||||
/**
|
||||
* Activates a content as a collapsible element.
|
||||
*/
|
||||
collapse(options?: CollapseOptions): JQuery;
|
||||
collapse(options?: CollapseOptions): this;
|
||||
|
||||
/**
|
||||
* Call a method on the carousel element:
|
||||
@@ -444,33 +451,33 @@ $('[data-spy="scroll"]').each(function () {
|
||||
*
|
||||
* Returns to the caller before the target item has been shown (i.e. before the `slid.bs.carousel` event occurs).
|
||||
*/
|
||||
carousel(action: "cycle" | "pause" | number | "prev" | "next"): JQuery;
|
||||
carousel(action: "cycle" | "pause" | number | "prev" | "next"): this;
|
||||
/**
|
||||
* Initializes the carousel and starts cycling through items.
|
||||
*/
|
||||
carousel(options?: CarouselOptions): JQuery;
|
||||
carousel(options?: CarouselOptions): this;
|
||||
|
||||
/**
|
||||
* Recalculates the state of the affix based on the dimensions, position, and scroll position of the relevant elements.
|
||||
* The `.affix`, `.affix-top`, and `.affix-bottom` classes are added to or removed from the affixed content according to the new state.
|
||||
* This method needs to be called whenever the dimensions of the affixed content or the target element are changed, to ensure correct positioning of the affixed content.
|
||||
*/
|
||||
affix(action: "checkPosition"): JQuery;
|
||||
affix(action: "checkPosition"): this;
|
||||
/**
|
||||
* Activates your content as affixed content.
|
||||
*/
|
||||
affix(options?: AffixOptions): JQuery;
|
||||
affix(options?: AffixOptions): this;
|
||||
|
||||
on(events: CarouselEvent, handler: JQuery.EventHandlerBase<HTMLElement, CarouselEventHandler<HTMLElement>>): this;
|
||||
on(events: DropdownEvent, handler: JQuery.EventHandlerBase<HTMLElement, DropdownsEventHandler<HTMLElement>>): this;
|
||||
on(events: TapEvent, handler: JQuery.EventHandlerBase<HTMLElement, TapEventHandler<HTMLElement>>): this;
|
||||
on(events: CarouselEvent, handler: JQueryEventHandlerBase<HTMLElement, CarouselEventHandler>): this;
|
||||
on(events: DropdownEvent, handler: JQueryEventHandlerBase<HTMLElement, DropdownsEventHandler>): this;
|
||||
on(events: TapEvent, handler: JQueryEventHandlerBase<HTMLElement, TapEventHandler>): this;
|
||||
on(
|
||||
events: AffixEvent | AlertEvent | CollapseEvent | PopoverEvent | ScrollspyEvent | TooltipEvent,
|
||||
handler: JQuery.EventHandler<HTMLElement>
|
||||
handler: JQueryEventHandlerBase<HTMLElement, JQueryEventObject>
|
||||
): this;
|
||||
|
||||
/** @deprecated */
|
||||
emulateTransitionEnd(duration: number): JQuery;
|
||||
emulateTransitionEnd(duration: number): this;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import btoa from 'btoa';
|
||||
import btoa = require('btoa');
|
||||
|
||||
btoa('foo');
|
||||
|
||||
Vendored
+4
-1
@@ -1,7 +1,10 @@
|
||||
// Type definitions for btoa 1.2
|
||||
// Project: https://git.coolaj86.com/coolaj86/btoa.js
|
||||
// Definitions by: John Wright <https://github.com/johngeorgewright>
|
||||
// Alex Brick <https://github.com/bricka>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
export default function(str: string): string;
|
||||
declare function btoa(str: string): string;
|
||||
|
||||
export = btoa;
|
||||
|
||||
@@ -8,7 +8,7 @@ const input = 'const answer = () => 42;';
|
||||
|
||||
console.log(output.code);
|
||||
console.log(output.map.toString());
|
||||
console.log(output.map.toUrl);
|
||||
console.log(output.map.toUrl());
|
||||
})();
|
||||
|
||||
// Transform for Chrome & Firefox
|
||||
|
||||
Vendored
+5
-5
@@ -1,7 +1,10 @@
|
||||
// Type definitions for buble 0.19
|
||||
// Project: https://github.com/Rich-Harris/buble#README
|
||||
// Definitions by: Kocal <https://github.com/Kocal>
|
||||
// Definitions by: Hugo Alliaume <https://github.com/Kocal>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
import { SourceMap } from "magic-string";
|
||||
|
||||
export interface TransformOptions {
|
||||
// source: https://github.com/Rich-Harris/buble/blob/master/src/support.js
|
||||
@@ -56,10 +59,7 @@ export interface TransformOptions {
|
||||
|
||||
export interface TransformOutput {
|
||||
code: string;
|
||||
map: {
|
||||
toString(): string;
|
||||
toUrl(): string;
|
||||
};
|
||||
map: SourceMap;
|
||||
}
|
||||
|
||||
export function transform(content: string, options?: TransformOptions): TransformOutput;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"csstype": "^2.2.0"
|
||||
"magic-string": "^0.25.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import buildOutputScript = require('build-output-script');
|
||||
|
||||
// $ExpectType string
|
||||
buildOutputScript([{ address: '1LukeQU5jwebXbMLDVydeH4vFSobRV9rkj', value: 100000000 }]);
|
||||
// $ExpectType string
|
||||
buildOutputScript([
|
||||
{ address: '1LukeQU5jwebXbMLDVydeH4vFSobRV9rkj', value: 100000000 },
|
||||
{ address: '1BitcoinEaterAddressDontSendf59kuE', value: 100000000 },
|
||||
]);
|
||||
// $ExpectError
|
||||
buildOutputScript([]);
|
||||
Vendored
+33
@@ -0,0 +1,33 @@
|
||||
// Type definitions for build-output-script 1.0
|
||||
// Project: https://github.com/lukechilds/build-output-script#readme
|
||||
// Definitions by: BendingBender <https://github.com/BendingBender>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 3.0
|
||||
|
||||
export = buildOutputScript;
|
||||
|
||||
/**
|
||||
* Builds a P2PKH Bitcoin transaction output script from an array of P2PKH addresses and amounts.
|
||||
* Will also work with any Bitcoin derived cryptocurrencies with a single byte pubkey hash address prefix.
|
||||
*
|
||||
* The output script is returned as a hex string and can be passed directly in to ledgerjs.
|
||||
*
|
||||
* @param outputs An array of one or more output objects.
|
||||
* @returns A (hex string) P2PKH transaction output script.
|
||||
*/
|
||||
declare function buildOutputScript(
|
||||
outputs: [buildOutputScript.Output, ...buildOutputScript.Output[]]
|
||||
): string;
|
||||
|
||||
declare namespace buildOutputScript {
|
||||
interface Output {
|
||||
/**
|
||||
* A valid P2PKH address.
|
||||
*/
|
||||
address: string;
|
||||
/**
|
||||
* Value to send to `address` in satoshis.
|
||||
*/
|
||||
value: number;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"build-output-script-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+5
@@ -585,6 +585,11 @@ declare namespace Bull {
|
||||
*/
|
||||
getJobCounts(): Promise<JobCounts>;
|
||||
|
||||
/**
|
||||
* Returns a promise that resolves with the job counts for the given queue of the given types.
|
||||
*/
|
||||
getJobCountByTypes(types: string[] | string): Promise<JobCounts>;
|
||||
|
||||
/**
|
||||
* Returns a promise that resolves with the quantity of completed jobs.
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import byteRange = require('byte-range');
|
||||
|
||||
byteRange(1); // $ExpectType [number, number]
|
||||
byteRange(1, { signed: false }); // $ExpectType [number, number]
|
||||
byteRange.uint8; // $ExpectType [number, number]
|
||||
byteRange.uint16; // $ExpectType [number, number]
|
||||
byteRange.uint32; // $ExpectType [number, number]
|
||||
byteRange.int8; // $ExpectType [number, number]
|
||||
byteRange.int16; // $ExpectType [number, number]
|
||||
byteRange.int32; // $ExpectType [number, number]
|
||||
Vendored
+49
@@ -0,0 +1,49 @@
|
||||
// Type definitions for byte-range 1.0
|
||||
// Project: https://github.com/lukechilds/byte-range#readme
|
||||
// Definitions by: BendingBender <https://github.com/BendingBender>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export = byteRange;
|
||||
|
||||
/**
|
||||
* Calculates integer ranges for a given number of bytes.
|
||||
*
|
||||
* @param bytes Number of bytes to return the integer range for. Must be a positive integer.
|
||||
*/
|
||||
declare function byteRange(bytes: number, options?: byteRange.Options): byteRange.ByteRange;
|
||||
|
||||
declare namespace byteRange {
|
||||
/**
|
||||
* Precomputed byte range for an unsigned 8 bit integer.
|
||||
*/
|
||||
const uint8: ByteRange;
|
||||
/**
|
||||
* Precomputed byte range for an unsigned 16 bit integer.
|
||||
*/
|
||||
const uint16: ByteRange;
|
||||
/**
|
||||
* Precomputed byte range for an unsigned 32 bit integer.
|
||||
*/
|
||||
const uint32: ByteRange;
|
||||
/**
|
||||
* Precomputed byte range for an signed 8 bit integer.
|
||||
*/
|
||||
const int8: ByteRange;
|
||||
/**
|
||||
* Precomputed byte range for an signed 16 bit integer.
|
||||
*/
|
||||
const int16: ByteRange;
|
||||
/**
|
||||
* Precomputed byte range for an signed 32 bit integer.
|
||||
*/
|
||||
const int32: ByteRange;
|
||||
|
||||
interface Options {
|
||||
/**
|
||||
* @default false
|
||||
*/
|
||||
signed?: boolean;
|
||||
}
|
||||
|
||||
type ByteRange = [number, number];
|
||||
}
|
||||
@@ -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",
|
||||
"byte-range-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+6
-1
@@ -127,7 +127,7 @@ declare class ByteBuffer
|
||||
* Calculates the number of UTF8 characters of a string.JavaScript itself uses UTF- 16, so that a string's length property does not reflect its actual UTF8 size if it contains code points larger than 0xFFFF.
|
||||
*/
|
||||
static calculateUTF8Chars( str: string ): number;
|
||||
|
||||
|
||||
/**
|
||||
* Calculates the number of UTF8 bytes of a string. This is an alias of ByteBuffer#calculateUTF8Bytes.
|
||||
*/
|
||||
@@ -574,6 +574,11 @@ declare class ByteBuffer
|
||||
*/
|
||||
writeInt8( value: number, offset?: number ): ByteBuffer;
|
||||
|
||||
/**
|
||||
* Write a 64bit signed integer. This is an alias of ByteBuffer#writeInt64.
|
||||
*/
|
||||
writeLong( value: number | Long, offset?: number ): ByteBuffer;
|
||||
|
||||
/**
|
||||
* Writes a 16bit signed integer. This is an alias of ByteBuffer#writeInt16.
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import * as http from 'http';
|
||||
import * as https from 'https';
|
||||
import CacheableRequest = require('cacheable-request');
|
||||
import QuickLRU = require('quick-lru');
|
||||
|
||||
// You can do
|
||||
let cacheableRequest = new CacheableRequest(http.request);
|
||||
const cacheReq = cacheableRequest('http://example.com', res => {
|
||||
res; // $ExpectType ServerResponse | ResponseLike
|
||||
});
|
||||
cacheReq.on('request', req => req.end());
|
||||
|
||||
cacheableRequest = new CacheableRequest(https.request);
|
||||
|
||||
cacheableRequest = new CacheableRequest(http.request, 'redis://user:pass@localhost:6379');
|
||||
cacheableRequest = new CacheableRequest(http.request, new Map());
|
||||
cacheableRequest = new CacheableRequest(http.request, new QuickLRU({ maxSize: 1000 }));
|
||||
|
||||
cacheableRequest('example.com', res => {
|
||||
res; // $ExpectType ServerResponse | ResponseLike
|
||||
})
|
||||
.on('error', err => {
|
||||
err; // $ExpectType RequestErrorCls | CacheErrorCls
|
||||
})
|
||||
.on('request', req => {
|
||||
req.on('error', () => {});
|
||||
req.end();
|
||||
});
|
||||
Vendored
+134
@@ -0,0 +1,134 @@
|
||||
// Type definitions for cacheable-request 6.0
|
||||
// Project: https://github.com/lukechilds/cacheable-request#readme
|
||||
// Definitions by: BendingBender <https://github.com/BendingBender>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
import { request, RequestOptions, ClientRequest, ServerResponse } from 'http';
|
||||
import { URL } from 'url';
|
||||
import { EventEmitter } from 'events';
|
||||
import { Store } from 'keyv';
|
||||
import { Options as CacheSemanticsOptions } from 'http-cache-semantics';
|
||||
import ResponseLike = require('responselike');
|
||||
|
||||
export = CacheableRequest;
|
||||
|
||||
declare const CacheableRequest: CacheableRequest;
|
||||
|
||||
type RequestFn = typeof request;
|
||||
|
||||
interface CacheableRequest {
|
||||
new (requestFn: RequestFn, storageAdapter?: string | Store<any>): (
|
||||
opts: string | URL | (RequestOptions & CacheSemanticsOptions),
|
||||
cb?: (response: ServerResponse | ResponseLike) => void
|
||||
) => CacheableRequest.Emitter;
|
||||
|
||||
RequestError: typeof RequestErrorCls;
|
||||
CacheError: typeof CacheErrorCls;
|
||||
}
|
||||
|
||||
declare namespace CacheableRequest {
|
||||
interface Options {
|
||||
/**
|
||||
* If the cache should be used. Setting this to `false` will completely bypass the cache for the current request.
|
||||
* @default true
|
||||
*/
|
||||
cache?: boolean;
|
||||
|
||||
/**
|
||||
* If set to `true` once a cached resource has expired it is deleted and will have to be re-requested.
|
||||
*
|
||||
* If set to `false`, after a cached resource's TTL expires it is kept in the cache and will be revalidated
|
||||
* on the next request with `If-None-Match`/`If-Modified-Since` headers.
|
||||
* @default false
|
||||
*/
|
||||
strictTtl?: boolean;
|
||||
|
||||
/**
|
||||
* Limits TTL. The `number` represents milliseconds.
|
||||
* @default undefined
|
||||
*/
|
||||
maxTtl?: number;
|
||||
|
||||
/**
|
||||
* When set to `true`, if the DB connection fails we will automatically fallback to a network request.
|
||||
* DB errors will still be emitted to notify you of the problem even though the request callback may succeed.
|
||||
* @default false
|
||||
*/
|
||||
automaticFailover?: boolean;
|
||||
|
||||
/**
|
||||
* Forces refreshing the cache. If the response could be retrieved from the cache, it will perform a
|
||||
* new request and override the cache instead.
|
||||
* @default false
|
||||
*/
|
||||
forceRefresh?: boolean;
|
||||
}
|
||||
|
||||
interface Emitter extends EventEmitter {
|
||||
addListener(event: 'request', listener: (request: ClientRequest) => void): this;
|
||||
addListener(
|
||||
event: 'response',
|
||||
listener: (response: ServerResponse | ResponseLike) => void
|
||||
): this;
|
||||
addListener(event: 'error', listener: (error: RequestError | CacheError) => void): this;
|
||||
on(event: 'request', listener: (request: ClientRequest) => void): this;
|
||||
on(event: 'response', listener: (response: ServerResponse | ResponseLike) => void): this;
|
||||
on(event: 'error', listener: (error: RequestError | CacheError) => void): this;
|
||||
once(event: 'request', listener: (request: ClientRequest) => void): this;
|
||||
once(event: 'response', listener: (response: ServerResponse | ResponseLike) => void): this;
|
||||
once(event: 'error', listener: (error: RequestError | CacheError) => void): this;
|
||||
prependListener(event: 'request', listener: (request: ClientRequest) => void): this;
|
||||
prependListener(
|
||||
event: 'response',
|
||||
listener: (response: ServerResponse | ResponseLike) => void
|
||||
): this;
|
||||
prependListener(event: 'error', listener: (error: RequestError | CacheError) => void): this;
|
||||
prependOnceListener(event: 'request', listener: (request: ClientRequest) => void): this;
|
||||
prependOnceListener(
|
||||
event: 'response',
|
||||
listener: (response: ServerResponse | ResponseLike) => void
|
||||
): this;
|
||||
prependOnceListener(
|
||||
event: 'error',
|
||||
listener: (error: RequestError | CacheError) => void
|
||||
): this;
|
||||
removeListener(event: 'request', listener: (request: ClientRequest) => void): this;
|
||||
removeListener(
|
||||
event: 'response',
|
||||
listener: (response: ServerResponse | ResponseLike) => void
|
||||
): this;
|
||||
removeListener(event: 'error', listener: (error: RequestError | CacheError) => void): this;
|
||||
off(event: 'request', listener: (request: ClientRequest) => void): this;
|
||||
off(event: 'response', listener: (response: ServerResponse | ResponseLike) => void): this;
|
||||
off(event: 'error', listener: (error: RequestError | CacheError) => void): this;
|
||||
removeAllListeners(event?: 'request' | 'response' | 'error'): this;
|
||||
listeners(event: 'request'): Array<(request: ClientRequest) => void>;
|
||||
listeners(event: 'response'): Array<(response: ServerResponse | ResponseLike) => void>;
|
||||
listeners(event: 'error'): Array<(error: RequestError | CacheError) => void>;
|
||||
rawListeners(event: 'request'): Array<(request: ClientRequest) => void>;
|
||||
rawListeners(event: 'response'): Array<(response: ServerResponse | ResponseLike) => void>;
|
||||
rawListeners(event: 'error'): Array<(error: RequestError | CacheError) => void>;
|
||||
emit(event: 'request', request: ClientRequest): boolean;
|
||||
emit(event: 'response', response: ServerResponse | ResponseLike): boolean;
|
||||
emit(event: 'error', error: RequestError | CacheError): boolean;
|
||||
eventNames(): Array<'request' | 'response' | 'error'>;
|
||||
listenerCount(type: 'request' | 'response' | 'error'): number;
|
||||
}
|
||||
|
||||
type RequestError = RequestErrorCls;
|
||||
type CacheError = CacheErrorCls;
|
||||
}
|
||||
|
||||
declare class RequestErrorCls extends Error {
|
||||
readonly name: 'RequestError';
|
||||
|
||||
constructor(error: Error);
|
||||
}
|
||||
declare class CacheErrorCls extends Error {
|
||||
readonly name: 'CacheError';
|
||||
|
||||
constructor(error: Error);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"cacheable-request-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+1
-1
@@ -231,7 +231,7 @@ export interface DecoratedPolicyOptions<T> extends PolicyOptions<T> {
|
||||
/**
|
||||
* @default false
|
||||
*/
|
||||
getDecoratedValue?: boolean;
|
||||
getDecoratedValue: boolean | undefined;
|
||||
}
|
||||
|
||||
export interface GenerateFuncFlags {
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@types/webdriverio": "^4.0.0"
|
||||
}
|
||||
}
|
||||
Vendored
+1
@@ -537,6 +537,7 @@ declare namespace Chart {
|
||||
interface LinearTickOptions extends TickOptions {
|
||||
maxTicksLimit?: number;
|
||||
stepSize?: number;
|
||||
precision?: number;
|
||||
suggestedMin?: number;
|
||||
suggestedMax?: number;
|
||||
}
|
||||
|
||||
@@ -485,3 +485,53 @@ new Chartist.Candle('.ct-chart', {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Create a simple bar chart and line chart with two dimensional arrays
|
||||
new Chartist.Bar('.ct-chart', {
|
||||
labels: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
|
||||
series: [
|
||||
[
|
||||
{value: 1},
|
||||
{value: 2},
|
||||
{value: 3},
|
||||
{value: 4},
|
||||
{value: 5},
|
||||
{value: 6},
|
||||
{value: 7}
|
||||
],
|
||||
[
|
||||
{value: 7},
|
||||
{value: 6},
|
||||
{value: 5},
|
||||
{value: 4},
|
||||
{value: 3},
|
||||
{value: 2},
|
||||
{value: 1}
|
||||
]
|
||||
]
|
||||
}, {})
|
||||
|
||||
new Chartist.Line('.ct-chart', {
|
||||
labels: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
|
||||
series: [
|
||||
[
|
||||
{value: 1},
|
||||
{value: 2},
|
||||
{value: 3},
|
||||
{value: 4},
|
||||
{value: 5},
|
||||
{value: 6},
|
||||
{value: 7}
|
||||
],
|
||||
[
|
||||
{value: 7},
|
||||
{value: 6},
|
||||
{value: 5},
|
||||
{value: 4},
|
||||
{value: 3},
|
||||
{value: 2},
|
||||
{value: 1}
|
||||
]
|
||||
]
|
||||
}, {})
|
||||
|
||||
Vendored
+1
-1
@@ -93,7 +93,7 @@ declare namespace Chartist {
|
||||
// TODO: come in and tidy this up and make it fit better
|
||||
interface IChartistData {
|
||||
labels?: Array<string> | Array<number> | Array<Date>;
|
||||
series: Array<IChartistSeriesData> | Array<Array<IChartistData>> | Array<number> | Array<Array<number>>;
|
||||
series: Array<IChartistSeriesData> | Array<Array<IChartistSeriesData>> | Array<Array<IChartistData>> | Array<number> | Array<Array<number>>;
|
||||
}
|
||||
|
||||
interface IChartistSeriesData {
|
||||
|
||||
@@ -289,6 +289,17 @@ function test_dom_node() {
|
||||
strong.insertBefore(em);
|
||||
strong.insertBeforeMe(em);
|
||||
element.isReadOnly();
|
||||
var prev = node.getPreviousSourceNode();
|
||||
prev = node.getPreviousSourceNode(true);
|
||||
prev = node.getPreviousSourceNode(true, CKEDITOR.NODE_TEXT);
|
||||
prev = node.getPreviousSourceNode(true, CKEDITOR.NODE_COMMENT, node);
|
||||
prev = node.getPreviousSourceNode(true, CKEDITOR.NODE_COMMENT, (current: CKEDITOR.dom.node) => false);
|
||||
var next = node.getNextSourceNode();
|
||||
next = node.getNextSourceNode(true);
|
||||
next = node.getNextSourceNode(true, CKEDITOR.NODE_ELEMENT);
|
||||
next = node.getNextSourceNode(true, CKEDITOR.NODE_DOCUMENT, node);
|
||||
next = node.getNextSourceNode(true, CKEDITOR.NODE_DOCUMENT_FRAGMENT, (current: CKEDITOR.dom.node) => true);
|
||||
console.log(node.type);
|
||||
}
|
||||
|
||||
function test_dom_nodeList() {
|
||||
|
||||
Vendored
+3
-2
@@ -333,6 +333,7 @@ declare namespace CKEDITOR {
|
||||
}
|
||||
|
||||
class node extends domObject {
|
||||
type: number;
|
||||
constructor(domNode: Node);
|
||||
appendTo(element: element): element;
|
||||
clone(includeChildren: boolean, cloneId: boolean): node;
|
||||
@@ -347,12 +348,12 @@ declare namespace CKEDITOR {
|
||||
getDocument(): document;
|
||||
getIndex(normalized?: boolean): number;
|
||||
getNext(evaluator?: (node: node) => boolean): node;
|
||||
getNextSourceNode(startFromSibling: boolean, nodeType: number, guard: node | ((node: node) => boolean)): void;
|
||||
getNextSourceNode(startFromSibling?: boolean, nodeType?: number, guard?: node | ((node: node) => boolean)): node;
|
||||
getParent(allowFragmentParent?: boolean): element;
|
||||
getParents(closerFirst?: boolean): node[];
|
||||
getPosition(otherNode: node): void;
|
||||
getPrevious(evaluator?: (node: node) => boolean): node;
|
||||
getPreviousSourceNode(startFromSibling: boolean, nodeType: number, guard: node | ((node: node) => boolean)): void;
|
||||
getPreviousSourceNode(startFromSibling?: boolean, nodeType?: number, guard?: node | ((node: node) => boolean)): node;
|
||||
hasAscendant(name: string, includeSelf: boolean): boolean;
|
||||
remove(preserveChildren?: boolean): node;
|
||||
replace(nodeToReplace: node): void;
|
||||
|
||||
@@ -81,3 +81,18 @@ new CleanCSS({ returnPromise: true, sourceMap: true }).minify(source, inputSourc
|
||||
console.log(error);
|
||||
}
|
||||
);
|
||||
|
||||
// test object return when passing options as object
|
||||
let CleanCssOptions: CleanCSS.Options = { returnPromise: true };
|
||||
new CleanCSS(CleanCssOptions).minify(source)
|
||||
.then((minified: CleanCSS.Output): void => {
|
||||
console.log(minified.styles);
|
||||
}).catch((error: any): void => {
|
||||
console.log(error);
|
||||
}
|
||||
);
|
||||
|
||||
CleanCssOptions = { returnPromise: false };
|
||||
new CleanCSS(CleanCssOptions).minify(source, (error: any, minified: CleanCSS.Output): void => {
|
||||
console.log(minified.styles);
|
||||
});
|
||||
|
||||
Vendored
+89
-66
@@ -8,83 +8,78 @@
|
||||
import { RequestOptions as HttpsRequestOptions } from "https";
|
||||
import { RequestOptions as HttpRequestOptions } from "http";
|
||||
|
||||
declare namespace CleanCSS {
|
||||
/**
|
||||
* Shared options passed when initializing a new instance of CleanCSS that returns either a promise or output
|
||||
*/
|
||||
interface OptionsBase {
|
||||
/**
|
||||
* Options passed when initializing a new instance of CleanCSS
|
||||
* Controls compatibility mode used; defaults to ie10+ using `'*'`.
|
||||
* Compatibility hash exposes the following properties: `colors`, `properties`, `selectors`, and `units`
|
||||
*/
|
||||
interface Options {
|
||||
/**
|
||||
* Controls compatibility mode used; defaults to ie10+ using `'*'`.
|
||||
* Compatibility hash exposes the following properties: `colors`, `properties`, `selectors`, and `units`
|
||||
*/
|
||||
compatibility?: "*" | "ie9" | "ie8" | "ie7" | CompatibilityOptions;
|
||||
compatibility?: "*" | "ie9" | "ie8" | "ie7" | CleanCSS.CompatibilityOptions;
|
||||
|
||||
/**
|
||||
* Controls a function for handling remote requests; Defaults to the build in `loadRemoteResource` function
|
||||
*/
|
||||
fetch?: (uri: string, inlineRequest: HttpRequestOptions | HttpsRequestOptions, inlineTimeout: number, done: (message: string | number, body: string) => void) => void;
|
||||
/**
|
||||
* Controls a function for handling remote requests; Defaults to the build in `loadRemoteResource` function
|
||||
*/
|
||||
fetch?: (uri: string, inlineRequest: HttpRequestOptions | HttpsRequestOptions, inlineTimeout: number, done: (message: string | number, body: string) => void) => void;
|
||||
|
||||
/**
|
||||
* Controls output CSS formatting; defaults to `false`.
|
||||
* Format hash exposes the following properties: `breaks`, `breakWith`, `indentBy`, `indentWith`, `spaces`, and `wrapAt`.
|
||||
*/
|
||||
format?: "beautify" | "keep-breaks" | FormatOptions | false;
|
||||
/**
|
||||
* Controls output CSS formatting; defaults to `false`.
|
||||
* Format hash exposes the following properties: `breaks`, `breakWith`, `indentBy`, `indentWith`, `spaces`, and `wrapAt`.
|
||||
*/
|
||||
format?: "beautify" | "keep-breaks" | CleanCSS.FormatOptions | false;
|
||||
|
||||
/**
|
||||
* inline option whitelists which @import rules will be processed. Defaults to `'local'`
|
||||
* Accepts the following values:
|
||||
* 'local': enables local inlining;
|
||||
* 'remote': enables remote inlining;
|
||||
* 'none': disables all inlining;
|
||||
* 'all': enables all inlining, same as ['local', 'remote'];
|
||||
* '[uri]': enables remote inlining from the specified uri;
|
||||
* '![url]': disables remote inlining from the specified uri;
|
||||
*/
|
||||
inline?: ReadonlyArray<string> | false;
|
||||
/**
|
||||
* inline option whitelists which @import rules will be processed. Defaults to `'local'`
|
||||
* Accepts the following values:
|
||||
* 'local': enables local inlining;
|
||||
* 'remote': enables remote inlining;
|
||||
* 'none': disables all inlining;
|
||||
* 'all': enables all inlining, same as ['local', 'remote'];
|
||||
* '[uri]': enables remote inlining from the specified uri;
|
||||
* '![url]': disables remote inlining from the specified uri;
|
||||
*/
|
||||
inline?: ReadonlyArray<string> | false;
|
||||
|
||||
/**
|
||||
* Controls extra options for inlining remote @import rules
|
||||
*/
|
||||
inlineRequest?: HttpRequestOptions | HttpsRequestOptions;
|
||||
/**
|
||||
* Controls extra options for inlining remote @import rules
|
||||
*/
|
||||
inlineRequest?: HttpRequestOptions | HttpsRequestOptions;
|
||||
|
||||
/**
|
||||
* Controls number of milliseconds after which inlining a remote @import fails; defaults to `5000`;
|
||||
*/
|
||||
inlineTimeout?: number;
|
||||
/**
|
||||
* Controls number of milliseconds after which inlining a remote @import fails; defaults to `5000`;
|
||||
*/
|
||||
inlineTimeout?: number;
|
||||
|
||||
/**
|
||||
* Controls optimization level used; defaults to `1`.
|
||||
* Level hash exposes `1`, and `2`.
|
||||
*/
|
||||
level?: 0 | 1 | 2 | OptimizationsOptions;
|
||||
/**
|
||||
* Controls optimization level used; defaults to `1`.
|
||||
* Level hash exposes `1`, and `2`.
|
||||
*/
|
||||
level?: 0 | 1 | 2 | CleanCSS.OptimizationsOptions;
|
||||
|
||||
/**
|
||||
* Controls URL rebasing; defaults to `true`;
|
||||
*/
|
||||
rebase?: boolean;
|
||||
/**
|
||||
* Controls URL rebasing; defaults to `true`;
|
||||
*/
|
||||
rebase?: boolean;
|
||||
|
||||
/**
|
||||
* controls a directory to which all URLs are rebased, most likely the directory under which the output file
|
||||
* will live; defaults to the current directory;
|
||||
*/
|
||||
rebaseTo?: string;
|
||||
/**
|
||||
* controls a directory to which all URLs are rebased, most likely the directory under which the output file
|
||||
* will live; defaults to the current directory;
|
||||
*/
|
||||
rebaseTo?: string;
|
||||
|
||||
/**
|
||||
* If you prefer clean-css to return a Promise object then you need to explicitely ask for it; defaults to `false`
|
||||
*/
|
||||
returnPromise?: boolean;
|
||||
/**
|
||||
* Controls whether an output source map is built; defaults to `false`
|
||||
*/
|
||||
sourceMap?: boolean;
|
||||
|
||||
/**
|
||||
* Controls whether an output source map is built; defaults to `false`
|
||||
*/
|
||||
sourceMap?: boolean;
|
||||
|
||||
/**
|
||||
* Controls embedding sources inside a source map's `sourcesContent` field; defaults to `false`
|
||||
*/
|
||||
sourceMapInlineSources?: boolean;
|
||||
}
|
||||
/**
|
||||
* Controls embedding sources inside a source map's `sourcesContent` field; defaults to `false`
|
||||
*/
|
||||
sourceMapInlineSources?: boolean;
|
||||
}
|
||||
|
||||
declare namespace CleanCSS {
|
||||
/**
|
||||
* Output returned when calling minify functions
|
||||
*/
|
||||
@@ -650,12 +645,40 @@ declare namespace CleanCSS {
|
||||
minify(sources: Sources, sourceMap?: string): Promise<Output>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Options when returning a promise
|
||||
*/
|
||||
type OptionsPromise = OptionsBase & {
|
||||
/**
|
||||
* If you prefer clean-css to return a Promise object then you need to explicitly ask for it; defaults to `false`
|
||||
*/
|
||||
returnPromise: true
|
||||
};
|
||||
|
||||
/**
|
||||
* Options when returning an output
|
||||
*/
|
||||
type OptionsOutput = OptionsBase & {
|
||||
/**
|
||||
* If you prefer clean-css to return a Promise object then you need to explicitly ask for it; defaults to `false`
|
||||
*/
|
||||
returnPromise?: false
|
||||
};
|
||||
|
||||
/**
|
||||
* Discriminant union of both sets of options types. If you initialize without setting `returnPromise: true`
|
||||
* and want to return a promise, you will need to cast to the correct options type so that TypeScript
|
||||
* knows what the expected return type will be:
|
||||
* `(options = options as CleanCSS.OptionsPromise).returnPromise = true`
|
||||
*/
|
||||
type Options = OptionsPromise | OptionsOutput;
|
||||
|
||||
/**
|
||||
* Constructor interface for CleanCSS
|
||||
*/
|
||||
interface Constructor {
|
||||
new(options: Options & { returnPromise: true }): MinifierPromise;
|
||||
new(options?: Options): MinifierOutput;
|
||||
new(options: OptionsPromise): MinifierPromise;
|
||||
new(options?: OptionsOutput): MinifierOutput;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as React from "react";
|
||||
import Cleave = require("cleave.js");
|
||||
import CleaveReact = require("cleave.js/react");
|
||||
import { Props } from "cleave.js/react/props";
|
||||
import { Props, ChangeEvent } from "cleave.js/react/props";
|
||||
|
||||
const ExampleSelector1 = () => {
|
||||
const cleave = new Cleave("#my-input", { phone: true });
|
||||
@@ -41,3 +41,17 @@ const ExampleReact2 = (props: Props) => {
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
const ExampleReact3 = (props: Props) => {
|
||||
const handleChange = (e: ChangeEvent<HTMLInputElement>) => {
|
||||
return e.target.rawValue;
|
||||
};
|
||||
return (
|
||||
<CleaveReact
|
||||
value="test"
|
||||
className="form-control"
|
||||
options={{ date: true }}
|
||||
onChange={handleChange}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for cleave.js 1.3
|
||||
// Type definitions for cleave.js 1.4
|
||||
// Project: https://github.com/nosir/cleave.js
|
||||
// Definitions by: C Lentfort <https://github.com/clentfort>,
|
||||
// J Giancono <https://github.com/jasongi-at-sportsbet>,
|
||||
|
||||
Vendored
+7
@@ -3,8 +3,15 @@ import { CleaveOptions } from "../options";
|
||||
|
||||
export type InitHandler = (owner: React.ReactInstance) => void;
|
||||
|
||||
export interface ChangeEvent<T> extends React.ChangeEvent<T> {
|
||||
target: { rawValue: string } & EventTarget & T;
|
||||
}
|
||||
|
||||
export type ChangeEventHandler<T = Element> = React.EventHandler<ChangeEvent<T>>;
|
||||
|
||||
export interface Props extends React.InputHTMLAttributes<HTMLInputElement> {
|
||||
onInit?: InitHandler;
|
||||
options: CleaveOptions;
|
||||
htmlRef?: (i: any) => void;
|
||||
onChange?: ChangeEventHandler<HTMLInputElement>;
|
||||
}
|
||||
|
||||
Vendored
+3
-3
@@ -32,9 +32,9 @@ declare namespace Clusterize {
|
||||
}
|
||||
|
||||
interface Callbacks {
|
||||
clusterWillChange?(cb: () => void): void;
|
||||
clusterChanged?(cb: () => void): void;
|
||||
scrollingProgress?(cb: (progress: number) => void): void;
|
||||
clusterWillChange?: () => void;
|
||||
clusterChanged?: () => void;
|
||||
scrollingProgress?: (progress: number) => void;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ client.getAccount("abcdef", (error: Error, account: coinbase.Account): void => {
|
||||
|
||||
account.getBuy("abcdef", (error: Error, buy: coinbase.Buy): void => undefined);
|
||||
|
||||
account.getBuys((error: Error, buy: coinbase.Buy[]): void => undefined);
|
||||
account.getBuys(null, (error: Error, buy: coinbase.Buy[]): void => undefined);
|
||||
|
||||
account.getDeposit("abcdef", (error: Error, deposit: coinbase.Deposit): void => undefined);
|
||||
|
||||
@@ -33,7 +33,7 @@ client.getAccount("abcdef", (error: Error, account: coinbase.Account): void => {
|
||||
|
||||
account.getSell("abcdef", (error: Error, deposit: coinbase.Sell): void => undefined);
|
||||
|
||||
account.getSells((error: Error, deposit: coinbase.Sell[]): void => undefined);
|
||||
account.getSells(null, (error: Error, deposit: coinbase.Sell[]): void => undefined);
|
||||
|
||||
account.getTransaction("abcdef", (error: Error, deposit: coinbase.Transaction): void => undefined);
|
||||
|
||||
|
||||
Vendored
+64
-3
@@ -536,6 +536,21 @@ export class Account implements Resource {
|
||||
*/
|
||||
balance: MoneyHash;
|
||||
|
||||
/**
|
||||
* Allow deposits
|
||||
*/
|
||||
allow_deposits: boolean;
|
||||
|
||||
/**
|
||||
* Allow withdrawls
|
||||
*/
|
||||
allow_withdrawals: boolean;
|
||||
|
||||
/**
|
||||
* Account worth in fiat.
|
||||
*/
|
||||
native_balance: MoneyHash;
|
||||
|
||||
/**
|
||||
* Promote an account as primary account.
|
||||
* Scope: wallet:accounts:update
|
||||
@@ -630,7 +645,7 @@ export class Account implements Resource {
|
||||
* Lists buys for an account.
|
||||
* Scope: wallet:buys:read
|
||||
*/
|
||||
getBuys(cb: (error: Error, result: Buy[]) => void): void;
|
||||
getBuys(opts: null, cb: (error: Error, result: Buy[]) => void): void;
|
||||
|
||||
/**
|
||||
* Show an individual buy.
|
||||
@@ -663,7 +678,7 @@ export class Account implements Resource {
|
||||
* Lists sells for an account.
|
||||
* Scope: wallet:sells:read
|
||||
*/
|
||||
getSells(cb: (error: Error, result: Sell[]) => void): void;
|
||||
getSells(opts: null, cb: (error: Error, result: Sell[]) => void): void;
|
||||
|
||||
/**
|
||||
* Show an individual sell.
|
||||
@@ -883,7 +898,7 @@ export class Buy implements Resource {
|
||||
/**
|
||||
* Fee associated to this buy
|
||||
*/
|
||||
fee: MoneyHash;
|
||||
fees: Fee[];
|
||||
|
||||
/**
|
||||
* Has this buy been committed?
|
||||
@@ -900,6 +915,26 @@ export class Buy implements Resource {
|
||||
*/
|
||||
payout_at?: string;
|
||||
|
||||
/**
|
||||
* Unit price of the base currency.
|
||||
*/
|
||||
unit_price: UnitPrice;
|
||||
|
||||
/**
|
||||
* Hold period for transfer.
|
||||
*/
|
||||
hold_business_days: number;
|
||||
|
||||
/**
|
||||
* Is it the first buy for this symbol?
|
||||
*/
|
||||
is_first_buy: boolean;
|
||||
|
||||
/**
|
||||
* Is there another action required to make the transfer pass?
|
||||
*/
|
||||
requires_completion_step: boolean;
|
||||
|
||||
/**
|
||||
* Completes a buy that is created in commit: false state.
|
||||
* If the exchange rate has changed since the buy was created, this call will fail with the error “The exchange rate updated while you
|
||||
@@ -910,6 +945,32 @@ export class Buy implements Resource {
|
||||
commit(cb: (error: Error, transaction: Buy) => void): void;
|
||||
}
|
||||
|
||||
export interface Fee {
|
||||
/**
|
||||
* Amount associated to this fee
|
||||
*/
|
||||
amount: MoneyHash;
|
||||
/**
|
||||
* Fee beneficiary ("bank", "coinbase", ...)
|
||||
*/
|
||||
type: string;
|
||||
}
|
||||
|
||||
export interface UnitPrice {
|
||||
/**
|
||||
* Amount as floating-point in a string
|
||||
*/
|
||||
amount: string;
|
||||
/**
|
||||
* Currency e.g. "BTC" (see Client#getCurrencies() for available strings)
|
||||
*/
|
||||
currency: string;
|
||||
/**
|
||||
* Type of price
|
||||
*/
|
||||
scale: number;
|
||||
}
|
||||
|
||||
export type SellStatus = "created" | "completed" | "canceled";
|
||||
|
||||
/**
|
||||
|
||||
Vendored
+6
-3
@@ -4,15 +4,18 @@
|
||||
// Leonard Thieu <https://github.com/leonard-thieu>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export type NodeType =
|
||||
'text' |'softbreak' | 'linebreak' | 'emph' | 'strong' | 'html_inline' | 'link' | 'image' | 'code' | 'document' | 'paragraph' |
|
||||
'block_quote' | 'item' | 'list' | 'heading' | 'code_block' | 'html_block' | 'thematic_break' | 'custom_inline' | 'custom_block';
|
||||
|
||||
export class Node {
|
||||
constructor(nodeType: string, sourcepos?: Position);
|
||||
constructor(nodeType: NodeType, sourcepos?: Position);
|
||||
|
||||
/**
|
||||
* (read-only): a String, one of text, softbreak, linebreak, emph, strong, html_inline, link, image, code, document, paragraph,
|
||||
* block_quote, item, list, heading, code_block, html_block, thematic_break.
|
||||
*/
|
||||
readonly type: 'text' | 'softbreak' | 'linebreak' | 'emph' | 'strong' | 'html_inline' | 'link' | 'image' | 'code' | 'document' | 'paragraph' |
|
||||
'block_quote' | 'item' | 'list' | 'heading' | 'code_block' | 'html_block' | 'thematic_break' | 'custom_inline' | 'custom_block';
|
||||
readonly type: NodeType;
|
||||
/**
|
||||
* (read-only): a Node or null.
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import { format, parse } from 'content-range';
|
||||
|
||||
format({
|
||||
first: 10,
|
||||
last: 100,
|
||||
length: 100,
|
||||
limit: 20,
|
||||
unit: 'items',
|
||||
});
|
||||
|
||||
format({
|
||||
length: null,
|
||||
unit: 'bytes',
|
||||
});
|
||||
|
||||
const parts = parse('items 10-29/100');
|
||||
|
||||
if (parts) {
|
||||
parts.first;
|
||||
parts.last;
|
||||
parts.length;
|
||||
parts.unit;
|
||||
}
|
||||
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
// Type definitions for content-range 1.1
|
||||
// Project: https://github.com/neoziro/content-range
|
||||
// Definitions by: Alex Brick <https://github.com/bricka>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export interface ContentRangeFormatOptions {
|
||||
first?: number;
|
||||
last?: number;
|
||||
length: number | null;
|
||||
limit?: number;
|
||||
unit: string;
|
||||
}
|
||||
|
||||
export interface ContentRangeParts {
|
||||
first: number | null;
|
||||
last: number | null;
|
||||
length: number | null;
|
||||
unit: string;
|
||||
}
|
||||
|
||||
export function format(options: ContentRangeFormatOptions): string;
|
||||
export function parse(str: string): ContentRangeParts | null;
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"content-range-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -0,0 +1,23 @@
|
||||
import createXpub = require('create-xpub');
|
||||
|
||||
// $ExpectType string
|
||||
createXpub({
|
||||
depth: 3,
|
||||
childNumber: 2147483648,
|
||||
chainCode: '84cf7d9029cdd9fcadbb3717fd92ec0db7d7d9787c57c13c08fc887c389b566b',
|
||||
publicKey:
|
||||
'048bcdcf59f046b13f1eb35b608d1211265fde8cc44fc7a5a7f7107c5cf238095328a0e0d7be17c7d3e48490e8c6433af6d2c3dacc687f3fecaa98a3d05f17de97',
|
||||
});
|
||||
|
||||
// $ExpectType string
|
||||
createXpub({
|
||||
networkVersion: createXpub.testnet,
|
||||
depth: 3,
|
||||
childNumber: 2147483648,
|
||||
chainCode: '84cf7d9029cdd9fcadbb3717fd92ec0db7d7d9787c57c13c08fc887c389b566b',
|
||||
publicKey:
|
||||
'048bcdcf59f046b13f1eb35b608d1211265fde8cc44fc7a5a7f7107c5cf238095328a0e0d7be17c7d3e48490e8c6433af6d2c3dacc687f3fecaa98a3d05f17de97',
|
||||
});
|
||||
|
||||
createXpub.mainnet; // $ExpectType 76067358
|
||||
createXpub.testnet; // $ExpectType 70617039
|
||||
Vendored
+52
@@ -0,0 +1,52 @@
|
||||
// Type definitions for create-xpub 2.1
|
||||
// Project: https://github.com/lukechilds/create-xpub#readme
|
||||
// Definitions by: BendingBender <https://github.com/BendingBender>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export = createXpub;
|
||||
|
||||
/**
|
||||
* Creates a Base58 encoded extended public key (xpub) for use in a
|
||||
* [BIP32 hierarchical deterministic wallet](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki).
|
||||
*
|
||||
* Tip: If you're working with ledgerjs you can pass the output of
|
||||
* [`getWalletPublicKey()`](http://ledgerhq.github.io/ledgerjs/docs/#btcgetwalletpublickey) almost directly in.
|
||||
*
|
||||
* @returns A Base58 encoded extended public key.
|
||||
*/
|
||||
declare function createXpub(options: createXpub.Options): string;
|
||||
|
||||
declare namespace createXpub {
|
||||
/**
|
||||
* Mainnet (xpub) version bytes.
|
||||
*/
|
||||
const mainnet: 0x0488B21E;
|
||||
/**
|
||||
* Testnet (tpub) version bytes.
|
||||
*/
|
||||
const testnet: 0x043587CF;
|
||||
|
||||
interface Options {
|
||||
/**
|
||||
* Network version bytes.
|
||||
* @default 0x0488B21E
|
||||
*/
|
||||
networkVersion?: number;
|
||||
/**
|
||||
* The depth of the derived key.
|
||||
*/
|
||||
depth: number;
|
||||
/**
|
||||
* The child number.
|
||||
*/
|
||||
childNumber: number;
|
||||
/**
|
||||
* The chain code.
|
||||
*/
|
||||
chainCode: string;
|
||||
/**
|
||||
* The public key in compressed or uncompressed form.
|
||||
*/
|
||||
publicKey: string;
|
||||
}
|
||||
}
|
||||
@@ -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",
|
||||
"create-xpub-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+19
-8
@@ -1,4 +1,4 @@
|
||||
// Type definitions for cron 1.3
|
||||
// Type definitions for cron 1.6
|
||||
// Project: https://www.npmjs.com/package/cron
|
||||
// Definitions by: Hiroki Horiuchi <https://github.com/horiuchi>
|
||||
// Lundarl Gholoi <https://github.com/winup>
|
||||
@@ -9,8 +9,9 @@ export declare class CronTime {
|
||||
* Create a new ```CronTime```.
|
||||
* @param source The time to fire off your job. This can be in the form of cron syntax or a JS ```Date``` object.
|
||||
* @param zone Timezone name. You can check all timezones available at [Moment Timezone Website](http://momentjs.com/timezone/).
|
||||
* @param utcOffset UTC offset. Don't use both ```zone``` and ```utcOffset``` together or weird things may happen.
|
||||
*/
|
||||
constructor(source: string | Date, zone?: string);
|
||||
constructor(source: string | Date, zone?: string, utcOffset?: string | number);
|
||||
|
||||
/**
|
||||
* Tells you when ```CronTime``` will be run.
|
||||
@@ -29,19 +30,19 @@ export declare interface CronJobParameters {
|
||||
*/
|
||||
cronTime: string | Date;
|
||||
/**
|
||||
* The function to fire at the specified time.
|
||||
* The function to fire at the specified time. If an ```onComplete``` callback was provided, ```onTick``` will receive it as an argument. ```onTick``` may call ```onComplete``` when it has finished its work.
|
||||
*/
|
||||
onTick: () => void;
|
||||
/**
|
||||
* A function that will fire when the job is complete, when it is stopped.
|
||||
* A function that will fire when the job is stopped with ```job.stop()```, and may also be called by ```onTick``` at the end of each run.
|
||||
*/
|
||||
onComplete?: () => void;
|
||||
/**
|
||||
* Specifies whether to start the job just before exiting the constructor. By default this is set to false. If left at default you will need to call ```job.start()``` in order to start the job (assuming ```job``` is the variable you set the cronjob to). This does not immediately fire your onTick function, it just gives you more control over the behavior of your jobs.
|
||||
* Specifies whether to start the job just before exiting the constructor. By default this is set to false. If left at default you will need to call ```job.start()``` in order to start the job (assuming ```job``` is the variable you set the cronjob to). This does not immediately fire your ```onTick``` function, it just gives you more control over the behavior of your jobs.
|
||||
*/
|
||||
start?: boolean;
|
||||
/**
|
||||
* Specify the timezone for the execution. This will modify the actual time relative to your timezone. If the timezone is invalid, an error is thrown. You can check all timezones available at [Moment Timezone Website](http://momentjs.com/timezone/).
|
||||
* Specify the timezone for the execution. This will modify the actual time relative to your timezone. If the timezone is invalid, an error is thrown. You can check all timezones available at [Moment Timezone Website](http://momentjs.com/timezone/). Probably don't use both ```timeZone``` and ```utcOffset``` together or weird things may happen.
|
||||
*/
|
||||
timeZone?: string;
|
||||
/**
|
||||
@@ -52,6 +53,14 @@ export declare interface CronJobParameters {
|
||||
* This will immediately fire your ```onTick``` function as soon as the requisit initialization has happened. This option is set to ```false``` by default for backwards compatibility.
|
||||
*/
|
||||
runOnInit?: boolean;
|
||||
/**
|
||||
* This allows you to specify the offset of your timezone rather than using the ```timeZone``` param. Probably don't use both ```timeZone``` and ```utcOffset``` together or weird things may happen.
|
||||
*/
|
||||
utcOffset?: string | number;
|
||||
/**
|
||||
* If you have code that keeps the event loop running and want to stop the node process when that finishes regardless of the state of your cronjob, you can do so making use of this parameter. This is off by default and cron will run as if it needs to control the event loop. For more information take a look at [timers#timers_timeout_unref](https://nodejs.org/api/timers.html#timers_timeout_unref) from the NodeJS docs.
|
||||
*/
|
||||
unrefTimeout?: boolean;
|
||||
}
|
||||
|
||||
export declare class CronJob {
|
||||
@@ -73,8 +82,10 @@ export declare class CronJob {
|
||||
* @param timeZone Specify the timezone for the execution. This will modify the actual time relative to your timezone. If the timezone is invalid, an error is thrown. You can check all timezones available at [Moment Timezone Website](http://momentjs.com/timezone/).
|
||||
* @param context The context within which to execute the onTick method. This defaults to the cronjob itself allowing you to call ```this.stop()```. However, if you change this you'll have access to the functions and values within your context object.
|
||||
* @param runOnInit This will immediately fire your ```onTick``` function as soon as the requisit initialization has happened. This option is set to ```false``` by default for backwards compatibility.
|
||||
* @param utcOffset This allows you to specify the offset of your timezone rather than using the ```timeZone``` param. Probably don't use both ```timeZone``` and ```utcOffset``` together or weird things may happen.
|
||||
* @param unrefTimeout If you have code that keeps the event loop running and want to stop the node process when that finishes regardless of the state of your cronjob, you can do so making use of this parameter. This is off by default and cron will run as if it needs to control the event loop. For more information take a look at [timers#timers_timeout_unref](https://nodejs.org/api/timers.html#timers_timeout_unref) from the NodeJS docs.
|
||||
*/
|
||||
constructor(cronTime: string | Date, onTick: () => void, onComplete?: () => void, start?: boolean, timeZone?: string, context?: any, runOnInit?: boolean);
|
||||
constructor(cronTime: string | Date, onTick: () => void, onComplete?: () => void, start?: boolean, timeZone?: string, context?: any, runOnInit?: boolean, utcOffset?: string | number, unrefTimeout?: boolean);
|
||||
/**
|
||||
* Create a new ```CronJob```.
|
||||
* @param options Job parameters.
|
||||
@@ -111,7 +122,7 @@ export declare class CronJob {
|
||||
}
|
||||
|
||||
export declare var job:
|
||||
((cronTime: string | Date, onTick: () => void, onComplete?: () => void, start?: boolean, timeZone?: string, context?: any, runOnInit?: boolean) => CronJob)
|
||||
((cronTime: string | Date, onTick: () => void, onComplete?: () => void, start?: boolean, timeZone?: string, context?: any, runOnInit?: boolean, utcOffset?: string | number, unrefTimeout?: boolean) => CronJob)
|
||||
| ((options: CronJobParameters) => CronJob);
|
||||
export declare var time: (source: string | Date, zone?: string) => CronTime;
|
||||
export declare var sendAt: (cronTime: CronTime) => Date;
|
||||
|
||||
@@ -10,17 +10,20 @@ CustomFunctions.associate({
|
||||
RANDOM: (n: number) => n * Math.random()
|
||||
});
|
||||
|
||||
function callerAddress(invocation: CustomFunctions.Invocation) {
|
||||
return invocation.address;
|
||||
}
|
||||
|
||||
async function getStockValues(ticker: string): Promise<number> {
|
||||
const response = await fetch(`myService.com/prices/${ticker}`);
|
||||
return (await response.json())["price"];
|
||||
}
|
||||
|
||||
async function getStockValuesCancellable(
|
||||
ticker: string,
|
||||
handler: CustomFunctions.CancelableHandler
|
||||
): Promise<number> {
|
||||
async function getStockValuesCancellable(ticker: string,
|
||||
invocation: CustomFunctions.CancelableInvocation): Promise<number> {
|
||||
const address = invocation.address;
|
||||
let shouldStop = false;
|
||||
handler.onCanceled = () => (shouldStop = true);
|
||||
invocation.onCanceled = () => (shouldStop = true);
|
||||
await pause(1000);
|
||||
|
||||
if (shouldStop) {
|
||||
@@ -31,10 +34,9 @@ async function getStockValuesCancellable(
|
||||
return (await response.json())["price"];
|
||||
}
|
||||
|
||||
function stockPriceStream(
|
||||
ticker: string,
|
||||
handler: CustomFunctions.StreamingHandler<number>
|
||||
) {
|
||||
function stockPriceStream(ticker: string,
|
||||
invocation: CustomFunctions.StreamingInvocation<number>) {
|
||||
const address = invocation.address;
|
||||
const updateFrequency = 10 /* milliseconds*/;
|
||||
let isPending = false;
|
||||
|
||||
@@ -49,14 +51,14 @@ function stockPriceStream(
|
||||
try {
|
||||
const response = await fetch(url);
|
||||
const data = await response.json();
|
||||
handler.setResult(data.price);
|
||||
invocation.setResult(data.price);
|
||||
} catch (error) {
|
||||
handler.setResult(error);
|
||||
invocation.setResult(error);
|
||||
}
|
||||
isPending = false;
|
||||
}, updateFrequency);
|
||||
|
||||
handler.onCanceled = () => {
|
||||
invocation.onCanceled = () => {
|
||||
clearInterval(timer);
|
||||
};
|
||||
}
|
||||
|
||||
+53
-13
@@ -1,6 +1,9 @@
|
||||
// Type definitions for Custom Functions 1.4
|
||||
// Project: https://github.com/OfficeDev/office-js
|
||||
// Definitions by: OfficeDev <https://github.com/OfficeDev>, Michael Zlatkovsky <https://github.com/Zlatkovsky>, Michelle Scharlock <https://github.com/mscharlock>
|
||||
// Definitions by: OfficeDev <https://github.com/OfficeDev>,
|
||||
// Adam Krantz <https://github.com/akrantz>,
|
||||
// Michael Zlatkovsky <https://github.com/Zlatkovsky>,
|
||||
// Michelle Scharlock <https://github.com/mscharlock>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.4
|
||||
|
||||
@@ -10,8 +13,8 @@ Copyright (c) Microsoft Corporation
|
||||
*/
|
||||
|
||||
/**
|
||||
* CustomFunctions namespace, used by Excel Custom Functions
|
||||
* @beta
|
||||
* CustomFunctions namespace, used by Excel Custom Functions
|
||||
*/
|
||||
declare namespace CustomFunctions {
|
||||
/**
|
||||
@@ -26,30 +29,67 @@ declare namespace CustomFunctions {
|
||||
function associate(mappings: { [key: string]: Function }): void;
|
||||
|
||||
/**
|
||||
* A handler passed automatically as the last parameter
|
||||
* to a streaming function. With this parameter, a
|
||||
* function can use handler.setResult to set a cell value
|
||||
* or hook into the handler.onCanceled event to
|
||||
* to handle what happens when the function stops streaming.
|
||||
* @beta
|
||||
* Provides information about the invocation of a custom function.
|
||||
*/
|
||||
interface StreamingHandler<T> extends CancelableHandler {
|
||||
interface Invocation {
|
||||
/**
|
||||
* Sets the returned result for a streaming custom function.
|
||||
* @beta
|
||||
* The cell address where the function is being called, if requested, otherwise undefined.
|
||||
*
|
||||
* To request the address for the function, in the metadata JSON file, the function options should specify:
|
||||
* `{ "requiresAddress": true }`
|
||||
*
|
||||
* If the metadata JSON file is being generated from JSDoc comments, include the tag `@requiresAddress`.
|
||||
*/
|
||||
setResult: (value: T | Error) => void;
|
||||
address?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @beta
|
||||
* CancelableHandler interface
|
||||
* Provides information about the invocation of a cancelable custom function.
|
||||
* A cancelable custom function can provide a handler for the onCanceled event.
|
||||
*
|
||||
* To indicate that a function is cancelable, in the metadata JSON file, the function options should specify:
|
||||
* `{ "cancelable": true }`
|
||||
*
|
||||
* If the metadata JSON file is being generated from JSDoc comments, include the tag `@cancelable`.
|
||||
*/
|
||||
interface CancelableHandler {
|
||||
interface CancelableInvocation extends Invocation {
|
||||
/**
|
||||
* Handles what should occur when a custom function is canceled.
|
||||
* @beta
|
||||
* Event handler called when the custom function is canceled.
|
||||
*/
|
||||
onCanceled: () => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* @beta
|
||||
* @deprecated Use `CancelableInvocation` instead.
|
||||
*/
|
||||
interface CancelableHandler extends CancelableInvocation {
|
||||
}
|
||||
|
||||
/**
|
||||
* @beta
|
||||
* Provides information about the invocation of a streaming custom function.
|
||||
* A streaming custom function can provide results which can change over time.
|
||||
*
|
||||
* Call `setResult()` one or more times to provide the result instead of returning
|
||||
* a result from the function.
|
||||
*/
|
||||
interface StreamingInvocation<ResultType> extends CancelableInvocation {
|
||||
/**
|
||||
* @beta
|
||||
* Set the result for the custom function. May be called more than once.
|
||||
*/
|
||||
setResult: (value: ResultType | Error) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* @beta
|
||||
* @deprecated Use `StreamingInvocation<ResultType>` instead.
|
||||
*/
|
||||
interface StreamingHandler<ResultType> extends StreamingInvocation<ResultType> {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"ban-types": false,
|
||||
"file-name-casing": false
|
||||
"file-name-casing": false,
|
||||
"no-empty-interface": false
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -181,7 +181,7 @@ export function ascending(a: Primitive | undefined, b: Primitive | undefined): n
|
||||
|
||||
// NB. this is limited to primitive values due to D3's use of the <, >, and >= operators. Results get weird for object instances.
|
||||
/**
|
||||
* Compares two primitive values for sorting (in ascending order).
|
||||
* Compares two primitive values for sorting (in descending order).
|
||||
*/
|
||||
export function descending(a: Primitive | undefined, b: Primitive | undefined): number;
|
||||
|
||||
|
||||
@@ -1464,6 +1464,7 @@ seriesDatum = seriesPoint.data;
|
||||
let order: number[];
|
||||
const seriesAnyAny: d3Shape.Series<any, any> = seriesArray[0];
|
||||
|
||||
order = d3Shape.stackOrderAppearance(seriesAnyAny);
|
||||
order = d3Shape.stackOrderAscending(seriesAnyAny);
|
||||
order = d3Shape.stackOrderDescending(seriesAnyAny);
|
||||
order = d3Shape.stackOrderInsideOut(seriesAnyAny);
|
||||
|
||||
Vendored
+9
-2
@@ -1,4 +1,4 @@
|
||||
// Type definitions for D3JS d3-shape module 1.2
|
||||
// Type definitions for D3JS d3-shape module 1.3
|
||||
// Project: https://github.com/d3/d3-shape/
|
||||
// Definitions by: Tom Wanzek <https://github.com/tomwanzek>
|
||||
// Alex Ford <https://github.com/gustavderdrache>
|
||||
@@ -7,7 +7,7 @@
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
// Last module patch version validated against: 1.2.0
|
||||
// Last module patch version validated against: 1.3.3
|
||||
|
||||
import { Path } from 'd3-path';
|
||||
|
||||
@@ -2670,6 +2670,13 @@ export function stack<Datum, Key>(): Stack<any, Datum, Key>;
|
||||
*/
|
||||
export function stack<This, Datum, Key>(): Stack<This, Datum, Key>;
|
||||
|
||||
/**
|
||||
* Returns a series order such that the earliest series (according to the maximum value) is at the bottom.
|
||||
*
|
||||
* @param series A series generated by a stack generator.
|
||||
*/
|
||||
export function stackOrderAppearance(series: Series<any, any>): number[];
|
||||
|
||||
/**
|
||||
* Returns a series order such that the smallest series (according to the sum of values) is at the bottom.
|
||||
*
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
import defaults = require('defaults-deep');
|
||||
|
||||
defaults();
|
||||
defaults({a: 'foo'});
|
||||
defaults({a: 'foo'}, {a: 'bar'});
|
||||
defaults({a: 'foo'}, {a: 'bar'}, {a: 'foobar'});
|
||||
defaults({a: {b: 'foo'}}, {a: {b: 'bar'}});
|
||||
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
// Type definitions for defaults-deep 0.2
|
||||
// Project: https://github.com/jonschlinkert/defaults-deep
|
||||
// Definitions by: Hugo Alliaume <https://github.com/Kocal>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
interface Obj {
|
||||
[k: string]: any;
|
||||
}
|
||||
|
||||
declare function defaultsDeep(...objs: Obj[]): Obj;
|
||||
|
||||
export = defaultsDeep;
|
||||
@@ -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",
|
||||
"defaults-deep-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+7
-1
@@ -434,4 +434,10 @@ declare global {
|
||||
}
|
||||
}
|
||||
|
||||
export { by, detox, device, element, expect, waitFor };
|
||||
export { by, detox, device, element, waitFor };
|
||||
|
||||
// Not exporting the global `expect` from the top of the file here
|
||||
// because `expect` conflicts with the global `expect` of jest and
|
||||
// therefore exporting it doesn't work. The global `expect` is kept
|
||||
// for backwards compatibility though.
|
||||
export const expect: Detox.Expect<Detox.Expect<any>>;
|
||||
|
||||
Vendored
+3
-3
@@ -1455,13 +1455,13 @@ interface GanttStatic {
|
||||
* exports a Gantt chart into the PDF format
|
||||
* @param _export_ an object with export settings (see the details)
|
||||
*/
|
||||
exportToPDF(_export_: any): void;
|
||||
exportToPDF(_export_?: any): void;
|
||||
|
||||
/**
|
||||
* exports a Gantt chart into the PNG format
|
||||
* @param _export_ an object with export settings (see the details)
|
||||
*/
|
||||
exportToPNG(_export_: any): void;
|
||||
exportToPNG(_export_?: any): void;
|
||||
|
||||
/**
|
||||
* returns all dependency loops in the chart
|
||||
@@ -2242,4 +2242,4 @@ declare module "gantt" {
|
||||
|
||||
declare module "Gantt" {
|
||||
export = Gantt;
|
||||
}
|
||||
}
|
||||
|
||||
+83
-75
@@ -1,47 +1,55 @@
|
||||
import jsdiff = require('diff');
|
||||
import * as diff from 'diff';
|
||||
|
||||
const one = 'beep boop';
|
||||
const other = 'beep boob blah';
|
||||
|
||||
let diff = jsdiff.diffChars(one, other);
|
||||
printDiff(diff);
|
||||
let changes = diff.diffChars(one, other);
|
||||
examineChanges(changes);
|
||||
|
||||
const diffArraysResult = jsdiff.diffArrays<string>(['a', 'b', 'c'], ['a', 'c', 'd']);
|
||||
// $ExpectType void
|
||||
diff.diffChars(one, other, {
|
||||
callback: (err, value) => {
|
||||
err; // $ExpectType undefined
|
||||
value; // $ExpectType Change[] | undefined
|
||||
},
|
||||
});
|
||||
// $ExpectType void
|
||||
diff.diffChars(one, other, (err, value) => {
|
||||
err; // $ExpectType undefined
|
||||
value; // $ExpectType Change[] | undefined
|
||||
});
|
||||
|
||||
const diffArraysResult = diff.diffArrays(['a', 'b', 'c'], ['a', 'c', 'd']);
|
||||
diffArraysResult.forEach(result => {
|
||||
if (result.added) {
|
||||
console.log(`added ${result.value.length} line(s):`, ...result.value);
|
||||
} else if (result.removed) {
|
||||
console.log(`removed ${result.value.length} line(s):`, ...result.value);
|
||||
} else {
|
||||
console.log(`no changes`);
|
||||
}
|
||||
result.added; // $ExpectType boolean | undefined
|
||||
result.removed; // $ExpectType boolean | undefined
|
||||
result.value; // $ExpectType string[]
|
||||
result.count; // $ExpectType number | undefined
|
||||
});
|
||||
|
||||
interface DiffObj {
|
||||
value: number;
|
||||
}
|
||||
const a: DiffObj = {value: 0};
|
||||
const b: DiffObj = {value: 1};
|
||||
const c: DiffObj = {value: 2};
|
||||
const d: DiffObj = {value: 3};
|
||||
const arrayOptions: jsdiff.IArrayOptions = {
|
||||
comparator: (left: DiffObj, right: DiffObj) => {
|
||||
return left.value === right.value;
|
||||
}
|
||||
const a: DiffObj = { value: 0 };
|
||||
const b: DiffObj = { value: 1 };
|
||||
const c: DiffObj = { value: 2 };
|
||||
const d: DiffObj = { value: 3 };
|
||||
const arrayOptions: diff.ArrayOptions<DiffObj, DiffObj> = {
|
||||
comparator: (left, right) => {
|
||||
return left.value === right.value;
|
||||
},
|
||||
};
|
||||
const diffResult = jsdiff.diffArrays([a, b, c], [a, b, d], arrayOptions);
|
||||
diffResult.forEach(result => {
|
||||
if (result.added) {
|
||||
console.log(`added ${result.value.length} line(s):`, ...result.value);
|
||||
} else if (result.removed) {
|
||||
console.log(`removed ${result.value.length} line(s):`, ...result.value);
|
||||
} else {
|
||||
console.log(`no changes`);
|
||||
}
|
||||
const arrayChanges = diff.diffArrays([a, b, c], [a, b, d], arrayOptions);
|
||||
arrayChanges.forEach(result => {
|
||||
result.added; // $ExpectType boolean | undefined
|
||||
result.removed; // $ExpectType boolean | undefined
|
||||
result.value; // $ExpectType DiffObj[]
|
||||
result.count; // $ExpectType number | undefined
|
||||
});
|
||||
|
||||
// --------------------------
|
||||
|
||||
class LineDiffWithoutWhitespace extends jsdiff.Diff {
|
||||
class LineDiffWithoutWhitespace extends diff.Diff {
|
||||
tokenize(value: string): any {
|
||||
return value.split(/^/m);
|
||||
}
|
||||
@@ -52,71 +60,71 @@ class LineDiffWithoutWhitespace extends jsdiff.Diff {
|
||||
}
|
||||
|
||||
const obj = new LineDiffWithoutWhitespace();
|
||||
diff = obj.diff(one, other);
|
||||
printDiff(diff);
|
||||
changes = obj.diff(one, other);
|
||||
examineChanges(changes);
|
||||
|
||||
function printDiff(diff: jsdiff.IDiffResult[]) {
|
||||
function addLineHeader(decorator: string, str: string | string[]) {
|
||||
return (typeof str === 'string' ? str.split("\n") : str).map((line, index, array) => {
|
||||
if (index === array.length - 1 && line === "") {
|
||||
return line;
|
||||
} else {
|
||||
return decorator + line;
|
||||
}
|
||||
}).join("\n");
|
||||
}
|
||||
|
||||
diff.forEach((part) => {
|
||||
if (part.added) {
|
||||
console.log(addLineHeader("+", part.value));
|
||||
} else if (part.removed) {
|
||||
console.log(addLineHeader("-", part.value));
|
||||
} else {
|
||||
console.log(addLineHeader(" ", part.value));
|
||||
}
|
||||
function examineChanges(diff: diff.Change[]) {
|
||||
diff.forEach(part => {
|
||||
part.added; // $ExpectType boolean | undefined
|
||||
part.removed; // $ExpectType boolean | undefined
|
||||
part.value; // $ExpectType string
|
||||
part.count; // $ExpectType number | undefined
|
||||
});
|
||||
}
|
||||
|
||||
function verifyPatchMethods(oldStr: string, newStr: string, uniDiff: jsdiff.IUniDiff) {
|
||||
const verifyPatch = jsdiff.parsePatch(
|
||||
jsdiff.createTwoFilesPatch("oldFile.ts", "newFile.ts", oldStr, newStr,
|
||||
"old", "new", { context: 1 }));
|
||||
function verifyPatchMethods(oldStr: string, newStr: string, uniDiff: diff.ParsedDiff) {
|
||||
const verifyPatch = diff.parsePatch(
|
||||
diff.createTwoFilesPatch('oldFile.ts', 'newFile.ts', oldStr, newStr, 'old', 'new', {
|
||||
context: 1,
|
||||
})
|
||||
);
|
||||
|
||||
if (JSON.stringify(verifyPatch[0], Object.keys(verifyPatch[0]).sort()) !== JSON.stringify(uniDiff, Object.keys(uniDiff).sort())) {
|
||||
console.error("Patch did not match uniDiff");
|
||||
if (
|
||||
JSON.stringify(verifyPatch[0], Object.keys(verifyPatch[0]).sort()) !==
|
||||
JSON.stringify(uniDiff, Object.keys(uniDiff).sort())
|
||||
) {
|
||||
throw new Error('Patch did not match uniDiff');
|
||||
}
|
||||
}
|
||||
function verifyApplyMethods(oldStr: string, newStr: string, uniDiff: jsdiff.IUniDiff) {
|
||||
const verifyApply = [
|
||||
jsdiff.applyPatch(oldStr, uniDiff),
|
||||
jsdiff.applyPatch(oldStr, [uniDiff])
|
||||
];
|
||||
jsdiff.applyPatches([uniDiff], {
|
||||
loadFile: (index: number, callback: (err: Error, data: string) => void) => {
|
||||
function verifyApplyMethods(oldStr: string, newStr: string, uniDiffStr: string) {
|
||||
const uniDiff = diff.parsePatch(uniDiffStr)[0];
|
||||
const verifyApply = [diff.applyPatch(oldStr, uniDiff), diff.applyPatch(oldStr, [uniDiff])];
|
||||
const options: diff.ApplyPatchesOptions = {
|
||||
loadFile(index, callback) {
|
||||
index; // $ExpectType ParsedDiff
|
||||
callback(undefined, one);
|
||||
},
|
||||
patched: (index: number, content: string) => {
|
||||
patched(index, content) {
|
||||
index; // $ExpectType ParsedDiff
|
||||
verifyApply.push(content);
|
||||
},
|
||||
complete: (err?: Error) => {
|
||||
complete(err) {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
throw err;
|
||||
}
|
||||
|
||||
verifyApply.forEach(result => {
|
||||
if (result !== newStr) {
|
||||
console.error("Result did not match newStr");
|
||||
throw new Error('Result did not match newStr');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
compareLine(_, line, operator, patchContent) {
|
||||
if (operator === ' ') {
|
||||
return true;
|
||||
}
|
||||
return line === patchContent;
|
||||
},
|
||||
fuzzFactor: 0
|
||||
};
|
||||
diff.applyPatches([uniDiff], options);
|
||||
diff.applyPatches(uniDiffStr, options);
|
||||
}
|
||||
|
||||
const uniDiffPatch = jsdiff.structuredPatch("oldFile.ts", "newFile.ts", one, other,
|
||||
"old", "new", { context: 1 });
|
||||
const uniDiffPatch = diff.structuredPatch('oldFile.ts', 'newFile.ts', one, other, 'old', 'new', {
|
||||
context: 1,
|
||||
});
|
||||
verifyPatchMethods(one, other, uniDiffPatch);
|
||||
|
||||
const uniDiffStr = jsdiff.createPatch("file.ts", one, other, "old", "new",
|
||||
{ context: 1 });
|
||||
const uniDiffApply = jsdiff.parsePatch(uniDiffStr)[0];
|
||||
verifyApplyMethods(one, other, uniDiffApply);
|
||||
const uniDiffStr = diff.createPatch('file.ts', one, other, 'old', 'new', { context: 1 });
|
||||
verifyApplyMethods(one, other, uniDiffStr);
|
||||
|
||||
Vendored
+392
-111
@@ -1,121 +1,402 @@
|
||||
// Type definitions for diff 3.5
|
||||
// Type definitions for diff 4.0
|
||||
// Project: https://github.com/kpdecker/jsdiff
|
||||
// Definitions by: vvakame <https://github.com/vvakame>
|
||||
// szdc <https://github.com/szdc>
|
||||
// moc-yuto <https://github.com/moc-yuto>
|
||||
// BendingBender <https://github.com/BendingBender>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
export = JsDiff;
|
||||
export as namespace JsDiff;
|
||||
export as namespace Diff;
|
||||
|
||||
declare namespace JsDiff {
|
||||
interface IOptions {
|
||||
ignoreCase: boolean;
|
||||
}
|
||||
export type Callback = (err: undefined, value?: Change[]) => void;
|
||||
|
||||
interface ILinesOptions extends IOptions {
|
||||
ignoreWhitespace?: boolean;
|
||||
newlineIsToken?: boolean;
|
||||
}
|
||||
|
||||
interface IArrayOptions {
|
||||
comparator?: (left: any, right: any) => boolean;
|
||||
}
|
||||
|
||||
interface IDiffResult {
|
||||
value: string;
|
||||
count?: number;
|
||||
added?: boolean;
|
||||
removed?: boolean;
|
||||
}
|
||||
|
||||
interface IDiffArraysResult<T> {
|
||||
value: T[];
|
||||
count?: number;
|
||||
added?: boolean;
|
||||
removed?: boolean;
|
||||
}
|
||||
|
||||
interface IBestPath {
|
||||
newPos: number;
|
||||
componenets: IDiffResult[];
|
||||
}
|
||||
|
||||
interface IHunk {
|
||||
oldStart: number;
|
||||
oldLines: number;
|
||||
newStart: number;
|
||||
newLines: number;
|
||||
lines: string[];
|
||||
}
|
||||
|
||||
interface IUniDiff {
|
||||
oldFileName: string;
|
||||
newFileName: string;
|
||||
oldHeader: string;
|
||||
newHeader: string;
|
||||
index: string;
|
||||
hunks: IHunk[];
|
||||
}
|
||||
|
||||
class Diff {
|
||||
diff(oldString: string, newString: string, options?: IOptions): IDiffResult[];
|
||||
|
||||
pushComponent(components: IDiffResult[], added: boolean, removed: boolean): void;
|
||||
|
||||
extractCommon(basePath: IBestPath, newString: string, oldString: string, diagonalPath: number): number;
|
||||
|
||||
equals(left: string, right: string): boolean;
|
||||
|
||||
removeEmpty(array: any[]): any[];
|
||||
|
||||
castInput(value: any): any;
|
||||
|
||||
join(chars: string[]): string;
|
||||
|
||||
tokenize(value: string): any; // return types are string or string[]
|
||||
}
|
||||
|
||||
function diffChars(oldStr: string, newStr: string, options?: IOptions): IDiffResult[];
|
||||
|
||||
function diffWords(oldStr: string, newStr: string, options?: IOptions): IDiffResult[];
|
||||
|
||||
function diffWordsWithSpace(oldStr: string, newStr: string, options?: IOptions): IDiffResult[];
|
||||
|
||||
function diffJson(oldObj: object, newObj: object, options?: IOptions): IDiffResult[];
|
||||
|
||||
function diffLines(oldStr: string, newStr: string, options?: ILinesOptions): IDiffResult[];
|
||||
|
||||
function diffCss(oldStr: string, newStr: string, options?: IOptions): IDiffResult[];
|
||||
|
||||
function diffTrimmedLines(oldStr: string, newStr: string, options?: ILinesOptions): IDiffResult[];
|
||||
|
||||
function diffSentences(oldStr: string, newStr: string, options?: IOptions): IDiffResult[];
|
||||
|
||||
function diffArrays<T>(oldArr: T[], newArr: T[], options?: IArrayOptions): Array<IDiffArraysResult<T>>;
|
||||
|
||||
function createPatch(fileName: string, oldStr: string, newStr: string, oldHeader: string, newHeader: string, options?: {context: number}): string;
|
||||
|
||||
function createTwoFilesPatch(oldFileName: string, newFileName: string, oldStr: string, newStr: string, oldHeader: string, newHeader: string, options?: {context: number}): string;
|
||||
|
||||
function structuredPatch(oldFileName: string, newFileName: string, oldStr: string, newStr: string, oldHeader: string, newHeader: string, options?: {context: number}): IUniDiff;
|
||||
|
||||
function applyPatch(oldStr: string, uniDiff: string | IUniDiff | IUniDiff[]): string;
|
||||
|
||||
function applyPatches(uniDiff: IUniDiff[], options: {
|
||||
loadFile(index: number, callback: (err: Error, data: string) => void): void,
|
||||
patched(index: number, content: string): void,
|
||||
complete(err?: Error): void
|
||||
}): void;
|
||||
|
||||
function parsePatch(diffStr: string, options?: {strict: boolean}): IUniDiff[];
|
||||
|
||||
function convertChangesToXML(changes: IDiffResult[]): string;
|
||||
|
||||
function convertChangesToDMP(changes: IDiffResult[]): Array<{0: number; 1: string; }>;
|
||||
|
||||
function merge(mine: string, theirs: string, base: string): IUniDiff;
|
||||
|
||||
function canonicalize(obj: any, stack: any[], replacementStack: any[]): any;
|
||||
export interface CallbackOptions {
|
||||
/**
|
||||
* Callback to call with the result instead of returning the result directly.
|
||||
*/
|
||||
callback: Callback;
|
||||
}
|
||||
|
||||
export interface BaseOptions {
|
||||
/**
|
||||
* `true` to ignore casing difference.
|
||||
* @default false
|
||||
*/
|
||||
ignoreCase?: boolean;
|
||||
}
|
||||
|
||||
export interface WordsOptions extends BaseOptions {
|
||||
/**
|
||||
* `true` to ignore leading and trailing whitespace. This is the same as `diffWords()`.
|
||||
*/
|
||||
ignoreWhitespace?: boolean;
|
||||
}
|
||||
|
||||
export interface LinesOptions extends BaseOptions {
|
||||
/**
|
||||
* `true` to ignore leading and trailing whitespace. This is the same as `diffTrimmedLines()`.
|
||||
*/
|
||||
ignoreWhitespace?: boolean;
|
||||
|
||||
/**
|
||||
* `true` to treat newline characters as separate tokens. This allows for changes to the newline structure
|
||||
* to occur independently of the line content and to be treated as such. In general this is the more
|
||||
* human friendly form of `diffLines()` and `diffLines()` is better suited for patches and other computer
|
||||
* friendly output.
|
||||
*/
|
||||
newlineIsToken?: boolean;
|
||||
}
|
||||
|
||||
export interface JsonOptions extends LinesOptions {
|
||||
/**
|
||||
* Replacer used to stringify the properties of the passed objects.
|
||||
*/
|
||||
stringifyReplacer?: (key: string, value: any) => any;
|
||||
|
||||
/**
|
||||
* The value to use when `undefined` values in the passed objects are encountered during stringification.
|
||||
* Will only be used if `stringifyReplacer` option wasn't specified.
|
||||
* @default undefined
|
||||
*/
|
||||
undefinedReplacement?: any;
|
||||
}
|
||||
|
||||
export interface ArrayOptions<TLeft, TRight> extends BaseOptions {
|
||||
/**
|
||||
* Comparator for custom equality checks.
|
||||
*/
|
||||
comparator?: (left: TLeft, right: TRight) => boolean;
|
||||
}
|
||||
|
||||
export interface PatchOptions extends LinesOptions {
|
||||
/**
|
||||
* Describes how many lines of context should be included.
|
||||
* @default 4
|
||||
*/
|
||||
context?: number;
|
||||
}
|
||||
|
||||
export interface ApplyPatchOptions {
|
||||
/**
|
||||
* Number of lines that are allowed to differ before rejecting a patch.
|
||||
* @default 0
|
||||
*/
|
||||
fuzzFactor?: number;
|
||||
|
||||
/**
|
||||
* Callback used to compare to given lines to determine if they should be considered equal when patching.
|
||||
* Should return `false` if the lines should be rejected.
|
||||
*
|
||||
* @default strict equality
|
||||
*/
|
||||
compareLine?: (
|
||||
lineNumber: number,
|
||||
line: string,
|
||||
operation: '-' | ' ',
|
||||
patchContent: string
|
||||
) => boolean;
|
||||
}
|
||||
|
||||
export interface ApplyPatchesOptions extends ApplyPatchOptions {
|
||||
loadFile(index: ParsedDiff, callback: (err: any, data: string) => void): void;
|
||||
patched(index: ParsedDiff, content: string, callback: (err: any) => void): void;
|
||||
complete(err: any): void;
|
||||
}
|
||||
|
||||
export interface Change {
|
||||
count?: number;
|
||||
/**
|
||||
* Text content.
|
||||
*/
|
||||
value: string;
|
||||
/**
|
||||
* `true` if the value was inserted into the new string.
|
||||
*/
|
||||
added?: boolean;
|
||||
/**
|
||||
* `true` if the value was removed from the old string.
|
||||
*/
|
||||
removed?: boolean;
|
||||
}
|
||||
|
||||
export interface ArrayChange<T> {
|
||||
value: T[];
|
||||
count?: number;
|
||||
added?: boolean;
|
||||
removed?: boolean;
|
||||
}
|
||||
|
||||
export interface ParsedDiff {
|
||||
index?: string;
|
||||
oldFileName?: string;
|
||||
newFileName?: string;
|
||||
oldHeader?: string;
|
||||
newHeader?: string;
|
||||
hunks: Hunk[];
|
||||
}
|
||||
|
||||
export interface Hunk {
|
||||
oldStart: number;
|
||||
oldLines: number;
|
||||
newStart: number;
|
||||
newLines: number;
|
||||
lines: string[];
|
||||
}
|
||||
|
||||
export interface BestPath {
|
||||
newPos: number;
|
||||
componenets: Change[];
|
||||
}
|
||||
|
||||
export class Diff {
|
||||
diff(
|
||||
oldString: string,
|
||||
newString: string,
|
||||
options?: Callback | (ArrayOptions<any, any> & Partial<CallbackOptions>)
|
||||
): Change[];
|
||||
|
||||
pushComponent(components: Change[], added: boolean, removed: boolean): void;
|
||||
|
||||
extractCommon(
|
||||
basePath: BestPath,
|
||||
newString: string,
|
||||
oldString: string,
|
||||
diagonalPath: number
|
||||
): number;
|
||||
|
||||
equals(left: any, right: any): boolean;
|
||||
|
||||
removeEmpty(array: any[]): any[];
|
||||
|
||||
castInput(value: any): any;
|
||||
|
||||
join(chars: string[]): string;
|
||||
|
||||
tokenize(value: string): any; // return types are string or string[]
|
||||
}
|
||||
|
||||
/**
|
||||
* Diffs two blocks of text, comparing character by character.
|
||||
*
|
||||
* @returns A list of change objects.
|
||||
*/
|
||||
export function diffChars(oldStr: string, newStr: string, options?: BaseOptions): Change[];
|
||||
export function diffChars(
|
||||
oldStr: string,
|
||||
newStr: string,
|
||||
options: Callback | (BaseOptions & CallbackOptions)
|
||||
): void;
|
||||
|
||||
/**
|
||||
* Diffs two blocks of text, comparing word by word, ignoring whitespace.
|
||||
*
|
||||
* @returns A list of change objects.
|
||||
*/
|
||||
export function diffWords(oldStr: string, newStr: string, options?: WordsOptions): Change[];
|
||||
export function diffWords(
|
||||
oldStr: string,
|
||||
newStr: string,
|
||||
options: Callback | (WordsOptions & CallbackOptions)
|
||||
): void;
|
||||
|
||||
/**
|
||||
* Diffs two blocks of text, comparing word by word, treating whitespace as significant.
|
||||
*
|
||||
* @returns A list of change objects.
|
||||
*/
|
||||
export function diffWordsWithSpace(
|
||||
oldStr: string,
|
||||
newStr: string,
|
||||
options?: WordsOptions
|
||||
): Change[];
|
||||
export function diffWordsWithSpace(
|
||||
oldStr: string,
|
||||
newStr: string,
|
||||
options: Callback | (WordsOptions & CallbackOptions)
|
||||
): void;
|
||||
|
||||
/**
|
||||
* Diffs two blocks of text, comparing line by line.
|
||||
*
|
||||
* @returns A list of change objects.
|
||||
*/
|
||||
export function diffLines(oldStr: string, newStr: string, options?: LinesOptions): Change[];
|
||||
export function diffLines(
|
||||
oldStr: string,
|
||||
newStr: string,
|
||||
options: Callback | (LinesOptions & CallbackOptions)
|
||||
): void;
|
||||
|
||||
/**
|
||||
* Diffs two blocks of text, comparing line by line, ignoring leading and trailing whitespace.
|
||||
*
|
||||
* @returns A list of change objects.
|
||||
*/
|
||||
export function diffTrimmedLines(oldStr: string, newStr: string, options?: LinesOptions): Change[];
|
||||
export function diffTrimmedLines(
|
||||
oldStr: string,
|
||||
newStr: string,
|
||||
options: Callback | (LinesOptions & CallbackOptions)
|
||||
): void;
|
||||
|
||||
/**
|
||||
* Diffs two blocks of text, comparing sentence by sentence.
|
||||
*
|
||||
* @returns A list of change objects.
|
||||
*/
|
||||
export function diffSentences(oldStr: string, newStr: string, options?: BaseOptions): Change[];
|
||||
export function diffSentences(
|
||||
oldStr: string,
|
||||
newStr: string,
|
||||
options: Callback | (BaseOptions & CallbackOptions)
|
||||
): void;
|
||||
|
||||
/**
|
||||
* Diffs two blocks of text, comparing CSS tokens.
|
||||
*
|
||||
* @returns A list of change objects.
|
||||
*/
|
||||
export function diffCss(oldStr: string, newStr: string, options?: BaseOptions): Change[];
|
||||
export function diffCss(
|
||||
oldStr: string,
|
||||
newStr: string,
|
||||
options: Callback | (BaseOptions & CallbackOptions)
|
||||
): void;
|
||||
|
||||
/**
|
||||
* Diffs two JSON objects, comparing the fields defined on each. The order of fields, etc does not matter
|
||||
* in this comparison.
|
||||
*
|
||||
* @returns A list of change objects.
|
||||
*/
|
||||
export function diffJson(
|
||||
oldObj: string | object,
|
||||
newObj: string | object,
|
||||
options?: JsonOptions
|
||||
): Change[];
|
||||
export function diffJson(
|
||||
oldObj: string | object,
|
||||
newObj: string | object,
|
||||
options: Callback | (JsonOptions & CallbackOptions)
|
||||
): void;
|
||||
|
||||
/**
|
||||
* Diffs two arrays, comparing each item for strict equality (`===`).
|
||||
*
|
||||
* @returns A list of change objects.
|
||||
*/
|
||||
export function diffArrays<TOld, TNew>(
|
||||
oldArr: TOld[],
|
||||
newArr: TNew[],
|
||||
options?: ArrayOptions<TOld, TNew>
|
||||
): Array<ArrayChange<TOld | TNew>>;
|
||||
|
||||
/**
|
||||
* Creates a unified diff patch.
|
||||
*
|
||||
* @param oldFileName String to be output in the filename section of the patch for the removals.
|
||||
* @param newFileName String to be output in the filename section of the patch for the additions.
|
||||
* @param oldStr Original string value.
|
||||
* @param newStr New string value.
|
||||
* @param oldHeader Additional information to include in the old file header.
|
||||
* @param newHeader Additional information to include in the new file header.
|
||||
*/
|
||||
export function createTwoFilesPatch(
|
||||
oldFileName: string,
|
||||
newFileName: string,
|
||||
oldStr: string,
|
||||
newStr: string,
|
||||
oldHeader?: string,
|
||||
newHeader?: string,
|
||||
options?: PatchOptions
|
||||
): string;
|
||||
|
||||
/**
|
||||
* Creates a unified diff patch.
|
||||
* Just like `createTwoFilesPatch()`, but with `oldFileName` being equal to `newFileName`.
|
||||
*
|
||||
* @param fileName String to be output in the filename section.
|
||||
* @param oldStr Original string value.
|
||||
* @param newStr New string value.
|
||||
* @param oldHeader Additional information to include in the old file header.
|
||||
* @param newHeader Additional information to include in the new file header.
|
||||
*/
|
||||
export function createPatch(
|
||||
fileName: string,
|
||||
oldStr: string,
|
||||
newStr: string,
|
||||
oldHeader?: string,
|
||||
newHeader?: string,
|
||||
options?: PatchOptions
|
||||
): string;
|
||||
|
||||
/**
|
||||
* This method is similar to `createTwoFilesPatch()`, but returns a data structure suitable for further processing.
|
||||
* Parameters are the same as `createTwoFilesPatch()`.
|
||||
*
|
||||
* @param oldFileName String to be output in the `oldFileName` hunk property.
|
||||
* @param newFileName String to be output in the `newFileName` hunk property.
|
||||
* @param oldStr Original string value.
|
||||
* @param newStr New string value.
|
||||
* @param oldHeader Additional information to include in the `oldHeader` hunk property.
|
||||
* @param newHeader Additional information to include in the `newHeader` hunk property.
|
||||
* @returns An object with an array of hunk objects.
|
||||
*/
|
||||
export function structuredPatch(
|
||||
oldFileName: string,
|
||||
newFileName: string,
|
||||
oldStr: string,
|
||||
newStr: string,
|
||||
oldHeader?: string,
|
||||
newHeader?: string,
|
||||
options?: PatchOptions
|
||||
): ParsedDiff;
|
||||
|
||||
/**
|
||||
* Applies a unified diff patch.
|
||||
*
|
||||
* @param patch May be a string diff or the output from the `parsePatch()` or `structuredPatch()` methods.
|
||||
* @returns A string containing new version of provided data.
|
||||
*/
|
||||
export function applyPatch(
|
||||
source: string,
|
||||
patch: string | ParsedDiff | [ParsedDiff],
|
||||
options?: ApplyPatchOptions
|
||||
): string;
|
||||
|
||||
/**
|
||||
* Applies one or more patches.
|
||||
* This method will iterate over the contents of the patch and apply to data provided through callbacks.
|
||||
*
|
||||
* The general flow for each patch index is:
|
||||
*
|
||||
* 1. `options.loadFile(index, callback)` is called. The caller should then load the contents of the file
|
||||
* and then pass that to the `callback(err, data)` callback. Passing an `err` will terminate further patch execution.
|
||||
* 2. `options.patched(index, content, callback)` is called once the patch has been applied. `content` will be
|
||||
* the return value from `applyPatch()`. When it's ready, the caller should call `callback(err)` callback.
|
||||
* Passing an `err` will terminate further patch execution.
|
||||
* 3. Once all patches have been applied or an error occurs, the `options.complete(err)` callback is made.
|
||||
*/
|
||||
export function applyPatches(patch: string | ParsedDiff[], options: ApplyPatchesOptions): void;
|
||||
|
||||
/**
|
||||
* Parses a patch into structured data.
|
||||
*
|
||||
* @returns A JSON object representation of the a patch, suitable for use with the `applyPatch()` method.
|
||||
*/
|
||||
export function parsePatch(diffStr: string, options?: { strict?: boolean }): ParsedDiff[];
|
||||
|
||||
/**
|
||||
* Converts a list of changes to a serialized XML format.
|
||||
*/
|
||||
export function convertChangesToXML(changes: Change[]): string;
|
||||
|
||||
/**
|
||||
* Converts a list of changes to [DMP](http://code.google.com/p/google-diff-match-patch/wiki/API) format.
|
||||
*/
|
||||
export function convertChangesToDMP(changes: Change[]): Array<[1 | 0 | -1, string]>;
|
||||
|
||||
export function merge(mine: string, theirs: string, base: string): ParsedDiff;
|
||||
|
||||
export function canonicalize(obj: any, stack: any[], replacementStack: any[]): any;
|
||||
|
||||
@@ -2,12 +2,11 @@
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
@@ -21,4 +20,4 @@
|
||||
"index.d.ts",
|
||||
"diff-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"interface-name": false,
|
||||
"export-just-namespace": false
|
||||
}
|
||||
}
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
import jsdiff = require('diff');
|
||||
const one = 'beep boop';
|
||||
const other = 'beep boob blah';
|
||||
|
||||
let diff = jsdiff.diffChars(one, other);
|
||||
printDiff(diff);
|
||||
|
||||
const diffArraysResult = jsdiff.diffArrays<string>(['a', 'b', 'c'], ['a', 'c', 'd']);
|
||||
diffArraysResult.forEach(result => {
|
||||
if (result.added) {
|
||||
console.log(`added ${result.value.length} line(s):`, ...result.value);
|
||||
} else if (result.removed) {
|
||||
console.log(`removed ${result.value.length} line(s):`, ...result.value);
|
||||
} else {
|
||||
console.log(`no changes`);
|
||||
}
|
||||
});
|
||||
|
||||
interface DiffObj {
|
||||
value: number;
|
||||
}
|
||||
const a: DiffObj = {value: 0};
|
||||
const b: DiffObj = {value: 1};
|
||||
const c: DiffObj = {value: 2};
|
||||
const d: DiffObj = {value: 3};
|
||||
const arrayOptions: jsdiff.IArrayOptions = {
|
||||
comparator: (left: DiffObj, right: DiffObj) => {
|
||||
return left.value === right.value;
|
||||
}
|
||||
};
|
||||
const diffResult = jsdiff.diffArrays([a, b, c], [a, b, d], arrayOptions);
|
||||
diffResult.forEach(result => {
|
||||
if (result.added) {
|
||||
console.log(`added ${result.value.length} line(s):`, ...result.value);
|
||||
} else if (result.removed) {
|
||||
console.log(`removed ${result.value.length} line(s):`, ...result.value);
|
||||
} else {
|
||||
console.log(`no changes`);
|
||||
}
|
||||
});
|
||||
|
||||
// --------------------------
|
||||
|
||||
class LineDiffWithoutWhitespace extends jsdiff.Diff {
|
||||
tokenize(value: string): any {
|
||||
return value.split(/^/m);
|
||||
}
|
||||
|
||||
equals(left: string, right: string): boolean {
|
||||
return left.trim() === right.trim();
|
||||
}
|
||||
}
|
||||
|
||||
const obj = new LineDiffWithoutWhitespace();
|
||||
diff = obj.diff(one, other);
|
||||
printDiff(diff);
|
||||
|
||||
function printDiff(diff: jsdiff.IDiffResult[]) {
|
||||
function addLineHeader(decorator: string, str: string | string[]) {
|
||||
return (typeof str === 'string' ? str.split("\n") : str).map((line, index, array) => {
|
||||
if (index === array.length - 1 && line === "") {
|
||||
return line;
|
||||
} else {
|
||||
return decorator + line;
|
||||
}
|
||||
}).join("\n");
|
||||
}
|
||||
|
||||
diff.forEach((part) => {
|
||||
if (part.added) {
|
||||
console.log(addLineHeader("+", part.value));
|
||||
} else if (part.removed) {
|
||||
console.log(addLineHeader("-", part.value));
|
||||
} else {
|
||||
console.log(addLineHeader(" ", part.value));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function verifyPatchMethods(oldStr: string, newStr: string, uniDiff: jsdiff.IUniDiff) {
|
||||
const verifyPatch = jsdiff.parsePatch(
|
||||
jsdiff.createTwoFilesPatch("oldFile.ts", "newFile.ts", oldStr, newStr,
|
||||
"old", "new", { context: 1 }));
|
||||
|
||||
if (JSON.stringify(verifyPatch[0], Object.keys(verifyPatch[0]).sort()) !== JSON.stringify(uniDiff, Object.keys(uniDiff).sort())) {
|
||||
console.error("Patch did not match uniDiff");
|
||||
}
|
||||
}
|
||||
function verifyApplyMethods(oldStr: string, newStr: string, uniDiff: jsdiff.IUniDiff) {
|
||||
const verifyApply = [
|
||||
jsdiff.applyPatch(oldStr, uniDiff),
|
||||
jsdiff.applyPatch(oldStr, [uniDiff])
|
||||
];
|
||||
jsdiff.applyPatches([uniDiff], {
|
||||
loadFile: (index: number, callback: (err: Error, data: string) => void) => {
|
||||
callback(undefined, one);
|
||||
},
|
||||
patched: (index: number, content: string) => {
|
||||
verifyApply.push(content);
|
||||
},
|
||||
complete: (err?: Error) => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
}
|
||||
|
||||
verifyApply.forEach(result => {
|
||||
if (result !== newStr) {
|
||||
console.error("Result did not match newStr");
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const uniDiffPatch = jsdiff.structuredPatch("oldFile.ts", "newFile.ts", one, other,
|
||||
"old", "new", { context: 1 });
|
||||
verifyPatchMethods(one, other, uniDiffPatch);
|
||||
|
||||
const uniDiffStr = jsdiff.createPatch("file.ts", one, other, "old", "new",
|
||||
{ context: 1 });
|
||||
const uniDiffApply = jsdiff.parsePatch(uniDiffStr)[0];
|
||||
verifyApplyMethods(one, other, uniDiffApply);
|
||||
Vendored
+121
@@ -0,0 +1,121 @@
|
||||
// Type definitions for diff 3.5
|
||||
// Project: https://github.com/kpdecker/jsdiff
|
||||
// Definitions by: vvakame <https://github.com/vvakame>
|
||||
// szdc <https://github.com/szdc>
|
||||
// moc-yuto <https://github.com/moc-yuto>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
export = JsDiff;
|
||||
export as namespace JsDiff;
|
||||
|
||||
declare namespace JsDiff {
|
||||
interface IOptions {
|
||||
ignoreCase: boolean;
|
||||
}
|
||||
|
||||
interface ILinesOptions extends IOptions {
|
||||
ignoreWhitespace?: boolean;
|
||||
newlineIsToken?: boolean;
|
||||
}
|
||||
|
||||
interface IArrayOptions {
|
||||
comparator?: (left: any, right: any) => boolean;
|
||||
}
|
||||
|
||||
interface IDiffResult {
|
||||
value: string;
|
||||
count?: number;
|
||||
added?: boolean;
|
||||
removed?: boolean;
|
||||
}
|
||||
|
||||
interface IDiffArraysResult<T> {
|
||||
value: T[];
|
||||
count?: number;
|
||||
added?: boolean;
|
||||
removed?: boolean;
|
||||
}
|
||||
|
||||
interface IBestPath {
|
||||
newPos: number;
|
||||
componenets: IDiffResult[];
|
||||
}
|
||||
|
||||
interface IHunk {
|
||||
oldStart: number;
|
||||
oldLines: number;
|
||||
newStart: number;
|
||||
newLines: number;
|
||||
lines: string[];
|
||||
}
|
||||
|
||||
interface IUniDiff {
|
||||
oldFileName: string;
|
||||
newFileName: string;
|
||||
oldHeader: string;
|
||||
newHeader: string;
|
||||
index: string;
|
||||
hunks: IHunk[];
|
||||
}
|
||||
|
||||
class Diff {
|
||||
diff(oldString: string, newString: string, options?: IOptions): IDiffResult[];
|
||||
|
||||
pushComponent(components: IDiffResult[], added: boolean, removed: boolean): void;
|
||||
|
||||
extractCommon(basePath: IBestPath, newString: string, oldString: string, diagonalPath: number): number;
|
||||
|
||||
equals(left: string, right: string): boolean;
|
||||
|
||||
removeEmpty(array: any[]): any[];
|
||||
|
||||
castInput(value: any): any;
|
||||
|
||||
join(chars: string[]): string;
|
||||
|
||||
tokenize(value: string): any; // return types are string or string[]
|
||||
}
|
||||
|
||||
function diffChars(oldStr: string, newStr: string, options?: IOptions): IDiffResult[];
|
||||
|
||||
function diffWords(oldStr: string, newStr: string, options?: IOptions): IDiffResult[];
|
||||
|
||||
function diffWordsWithSpace(oldStr: string, newStr: string, options?: IOptions): IDiffResult[];
|
||||
|
||||
function diffJson(oldObj: object, newObj: object, options?: IOptions): IDiffResult[];
|
||||
|
||||
function diffLines(oldStr: string, newStr: string, options?: ILinesOptions): IDiffResult[];
|
||||
|
||||
function diffCss(oldStr: string, newStr: string, options?: IOptions): IDiffResult[];
|
||||
|
||||
function diffTrimmedLines(oldStr: string, newStr: string, options?: ILinesOptions): IDiffResult[];
|
||||
|
||||
function diffSentences(oldStr: string, newStr: string, options?: IOptions): IDiffResult[];
|
||||
|
||||
function diffArrays<T>(oldArr: T[], newArr: T[], options?: IArrayOptions): Array<IDiffArraysResult<T>>;
|
||||
|
||||
function createPatch(fileName: string, oldStr: string, newStr: string, oldHeader: string, newHeader: string, options?: {context: number}): string;
|
||||
|
||||
function createTwoFilesPatch(oldFileName: string, newFileName: string, oldStr: string, newStr: string, oldHeader: string, newHeader: string, options?: {context: number}): string;
|
||||
|
||||
function structuredPatch(oldFileName: string, newFileName: string, oldStr: string, newStr: string, oldHeader: string, newHeader: string, options?: {context: number}): IUniDiff;
|
||||
|
||||
function applyPatch(oldStr: string, uniDiff: string | IUniDiff | IUniDiff[]): string;
|
||||
|
||||
function applyPatches(uniDiff: IUniDiff[], options: {
|
||||
loadFile(index: number, callback: (err: Error, data: string) => void): void,
|
||||
patched(index: number, content: string): void,
|
||||
complete(err?: Error): void
|
||||
}): void;
|
||||
|
||||
function parsePatch(diffStr: string, options?: {strict: boolean}): IUniDiff[];
|
||||
|
||||
function convertChangesToXML(changes: IDiffResult[]): string;
|
||||
|
||||
function convertChangesToDMP(changes: IDiffResult[]): Array<{0: number; 1: string; }>;
|
||||
|
||||
function merge(mine: string, theirs: string, base: string): IUniDiff;
|
||||
|
||||
function canonicalize(obj: any, stack: any[], replacementStack: any[]): any;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../../",
|
||||
"typeRoots": [
|
||||
"../../"
|
||||
],
|
||||
"paths": {
|
||||
"diff": [
|
||||
"diff/v3"
|
||||
]
|
||||
},
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"diff-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"interface-name": false,
|
||||
"export-just-namespace": false
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
import dlv from 'dlv';
|
||||
|
||||
const obj = {
|
||||
undef: undefined,
|
||||
zero: 0,
|
||||
one: 1,
|
||||
n: null,
|
||||
f: false,
|
||||
a: {
|
||||
two: 2,
|
||||
b: {
|
||||
three: 3,
|
||||
c: {
|
||||
four: 4
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Test without defaults
|
||||
dlv(obj, '');
|
||||
dlv(obj, 'one');
|
||||
dlv(obj, 'one.two');
|
||||
dlv(obj, 'a');
|
||||
dlv(obj, 'a.two');
|
||||
dlv(obj, 'a.b');
|
||||
dlv(obj, 'a.b.three');
|
||||
dlv(obj, 'a.b.c');
|
||||
dlv(obj, 'a.b.c.four');
|
||||
dlv(obj, 'n');
|
||||
dlv(obj, 'n.badkey');
|
||||
dlv(obj, 'f');
|
||||
dlv(obj, 'f.badkey');
|
||||
|
||||
// Test defaults
|
||||
dlv(obj, '', 'foo');
|
||||
dlv(obj, 'undef', 'foo');
|
||||
dlv(obj, 'n', null);
|
||||
dlv(obj, 'n.badkey', 'foo');
|
||||
dlv(obj, 'zero', 0);
|
||||
dlv(obj, 'a.badkey', 'foo');
|
||||
dlv(obj, 'a.badkey.anotherbadkey', 'foo');
|
||||
dlv(obj, 'f', false);
|
||||
dlv(obj, 'f.badkey', 'foo');
|
||||
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
// Type definitions for dlv 1.1
|
||||
// Project: https://github.com/developit/dlv#readme
|
||||
// Definitions by: Ryan Sonshine <https://github.com/ryansonshine>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
/**
|
||||
* Safely get a dot-notated path within a nested object, with ability to
|
||||
* return a default if the full key path does not exist or the value is
|
||||
* undefined
|
||||
*/
|
||||
export default function dlv(object: object, key: string | string[], defaultValue?: any): any;
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strictFunctionTypes": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"dlv-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -1,4 +1,4 @@
|
||||
import { dasherize, camelize, capitalize, classify, decamelize, htmlSafe, loc, underscore, w } from '@ember/string';
|
||||
import { dasherize, camelize, capitalize, classify, decamelize, htmlSafe, loc, underscore, w, isHTMLSafe } from '@ember/string';
|
||||
import { SafeString } from 'handlebars';
|
||||
|
||||
dasherize(); // $ExpectError
|
||||
@@ -36,3 +36,11 @@ loc("_Hello %@ %@", ["John", "Smith"]); // $ExpectType string
|
||||
const handlebarsSafeString: SafeString = htmlSafe('lorem ipsum...');
|
||||
htmlSafe('lorem ipsum...'); // $ExpectType SafeString
|
||||
const regularString: string = htmlSafe('lorem ipsum...'); // $ExpectError
|
||||
|
||||
function isSafeTest(a: string|Handlebars.SafeString) {
|
||||
if (isHTMLSafe(a)) {
|
||||
a = a.toString();
|
||||
}
|
||||
|
||||
camelize(a);
|
||||
}
|
||||
|
||||
Vendored
+2
-2
@@ -11,8 +11,8 @@ export function capitalize(str: string): string;
|
||||
export function classify(str: string): string;
|
||||
export function dasherize(str: string): string;
|
||||
export function decamelize(str: string): string;
|
||||
export function htmlSafe(str: string): Handlebars.SafeString;
|
||||
export function isHTMLSafe(str: string): boolean;
|
||||
export function htmlSafe(str: string): SafeString;
|
||||
export function isHTMLSafe(str: any): str is SafeString;
|
||||
export function loc(template: string, args?: string[]): string;
|
||||
export function underscore(str: string): string;
|
||||
export function w(str: string): string[];
|
||||
|
||||
Vendored
+1
-1
@@ -1,6 +1,6 @@
|
||||
// Type definitions for emoji-mart 2.8
|
||||
// Project: https://github.com/missive/emoji-mart
|
||||
// Definitions by: Jessica Franco <https://github.com/Kovensky>
|
||||
// Definitions by: Jessica Franco <https://github.com/Jessidhia>
|
||||
// Nick Winans <https://github.com/Nicell>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
@@ -35,6 +35,10 @@ interface MyComponentState {
|
||||
stateProperty: string;
|
||||
}
|
||||
|
||||
function toComponentType<T>(Component: ComponentClass<T> | StatelessComponent<T>): ComponentClass<T> | StatelessComponent<T> {
|
||||
return Component;
|
||||
}
|
||||
|
||||
class MyComponent extends Component<MyComponentProps, MyComponentState> {
|
||||
handleEcho(value: string) {
|
||||
return value;
|
||||
@@ -59,6 +63,8 @@ const MyStatelessComponent = (props: StatelessProps) => <span />;
|
||||
|
||||
const AnotherStatelessComponent = (props: AnotherStatelessProps) => <span />;
|
||||
|
||||
const ComponentType = toComponentType(MyComponent);
|
||||
|
||||
// Enzyme.configure
|
||||
function configureTest() {
|
||||
const configureAdapter: { adapter: EnzymeAdapter } = { adapter: {} };
|
||||
@@ -859,6 +865,14 @@ function ReactWrapperTest() {
|
||||
reactWrapper = new ReactWrapper<MyComponentProps, MyComponentState>(<MyComponent stringProp="1" numberProp={1} />, undefined, { attachTo: document.createElement('div') });
|
||||
reactWrapper = new ReactWrapper<MyComponentProps, MyComponentState>(<MyComponent stringProp="1" numberProp={1} />, reactWrapper, { attachTo: document.createElement('div') });
|
||||
}
|
||||
|
||||
function test_component_type() {
|
||||
const wrapper1 = shallow(<div><ComponentType stringProp={"S"} numberProp={1} /></div>);
|
||||
wrapper1.find<MyComponentProps>(ComponentType).props().stringProp; // $ExpectType string
|
||||
|
||||
const wrapper2 = mount(<div><ComponentType stringProp={"S"} numberProp={1} /></div>);
|
||||
wrapper2.find<MyComponentProps>(ComponentType).props().stringProp; // $ExpectType string
|
||||
}
|
||||
}
|
||||
|
||||
// CheerioWrapper
|
||||
|
||||
Vendored
+13
-11
@@ -27,7 +27,9 @@ export interface ComponentClass<Props> {
|
||||
new(props: Props, context?: any): Component<Props>;
|
||||
}
|
||||
|
||||
export type StatelessComponent<Props> = (props: Props, context?: any) => JSX.Element;
|
||||
export type StatelessComponent<Props> = (props: Props, context?: any) => JSX.Element | null;
|
||||
|
||||
export type ComponentType<Props> = ComponentClass<Props> | StatelessComponent<Props>;
|
||||
|
||||
/**
|
||||
* Many methods in Enzyme's API accept a selector as an argument. Selectors in Enzyme can fall into one of the
|
||||
@@ -372,8 +374,8 @@ export class ShallowWrapper<P = {}, S = {}, C = Component> {
|
||||
* Find every node in the render tree that matches the provided selector.
|
||||
* @param selector The selector to match.
|
||||
*/
|
||||
find<P2>(component: ComponentClass<P2>): ShallowWrapper<P2, any>;
|
||||
find<P2>(statelessComponent: StatelessComponent<P2>): ShallowWrapper<P2, never>;
|
||||
find<P2>(component: ComponentType<P2>): ShallowWrapper<P2, any>;
|
||||
find(props: EnzymePropSelector): ShallowWrapper<any, any>;
|
||||
find(selector: string): ShallowWrapper<HTMLAttributes, any>;
|
||||
|
||||
@@ -381,8 +383,8 @@ export class ShallowWrapper<P = {}, S = {}, C = Component> {
|
||||
* Removes nodes in the current wrapper that do not match the provided selector.
|
||||
* @param selector The selector to match.
|
||||
*/
|
||||
filter<P2>(component: ComponentClass<P2>): ShallowWrapper<P2, any>;
|
||||
filter<P2>(statelessComponent: StatelessComponent<P2>): ShallowWrapper<P2, never>;
|
||||
filter<P2>(component: ComponentType<P2>): ShallowWrapper<P2, any>;
|
||||
filter(props: EnzymePropSelector | string): ShallowWrapper<P, S>;
|
||||
|
||||
/**
|
||||
@@ -394,8 +396,8 @@ export class ShallowWrapper<P = {}, S = {}, C = Component> {
|
||||
* Returns a new wrapper with all of the children of the node(s) in the current wrapper. Optionally, a selector
|
||||
* can be provided and it will filter the children by this selector.
|
||||
*/
|
||||
children<P2>(component: ComponentClass<P2>): ShallowWrapper<P2, any>;
|
||||
children<P2>(statelessComponent: StatelessComponent<P2>): ShallowWrapper<P2, never>;
|
||||
children<P2>(component: ComponentType<P2>): ShallowWrapper<P2, any>;
|
||||
children(selector: string): ShallowWrapper<HTMLAttributes, any>;
|
||||
children(props?: EnzymePropSelector): ShallowWrapper<any, any>;
|
||||
|
||||
@@ -425,8 +427,8 @@ export class ShallowWrapper<P = {}, S = {}, C = Component> {
|
||||
*
|
||||
* Note: can only be called on a wrapper of a single node.
|
||||
*/
|
||||
parents<P2>(component: ComponentClass<P2>): ShallowWrapper<P2, any>;
|
||||
parents<P2>(statelessComponent: StatelessComponent<P2>): ShallowWrapper<P2, never>;
|
||||
parents<P2>(component: ComponentType<P2>): ShallowWrapper<P2, any>;
|
||||
parents(selector: string): ShallowWrapper<HTMLAttributes, any>;
|
||||
parents(props?: EnzymePropSelector): ShallowWrapper<any, any>;
|
||||
|
||||
@@ -436,8 +438,8 @@ export class ShallowWrapper<P = {}, S = {}, C = Component> {
|
||||
*
|
||||
* Note: can only be called on a wrapper of a single node.
|
||||
*/
|
||||
closest<P2>(component: ComponentClass<P2>): ShallowWrapper<P2, any>;
|
||||
closest<P2>(statelessComponent: StatelessComponent<P2>): ShallowWrapper<P2, never>;
|
||||
closest<P2>(component: ComponentType<P2>): ShallowWrapper<P2, any>;
|
||||
closest(props: EnzymePropSelector): ShallowWrapper<any, any>;
|
||||
closest(selector: string): ShallowWrapper<HTMLAttributes, any>;
|
||||
|
||||
@@ -487,8 +489,8 @@ export class ReactWrapper<P = {}, S = {}, C = Component> {
|
||||
* Find every node in the render tree that matches the provided selector.
|
||||
* @param selector The selector to match.
|
||||
*/
|
||||
find<P2>(component: ComponentClass<P2>): ReactWrapper<P2, any>;
|
||||
find<P2>(statelessComponent: StatelessComponent<P2>): ReactWrapper<P2, never>;
|
||||
find<P2>(component: ComponentType<P2>): ReactWrapper<P2, any>;
|
||||
find(props: EnzymePropSelector): ReactWrapper<any, any>;
|
||||
find(selector: string): ReactWrapper<HTMLAttributes, any>;
|
||||
|
||||
@@ -501,16 +503,16 @@ export class ReactWrapper<P = {}, S = {}, C = Component> {
|
||||
* Removes nodes in the current wrapper that do not match the provided selector.
|
||||
* @param selector The selector to match.
|
||||
*/
|
||||
filter<P2>(component: ComponentClass<P2>): ReactWrapper<P2, any>;
|
||||
filter<P2>(statelessComponent: StatelessComponent<P2>): ReactWrapper<P2, never>;
|
||||
filter<P2>(component: ComponentType<P2>): ReactWrapper<P2, any>;
|
||||
filter(props: EnzymePropSelector | string): ReactWrapper<P, S>;
|
||||
|
||||
/**
|
||||
* Returns a new wrapper with all of the children of the node(s) in the current wrapper. Optionally, a selector
|
||||
* can be provided and it will filter the children by this selector.
|
||||
*/
|
||||
children<P2>(component: ComponentClass<P2>): ReactWrapper<P2, any>;
|
||||
children<P2>(statelessComponent: StatelessComponent<P2>): ReactWrapper<P2, never>;
|
||||
children<P2>(component: ComponentType<P2>): ReactWrapper<P2, any>;
|
||||
children(selector: string): ReactWrapper<HTMLAttributes, any>;
|
||||
children(props?: EnzymePropSelector): ReactWrapper<any, any>;
|
||||
|
||||
@@ -526,8 +528,8 @@ export class ReactWrapper<P = {}, S = {}, C = Component> {
|
||||
*
|
||||
* Note: can only be called on a wrapper of a single node.
|
||||
*/
|
||||
parents<P2>(component: ComponentClass<P2>): ReactWrapper<P2, any>;
|
||||
parents<P2>(statelessComponent: StatelessComponent<P2>): ReactWrapper<P2, never>;
|
||||
parents<P2>(component: ComponentType<P2>): ReactWrapper<P2, any>;
|
||||
parents(selector: string): ReactWrapper<HTMLAttributes, any>;
|
||||
parents(props?: EnzymePropSelector): ReactWrapper<any, any>;
|
||||
|
||||
@@ -537,8 +539,8 @@ export class ReactWrapper<P = {}, S = {}, C = Component> {
|
||||
*
|
||||
* Note: can only be called on a wrapper of a single node.
|
||||
*/
|
||||
closest<P2>(component: ComponentClass<P2>): ReactWrapper<P2, any>;
|
||||
closest<P2>(statelessComponent: StatelessComponent<P2>): ReactWrapper<P2, never>;
|
||||
closest<P2>(component: ComponentType<P2>): ReactWrapper<P2, any>;
|
||||
closest(props: EnzymePropSelector): ReactWrapper<any, any>;
|
||||
closest(selector: string): ReactWrapper<HTMLAttributes, any>;
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
import expired = require('expired');
|
||||
|
||||
const headers = `
|
||||
Age: 0
|
||||
Cache-Control: public, max-age=300
|
||||
Content-Encoding: gzip
|
||||
Content-Type: application/json;charset=utf-8
|
||||
Date: Fri, 23 Dec 2016 05:50:31 GMT
|
||||
Last-Modified: Fri, 23 Dec 2016 05:23:23 GMT`;
|
||||
|
||||
expired(headers); // $ExpectType boolean
|
||||
expired.in(headers); // $ExpectType number
|
||||
expired.on(headers); // $ExpectType Date
|
||||
|
||||
const parsedHeaders = {
|
||||
age: '0',
|
||||
'cache-control': 'public, max-age=300',
|
||||
'content-encoding': 'gzip',
|
||||
'content-type': 'application/json;charset=utf-8',
|
||||
date: 'Fri, 23 Dec 2016 05:50:31 GMT',
|
||||
'last-modified': 'Fri, 23 Dec 2016 05:23:23 GMT',
|
||||
};
|
||||
|
||||
expired(parsedHeaders); // $ExpectType boolean
|
||||
|
||||
const date = new Date();
|
||||
|
||||
expired(headers, date); // $ExpectType boolean
|
||||
expired.in(headers, date); // $ExpectType number
|
||||
Vendored
+29
@@ -0,0 +1,29 @@
|
||||
// Type definitions for expired 1.3
|
||||
// Project: https://github.com/lukechilds/expired
|
||||
// Definitions by: BendingBender <https://github.com/BendingBender>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export = expired;
|
||||
|
||||
declare const expired: expired;
|
||||
|
||||
interface expired {
|
||||
/**
|
||||
* @returns A boolean relating to whether the resource has expired or not.
|
||||
* `true` means it's expired, `false` means it's fresh.
|
||||
*/
|
||||
(headers: expired.Headers, compareWith?: Date): boolean;
|
||||
/**
|
||||
* @returns The amount of milliseconds from the current date until the resource will expire.
|
||||
* If the resource has already expired it will return a negative integer.
|
||||
*/
|
||||
in(headers: expired.Headers, compareWith?: Date): number;
|
||||
/**
|
||||
* @returns A JavaScript `Date` object for the date the resource will expire.
|
||||
*/
|
||||
on(headers: expired.Headers): Date;
|
||||
}
|
||||
|
||||
declare namespace expired {
|
||||
type Headers = string | { [header: string]: string | string[] | undefined };
|
||||
}
|
||||
@@ -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",
|
||||
"expired-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+2
@@ -2451,6 +2451,8 @@ export interface SvgCommonProps {
|
||||
export interface SvgRectProps extends SvgCommonProps {
|
||||
width: number | string;
|
||||
height: number | string;
|
||||
rx?: number | string;
|
||||
ry?: number | string;
|
||||
}
|
||||
|
||||
export interface SvgCircleProps extends SvgCommonProps {
|
||||
|
||||
Vendored
+2
@@ -1949,6 +1949,8 @@ export interface SvgCommonProps {
|
||||
export interface SvgRectProps extends SvgCommonProps {
|
||||
width: number | string;
|
||||
height: number | string;
|
||||
rx?: number | string;
|
||||
ry?: number | string;
|
||||
}
|
||||
|
||||
export interface SvgCircleProps extends SvgCommonProps {
|
||||
|
||||
Vendored
+2
@@ -1978,6 +1978,8 @@ export interface SvgCommonProps {
|
||||
export interface SvgRectProps extends SvgCommonProps {
|
||||
width: number | string;
|
||||
height: number | string;
|
||||
rx?: number | string;
|
||||
ry?: number | string;
|
||||
}
|
||||
|
||||
export interface SvgCircleProps extends SvgCommonProps {
|
||||
|
||||
Vendored
+2
@@ -2006,6 +2006,8 @@ export interface SvgCommonProps {
|
||||
export interface SvgRectProps extends SvgCommonProps {
|
||||
width: number | string;
|
||||
height: number | string;
|
||||
rx?: number | string;
|
||||
ry?: number | string;
|
||||
}
|
||||
|
||||
export interface SvgCircleProps extends SvgCommonProps {
|
||||
|
||||
Vendored
+2
@@ -2083,6 +2083,8 @@ export interface SvgCommonProps {
|
||||
export interface SvgRectProps extends SvgCommonProps {
|
||||
width: number | string;
|
||||
height: number | string;
|
||||
rx?: number | string;
|
||||
ry?: number | string;
|
||||
}
|
||||
|
||||
export interface SvgCircleProps extends SvgCommonProps {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user