mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 22:30:01 +00:00
Merge branch 'master' of github.com:DefinitelyTyped/DefinitelyTyped into b_codert_fabric
This commit is contained in:
227
.github/CODEOWNERS
vendored
227
.github/CODEOWNERS
vendored
File diff suppressed because it is too large
Load Diff
@@ -332,5 +332,3 @@ Es más apropiado importar este módulo utilizando la sintaxis `import foo = req
|
||||
Este proyecto es licenciado bajo la licencia MIT.
|
||||
|
||||
Los derechos de autor de cada archivo de definición son respectivos de cada contribuidor listado al comienzo de cada archivo de definición.
|
||||
|
||||
[](https://github.com/igrigorik/ga-beacon)
|
||||
|
||||
@@ -334,5 +334,3 @@ NPM 패키지의 경우, `node -p 'require("foo")'` 가 원하는 값이라면 `
|
||||
이 프로젝트는 MIT license 가 적용되어 있습니다.
|
||||
|
||||
각 자료형 정의(Type definition) 파일들의 저작권은 각 기여자들에게 있으며, 기여자들은 해당 자료형 정의(Type definition) 파일들의 맨 위에 나열되어 있습니다.
|
||||
|
||||
[](https://github.com/igrigorik/ga-beacon)
|
||||
|
||||
@@ -169,7 +169,7 @@ When a package [bundles](http://www.typescriptlang.org/docs/handbook/declaration
|
||||
|
||||
You can remove it by running `npm run not-needed -- typingsPackageName asOfVersion sourceRepoURL [libraryName]`.
|
||||
- `typingsPackageName`: This is the name of the directory to delete.
|
||||
- `asOfVersion`: A stub will be published to `@types/foo` with this version. Should be higher than any currently published version.
|
||||
- `asOfVersion`: A stub will be published to `@types/foo` with this version. Should be higher than any currently published version, and should be a version of `foo` on npm.
|
||||
- `sourceRepoURL`: This should point to the repository that contains the typings.
|
||||
- `libraryName`: Name of npm package that replaces the Definitely Typed types. Usually this is identical to "typingsPackageName", in which case you can omit it.
|
||||
|
||||
@@ -452,5 +452,3 @@ GitHub doesn't [support](http://stackoverflow.com/questions/5646174/how-to-make-
|
||||
This project is licensed under the MIT license.
|
||||
|
||||
Copyrights on the definition files are respective of each contributor listed at the beginning of each definition file.
|
||||
|
||||
[](https://github.com/igrigorik/ga-beacon)
|
||||
|
||||
@@ -346,8 +346,6 @@ GitHub не [поддерживает](http://stackoverflow.com/questions/564617
|
||||
|
||||
Авторские права на файлы определений принадлежат каждому участнику, указанному в начале каждого файла определения.
|
||||
|
||||
[](https://github.com/igrigorik/ga-beacon)
|
||||
|
||||
[](https://typescript.visualstudio.com/TypeScript/_build/latest?definitionId=13) В среднем пакеты публикуются на npm менее чем за 10000 секунд?
|
||||
|
||||
[](https://typescript.visualstudio.com/TypeScript/_build/latest?definitionId=14) Был ли typescript-bot активным на DefinitelyTyped в последние два часа?
|
||||
|
||||
24
azure-pipelines.yml
Normal file
24
azure-pipelines.yml
Normal file
@@ -0,0 +1,24 @@
|
||||
# Starter pipeline
|
||||
# Start with a minimal pipeline that you can customize to build and deploy your code.
|
||||
# Add steps that build, run tests, deploy, and more:
|
||||
# https://aka.ms/yaml
|
||||
jobs:
|
||||
- job: npmRunTest
|
||||
pool:
|
||||
vmImage: 'Ubuntu 16.04'
|
||||
demands: npm
|
||||
|
||||
timeoutInMinutes: 360
|
||||
|
||||
steps:
|
||||
- task: Npm@1
|
||||
displayName: 'npm install'
|
||||
inputs:
|
||||
verbose: false
|
||||
|
||||
- script: 'git checkout -- . && npm run test'
|
||||
displayName: 'npm run test'
|
||||
|
||||
trigger:
|
||||
- master
|
||||
|
||||
@@ -570,6 +570,12 @@
|
||||
"sourceRepoURL": "https://github.com/eggjs/egg",
|
||||
"asOfVersion": "1.5.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "elastic-apm-node",
|
||||
"typingsPackageName": "elastic-apm-node",
|
||||
"sourceRepoURL": "https://github.com/elastic/apm-agent-nodejs",
|
||||
"asOfVersion": "2.7.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "electron",
|
||||
"typingsPackageName": "electron",
|
||||
@@ -786,6 +792,12 @@
|
||||
"sourceRepoURL": "https://github.com/manuelbieh/Geolib",
|
||||
"asOfVersion": "2.0.23"
|
||||
},
|
||||
{
|
||||
"libraryName": "get-port",
|
||||
"typingsPackageName": "get-port",
|
||||
"sourceRepoURL": "https://github.com/sindresorhus/get-port",
|
||||
"asOfVersion": "4.2.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "get-stream",
|
||||
"typingsPackageName": "get-stream",
|
||||
@@ -1410,6 +1422,12 @@
|
||||
"sourceRepoURL": "http://onsen.io",
|
||||
"asOfVersion": "2.0.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "opn",
|
||||
"typingsPackageName": "opn",
|
||||
"sourceRepoURL": "https://github.com/sindresorhus/opn",
|
||||
"asOfVersion": "5.5.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "ora",
|
||||
"typingsPackageName": "ora",
|
||||
@@ -2124,6 +2142,12 @@
|
||||
"sourceRepoURL": "https://servicestack.net/",
|
||||
"asOfVersion": "0.1.5"
|
||||
},
|
||||
{
|
||||
"libraryName": "@storybook/addon-notes",
|
||||
"typingsPackageName": "storybook__addon-notes",
|
||||
"sourceRepoURL": "https://github.com/storybooks/storybook",
|
||||
"asOfVersion": "5.0.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "striptags",
|
||||
"typingsPackageName": "striptags",
|
||||
|
||||
2
types/activestorage/index.d.ts
vendored
2
types/activestorage/index.d.ts
vendored
@@ -13,7 +13,7 @@ export class DirectUpload {
|
||||
file: File;
|
||||
url: string;
|
||||
|
||||
constructor(file: File, url: string, delegate: DirectUploadDelegate)
|
||||
constructor(file: File, url: string, delegate?: DirectUploadDelegate)
|
||||
|
||||
create(callback: (error: Error, blob: Blob) => void): void;
|
||||
}
|
||||
|
||||
@@ -104,12 +104,13 @@ AirbnbPropTypes.forbidExtraProps<ForbidShape>({
|
||||
// $ExpectType Requireable<number>
|
||||
AirbnbPropTypes.integer();
|
||||
|
||||
// $ExpectType Requireable<{}>
|
||||
AirbnbPropTypes.keysOf(PropTypes.number);
|
||||
// $ExpectType Requireable<{}>
|
||||
AirbnbPropTypes.keysOf(PropTypes.number, 'foo');
|
||||
// $ExpectType Requireable<{}>
|
||||
AirbnbPropTypes.keysOf(PropTypes.oneOf(['foo', 'bar']));
|
||||
const top = (<T>(x?: T): T => x!)();
|
||||
type Top = typeof top;
|
||||
declare function validateRequireableTop(x: React.Requireable<Top>): void;
|
||||
|
||||
validateRequireableTop(AirbnbPropTypes.keysOf(PropTypes.number));
|
||||
validateRequireableTop(AirbnbPropTypes.keysOf(PropTypes.number, 'foo'));
|
||||
validateRequireableTop(AirbnbPropTypes.keysOf(PropTypes.oneOf(['foo', 'bar'])));
|
||||
|
||||
// $ExpectType Requireable<number>
|
||||
AirbnbPropTypes.mutuallyExclusiveProps(PropTypes.number);
|
||||
@@ -137,8 +138,8 @@ AirbnbPropTypes.nonNegativeNumber();
|
||||
// $ExpectType Requireable<string>
|
||||
AirbnbPropTypes.numericString();
|
||||
|
||||
// $ExpectType Requireable<{}>
|
||||
AirbnbPropTypes.object();
|
||||
// $ExpectType Requireable<object>
|
||||
const props: PropTypes.Requireable<object> = AirbnbPropTypes.object();
|
||||
// $ExpectType Requireable<{ foo: string; }>
|
||||
AirbnbPropTypes.object<{ foo: string }>();
|
||||
|
||||
@@ -156,23 +157,17 @@ AirbnbPropTypes.requiredBy('foo', PropTypes.string);
|
||||
// $ExpectType Validator<number>
|
||||
AirbnbPropTypes.requiredBy('bar', PropTypes.number, 42).isRequired;
|
||||
|
||||
// $ExpectType Requireable<{}>
|
||||
AirbnbPropTypes.restrictedProp();
|
||||
// $ExpectType Requireable<{}>
|
||||
AirbnbPropTypes.restrictedProp(() => 'Error');
|
||||
// $ExpectType Requireable<{}>
|
||||
AirbnbPropTypes.restrictedProp(() => new Error('Error'));
|
||||
validateRequireableTop(AirbnbPropTypes.restrictedProp());
|
||||
validateRequireableTop(AirbnbPropTypes.restrictedProp(() => 'Error'));
|
||||
validateRequireableTop(AirbnbPropTypes.restrictedProp(() => new Error('Error')));
|
||||
|
||||
// $ExpectType Requireable<{}>
|
||||
AirbnbPropTypes.sequenceOf({ validator: PropTypes.number });
|
||||
// $ExpectType Requireable<{}>
|
||||
AirbnbPropTypes.sequenceOf({ validator: PropTypes.number }, { validator: PropTypes.string });
|
||||
// $ExpectType Requireable<{}>
|
||||
AirbnbPropTypes.sequenceOf(
|
||||
validateRequireableTop(AirbnbPropTypes.sequenceOf({ validator: PropTypes.number }));
|
||||
validateRequireableTop(AirbnbPropTypes.sequenceOf({ validator: PropTypes.number }, { validator: PropTypes.string }));
|
||||
validateRequireableTop(AirbnbPropTypes.sequenceOf(
|
||||
{ validator: PropTypes.number, min: 0, max: 10 },
|
||||
{ validator: PropTypes.string },
|
||||
{ validator: PropTypes.bool },
|
||||
);
|
||||
));
|
||||
|
||||
interface ShapeShape {
|
||||
foo: string;
|
||||
|
||||
43
types/airtable/airtable-tests.ts
Normal file
43
types/airtable/airtable-tests.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import * as Airtable from 'airtable';
|
||||
|
||||
interface Row extends Airtable.FieldSet {
|
||||
field1: string;
|
||||
attachments: Airtable.Attachment[];
|
||||
}
|
||||
|
||||
const airtable = new Airtable();
|
||||
|
||||
const base = airtable.base('app id');
|
||||
|
||||
const table = base('table name') as Airtable.Table<Row>;
|
||||
|
||||
async () => {
|
||||
const query = table.select();
|
||||
{
|
||||
const rows = await query.all();
|
||||
for (const row of rows) {
|
||||
row.id; // $ExpectType string
|
||||
row.fields.field1; // $ExpectType string
|
||||
for (const attachment of row.fields.attachments) {
|
||||
attachment.id; // $ExpectType string
|
||||
attachment.filename; // $ExpectType string
|
||||
attachment.size; // $ExpectType number
|
||||
attachment.type; // $ExpectType string
|
||||
attachment.url; // $ExpectType string
|
||||
if (attachment.thumbnails) {
|
||||
attachment.thumbnails.full.height; // $ExpectType number
|
||||
attachment.thumbnails.full.width; // $ExpectType number
|
||||
attachment.thumbnails.full.url; // $ExpectType string
|
||||
|
||||
attachment.thumbnails.large.height; // $ExpectType number
|
||||
attachment.thumbnails.large.width; // $ExpectType number
|
||||
attachment.thumbnails.large.url; // $ExpectType string
|
||||
|
||||
attachment.thumbnails.small.height; // $ExpectType number
|
||||
attachment.thumbnails.small.width; // $ExpectType number
|
||||
attachment.thumbnails.small.url; // $ExpectType string
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
62
types/airtable/index.d.ts
vendored
Normal file
62
types/airtable/index.d.ts
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
// Type definitions for airtable 0.5
|
||||
// Project: https://github.com/airtable/airtable.js
|
||||
// Definitions by: Brandon Valosek <https://github.com/bvalosek>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
export = Airtable;
|
||||
|
||||
declare global {
|
||||
class Airtable {
|
||||
base(appId: string): Airtable.Base;
|
||||
}
|
||||
|
||||
namespace Airtable {
|
||||
interface FieldSet {
|
||||
[ key: string ]: undefined | string | ReadonlyArray<Attachment>;
|
||||
}
|
||||
|
||||
interface Base {
|
||||
(tableName: string): Table<{}>;
|
||||
}
|
||||
|
||||
interface Table<TFields extends FieldSet> {
|
||||
select(opt?: SelectOptions): Query<TFields>;
|
||||
}
|
||||
|
||||
interface SelectOptions {
|
||||
view?: string;
|
||||
}
|
||||
|
||||
interface Query<TFields extends object> {
|
||||
all(): Promise<Response<TFields>>;
|
||||
firstPage(): Promise<Response<TFields>>;
|
||||
}
|
||||
|
||||
type Response<TFields> = ReadonlyArray<Row<TFields>>;
|
||||
|
||||
interface Row<TFields> {
|
||||
id: string;
|
||||
fields: TFields;
|
||||
}
|
||||
|
||||
interface Attachment {
|
||||
id: string;
|
||||
url: string;
|
||||
filename: string;
|
||||
size: number;
|
||||
type: string;
|
||||
thumbnails?: {
|
||||
small: Thumbnail;
|
||||
large: Thumbnail;
|
||||
full: Thumbnail;
|
||||
};
|
||||
}
|
||||
|
||||
interface Thumbnail {
|
||||
url: string;
|
||||
width: number;
|
||||
height: number;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,6 @@
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"get-port-tests.ts"
|
||||
"airtable-tests.ts"
|
||||
]
|
||||
}
|
||||
37
types/align-text/index.d.ts
vendored
Normal file
37
types/align-text/index.d.ts
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
// Type definitions for align-text 1.0
|
||||
// Project: https://github.com/jonschlinkert/align-text
|
||||
// Definitions by: Claas Ahlrichs <https://github.com/claasahl>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
interface TransformResult {
|
||||
/**
|
||||
* the amount of indentation to use. Default is 0 when an object is returned.
|
||||
*/
|
||||
indent: number;
|
||||
/**
|
||||
* the character to use for indentation. Default is '' (empty string) when an object is returned.
|
||||
*/
|
||||
character: string;
|
||||
/**
|
||||
* leading characters to use at the beginning of each line. '' (empty string) when an object is returned.
|
||||
*/
|
||||
prefix: string;
|
||||
}
|
||||
|
||||
interface Callback {
|
||||
/**
|
||||
* @param len the length of the "current" line
|
||||
* @param longest the length of the longest line
|
||||
* @param line the current line (string) being aligned
|
||||
* @param lines the array of all lines
|
||||
*/
|
||||
(len: number, longest: number, line: string, lines: string[]):
|
||||
| number
|
||||
| TransformResult;
|
||||
}
|
||||
|
||||
declare function align_text(text: string, fn?: number | Callback): string;
|
||||
declare function align_text(text: any[], fn?: number | Callback): string[];
|
||||
|
||||
export = align_text;
|
||||
6
types/align-text/test/array.ts
Normal file
6
types/align-text/test/array.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import align from "align-text";
|
||||
|
||||
const text = ["abc", true, 123456, { hello: "world" }];
|
||||
align(text, 4);
|
||||
|
||||
align(text);
|
||||
12
types/align-text/test/center-complex.ts
Normal file
12
types/align-text/test/center-complex.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import align from "align-text";
|
||||
|
||||
function centerAlign(len: number, longest: number) {
|
||||
return {
|
||||
character: "\t",
|
||||
indent: Math.floor((longest - len) / 2),
|
||||
prefix: "~ "
|
||||
};
|
||||
}
|
||||
|
||||
const text = ["abc", "abc", "abc"];
|
||||
align(text, centerAlign);
|
||||
8
types/align-text/test/center-simple.ts
Normal file
8
types/align-text/test/center-simple.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import align from "align-text";
|
||||
|
||||
function centerAlign(len: number, longest: number) {
|
||||
return Math.floor((longest - len) / 2);
|
||||
}
|
||||
|
||||
const text = ["abc", "abc", "abc"];
|
||||
align(text, centerAlign);
|
||||
8
types/align-text/test/simple.ts
Normal file
8
types/align-text/test/simple.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import align from "align-text";
|
||||
|
||||
const text = ["abc", "abc", "abc"];
|
||||
align(text, 4);
|
||||
|
||||
align("abc", 2);
|
||||
|
||||
align("abc");
|
||||
23
types/align-text/tsconfig.json
Normal file
23
types/align-text/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es6"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"allowSyntheticDefaultImports": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"test/simple.ts",
|
||||
"test/center-simple.ts",
|
||||
"test/center-complex.ts",
|
||||
"test/array.ts"
|
||||
]
|
||||
}
|
||||
1
types/align-text/tslint.json
Normal file
1
types/align-text/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
108
types/amap-js-api-autocomplete/amap-js-api-autocomplete-tests.ts
Normal file
108
types/amap-js-api-autocomplete/amap-js-api-autocomplete-tests.ts
Normal file
@@ -0,0 +1,108 @@
|
||||
declare const div: HTMLDivElement;
|
||||
|
||||
const input = document.createElement('input');
|
||||
// $ExpectType Autocomplete
|
||||
const autoComplete = new AMap.Autocomplete();
|
||||
// $ExpectType Autocomplete
|
||||
new AMap.Autocomplete({});
|
||||
// $ExpectType Autocomplete
|
||||
new AMap.Autocomplete({
|
||||
type: 'type',
|
||||
city: 'city',
|
||||
datatype: 'all',
|
||||
citylimit: true,
|
||||
input: 'input',
|
||||
output: 'output',
|
||||
outPutDirAuto: true
|
||||
});
|
||||
// $ExpectType Autocomplete
|
||||
new AMap.Autocomplete({
|
||||
type: 'type',
|
||||
city: 'city',
|
||||
datatype: 'all',
|
||||
citylimit: true,
|
||||
input,
|
||||
output: div,
|
||||
outPutDirAuto: true
|
||||
});
|
||||
|
||||
autoComplete.search('keyword', (status, result) => {
|
||||
const temp: 'error' | 'complete' | 'no_data' = status;
|
||||
if (typeof result !== 'string') {
|
||||
// $ExpectType number
|
||||
result.count;
|
||||
// $ExpectType string
|
||||
result.info;
|
||||
// $ExpectType Tip[]
|
||||
result.tips;
|
||||
{
|
||||
const tip = result.tips[0];
|
||||
// $ExpectType string
|
||||
tip.adcode;
|
||||
// $ExpectType string
|
||||
tip.address;
|
||||
// $ExpectType any[]
|
||||
tip.city;
|
||||
// $ExpectType string
|
||||
tip.district;
|
||||
// $ExpectType string
|
||||
tip.id;
|
||||
// $ExpectType LngLat
|
||||
tip.location;
|
||||
// $ExpectType string
|
||||
tip.name;
|
||||
// $ExpectType string
|
||||
tip.typecode;
|
||||
}
|
||||
} else {
|
||||
// $ExpectType string
|
||||
result;
|
||||
}
|
||||
});
|
||||
|
||||
// $ExpectType void
|
||||
autoComplete.setType();
|
||||
// $ExpectType void
|
||||
autoComplete.setType('type');
|
||||
|
||||
// $ExpectType void
|
||||
autoComplete.setCity();
|
||||
// $ExpectType void
|
||||
autoComplete.setCity('city');
|
||||
|
||||
// $ExpectType void
|
||||
autoComplete.setCityLimit(false);
|
||||
|
||||
autoComplete.on('complete', (event: AMap.Autocomplete.EventMap['complete']) => {
|
||||
// $ExpectType "complete"
|
||||
event.type;
|
||||
// $ExpectType string
|
||||
event.info;
|
||||
if ('tips' in event) {
|
||||
// $ExpectType number
|
||||
event.count;
|
||||
// $ExpectType Tip[]
|
||||
event.tips;
|
||||
}
|
||||
});
|
||||
|
||||
autoComplete.on('error', (event: AMap.Autocomplete.EventMap['error']) => {
|
||||
// $ExpectType "error"
|
||||
event.type;
|
||||
// $ExpectType string
|
||||
event.info;
|
||||
});
|
||||
|
||||
autoComplete.on('select', (event: AMap.Autocomplete.EventMap['select']) => {
|
||||
// $ExpectType "select"
|
||||
event.type;
|
||||
// $ExpectType Tip
|
||||
event.tip;
|
||||
});
|
||||
|
||||
autoComplete.on('choose', (event: AMap.Autocomplete.EventMap['choose']) => {
|
||||
// $ExpectType "choose"
|
||||
event.type;
|
||||
// $ExpectType Tip
|
||||
event.tip;
|
||||
});
|
||||
144
types/amap-js-api-autocomplete/index.d.ts
vendored
Normal file
144
types/amap-js-api-autocomplete/index.d.ts
vendored
Normal file
@@ -0,0 +1,144 @@
|
||||
// Type definitions for non-npm package amap-js-api-autocomplete 1.4
|
||||
// Project: https://lbs.amap.com/api/javascript-api/reference/search#m_AMap.Autocomplete
|
||||
// Definitions by: breeze9527 <https://github.com/breeze9527>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
/// <reference types="amap-js-api" />
|
||||
|
||||
declare namespace AMap {
|
||||
namespace Autocomplete {
|
||||
interface EventMap {
|
||||
complete: Event<'complete', SearchResult | { info: string }>;
|
||||
error: Event<'error', { info: string }>;
|
||||
select: Event<'select', { tip: Tip }>;
|
||||
choose: Event<'choose', { tip: Tip }>;
|
||||
}
|
||||
type DataType = 'all' | 'bus' | 'poi' | 'busline';
|
||||
interface Options {
|
||||
/**
|
||||
* 输入提示时限定POI类型,多个类型用“|”分隔
|
||||
*/
|
||||
type?: string;
|
||||
/**
|
||||
* 输入提示时限定城市
|
||||
*/
|
||||
city?: string;
|
||||
/**
|
||||
* 返回的数据类型
|
||||
*/
|
||||
datatype?: DataType;
|
||||
/**
|
||||
* 是否强制限制在设置的城市内搜索
|
||||
*/
|
||||
citylimit?: boolean;
|
||||
/**
|
||||
* 指定输入框
|
||||
*/
|
||||
input?: string | HTMLInputElement;
|
||||
/**
|
||||
* 指定输出面板
|
||||
*/
|
||||
output?: string | HTMLDivElement;
|
||||
/**
|
||||
* 是否在input位于页面较下方的时候自动将输入面板显示在input上方以避免被遮挡
|
||||
*/
|
||||
outPutDirAuto?: boolean;
|
||||
|
||||
// internal
|
||||
closeResultOnScroll?: boolean;
|
||||
lang?: Lang;
|
||||
}
|
||||
interface Tip {
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* 所属区域
|
||||
*/
|
||||
district: string;
|
||||
/**
|
||||
* 区域编码
|
||||
*/
|
||||
adcode: string;
|
||||
/**
|
||||
* 地址
|
||||
*/
|
||||
address: string;
|
||||
/**
|
||||
* 城市
|
||||
*/
|
||||
city: any[];
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* 坐标经纬度
|
||||
*/
|
||||
location: LngLat;
|
||||
/**
|
||||
* 类型编码
|
||||
*/
|
||||
typecode: string;
|
||||
}
|
||||
interface SearchResult {
|
||||
/**
|
||||
* 查询状态说明
|
||||
*/
|
||||
info: string;
|
||||
/**
|
||||
* 输入提示条数
|
||||
*/
|
||||
count: number;
|
||||
/**
|
||||
* 输入提示列表
|
||||
*/
|
||||
tips: Tip[];
|
||||
}
|
||||
type SearchStatus = 'complete' | 'error' | 'no_data';
|
||||
}
|
||||
class Autocomplete extends EventEmitter {
|
||||
/**
|
||||
* 输入提示,根据输入关键字提示匹配信息
|
||||
* @param options 选项
|
||||
*/
|
||||
constructor(options?: Autocomplete.Options);
|
||||
/**
|
||||
* 根据输入关键字提示匹配信息
|
||||
* @param keyword 关键字
|
||||
* @param callback 回调
|
||||
*/
|
||||
search(
|
||||
keyword: string,
|
||||
callback: (status: Autocomplete.SearchStatus, result: Autocomplete.SearchResult | string) => void
|
||||
): void;
|
||||
/**
|
||||
* 设置提示Poi类型,多个类型用“|”分隔
|
||||
* @param type Poi类型
|
||||
*/
|
||||
setType(type?: string): void;
|
||||
/**
|
||||
* 设置城市
|
||||
* @param city 城市
|
||||
*/
|
||||
setCity(city?: string): void;
|
||||
/**
|
||||
* 设置是否强制限制城市
|
||||
* @param cityLimit 是否强制限制城市
|
||||
*/
|
||||
setCityLimit(cityLimit: boolean): void;
|
||||
|
||||
// internal
|
||||
/**
|
||||
* 设置查询语言
|
||||
* @param lang 语言
|
||||
*/
|
||||
setLang(lang?: Lang): void;
|
||||
/**
|
||||
* 返回查询语言
|
||||
*/
|
||||
getLang(): Lang | undefined;
|
||||
}
|
||||
}
|
||||
24
types/amap-js-api-autocomplete/tsconfig.json
Normal file
24
types/amap-js-api-autocomplete/tsconfig.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noEmit": true,
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"amap-js-api-autocomplete-tests.ts"
|
||||
]
|
||||
}
|
||||
227
types/amap-js-api-geocoder/amap-js-api-geocoder-tests.ts
Normal file
227
types/amap-js-api-geocoder/amap-js-api-geocoder-tests.ts
Normal file
@@ -0,0 +1,227 @@
|
||||
declare const lnglat: AMap.LngLat;
|
||||
declare const lnglatTuple: [number, number];
|
||||
|
||||
// $ExpectType Geocoder
|
||||
new AMap.Geocoder();
|
||||
// $ExpectType Geocoder
|
||||
new AMap.Geocoder({});
|
||||
// $ExpectType Geocoder
|
||||
const geocoder = new AMap.Geocoder({
|
||||
city: 'city',
|
||||
radius: 10,
|
||||
lang: 'zh_cn',
|
||||
batch: true,
|
||||
extensions: 'all'
|
||||
});
|
||||
|
||||
// $ExpectType void
|
||||
geocoder.getLocation('address', (status, result) => {
|
||||
// $ExpectType SearchStatus
|
||||
status;
|
||||
if (typeof result !== 'string') {
|
||||
const geocode = result.geocodes[0];
|
||||
const addressComponent = geocode.addressComponent;
|
||||
// $ExpectType string
|
||||
result.info;
|
||||
// $ExpectType string
|
||||
result.resultNum;
|
||||
// $ExpectType string
|
||||
geocode.adcode;
|
||||
// $ExpectType string
|
||||
geocode.formattedAddress;
|
||||
// $ExpectType string
|
||||
geocode.level;
|
||||
// $ExpectType LngLat
|
||||
geocode.location;
|
||||
// $ExpectType string
|
||||
addressComponent.building;
|
||||
// $ExpectType string
|
||||
addressComponent.building;
|
||||
// $ExpectType string
|
||||
addressComponent.buildingType;
|
||||
// $ExpectType string
|
||||
addressComponent.city;
|
||||
// $ExpectType string
|
||||
addressComponent.citycode;
|
||||
// $ExpectType string
|
||||
addressComponent.district;
|
||||
// $ExpectType string
|
||||
addressComponent.neighborhood;
|
||||
// $ExpectType string
|
||||
addressComponent.neighborhoodType;
|
||||
// $ExpectType string
|
||||
addressComponent.province;
|
||||
// $ExpectType string
|
||||
addressComponent.street;
|
||||
// $ExpectType string
|
||||
addressComponent.streetNumber;
|
||||
// $ExpectType string
|
||||
addressComponent.township;
|
||||
} else {
|
||||
// $ExpectType string
|
||||
result;
|
||||
}
|
||||
});
|
||||
|
||||
// $ExpectType void
|
||||
geocoder.getLocation(['address', 'address'], () => { });
|
||||
|
||||
// $ExpectType void
|
||||
geocoder.setCity();
|
||||
// $ExpectType void
|
||||
geocoder.setCity('city');
|
||||
|
||||
// $ExpectType void
|
||||
geocoder.getAddress(lnglat, (status, result) => {
|
||||
// $ExpectType SearchStatus
|
||||
status;
|
||||
if (typeof result !== 'string') {
|
||||
// $ExpectType string
|
||||
result.info;
|
||||
|
||||
// $ExpectType ReGeocode
|
||||
const regeocode = result.regeocode;
|
||||
// $ExpectType ReGeocodeAddressComponent
|
||||
const addressComponent = regeocode.addressComponent;
|
||||
{
|
||||
// $ExpectType string
|
||||
addressComponent.adcode;
|
||||
// $ExpectType string
|
||||
addressComponent.building;
|
||||
// $ExpectType string
|
||||
addressComponent.buildingType;
|
||||
// $ExpectType BuildingArea[]
|
||||
addressComponent.businessAreas;
|
||||
{
|
||||
const businessArea = addressComponent.businessAreas[0];
|
||||
// $ExpectType string
|
||||
businessArea.id;
|
||||
// $ExpectType LngLat
|
||||
businessArea.location;
|
||||
// $ExpectType string
|
||||
businessArea.name;
|
||||
}
|
||||
// $ExpectType string
|
||||
addressComponent.city;
|
||||
// $ExpectType string
|
||||
addressComponent.citycode;
|
||||
// $ExpectType string
|
||||
addressComponent.district;
|
||||
// $ExpectType string
|
||||
addressComponent.neighborhood;
|
||||
// $ExpectType string
|
||||
addressComponent.neighborhoodType;
|
||||
// $ExpectType string
|
||||
addressComponent.province;
|
||||
// $ExpectType string
|
||||
addressComponent.street;
|
||||
// $ExpectType string
|
||||
addressComponent.streetNumber;
|
||||
// $ExpectType string
|
||||
addressComponent.township;
|
||||
}
|
||||
// $ExpectType Cross[]
|
||||
regeocode.crosses;
|
||||
{
|
||||
const cross = regeocode.crosses[0];
|
||||
// $ExpectType string
|
||||
cross.direction;
|
||||
// $ExpectType number
|
||||
cross.distance;
|
||||
// $ExpectType string
|
||||
cross.first_id;
|
||||
// $ExpectType string
|
||||
cross.first_name;
|
||||
// $ExpectType LngLat
|
||||
cross.location;
|
||||
// $ExpectType string
|
||||
cross.second_id;
|
||||
// $ExpectType string
|
||||
cross.second_name;
|
||||
}
|
||||
// $ExpectType string
|
||||
regeocode.formattedAddress;
|
||||
// $ExpectType ReGeocodePoi[]
|
||||
regeocode.pois;
|
||||
{
|
||||
const poi = regeocode.pois[0];
|
||||
// $ExpectType string
|
||||
poi.address;
|
||||
// $ExpectType string
|
||||
poi.businessArea;
|
||||
// $ExpectType string
|
||||
poi.direction;
|
||||
// $ExpectType number
|
||||
poi.distance;
|
||||
// $ExpectType string
|
||||
poi.id;
|
||||
// $ExpectType LngLat
|
||||
poi.location;
|
||||
// $ExpectType string
|
||||
poi.name;
|
||||
// $ExpectType string
|
||||
poi.tel;
|
||||
// $ExpectType string
|
||||
poi.type;
|
||||
}
|
||||
// $ExpectType Road[]
|
||||
regeocode.roads;
|
||||
{
|
||||
const road = regeocode.roads[0];
|
||||
// $ExpectType string
|
||||
road.direction;
|
||||
// $ExpectType number
|
||||
road.distance;
|
||||
// $ExpectType string
|
||||
road.id;
|
||||
// $ExpectType LngLat
|
||||
road.location;
|
||||
// $ExpectType string
|
||||
road.name;
|
||||
}
|
||||
} else {
|
||||
// $ExpectType string
|
||||
result;
|
||||
}
|
||||
});
|
||||
|
||||
// $ExpectType void
|
||||
geocoder.getAddress([lnglat, lnglat], (status, result) => {
|
||||
if (typeof result !== 'string') {
|
||||
// $ExpectType ReGeocode[]
|
||||
result.regeocodes;
|
||||
}
|
||||
});
|
||||
|
||||
geocoder.on('error', (event: AMap.Geocoder.EventMap['error']) => {
|
||||
// $ExpectType "error"
|
||||
event.type;
|
||||
// $ExpectType string
|
||||
event.info;
|
||||
});
|
||||
|
||||
geocoder.on('complete', (event: AMap.Geocoder.EventMap['complete']) => {
|
||||
// $ExpectType "complete"
|
||||
event.type;
|
||||
if ('info' in event) {
|
||||
// $ExpectType string
|
||||
event.info;
|
||||
}
|
||||
if ('geocodes' in event) {
|
||||
// $ExpectType string
|
||||
event.resultNum;
|
||||
}
|
||||
if ('regeocode' in event) {
|
||||
// $ExpectType ReGeocode
|
||||
event.regeocode;
|
||||
}
|
||||
if ('regeocodes' in event) {
|
||||
// $ExpectType ReGeocode[]
|
||||
event.regeocodes;
|
||||
}
|
||||
});
|
||||
|
||||
// $ExpectType void
|
||||
geocoder.getAddress(lnglatTuple, () => { });
|
||||
// $ExpectType void
|
||||
geocoder.getAddress([lnglatTuple, lnglatTuple], () => { });
|
||||
373
types/amap-js-api-geocoder/index.d.ts
vendored
Normal file
373
types/amap-js-api-geocoder/index.d.ts
vendored
Normal file
@@ -0,0 +1,373 @@
|
||||
// Type definitions for non-npm package amap-js-api-geocoder 1.4
|
||||
// Project: https://lbs.amap.com/api/javascript-api/reference/lnglat-to-address#m_AMap.Geocoder
|
||||
// Definitions by: breeze9527 <https://github.com/breeze9527>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
/// <reference types="amap-js-api" />
|
||||
|
||||
declare namespace AMap {
|
||||
namespace Geocoder {
|
||||
interface EventMap {
|
||||
complete: Event<'complete', GeocodeResult | {} | ReGeocodeResult | BatchReGeocodeResult>;
|
||||
error: Event<'error', { info: string }>;
|
||||
}
|
||||
interface Options {
|
||||
/**
|
||||
* 城市
|
||||
*/
|
||||
city?: string;
|
||||
/**
|
||||
* 中心点
|
||||
*/
|
||||
radius?: number;
|
||||
/**
|
||||
* 语言类型
|
||||
*/
|
||||
lang?: Lang;
|
||||
/**
|
||||
* 是否批量查询
|
||||
*/
|
||||
batch?: boolean;
|
||||
/**
|
||||
* 是否返回详细信息
|
||||
*/
|
||||
extensions?: 'base' | 'all';
|
||||
}
|
||||
interface BuildingArea {
|
||||
/**
|
||||
* 唯一标识
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* 中心点经纬度
|
||||
*/
|
||||
location: LngLat;
|
||||
}
|
||||
interface GeocodeAddressComponent {
|
||||
/**
|
||||
* 社区
|
||||
*/
|
||||
neighborhood: string;
|
||||
/**
|
||||
* 社区类型
|
||||
*/
|
||||
neighborhoodType: string;
|
||||
/**
|
||||
* 楼/大厦
|
||||
*/
|
||||
building: string;
|
||||
/**
|
||||
* 楼类型
|
||||
*/
|
||||
buildingType: string;
|
||||
/**
|
||||
* 省
|
||||
*/
|
||||
province: string;
|
||||
/**
|
||||
* 城市
|
||||
*/
|
||||
city: string;
|
||||
/**
|
||||
* 区
|
||||
*/
|
||||
district: string;
|
||||
/**
|
||||
* 乡镇
|
||||
*/
|
||||
township: string;
|
||||
/**
|
||||
* 城市编码
|
||||
*/
|
||||
citycode: string;
|
||||
/**
|
||||
* 街道
|
||||
*/
|
||||
street: string;
|
||||
/**
|
||||
* 门牌号
|
||||
*/
|
||||
streetNumber: string;
|
||||
}
|
||||
interface ReGeocodeAddressComponent {
|
||||
/**
|
||||
* 城市编码
|
||||
*/
|
||||
citycode: string;
|
||||
/**
|
||||
* 区域编码
|
||||
*/
|
||||
adcode: string;
|
||||
/**
|
||||
* 所属商圈信息
|
||||
*/
|
||||
businessAreas: BuildingArea[];
|
||||
/**
|
||||
* 社区
|
||||
*/
|
||||
neighborhoodType: string;
|
||||
/**
|
||||
* 社区类型
|
||||
*/
|
||||
neighborhood: string;
|
||||
/**
|
||||
* 楼/大厦
|
||||
*/
|
||||
building: string;
|
||||
/**
|
||||
* 楼类型
|
||||
*/
|
||||
buildingType: string;
|
||||
/**
|
||||
* 街道
|
||||
*/
|
||||
street: string;
|
||||
/**
|
||||
* 门牌号
|
||||
*/
|
||||
streetNumber: string;
|
||||
/**
|
||||
* 省
|
||||
*/
|
||||
province: string;
|
||||
/**
|
||||
* 城市
|
||||
*/
|
||||
city: string;
|
||||
/**
|
||||
* 区
|
||||
*/
|
||||
district: string;
|
||||
/**
|
||||
* 乡镇
|
||||
*/
|
||||
township: string;
|
||||
}
|
||||
interface Geocode {
|
||||
/**
|
||||
* 地址组成元素
|
||||
*/
|
||||
addressComponent: GeocodeAddressComponent;
|
||||
/**
|
||||
* 格式化地址
|
||||
*/
|
||||
formattedAddress: string;
|
||||
/**
|
||||
* 坐标
|
||||
*/
|
||||
location: LngLat;
|
||||
/**
|
||||
* 区域编码
|
||||
*/
|
||||
adcode: string;
|
||||
/**
|
||||
* 给定地址匹配级别
|
||||
*/
|
||||
level: string;
|
||||
}
|
||||
interface GeocodeResult {
|
||||
/**
|
||||
* 状态说明
|
||||
*/
|
||||
info: string;
|
||||
/**
|
||||
* 地理编码结果数目
|
||||
*/
|
||||
resultNum: string;
|
||||
/**
|
||||
* 地理编码结果
|
||||
*/
|
||||
geocodes: Geocode[];
|
||||
}
|
||||
interface Road {
|
||||
/**
|
||||
* 唯一标识
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* 道路离查询点最近距离
|
||||
*/
|
||||
distance: number;
|
||||
/**
|
||||
* 道路上离查询点最近的点坐标
|
||||
*/
|
||||
location: LngLat;
|
||||
/**
|
||||
* 与查询点的相对方位
|
||||
*/
|
||||
direction: string;
|
||||
}
|
||||
interface Cross {
|
||||
/**
|
||||
* 道路离查询点最近距离
|
||||
*/
|
||||
distance: number;
|
||||
/**
|
||||
* 与查询点的相对方位
|
||||
*/
|
||||
direction: string;
|
||||
/**
|
||||
* 经纬度
|
||||
*/
|
||||
location: LngLat;
|
||||
/**
|
||||
* 第一条道路id
|
||||
*/
|
||||
first_id: string;
|
||||
/**
|
||||
* 第一条道路名称
|
||||
*/
|
||||
first_name: string;
|
||||
/**
|
||||
* 第二条道路id
|
||||
*/
|
||||
second_id: string;
|
||||
/**
|
||||
* 第二条道路名称
|
||||
*/
|
||||
second_name: string;
|
||||
}
|
||||
interface ReGeocodePoi {
|
||||
/**
|
||||
* 唯一标识
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
type: string;
|
||||
/**
|
||||
* 电话
|
||||
*/
|
||||
tel: string;
|
||||
/**
|
||||
* 该Poi到请求坐标的距离
|
||||
*/
|
||||
distance: number;
|
||||
/**
|
||||
* 该Poi相对于请求坐标的方向
|
||||
*/
|
||||
direction: string;
|
||||
/**
|
||||
* 址信息
|
||||
*/
|
||||
address: string;
|
||||
/**
|
||||
* 坐标
|
||||
*/
|
||||
location: LngLat;
|
||||
/**
|
||||
* 商圈名称
|
||||
*/
|
||||
businessArea: string;
|
||||
}
|
||||
interface ReGeocodeAoi {
|
||||
adcode: string;
|
||||
area: string;
|
||||
id: string;
|
||||
location: LngLat;
|
||||
name: string;
|
||||
type: string;
|
||||
}
|
||||
interface ReGeocode {
|
||||
/**
|
||||
* 地址组成元素
|
||||
*/
|
||||
addressComponent: ReGeocodeAddressComponent;
|
||||
/**
|
||||
* 格式化地址
|
||||
*/
|
||||
formattedAddress: string;
|
||||
/**
|
||||
* 道路信息列表
|
||||
*/
|
||||
roads: Road[];
|
||||
/**
|
||||
* 道路路口列表
|
||||
*/
|
||||
crosses: Cross[];
|
||||
/**
|
||||
* 兴趣点列表
|
||||
*/
|
||||
pois: ReGeocodePoi[];
|
||||
aois?: ReGeocodeAoi[];
|
||||
}
|
||||
interface ReGeocodeResult {
|
||||
/**
|
||||
* 状态说明
|
||||
*/
|
||||
info: string;
|
||||
/**
|
||||
* 逆地理编码结果
|
||||
*/
|
||||
regeocode: ReGeocode;
|
||||
}
|
||||
interface BatchReGeocodeResult {
|
||||
/**
|
||||
* 状态说明
|
||||
*/
|
||||
info: string;
|
||||
/**
|
||||
* 批量逆地理编码结果
|
||||
*/
|
||||
regeocodes: ReGeocode[];
|
||||
}
|
||||
type SearchStatus = 'complete' | 'no_data' | 'error';
|
||||
}
|
||||
class Geocoder extends EventEmitter {
|
||||
/**
|
||||
* 地理编码与逆地理编码
|
||||
* @param options 选项
|
||||
*/
|
||||
constructor(options?: Geocoder.Options);
|
||||
/**
|
||||
* 根据给定的地址描述进行解析
|
||||
* @param address 地址描述
|
||||
* @param callback 回调
|
||||
*/
|
||||
getLocation(
|
||||
address: string | string[],
|
||||
callback: (status: Geocoder.SearchStatus, result: Geocoder.GeocodeResult | string) => void
|
||||
): void;
|
||||
/**
|
||||
* 设置地址描述所在城市
|
||||
* @param city 城市
|
||||
*/
|
||||
setCity(city?: string): void;
|
||||
/**
|
||||
* 根据给定坐标进行解析
|
||||
* @param location 坐标
|
||||
* @param callback 回调
|
||||
*/
|
||||
getAddress(
|
||||
location: LocationValue,
|
||||
callback: (status: Geocoder.SearchStatus, result: Geocoder.ReGeocodeResult | string) => void
|
||||
): void;
|
||||
/**
|
||||
* 根据给定坐标进行解析
|
||||
* @param locations 坐标数组
|
||||
* @param callback 回调
|
||||
*/
|
||||
getAddress(
|
||||
locations: LocationValue[],
|
||||
callback: (status: Geocoder.SearchStatus, result: Geocoder.BatchReGeocodeResult | string) => void
|
||||
): void;
|
||||
|
||||
// internal
|
||||
setLang(lang?: Lang): void;
|
||||
getLang(): Lang | undefined;
|
||||
}
|
||||
}
|
||||
24
types/amap-js-api-geocoder/tsconfig.json
Normal file
24
types/amap-js-api-geocoder/tsconfig.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noEmit": true,
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"amap-js-api-geocoder-tests.ts"
|
||||
]
|
||||
}
|
||||
435
types/amap-js-api-place-search/amap-js-api-place-search-tests.ts
Normal file
435
types/amap-js-api-place-search/amap-js-api-place-search-tests.ts
Normal file
@@ -0,0 +1,435 @@
|
||||
declare const map: AMap.Map;
|
||||
declare const div: HTMLElement;
|
||||
declare const lnglat: AMap.LngLat;
|
||||
declare const lnglatTuple: [number, number];
|
||||
declare const bounds: AMap.Bounds;
|
||||
declare const polygon: AMap.Polygon;
|
||||
declare const lang: AMap.Lang;
|
||||
|
||||
// $ExpectType PlaceSearch
|
||||
const placeSearch = new AMap.PlaceSearch();
|
||||
// $ExpectType PlaceSearch
|
||||
new AMap.PlaceSearch({});
|
||||
// $ExpectType PlaceSearch
|
||||
new AMap.PlaceSearch({
|
||||
city: '深圳',
|
||||
citylimit: true,
|
||||
children: 1,
|
||||
type: '餐饮服务',
|
||||
lang: 'zh_cn',
|
||||
pageSize: 10,
|
||||
pageIndex: 10,
|
||||
extensions: 'all',
|
||||
map,
|
||||
panel: div,
|
||||
showCover: true,
|
||||
renderStyle: 'newpc',
|
||||
autoFitView: true
|
||||
});
|
||||
|
||||
// $ExpectType void
|
||||
placeSearch.search('keyword', (status, result) => {
|
||||
const temp: 'error' | 'complete' | 'no_data' = status;
|
||||
// $ExpectType string | SearchResult
|
||||
result;
|
||||
if (typeof result !== 'string') {
|
||||
// $ExpectType string
|
||||
result.info;
|
||||
// $ExpectType PoiList
|
||||
result.poiList;
|
||||
// $ExpectType string[] | undefined
|
||||
result.keywordList;
|
||||
// $ExpectType CityInfo[] | undefined
|
||||
result.cityList;
|
||||
|
||||
const poiList = result.poiList;
|
||||
// $ExpectType number
|
||||
poiList.pageIndex;
|
||||
// $ExpectType number
|
||||
poiList.pageSize;
|
||||
// $ExpectType number
|
||||
poiList.count;
|
||||
|
||||
const poi = poiList.pois[0];
|
||||
// $ExpectType string
|
||||
poi.address;
|
||||
// $ExpectType number
|
||||
poi.distance;
|
||||
// $ExpectType string
|
||||
poi.id;
|
||||
// $ExpectType LngLat | null
|
||||
poi.location;
|
||||
// $ExpectType string
|
||||
poi.name;
|
||||
// $ExpectType string
|
||||
poi.shopinfo;
|
||||
// $ExpectType string
|
||||
poi.tel;
|
||||
// $ExpectType string
|
||||
poi.type;
|
||||
if ('website' in poi) {
|
||||
// $ExpectType string
|
||||
poi.adcode;
|
||||
// $ExpectType string
|
||||
poi.adname;
|
||||
// $ExpectType string
|
||||
poi.citycode;
|
||||
// $ExpectType string
|
||||
poi.cityname;
|
||||
// $ExpectType boolean
|
||||
poi.discount;
|
||||
// $ExpectType string
|
||||
poi.email;
|
||||
// $ExpectType LngLat | null
|
||||
poi.entr_location;
|
||||
// $ExpectType LngLat | null
|
||||
poi.exit_location;
|
||||
// $ExpectType boolean
|
||||
poi.groupbuy;
|
||||
if (poi.indoor_map) {
|
||||
const indoorData = poi.indoor_data;
|
||||
// $ExpectType string
|
||||
indoorData.cpid;
|
||||
// $ExpectType string
|
||||
indoorData.floor;
|
||||
// $ExpectType string
|
||||
indoorData.truefloor;
|
||||
}
|
||||
poi.pcode;
|
||||
// $ExpectType PoiPhoto[]
|
||||
poi.photos;
|
||||
// $ExpectType string
|
||||
poi.pname;
|
||||
// $ExpectType string
|
||||
poi.postcode;
|
||||
// $ExpectType string
|
||||
poi.website;
|
||||
|
||||
const photo = poi.photos[0];
|
||||
// $ExpectType string
|
||||
photo.title;
|
||||
// $ExpectType string
|
||||
photo.url;
|
||||
// $ExpectType Groupbuy[] | undefined
|
||||
poi.groupbuys;
|
||||
if (poi.groupbuys) {
|
||||
const groupbuy = poi.groupbuys[0];
|
||||
// $ExpectType string
|
||||
groupbuy.title;
|
||||
// $ExpectType string
|
||||
groupbuy.type_code;
|
||||
// $ExpectType string
|
||||
groupbuy.type;
|
||||
// $ExpectType string
|
||||
groupbuy.detail;
|
||||
// $ExpectType string
|
||||
groupbuy.stime;
|
||||
// $ExpectType string
|
||||
groupbuy.etime;
|
||||
// $ExpectType number
|
||||
groupbuy.count;
|
||||
// $ExpectType number
|
||||
groupbuy.sold_num;
|
||||
// $ExpectType number
|
||||
groupbuy.original_price;
|
||||
// $ExpectType number
|
||||
groupbuy.groupbuy_price;
|
||||
// $ExpectType number
|
||||
groupbuy.discount;
|
||||
// $ExpectType string
|
||||
groupbuy.ticket_address;
|
||||
// $ExpectType string
|
||||
groupbuy.ticket_tel;
|
||||
// $ExpectType PoiPhoto[]
|
||||
groupbuy.photos;
|
||||
// $ExpectType string
|
||||
groupbuy.url;
|
||||
// $ExpectType string
|
||||
groupbuy.provider;
|
||||
}
|
||||
// $ExpectType Discount[] | undefined
|
||||
poi.discounts;
|
||||
if (poi.discounts) {
|
||||
const discount = poi.discounts[0];
|
||||
// $ExpectType string
|
||||
discount.title;
|
||||
// $ExpectType string
|
||||
discount.detail;
|
||||
// $ExpectType string
|
||||
discount.start_time;
|
||||
// $ExpectType string
|
||||
discount.end_time;
|
||||
// $ExpectType number
|
||||
discount.sold_num;
|
||||
// $ExpectType PoiPhoto[]
|
||||
discount.photos;
|
||||
// $ExpectType string
|
||||
discount.url;
|
||||
// $ExpectType string
|
||||
discount.provider;
|
||||
}
|
||||
if (poi.deep_type === 'CINEMA') {
|
||||
// $ExpectType Cinema
|
||||
const cinema = poi.cinema;
|
||||
// $ExpectType string
|
||||
cinema.intro;
|
||||
// $ExpectType string
|
||||
cinema.rating;
|
||||
// $ExpectType string
|
||||
cinema.deep_src;
|
||||
// $ExpectType string
|
||||
cinema.parking;
|
||||
// $ExpectType string
|
||||
cinema.opentime_GDF;
|
||||
// $ExpectType string
|
||||
cinema.opentime;
|
||||
// $ExpectType PoiPhoto[]
|
||||
cinema.photos;
|
||||
}
|
||||
if (poi.deep_type === 'DINING') {
|
||||
// $ExpectType Dining
|
||||
const dining = poi.dining;
|
||||
// $ExpectType string
|
||||
dining.cuisines;
|
||||
// $ExpectType string
|
||||
dining.tag;
|
||||
// $ExpectType string
|
||||
dining.intro;
|
||||
// $ExpectType string
|
||||
dining.rating;
|
||||
// $ExpectType string
|
||||
dining.cp_rating;
|
||||
// $ExpectType string
|
||||
dining.deep_src;
|
||||
// $ExpectType string
|
||||
dining.taste_rating;
|
||||
// $ExpectType string
|
||||
dining.environment_rating;
|
||||
// $ExpectType string
|
||||
dining.service_rating;
|
||||
// $ExpectType string
|
||||
dining.cost;
|
||||
// $ExpectType string
|
||||
dining.recommend;
|
||||
// $ExpectType string
|
||||
dining.atmosphere;
|
||||
// $ExpectType string
|
||||
dining.ordering_wap_url;
|
||||
// $ExpectType string
|
||||
dining.ordering_web_url;
|
||||
// $ExpectType string
|
||||
dining.ordering_app_url;
|
||||
// $ExpectType string
|
||||
dining.opentime_GDF;
|
||||
// $ExpectType string
|
||||
dining.opentime;
|
||||
// $ExpectType string
|
||||
dining.addition;
|
||||
// $ExpectType PoiPhoto[]
|
||||
dining.photos;
|
||||
}
|
||||
if (poi.deep_type === 'SCENIC') {
|
||||
// $ExpectType Scenic
|
||||
const scenic = poi.scenic;
|
||||
// $ExpectType string
|
||||
scenic.intro;
|
||||
// $ExpectType string
|
||||
scenic.rating;
|
||||
// $ExpectType string
|
||||
scenic.deep_src;
|
||||
// $ExpectType string
|
||||
scenic.level;
|
||||
// $ExpectType string
|
||||
scenic.price;
|
||||
// $ExpectType string
|
||||
scenic.season;
|
||||
// $ExpectType string
|
||||
scenic.recommend;
|
||||
// $ExpectType string
|
||||
scenic.theme;
|
||||
// $ExpectType string
|
||||
scenic.ordering_wap_url;
|
||||
// $ExpectType string
|
||||
scenic.ordering_web_url;
|
||||
// $ExpectType string
|
||||
scenic.opentime_GDF;
|
||||
// $ExpectType string
|
||||
scenic.opentime;
|
||||
// $ExpectType PoiPhoto[]
|
||||
scenic.photos;
|
||||
}
|
||||
if (poi.deep_type === 'HOTEL') {
|
||||
// $ExpectType Hotel
|
||||
const hotel = poi.hotel;
|
||||
// $ExpectType string
|
||||
hotel.rating;
|
||||
// $ExpectType string
|
||||
hotel.star;
|
||||
// $ExpectType string
|
||||
hotel.intro;
|
||||
// $ExpectType string
|
||||
hotel.lowest_price;
|
||||
// $ExpectType string
|
||||
hotel.faci_rating;
|
||||
// $ExpectType string
|
||||
hotel.health_rating;
|
||||
// $ExpectType string
|
||||
hotel.environment_rating;
|
||||
// $ExpectType string
|
||||
hotel.service_rating;
|
||||
// $ExpectType string
|
||||
hotel.traffic;
|
||||
// $ExpectType string
|
||||
hotel.addition;
|
||||
// $ExpectType string
|
||||
hotel.deep_src;
|
||||
// $ExpectType PoiPhoto[]
|
||||
hotel.photos;
|
||||
}
|
||||
}
|
||||
|
||||
if (result.cityList) {
|
||||
const city = result.cityList[0];
|
||||
// $ExpectType string
|
||||
city.adcode;
|
||||
// $ExpectType string
|
||||
city.citycode;
|
||||
// $ExpectType number
|
||||
city.count;
|
||||
// $ExpectType string
|
||||
city.name;
|
||||
}
|
||||
} else {
|
||||
// $ExpectType string
|
||||
result;
|
||||
}
|
||||
});
|
||||
|
||||
// $ExpectType void
|
||||
placeSearch.searchNearBy('keyword', lnglat, 10, (status, result) => {
|
||||
const temp: 'error' | 'complete' | 'no_data' = status;
|
||||
// $ExpectType string | SearchResult
|
||||
result;
|
||||
});
|
||||
// $ExpectType void
|
||||
placeSearch.searchNearBy('keyword', lnglatTuple, 10, () => { });
|
||||
|
||||
// $ExpectType void
|
||||
placeSearch.searchInBounds('keyword', bounds, (status, result) => {
|
||||
const temp: 'error' | 'complete' | 'no_data' = status;
|
||||
// $ExpectType string | SearchResult
|
||||
result;
|
||||
});
|
||||
// $ExpectType void
|
||||
placeSearch.searchInBounds('keyword', polygon, () => { });
|
||||
|
||||
// $ExpectType void
|
||||
placeSearch.getDetails('id', (status, result) => {
|
||||
const temp: 'error' | 'complete' | 'no_data' = status;
|
||||
// $ExpectType string | SearchResult
|
||||
result;
|
||||
});
|
||||
|
||||
// $ExpectType void
|
||||
placeSearch.setType('type');
|
||||
// $ExpectType void
|
||||
placeSearch.setType();
|
||||
|
||||
// $ExpectType void
|
||||
placeSearch.setCityLimit(true);
|
||||
// $ExpectType void
|
||||
placeSearch.setCityLimit();
|
||||
|
||||
// $ExpectType void
|
||||
placeSearch.setPageIndex(1);
|
||||
// $ExpectType void
|
||||
placeSearch.setPageIndex();
|
||||
|
||||
// $ExpectType void
|
||||
placeSearch.setPageSize(1);
|
||||
// $ExpectType void
|
||||
placeSearch.setPageSize();
|
||||
|
||||
// $ExpectType void
|
||||
placeSearch.setCity('city');
|
||||
// $ExpectType void
|
||||
placeSearch.setCity();
|
||||
|
||||
// $ExpectType void
|
||||
placeSearch.setLang(lang);
|
||||
// $ExpectType void
|
||||
placeSearch.setLang();
|
||||
|
||||
// $ExpectType "zh_cn" | "en" | "zh_en" | undefined
|
||||
placeSearch.getLang();
|
||||
|
||||
// $ExpectType void
|
||||
placeSearch.clear();
|
||||
|
||||
// $ExpectType void
|
||||
placeSearch.poiOnAMAP({
|
||||
id: 'id',
|
||||
});
|
||||
// $ExpectType void
|
||||
placeSearch.poiOnAMAP({
|
||||
location: lnglat,
|
||||
id: 'id',
|
||||
name: 'name'
|
||||
});
|
||||
|
||||
// $ExpectType void
|
||||
placeSearch.detailOnAMAP({
|
||||
id: 'id',
|
||||
});
|
||||
// $ExpectType void
|
||||
placeSearch.detailOnAMAP({
|
||||
location: lnglat,
|
||||
id: 'id',
|
||||
name: 'name'
|
||||
});
|
||||
|
||||
// $ExpectType void
|
||||
placeSearch.open();
|
||||
|
||||
// $ExpectType void
|
||||
placeSearch.close();
|
||||
|
||||
placeSearch.on('complete', (event: AMap.PlaceSearch.EventMap['complete']) => {
|
||||
// $ExpectType "complete"
|
||||
event.type;
|
||||
// $ExpectType string
|
||||
event.info;
|
||||
// $ExpectType PoiList
|
||||
event.poiList;
|
||||
// $ExpectType string[] | undefined
|
||||
event.keywordList;
|
||||
// $ExpectType CityInfo[] | undefined
|
||||
event.cityList;
|
||||
});
|
||||
|
||||
placeSearch.on('listElementClick', (event: AMap.PlaceSearch.EventMap['listElementClick']) => {
|
||||
// $ExpectType MouseEvent
|
||||
event.event;
|
||||
// $ExpectType string
|
||||
event.id;
|
||||
// $ExpectType number
|
||||
event.index;
|
||||
// $ExpectType Marker<any>
|
||||
event.marker;
|
||||
// $ExpectType HTMLLIElement
|
||||
event.listElement;
|
||||
});
|
||||
|
||||
placeSearch.on('markerClick', (event: AMap.PlaceSearch.EventMap['markerClick']) => {
|
||||
const markerEvent = event.event;
|
||||
// $ExpectType Marker<any>
|
||||
markerEvent.target;
|
||||
// $ExpectType string
|
||||
event.id;
|
||||
// $ExpectType number
|
||||
event.index;
|
||||
// $ExpectType Marker<any>
|
||||
event.marker;
|
||||
// $ExpectType HTMLLIElement
|
||||
event.listElement;
|
||||
});
|
||||
737
types/amap-js-api-place-search/index.d.ts
vendored
Normal file
737
types/amap-js-api-place-search/index.d.ts
vendored
Normal file
@@ -0,0 +1,737 @@
|
||||
// Type definitions for non-npm package amap-js-api-place-search 1.4
|
||||
// Project: https://lbs.amap.com/api/javascript-api/reference/search#m_AMap.PlaceSearch
|
||||
// Definitions by: breeze9527 <https://github.com/breeze9527>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
/// <reference types="amap-js-api" />
|
||||
|
||||
declare namespace AMap {
|
||||
namespace PlaceSearch {
|
||||
interface EventMap {
|
||||
complete: Event<'complete', SearchResult>;
|
||||
error: Event<'error', { info: string }>;
|
||||
selectChanged: Event<'selectChanged', {
|
||||
selected: SelectChangeEventData | EventMap['markerClick'] | EventMap['listElementClick'];
|
||||
lastSelected: SelectChangeEventData | EventMap['markerClick'] | EventMap['listElementClick'] | null;
|
||||
}>;
|
||||
listElementClick: SelectChangeEvent<'listElementClick', MouseEvent>;
|
||||
markerClick: SelectChangeEvent<'markerClick', Marker.EventMap['click']>;
|
||||
// internal
|
||||
renderComplete: Event<'renderComplete', {
|
||||
result: SelectChangeEventData[];
|
||||
markers: Marker[];
|
||||
listElements: HTMLElement[];
|
||||
}>;
|
||||
infoWindowClick: Event<'infoWindowClick', SelectChangeEventData & {
|
||||
event: MouseEvent;
|
||||
infoWindow: InfoWindow;
|
||||
infoWindowContentDom: HTMLDivElement;
|
||||
}>;
|
||||
willClear: Event<'willClear', {
|
||||
id: string;
|
||||
index: number;
|
||||
data: Poi[];
|
||||
}>;
|
||||
markerDestoryed: Event<'markerDestoryed', SelectChangeEventData>; // typo in source code
|
||||
listElementDetroyed: Event<'listElementDetroyed', SelectChangeEventData>; // typo too
|
||||
}
|
||||
|
||||
interface SelectChangeEventData {
|
||||
/**
|
||||
* 当前选中的POI的ID
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* 索引
|
||||
*/
|
||||
index: number;
|
||||
/**
|
||||
* 当前选中的POI对应的在地图中的Marker对象
|
||||
*/
|
||||
marker: Marker;
|
||||
/**
|
||||
* 当前选中的POI在结果面板中对应的列表项
|
||||
*/
|
||||
listElement: HTMLLIElement;
|
||||
/**
|
||||
* 当前选中的POI的信息
|
||||
*/
|
||||
data: Poi[];
|
||||
}
|
||||
type SelectChangeEvent<N extends string, E> = Event<N, SelectChangeEventData & {
|
||||
event: E;
|
||||
}>;
|
||||
interface PoiPhoto {
|
||||
/**
|
||||
* 图片名称
|
||||
*/
|
||||
title: string;
|
||||
/**
|
||||
* 图片url
|
||||
*/
|
||||
url: string;
|
||||
}
|
||||
interface PoiBase {
|
||||
/**
|
||||
* 全局唯一ID
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* 兴趣点类型
|
||||
*/
|
||||
type: string;
|
||||
/**
|
||||
* 兴趣点经纬度
|
||||
*/
|
||||
location: LngLat | null;
|
||||
/**
|
||||
* 地址
|
||||
*/
|
||||
address: string;
|
||||
/**
|
||||
* 离中心点距离
|
||||
*/
|
||||
distance: number;
|
||||
/**
|
||||
* 电话
|
||||
*/
|
||||
tel: string;
|
||||
shopinfo: string;
|
||||
children?: any[]; // TODO Array<{location: LngLat | null}>
|
||||
}
|
||||
interface Groupbuy {
|
||||
/**
|
||||
* 团购标题
|
||||
*/
|
||||
title: string;
|
||||
/**
|
||||
* 团购分类代码
|
||||
*/
|
||||
type_code: string;
|
||||
/**
|
||||
* 团购分类
|
||||
*/
|
||||
type: string;
|
||||
/**
|
||||
* 团购详情
|
||||
*/
|
||||
detail: string;
|
||||
/**
|
||||
* 团购开始时间
|
||||
*/
|
||||
stime: string;
|
||||
/**
|
||||
* 团购结束时间
|
||||
*/
|
||||
etime: string;
|
||||
/**
|
||||
* 团购总量
|
||||
*/
|
||||
count: number;
|
||||
/**
|
||||
* 已卖出数量
|
||||
*/
|
||||
sold_num: number;
|
||||
/**
|
||||
* 原价
|
||||
*/
|
||||
original_price: number;
|
||||
/**
|
||||
* 折扣价
|
||||
*/
|
||||
groupbuy_price: number;
|
||||
/**
|
||||
* 折扣
|
||||
*/
|
||||
discount: number;
|
||||
/**
|
||||
* 取票地址
|
||||
*/
|
||||
ticket_address: string;
|
||||
/**
|
||||
* 取票电话
|
||||
*/
|
||||
ticket_tel: string;
|
||||
/**
|
||||
* 图片信息
|
||||
*/
|
||||
photos: PoiPhoto[];
|
||||
/**
|
||||
* 来源url
|
||||
*/
|
||||
url: string;
|
||||
/**
|
||||
* 来源标识
|
||||
*/
|
||||
provider: string;
|
||||
}
|
||||
interface Discount {
|
||||
/**
|
||||
* 优惠标题
|
||||
*/
|
||||
title: string;
|
||||
/**
|
||||
* 优惠详情
|
||||
*/
|
||||
detail: string;
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
start_time: string;
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
end_time: string;
|
||||
/**
|
||||
* 已卖出数量
|
||||
*/
|
||||
sold_num: number;
|
||||
/**
|
||||
* 图片信息列表
|
||||
*/
|
||||
photos: PoiPhoto[];
|
||||
/**
|
||||
* 来源url
|
||||
*/
|
||||
url: string;
|
||||
/**
|
||||
* 来源标识
|
||||
*/
|
||||
provider: string;
|
||||
}
|
||||
interface Cinema {
|
||||
/**
|
||||
* 简介
|
||||
*/
|
||||
intro: string;
|
||||
/**
|
||||
* 综合评分
|
||||
*/
|
||||
rating: string;
|
||||
/**
|
||||
* 信息来源
|
||||
*/
|
||||
deep_src: string;
|
||||
/**
|
||||
* 停车场设施
|
||||
*/
|
||||
parking: string;
|
||||
/**
|
||||
* 规范格式的营业时间
|
||||
*/
|
||||
opentime_GDF: string;
|
||||
/**
|
||||
* 非规范格式的营业时间
|
||||
*/
|
||||
opentime: string;
|
||||
/**
|
||||
* 图片信息列表
|
||||
*/
|
||||
photos: PoiPhoto[];
|
||||
}
|
||||
interface Dining {
|
||||
/**
|
||||
* 菜系
|
||||
*/
|
||||
cuisines: string;
|
||||
/**
|
||||
* 标签
|
||||
*/
|
||||
tag: string;
|
||||
/**
|
||||
* 简介
|
||||
*/
|
||||
intro: string;
|
||||
/**
|
||||
* 综合评分
|
||||
*/
|
||||
rating: string;
|
||||
/**
|
||||
* 单数据源的评分
|
||||
*/
|
||||
cp_rating: string;
|
||||
/**
|
||||
* 信息来源
|
||||
*/
|
||||
deep_src: string;
|
||||
/**
|
||||
* 口味评分
|
||||
*/
|
||||
taste_rating: string;
|
||||
/**
|
||||
* 环境评分
|
||||
*/
|
||||
environment_rating: string;
|
||||
/**
|
||||
* 服务评分
|
||||
*/
|
||||
service_rating: string;
|
||||
/**
|
||||
* 人均消费
|
||||
*/
|
||||
cost: string;
|
||||
/**
|
||||
* 特色菜
|
||||
*/
|
||||
recommend: string;
|
||||
/**
|
||||
* 氛围
|
||||
*/
|
||||
atmosphere: string;
|
||||
/**
|
||||
* 订餐wap链接
|
||||
*/
|
||||
ordering_wap_url: string;
|
||||
/**
|
||||
* 订餐web链接
|
||||
*/
|
||||
ordering_web_url: string;
|
||||
/**
|
||||
* 订餐APP URL
|
||||
*/
|
||||
ordering_app_url: string;
|
||||
/**
|
||||
* 规范格式的营业时间
|
||||
*/
|
||||
opentime_GDF: string;
|
||||
/**
|
||||
* 非规范格式的营业时间
|
||||
*/
|
||||
opentime: string;
|
||||
/**
|
||||
* 餐厅特色
|
||||
*/
|
||||
addition: string;
|
||||
/**
|
||||
* 图片信息列表
|
||||
*/
|
||||
photos: PoiPhoto[];
|
||||
}
|
||||
interface Scenic {
|
||||
/**
|
||||
* 简介
|
||||
*/
|
||||
intro: string;
|
||||
/**
|
||||
* 综合评分
|
||||
*/
|
||||
rating: string;
|
||||
/**
|
||||
* 信息来源
|
||||
*/
|
||||
deep_src: string;
|
||||
/**
|
||||
* 景区国标级别
|
||||
*/
|
||||
level: string;
|
||||
/**
|
||||
* 门票价格
|
||||
*/
|
||||
price: string;
|
||||
/**
|
||||
* 适合游玩的季节
|
||||
*/
|
||||
season: string;
|
||||
/**
|
||||
* 推荐景点
|
||||
*/
|
||||
recommend: string;
|
||||
/**
|
||||
* 景区主题
|
||||
*/
|
||||
theme: string;
|
||||
/**
|
||||
* wap购票链接
|
||||
*/
|
||||
ordering_wap_url: string;
|
||||
/**
|
||||
* web购票链接
|
||||
*/
|
||||
ordering_web_url: string;
|
||||
/**
|
||||
* 规范格式的营业时间
|
||||
*/
|
||||
opentime_GDF: string;
|
||||
/**
|
||||
* 非规范格式的营业时间
|
||||
*/
|
||||
opentime: string;
|
||||
/**
|
||||
* 图片信息列表
|
||||
*/
|
||||
photos: PoiPhoto[];
|
||||
}
|
||||
interface Hotel {
|
||||
/**
|
||||
* 综合评分
|
||||
*/
|
||||
rating: string;
|
||||
/**
|
||||
* 星级
|
||||
*/
|
||||
star: string;
|
||||
/**
|
||||
* 简介
|
||||
*/
|
||||
intro: string;
|
||||
/**
|
||||
* 最低房价
|
||||
*/
|
||||
lowest_price: string;
|
||||
/**
|
||||
* 设施评分
|
||||
*/
|
||||
faci_rating: string;
|
||||
/**
|
||||
* 卫生评分
|
||||
*/
|
||||
health_rating: string;
|
||||
/**
|
||||
* 环境评分
|
||||
*/
|
||||
environment_rating: string;
|
||||
/**
|
||||
* 服务评分
|
||||
*/
|
||||
service_rating: string;
|
||||
/**
|
||||
* 交通提示
|
||||
*/
|
||||
traffic: string;
|
||||
/**
|
||||
* 特色服务
|
||||
*/
|
||||
addition: string;
|
||||
/**
|
||||
* 信息来源
|
||||
*/
|
||||
deep_src: string;
|
||||
/**
|
||||
* 图片信息列表
|
||||
*/
|
||||
photos: PoiPhoto[];
|
||||
}
|
||||
type PoiExt = PoiBase & {
|
||||
/**
|
||||
* 网址
|
||||
*/
|
||||
website: string;
|
||||
/**
|
||||
* 所在省份编码
|
||||
*/
|
||||
pcode: string;
|
||||
/**
|
||||
* 所在城市编码
|
||||
*/
|
||||
citycode: string;
|
||||
/**
|
||||
* 所在区域编码
|
||||
*/
|
||||
adcode: string;
|
||||
/**
|
||||
* 邮编
|
||||
*/
|
||||
postcode: string;
|
||||
/**
|
||||
* 所在省份
|
||||
*/
|
||||
pname: string;
|
||||
/**
|
||||
* 所在城市名称
|
||||
*/
|
||||
cityname: string;
|
||||
/**
|
||||
* 所在行政区名称
|
||||
*/
|
||||
adname: string;
|
||||
/**
|
||||
* 电子邮箱
|
||||
*/
|
||||
email: string;
|
||||
/**
|
||||
* 照片
|
||||
*/
|
||||
photos: PoiPhoto[];
|
||||
/**
|
||||
* 入口经纬度
|
||||
*/
|
||||
entr_location: LngLat | null;
|
||||
/**
|
||||
* 出口经纬度
|
||||
*/
|
||||
exit_location: LngLat | null;
|
||||
/**
|
||||
* @deprecated 是否有团购信息
|
||||
*/
|
||||
groupbuy: boolean;
|
||||
/**
|
||||
* @deprecated 是否有优惠信息
|
||||
*/
|
||||
discount: boolean;
|
||||
} & ({
|
||||
indoor_map: true;
|
||||
indoor_data: {
|
||||
cpid: string;
|
||||
floor: string;
|
||||
truefloor: string;
|
||||
};
|
||||
} | {
|
||||
indoor_map: false;
|
||||
}) & {
|
||||
/**
|
||||
* @deprecated 团购信息
|
||||
*/
|
||||
groupbuys?: Groupbuy[];
|
||||
/**
|
||||
* @deprecated 优惠信息
|
||||
*/
|
||||
discounts?: Discount[];
|
||||
} & ({
|
||||
deep_type: 'CINEMA';
|
||||
/**
|
||||
* @deprecated 影院类深度信息
|
||||
*/
|
||||
cinema: Cinema;
|
||||
} | {
|
||||
deep_type: 'DINING';
|
||||
/**
|
||||
* @deprecated 餐饮类深度信息
|
||||
*/
|
||||
dining: Dining;
|
||||
} | {
|
||||
deep_type: 'SCENIC';
|
||||
/**
|
||||
* @deprecated 景点类深度信息
|
||||
*/
|
||||
scenic: Scenic;
|
||||
} | {
|
||||
deep_type: 'HOTEL';
|
||||
/**
|
||||
* @deprecated 酒店类深度信息
|
||||
*/
|
||||
hotel: Hotel;
|
||||
});
|
||||
interface Options {
|
||||
/**
|
||||
* 兴趣点城市
|
||||
*/
|
||||
city?: string;
|
||||
/**
|
||||
* 是否强制限制在设置的城市内搜索
|
||||
*/
|
||||
citylimit?: boolean;
|
||||
/**
|
||||
* 是否按照层级展示子POI数据
|
||||
* children=1,展示子节点POI数据,children=0,不展示子节点数据
|
||||
*/
|
||||
children?: number;
|
||||
/**
|
||||
* 兴趣点类别,多个类别用“|”分割
|
||||
*/
|
||||
type?: string;
|
||||
/**
|
||||
* 检索语言类型
|
||||
*/
|
||||
lang?: Lang;
|
||||
/**
|
||||
* 单页显示结果条数
|
||||
*/
|
||||
pageSize?: number;
|
||||
/**
|
||||
* 页码
|
||||
*/
|
||||
pageIndex?: number;
|
||||
/**
|
||||
* 是否返回详细信息
|
||||
* base返回基本地址信息;all返回基本+详细信息
|
||||
*/
|
||||
extensions?: 'base' | 'all';
|
||||
/**
|
||||
* Map对象
|
||||
*/
|
||||
map?: Map;
|
||||
/**
|
||||
* 结果列表的HTML容器id或容器元素
|
||||
*/
|
||||
panel?: string | HTMLElement;
|
||||
/**
|
||||
* 是否在地图上显示周边搜索的圆或者范围搜索的多边形
|
||||
*/
|
||||
showCover?: boolean;
|
||||
/**
|
||||
* 绘制的UI风格
|
||||
*/
|
||||
renderStyle?: 'newpc' | 'default';
|
||||
/**
|
||||
* 是否自动调整地图视野使绘制的Marker点都处于视口的可见范围
|
||||
*/
|
||||
autoFitView?: boolean;
|
||||
|
||||
// internal
|
||||
renderEngine?: string;
|
||||
rankBy?: string;
|
||||
}
|
||||
interface PoiList {
|
||||
/**
|
||||
* Poi列表
|
||||
*/
|
||||
pois: Poi[]; // PlaceSearchPoiBase[] | PlaceSearchPoiExt[];
|
||||
/**
|
||||
* 页码
|
||||
*/
|
||||
pageIndex: number;
|
||||
/**
|
||||
* 单页结果数
|
||||
*/
|
||||
pageSize: number;
|
||||
/**
|
||||
* 查询结果总数
|
||||
*/
|
||||
count: number;
|
||||
}
|
||||
interface CityInfo {
|
||||
/**
|
||||
* 建议城市名称
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* 城市编码
|
||||
*/
|
||||
citycode: string;
|
||||
/**
|
||||
* 行政区编码
|
||||
*/
|
||||
adcode: string;
|
||||
/**
|
||||
* 该城市的建议结果数目
|
||||
*/
|
||||
count: number;
|
||||
}
|
||||
interface SearchResult {
|
||||
/**
|
||||
* 成功状态说明
|
||||
*/
|
||||
info: string;
|
||||
/**
|
||||
* 兴趣点列表
|
||||
*/
|
||||
poiList: PoiList;
|
||||
/**
|
||||
* 建议关键字列表
|
||||
*/
|
||||
keywordList?: string[];
|
||||
/**
|
||||
* 城市建议列表
|
||||
*/
|
||||
cityList?: CityInfo[];
|
||||
}
|
||||
type Poi = PoiBase | PoiExt;
|
||||
type SearchStatus = 'complete' | 'error' | 'no_data';
|
||||
}
|
||||
class PlaceSearch extends EventEmitter {
|
||||
/**
|
||||
* 地点搜索服务
|
||||
* @param options 选项
|
||||
*/
|
||||
constructor(options?: PlaceSearch.Options);
|
||||
/**
|
||||
* 根据关键字搜索
|
||||
* @param keyword 根据关键字搜索
|
||||
* @param callback 回调
|
||||
*/
|
||||
search(
|
||||
keyword: string,
|
||||
callback: (status: PlaceSearch.SearchStatus, result: string | PlaceSearch.SearchResult) => void
|
||||
): void;
|
||||
/**
|
||||
* 周边查询
|
||||
* @param keyword 关键字
|
||||
* @param center 搜索中心
|
||||
* @param radius 搜索半径
|
||||
* @param callback 回调
|
||||
*/
|
||||
searchNearBy(
|
||||
keyword: string,
|
||||
center: LocationValue,
|
||||
radius: number,
|
||||
callback: (status: PlaceSearch.SearchStatus, result: string | PlaceSearch.SearchResult) => void
|
||||
): void;
|
||||
/**
|
||||
* 根据范围和关键词进行范围查询
|
||||
* @param keyword 关键字
|
||||
* @param bounds 搜索范围
|
||||
* @param callback 回调
|
||||
*/
|
||||
searchInBounds(
|
||||
keyword: string,
|
||||
bounds: Bounds | Polygon,
|
||||
callback: (status: PlaceSearch.SearchStatus, result: string | PlaceSearch.SearchResult) => void
|
||||
): void;
|
||||
/**
|
||||
* 根据POIID 查询POI 详细信息
|
||||
* @param POIID POIID
|
||||
* @param callback 搜索回调
|
||||
*/
|
||||
getDetails(
|
||||
POIID: string,
|
||||
callback: (status: PlaceSearch.SearchStatus, result: string | PlaceSearch.SearchResult) => void
|
||||
): void;
|
||||
/**
|
||||
* 设置查询类别
|
||||
* @param type 查询类别
|
||||
*/
|
||||
setType(type?: string): void;
|
||||
/**
|
||||
* 设置是否强制限制城市
|
||||
* @param limit 是否强制限制城市
|
||||
*/
|
||||
setCityLimit(limit?: boolean): void;
|
||||
/**
|
||||
* 设置查询结果特定页数
|
||||
* @param pageIndex 页码
|
||||
*/
|
||||
setPageIndex(pageIndex?: number): void;
|
||||
/**
|
||||
* 设置查询单页结果数
|
||||
* @param pageSize 结果数
|
||||
*/
|
||||
setPageSize(pageSize?: number): void;
|
||||
/**
|
||||
* 设置查询城市
|
||||
* @param city 城市
|
||||
*/
|
||||
setCity(city?: string): void;
|
||||
/**
|
||||
* 设置检索语言类型
|
||||
* @param lang 语言类型
|
||||
*/
|
||||
setLang(lang?: Lang): void;
|
||||
/**
|
||||
* 获取检索语言类型
|
||||
*/
|
||||
getLang(): Lang | undefined;
|
||||
/**
|
||||
* 清除搜索结果
|
||||
*/
|
||||
clear(): void;
|
||||
/**
|
||||
* 唤起高德地图客户端marker页
|
||||
* @param obj 唤起参数
|
||||
*/
|
||||
poiOnAMAP(obj: { location?: LocationValue; id: string; name?: string; }): void;
|
||||
/**
|
||||
* 唤起高德地图客户端POI详情页
|
||||
* @param obj 唤起参数
|
||||
*/
|
||||
detailOnAMAP(obj: { location?: LocationValue; id: string; name?: string; }): void;
|
||||
|
||||
// internal
|
||||
open(): void;
|
||||
close(): void;
|
||||
}
|
||||
}
|
||||
24
types/amap-js-api-place-search/tsconfig.json
Normal file
24
types/amap-js-api-place-search/tsconfig.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noEmit": true,
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"amap-js-api-place-search-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -2415,6 +2415,7 @@ const testInfoWindow = new AMap.InfoWindow<InfoWindowExtraData>({
|
||||
closeWhenClickMap: false,
|
||||
content: 'content',
|
||||
size: [100, 100],
|
||||
anchor: 'bottom-center',
|
||||
offset: new AMap.Pixel(10, 10),
|
||||
position: lnglat,
|
||||
showShadow: true
|
||||
@@ -2449,6 +2450,20 @@ testInfoWindow.setPosition(lnglatTuple);
|
||||
// $ExpectType LngLat | undefined
|
||||
testInfoWindow.getPosition();
|
||||
|
||||
const testInfoWindowAnchor = testInfoWindow.getAnchor();
|
||||
if (testInfoWindowAnchor !== undefined) {
|
||||
// $ExpectType Anchor
|
||||
testInfoWindowAnchor;
|
||||
} else {
|
||||
// $ExpectType undefined
|
||||
testInfoWindowAnchor;
|
||||
}
|
||||
|
||||
// $ExpectType void
|
||||
testInfoWindow.setAnchor();
|
||||
// $ExpectType void
|
||||
testInfoWindow.setAnchor(testInfoWindowAnchor);
|
||||
|
||||
// $ExpectType Size | undefined
|
||||
testInfoWindow.getSize();
|
||||
|
||||
@@ -2491,6 +2506,7 @@ new AMap.Marker({});
|
||||
export const testMarker = new AMap.Marker<MarkerExtraData>({
|
||||
map,
|
||||
position: lnglat,
|
||||
anchor: 'bottom-center',
|
||||
offset: pixel,
|
||||
icon: 'iconUrl',
|
||||
content: 'htmlString',
|
||||
@@ -2526,6 +2542,20 @@ testMarker.markOnAMAP({
|
||||
name: '123'
|
||||
});
|
||||
|
||||
const testMarkerAnchor = testMarker.getAnchor();
|
||||
if (testMarkerAnchor) {
|
||||
// $ExpectType Anchor
|
||||
testMarkerAnchor;
|
||||
} else {
|
||||
// $ExpectType undefined
|
||||
testMarkerAnchor;
|
||||
}
|
||||
|
||||
// $ExpectType void
|
||||
testMarker.setAnchor(testMarkerAnchor);
|
||||
// $ExpectType void
|
||||
testMarker.setAnchor();
|
||||
|
||||
// $ExpectType Pixel
|
||||
testMarker.getOffset();
|
||||
|
||||
@@ -3229,6 +3259,7 @@ const testText = new AMap.Text<TextExtraData>({
|
||||
verticalAlign: 'top',
|
||||
map,
|
||||
position: lnglat,
|
||||
anchor: 'bottom-center',
|
||||
offset: pixel,
|
||||
topWhenClick: true,
|
||||
bubble: true,
|
||||
@@ -3246,6 +3277,20 @@ const testText = new AMap.Text<TextExtraData>({
|
||||
extData: { test: 1 }
|
||||
});
|
||||
|
||||
const testTextAnchor = testText.getAnchor();
|
||||
if (testTextAnchor) {
|
||||
// $ExpectType Anchor
|
||||
testTextAnchor;
|
||||
} else {
|
||||
// $ExpectType undefined
|
||||
testTextAnchor;
|
||||
}
|
||||
|
||||
// $ExpectType void
|
||||
testText.setAnchor(testTextAnchor);
|
||||
// $ExpectType void
|
||||
testText.setAnchor();
|
||||
|
||||
// $ExpectType string
|
||||
testText.getText();
|
||||
|
||||
@@ -3363,7 +3408,7 @@ testText.setShadow(icon);
|
||||
testText.setShadow('shadow url');
|
||||
|
||||
// $ExpectType void
|
||||
testText.setExtData({test: 1});
|
||||
testText.setExtData({ test: 1 });
|
||||
|
||||
// $ExpectType {} | TextExtraData
|
||||
testText.getExtData();
|
||||
|
||||
15
types/amap-js-api/overlay/infoWindow.d.ts
vendored
15
types/amap-js-api/overlay/infoWindow.d.ts
vendored
@@ -6,6 +6,8 @@ declare namespace AMap {
|
||||
close: Event<'close', { target: I }>;
|
||||
}
|
||||
|
||||
type Anchor = 'top-left' | 'top-center' | 'top-right' | 'middle-left' | 'center' | 'middle-right' | 'bottom-left' | 'bottom-center' | 'bottom-right';
|
||||
|
||||
interface Options<ExtraData = any> extends Overlay.Options<ExtraData> {
|
||||
/**
|
||||
* 是否自定义窗体
|
||||
@@ -27,6 +29,10 @@ declare namespace AMap {
|
||||
* 信息窗体尺寸
|
||||
*/
|
||||
size?: SizeValue;
|
||||
/**
|
||||
* 信息窗体锚点
|
||||
*/
|
||||
anchor?: Anchor;
|
||||
/**
|
||||
* 信息窗体显示位置偏移量
|
||||
*/
|
||||
@@ -82,6 +88,15 @@ declare namespace AMap {
|
||||
* 获取信息窗体显示基点位置
|
||||
*/
|
||||
getPosition(): LngLat | undefined;
|
||||
/**
|
||||
* 获取锚点
|
||||
*/
|
||||
getAnchor(): InfoWindow.Anchor | undefined;
|
||||
/**
|
||||
* 设置锚点
|
||||
* @param anchor 锚点
|
||||
*/
|
||||
setAnchor(anchor?: InfoWindow.Anchor): void;
|
||||
/**
|
||||
* 设置信息窗体大小
|
||||
* @param size 大小
|
||||
|
||||
14
types/amap-js-api/overlay/marker.d.ts
vendored
14
types/amap-js-api/overlay/marker.d.ts
vendored
@@ -25,11 +25,17 @@ declare namespace AMap {
|
||||
offset?: Pixel;
|
||||
}
|
||||
|
||||
type Anchor = 'top-left' | 'top-center' | 'top-right' | 'middle-left' | 'center' | 'middle-right' | 'bottom-left' | 'bottom-center' | 'bottom-right';
|
||||
|
||||
interface Options<ExtraData = any> extends Overlay.Options<ExtraData> {
|
||||
/**
|
||||
* 点标记在地图上显示的位置
|
||||
*/
|
||||
position?: LocationValue;
|
||||
/**
|
||||
* 标记锚点
|
||||
*/
|
||||
anchor?: Anchor;
|
||||
/**
|
||||
* 点标记显示位置偏移量
|
||||
*/
|
||||
@@ -117,6 +123,14 @@ declare namespace AMap {
|
||||
* @param obj 唤起参数
|
||||
*/
|
||||
markOnAMAP(obj?: { name?: string, position?: LocationValue }): void;
|
||||
/**
|
||||
* 获取锚点
|
||||
*/
|
||||
getAnchor(): Marker.Anchor | undefined;
|
||||
/**
|
||||
* 设置锚点
|
||||
*/
|
||||
setAnchor(anchor?: Marker.Anchor): void;
|
||||
/**
|
||||
* 获取偏移量
|
||||
*/
|
||||
|
||||
20
types/amap-js-api/type-util.d.ts
vendored
20
types/amap-js-api/type-util.d.ts
vendored
@@ -1,12 +1,12 @@
|
||||
type Omit<T, E extends keyof T> = {
|
||||
[K in Exclude<keyof T, E>]: T[K]
|
||||
};
|
||||
declare namespace AMap {
|
||||
type Omit<T, E extends keyof T> = {
|
||||
[K in Exclude<keyof T, E>]: T[K]
|
||||
};
|
||||
|
||||
type OptionalKey<T> = { [K in keyof T]-?: undefined extends T[K] ? K : never }[keyof T];
|
||||
// type OmitUndefined<M> = Omit<M, { [K in keyof M]: M[K] extends undefined ? K : never }[keyof M]>;
|
||||
// type PickUndefined<M> = Omit<M, keyof OmitUndefined<M>>;
|
||||
type OptionalKey<T> = { [K in keyof T]-?: undefined extends T[K] ? K : never }[keyof T];
|
||||
|
||||
type Merge<O, T> =
|
||||
{ [K in Exclude<keyof O, keyof T | OptionalKey<O>>]-?: O[K]; } &
|
||||
{ [K in Extract<Exclude<keyof O, keyof T>, OptionalKey<O>>]?: O[K]; } &
|
||||
T;
|
||||
type Merge<O, T> =
|
||||
{ [K in Exclude<keyof O, keyof T | OptionalKey<O>>]-?: O[K]; } &
|
||||
{ [K in Extract<Exclude<keyof O, keyof T>, OptionalKey<O>>]?: O[K]; } &
|
||||
T;
|
||||
}
|
||||
|
||||
@@ -419,3 +419,14 @@ myApp.controller('StickyController', ($scope: TestScope, $mdSticky: ng.material.
|
||||
$mdSticky($scope, stickyElement);
|
||||
$mdSticky($scope, stickyElement, cloneStickyElement);
|
||||
});
|
||||
|
||||
function mdUtil($mdUtil: ng.material.IUtilService) {
|
||||
// $ExpectType void
|
||||
$mdUtil.enableScrolling();
|
||||
|
||||
// $ExpectType () => void
|
||||
$mdUtil.debounce(() => {});
|
||||
|
||||
// $ExpectType () => string
|
||||
$mdUtil.debounce((): string => "");
|
||||
}
|
||||
|
||||
6
types/angular-material/index.d.ts
vendored
6
types/angular-material/index.d.ts
vendored
@@ -517,5 +517,11 @@ declare module 'angular' {
|
||||
getLastInteractionType(): string|null;
|
||||
isUserInvoked(checkDelay?: number): boolean;
|
||||
}
|
||||
|
||||
interface IUtilService {
|
||||
// tslint:disable-next-line:ban-types debounce takes in a user provided function
|
||||
debounce<T extends Function>(func: T, wait?: number, scope?: any, invokeApply?: boolean): T;
|
||||
enableScrolling(): void;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"npm-naming": false,
|
||||
"dt-header": false
|
||||
}
|
||||
}
|
||||
|
||||
12010
types/arcgis-js-api/index.d.ts
vendored
12010
types/arcgis-js-api/index.d.ts
vendored
File diff suppressed because it is too large
Load Diff
19
types/arcgis-js-api/v3/index.d.ts
vendored
19
types/arcgis-js-api/v3/index.d.ts
vendored
@@ -1,4 +1,4 @@
|
||||
// Type definitions for ArcGIS API for JavaScript 3.27
|
||||
// Type definitions for ArcGIS API for JavaScript 3.28
|
||||
// Project: https://developers.arcgis.com/javascript/3/
|
||||
// Definitions by: Esri <https://github.com/Esri>
|
||||
// Bjorn Svensson <https://github.com/bsvensson>
|
||||
@@ -3477,19 +3477,19 @@ declare module "esri/basemaps" {
|
||||
var basemaps: {
|
||||
/** The Light Gray Canvas basemap is designed to be used as a neutral background map for overlaying and emphasizing other map layers. */
|
||||
gray: any;
|
||||
/** The World Imagery map is a detailed imagery map layer and labels that is designed to be used as a basemap for various maps and applications. */
|
||||
/** The World Imagery with Labels map is a detailed imagery map layer and labels that is designed to be used as a basemap for various maps and applications: https://services.arcgisonline.com/ArcGIS/rest/services/Reference/World_Boundaries_and_Places/MapServer https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer */
|
||||
hybrid: any;
|
||||
/** The Ocean Basemap is designed to be used as a basemap by marine GIS professionals and as a reference map by anyone interested in ocean data. */
|
||||
oceans: any;
|
||||
/** The OpenStreetMap is a community map layer that is designed to be used as a basemap for various maps and applications. */
|
||||
osm: any;
|
||||
/** The World Imagery map is a detailed imagery map layer that is designed to be used as a basemap for various maps and applications. */
|
||||
/** The World Imagery map is a detailed imagery map layer that is designed to be used as a basemap for various maps and applications: https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer. */
|
||||
satellite: any;
|
||||
/** The Streets basemap presents a multiscale street map for the world. */
|
||||
/** The Streets basemap presents a multiscale street map for the world: https://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer. */
|
||||
streets: any;
|
||||
/** The Terrain with Labels basemap is designed to be used to overlay and emphasize other thematic map layers. */
|
||||
terrain: any;
|
||||
/** The Topographic map includes boundaries, cities, water features, physiographic features, parks, landmarks, transportation, and buildings. */
|
||||
/** The Topographic map includes boundaries, cities, water features, physiographic features, parks, landmarks, transportation, and buildings: https://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer */
|
||||
topo: any;
|
||||
};
|
||||
export = basemaps;
|
||||
@@ -9228,8 +9228,9 @@ declare module "esri/lang" {
|
||||
* @param data The data object used in the substitution.
|
||||
* @param template The template used for the substitution.
|
||||
* @param first When true, returns only the first property found in the data object.
|
||||
* @param format The format object used in the substitution.
|
||||
*/
|
||||
substitute(data: any, template?: string, first?: boolean): string;
|
||||
substitute(data: any, template?: string, first?: boolean, format?: any): string;
|
||||
/**
|
||||
* Iterates through the argument array and searches for the identifier to which the argument value matches.
|
||||
* @param array The argument array for testing.
|
||||
@@ -10000,6 +10001,8 @@ declare module "esri/layers/FeatureLayer" {
|
||||
displayField: string;
|
||||
/** Indicates the field names for the editor fields. */
|
||||
editFieldsInfo: any;
|
||||
/** Applicable to ArcGIS Online hosted feature services. */
|
||||
editingInfo: any;
|
||||
/** The array of fields in the layer. */
|
||||
fields: Field[];
|
||||
/** The full extent of the layer. */
|
||||
@@ -10054,6 +10057,8 @@ declare module "esri/layers/FeatureLayer" {
|
||||
supportsAttachmentsByUploadId: boolean;
|
||||
/** When true, the layer supports the Calculate REST operation when updating features. */
|
||||
supportsCalculate: boolean;
|
||||
/** If true, the layer supports a user-defined field description. */
|
||||
supportsFieldDescription: boolean;
|
||||
/** When true, the layer supports statistical functions in query operations. */
|
||||
supportsStatistics: boolean;
|
||||
/** When true, the layer is suspended. */
|
||||
@@ -10468,6 +10473,8 @@ declare module "esri/layers/Field" {
|
||||
class Field {
|
||||
/** The alias name for the field. */
|
||||
alias: string;
|
||||
/** A string that describes the default value set for a field. */
|
||||
defaultValue: string;
|
||||
/** Domain associated with the field. */
|
||||
domain: Domain;
|
||||
/** Indicates whether the field is editable. */
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
"rules": {
|
||||
// TODOs
|
||||
"ban-types": false,
|
||||
"npm-naming": false,
|
||||
"dt-header": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ const o: Options = {
|
||||
minTimeout: 3,
|
||||
maxTimeout: 4,
|
||||
randomize: true,
|
||||
forever: false,
|
||||
onRetry: (e: Error) => 42
|
||||
};
|
||||
|
||||
|
||||
15
types/async-retry/index.d.ts
vendored
15
types/async-retry/index.d.ts
vendored
@@ -1,8 +1,12 @@
|
||||
// Type definitions for async-retry 1.2
|
||||
// Type definitions for async-retry 1.4
|
||||
// Project: https://github.com/zeit/async-retry#readme
|
||||
// Definitions by: Albert Wu <https://github.com/albertywu>
|
||||
// Pablo Rodríguez <https://github.com/MeLlamoPablo>
|
||||
// Rafał Sawicki <https://github.com/rafsawicki>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import { OperationOptions } from 'retry';
|
||||
|
||||
declare function AsyncRetry<A>(
|
||||
fn: AsyncRetry.RetryFunction<A>,
|
||||
@@ -10,13 +14,8 @@ declare function AsyncRetry<A>(
|
||||
): Promise<A>;
|
||||
|
||||
declare namespace AsyncRetry {
|
||||
interface Options {
|
||||
retries?: number;
|
||||
factor?: number;
|
||||
minTimeout?: number;
|
||||
maxTimeout?: number;
|
||||
randomize?: boolean;
|
||||
onRetry?: (e: Error) => any;
|
||||
interface Options extends OperationOptions {
|
||||
onRetry?: (e: Error, attempt: number) => any;
|
||||
}
|
||||
|
||||
type RetryFunction<A> = (bail: (e: Error) => void, attempt: number) => A|Promise<A>;
|
||||
|
||||
@@ -179,7 +179,7 @@ webAuth.popup.signupAndLogin({ email: "", password: "", connection: "" }, (err,
|
||||
// do something with data
|
||||
});
|
||||
|
||||
webAuth.login({username: 'bar', password: 'foo'}, (err, data) => {});
|
||||
webAuth.login({username: 'bar', password: 'foo', state: '1234'}, (err, data) => {});
|
||||
|
||||
webAuth.crossOriginAuthenticationCallback();
|
||||
|
||||
|
||||
10
types/auth0-js/index.d.ts
vendored
10
types/auth0-js/index.d.ts
vendored
@@ -3,6 +3,7 @@
|
||||
// Definitions by: Adrian Chia <https://github.com/adrianchia>
|
||||
// Matt Durrant <https://github.com/mdurrant>
|
||||
// Peter Blazejewicz <https://github.com/peterblazejewicz>
|
||||
// Bartosz Kotrys <https://github.com/bkotrys>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
@@ -703,6 +704,15 @@ export interface CrossOriginLoginOptions {
|
||||
email?: string;
|
||||
password: string;
|
||||
realm?: string;
|
||||
domain?: string;
|
||||
clientID?: string;
|
||||
redirectUri?: string;
|
||||
responseType?: string;
|
||||
responseMode?: string;
|
||||
state?: string;
|
||||
nonce?: string;
|
||||
scope?: string;
|
||||
audience?: string;
|
||||
}
|
||||
|
||||
export interface LogoutOptions {
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
// TODO
|
||||
"npm-naming": false,
|
||||
"dt-header": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
// TODO
|
||||
"npm-naming": false,
|
||||
"dt-header": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,11 @@ const inTest = async (webDriver: WebDriver) => {
|
||||
.disableRules("rule")
|
||||
.disableRules(["rule", "rule"])
|
||||
.configure(spec)
|
||||
.analyze((internalResults: AxeAnalysis) => {});
|
||||
.analyze((err: Error | null, internalResults: AxeAnalysis) => {});
|
||||
|
||||
const deprecatedAnalysis: AxeAnalysis = await AxeBuilder(webDriver).analyze(
|
||||
(internalResults: AxeAnalysis) => {}
|
||||
);
|
||||
|
||||
const inapplicable: Result[] = analysis.inapplicable;
|
||||
const incomplete: Result[] = analysis.incomplete;
|
||||
|
||||
12
types/axe-webdriverjs/index.d.ts
vendored
12
types/axe-webdriverjs/index.d.ts
vendored
@@ -1,8 +1,9 @@
|
||||
// Type definitions for axe-webdriverjs 2.0
|
||||
// Type definitions for axe-webdriverjs 2.1
|
||||
// Project: https://github.com/dequelabs/axe-webdriverjs#readme
|
||||
// Definitions by: Joshua Goldberg <https://github.com/JoshuaKGoldberg>
|
||||
// Tyler Krupicka <https://github.com/tylerkrupicka>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
// TypeScript Version: 2.4
|
||||
|
||||
import { Result, RunOptions, Spec } from "axe-core";
|
||||
import { WebDriver } from "selenium-webdriver";
|
||||
@@ -16,6 +17,9 @@ export interface AxeAnalysis {
|
||||
violations: Result[];
|
||||
}
|
||||
|
||||
export type DeprecatedAnalyzeCallback = (results: AxeAnalysis) => void;
|
||||
export type AnalyzeCallback = (err: Error | null, results: AxeAnalysis) => void;
|
||||
|
||||
export interface AxeBuilder {
|
||||
/**
|
||||
* Includes a selector in analysis.
|
||||
@@ -74,7 +78,9 @@ export interface AxeBuilder {
|
||||
* Perform analysis and retrieve results.
|
||||
* @param callback Function to execute when analysis completes.
|
||||
*/
|
||||
analyze(callback: (results: AxeAnalysis) => void): Promise<AxeAnalysis>;
|
||||
analyze(
|
||||
callback?: AnalyzeCallback | DeprecatedAnalyzeCallback
|
||||
): Promise<AxeAnalysis>;
|
||||
}
|
||||
|
||||
export const AxeBuilder: {
|
||||
|
||||
@@ -11,7 +11,7 @@ const registrationOptions: Sqlite.RegistrationOptions = {
|
||||
};
|
||||
|
||||
let db: Sqlite.Database = Sqlite('.');
|
||||
db = new Sqlite('.', { memory: true });
|
||||
db = new Sqlite('.', { memory: true, verbose: () => {} });
|
||||
db.exec('CREATE TABLE test (id INTEGER PRIMARY KEY NOT NULL, name TEXT NOT NULL);');
|
||||
db.exec('INSERT INTO test(name) VALUES("name");');
|
||||
db.pragma('data_version', { simple: true });
|
||||
|
||||
2
types/better-sqlite3/index.d.ts
vendored
2
types/better-sqlite3/index.d.ts
vendored
@@ -5,6 +5,7 @@
|
||||
// Santiago Aguilar <https://github.com/sant123>
|
||||
// Alessandro Vergani <https://github.com/loghorn>
|
||||
// Andrew Kaiser <https://github.com/andykais>
|
||||
// Mark Stewart <https://github.com/mrkstwrt>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 3.0
|
||||
|
||||
@@ -97,6 +98,7 @@ declare namespace Database {
|
||||
readonly?: boolean;
|
||||
fileMustExist?: boolean;
|
||||
timeout?: number;
|
||||
verbose?: (message?: any, ...additionalArgs: any[]) => void;
|
||||
}
|
||||
|
||||
interface PragmaOptions {
|
||||
|
||||
@@ -16,3 +16,8 @@ const red = bn.toRed(ctx);
|
||||
const newRed = red.redAdd(new BN(1));
|
||||
newRed.cmp(bn);
|
||||
newRed.fromRed();
|
||||
|
||||
const expected = new BN(0x4020);
|
||||
const actualArray = new BN([0x40, 0x20]);
|
||||
const actualUint8Array = new BN(new Uint8Array([0x40, 0x20]));
|
||||
const actualString = new BN('0x4020');
|
||||
|
||||
4
types/bn.js/index.d.ts
vendored
4
types/bn.js/index.d.ts
vendored
@@ -25,12 +25,12 @@ interface ReductionContext {
|
||||
|
||||
declare class BN {
|
||||
constructor(
|
||||
number: number | string | number[] | Buffer | BN,
|
||||
number: number | string | number[] | Uint8Array | Buffer | BN,
|
||||
base?: number | 'hex',
|
||||
endian?: Endianness
|
||||
);
|
||||
constructor(
|
||||
number: number | string | number[] | Buffer | BN,
|
||||
number: number | string | number[] | Uint8Array | Buffer | BN,
|
||||
endian?: Endianness
|
||||
)
|
||||
|
||||
|
||||
2
types/bro-fs/index.d.ts
vendored
2
types/bro-fs/index.d.ts
vendored
@@ -44,6 +44,8 @@ export function isSupported(): boolean;
|
||||
export function mkdir(path: string): Promise<DirectoryEntry>;
|
||||
export function readdir(path: string | DirectoryEntry, options?: {deep?: boolean}): Promise<FileEntry[]>;
|
||||
export function readFile(path: string | FileEntry, options: {type: 'ArrayBuffer'}): Promise<ArrayBuffer>;
|
||||
export function readFile(path: string | FileEntry, options: {type: 'Blob'}): Promise<Blob>;
|
||||
export function readFile(path: string | FileEntry, options: {type: 'File'}): Promise<File>;
|
||||
export function readFile(path: string | FileEntry, options?: {type?: TextType}): Promise<string>;
|
||||
export function rename(oldPath: string | FileEntry, newPath: string, options?: {create?: boolean}): Promise<FileEntry>;
|
||||
export function rmdir(path: string | DirectoryEntry): Promise<boolean>;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import btoa = require('btoa');
|
||||
|
||||
btoa('foo');
|
||||
|
||||
btoa(Buffer.from('foo'));
|
||||
|
||||
4
types/btoa/index.d.ts
vendored
4
types/btoa/index.d.ts
vendored
@@ -5,6 +5,8 @@
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
declare function btoa(str: string): string;
|
||||
/// <reference types="node" />
|
||||
|
||||
declare function btoa(str: string | Buffer): string;
|
||||
|
||||
export = btoa;
|
||||
|
||||
10
types/bull/index.d.ts
vendored
10
types/bull/index.d.ts
vendored
@@ -26,10 +26,12 @@ import { EventEmitter } from "events";
|
||||
* Everytime the same queue is instantiated it tries to process all the old jobs that may exist from a previous unfinished session.
|
||||
*/
|
||||
declare const Bull: {
|
||||
(queueName: string, opts?: Bull.QueueOptions): Bull.Queue;
|
||||
(queueName: string, url: string, opts?: Bull.QueueOptions): Bull.Queue; // tslint:disable-line unified-signatures
|
||||
new (queueName: string, opts?: Bull.QueueOptions): Bull.Queue;
|
||||
new (queueName: string, url: string, opts?: Bull.QueueOptions): Bull.Queue; // tslint:disable-line unified-signatures
|
||||
/* tslint:disable:no-unnecessary-generics unified-signatures */
|
||||
<T = any>(queueName: string, opts?: Bull.QueueOptions): Bull.Queue<T>;
|
||||
<T = any>(queueName: string, url: string, opts?: Bull.QueueOptions): Bull.Queue<T>;
|
||||
new <T = any>(queueName: string, opts?: Bull.QueueOptions): Bull.Queue<T>;
|
||||
new <T = any>(queueName: string, url: string, opts?: Bull.QueueOptions): Bull.Queue<T>;
|
||||
/* tslint:enable:no-unnecessary-generics unified-signatures */
|
||||
};
|
||||
|
||||
declare namespace Bull {
|
||||
|
||||
29
types/burns/burns-tests.ts
Normal file
29
types/burns/burns-tests.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import burns from 'burns';
|
||||
|
||||
interface OrderData {
|
||||
userName: string;
|
||||
orderId: string;
|
||||
}
|
||||
|
||||
function handleEverything() {
|
||||
console.log('Do absolutely nothing! 😄');
|
||||
}
|
||||
|
||||
function sendEmail(message: string) {
|
||||
console.log(message);
|
||||
}
|
||||
|
||||
function sendOrderShippedEmail(data: OrderData) {
|
||||
sendEmail(`Hi ${data.userName}, Your order ${data.orderId} has been shipped`);
|
||||
}
|
||||
|
||||
burns.configure({
|
||||
defaultHandler: handleEverything
|
||||
});
|
||||
burns.registerEvents({
|
||||
newPurchase: sendOrderShippedEmail
|
||||
});
|
||||
burns.dispatch('newPurchase', {
|
||||
userName: 'Johnny',
|
||||
orderId: 'rand'
|
||||
});
|
||||
23
types/burns/index.d.ts
vendored
Normal file
23
types/burns/index.d.ts
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
// Type definitions for burns 2.0
|
||||
// Project: https://github.com/shalvah/burns#readme
|
||||
// Definitions by: Timothy Onyiuke <https://github.com/timolinn>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
declare const _Burns: Burns;
|
||||
|
||||
export interface Config {
|
||||
defaultHandler?: any;
|
||||
broadcaster?: any;
|
||||
pusher?: any;
|
||||
}
|
||||
|
||||
declare class Burns {
|
||||
configure(config?: Config): this;
|
||||
|
||||
registerEvents(newEvents: Record<string, any>): this;
|
||||
|
||||
dispatch(eventName: string, eventData?: Record<string, any>, exclude?: { exclude?: any }): this;
|
||||
}
|
||||
|
||||
export default _Burns;
|
||||
24
types/burns/tsconfig.json
Normal file
24
types/burns/tsconfig.json
Normal file
@@ -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",
|
||||
"burns-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/burns/tslint.json
Normal file
1
types/burns/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -11,7 +11,8 @@
|
||||
"types": [],
|
||||
"paths": {
|
||||
"d3-scale": ["d3-scale/v1"],
|
||||
"d3": ["d3/v4"]
|
||||
"d3": ["d3/v4"],
|
||||
"d3-array": ["d3-array/v1"]
|
||||
},
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
|
||||
5
types/cacheable-request/index.d.ts
vendored
5
types/cacheable-request/index.d.ts
vendored
@@ -1,6 +1,7 @@
|
||||
// Type definitions for cacheable-request 6.0
|
||||
// Project: https://github.com/lukechilds/cacheable-request#readme
|
||||
// Definitions by: BendingBender <https://github.com/BendingBender>
|
||||
// Paul Melnikow <https://github.com/paulmelnikow>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
@@ -20,7 +21,7 @@ declare const CacheableRequest: CacheableRequest;
|
||||
type RequestFn = typeof request;
|
||||
|
||||
interface CacheableRequest {
|
||||
new (requestFn: RequestFn, storageAdapter?: string | Store<any>): (
|
||||
new (requestFn: RequestFn, storageAdapter?: string | CacheableRequest.StorageAdapter): (
|
||||
opts: string | URL | (RequestOptions & CacheSemanticsOptions),
|
||||
cb?: (response: ServerResponse | ResponseLike) => void
|
||||
) => CacheableRequest.Emitter;
|
||||
@@ -30,6 +31,8 @@ interface CacheableRequest {
|
||||
}
|
||||
|
||||
declare namespace CacheableRequest {
|
||||
type StorageAdapter = Store<any>;
|
||||
|
||||
interface Options {
|
||||
/**
|
||||
* If the cache should be used. Setting this to `false` will completely bypass the cache for the current request.
|
||||
|
||||
17
types/center-align/center-align-tests.ts
Normal file
17
types/center-align/center-align-tests.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import center from "center-align";
|
||||
|
||||
// multi-line sample
|
||||
center([
|
||||
"Lorem ipsum dolor sit amet,",
|
||||
"consectetur adipiscing",
|
||||
"elit, sed do eiusmod tempor incididunt",
|
||||
"ut labore et dolore",
|
||||
"magna aliqua. Ut enim ad minim",
|
||||
"veniam, quis"
|
||||
]);
|
||||
|
||||
// single-line samples
|
||||
center("foo"); // => 'foo' (does nothing)
|
||||
center("foo", 12); // => ' foo '
|
||||
center("foo", 10); // => ' foo '
|
||||
center("foo", 8); // => ' foo '
|
||||
10
types/center-align/index.d.ts
vendored
Normal file
10
types/center-align/index.d.ts
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
// Type definitions for center-align 1.0
|
||||
// Project: https://github.com/jonschlinkert/center-align
|
||||
// Definitions by: Claas Ahlrichs <https://github.com/claasahl>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.7
|
||||
|
||||
declare function center_align(val: string, width?: number): string;
|
||||
declare function center_align(val: string[], width?: number): string[];
|
||||
|
||||
export = center_align;
|
||||
17
types/center-align/tsconfig.json
Normal file
17
types/center-align/tsconfig.json
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es6"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"esModuleInterop": true
|
||||
},
|
||||
"files": ["index.d.ts", "center-align-tests.ts"]
|
||||
}
|
||||
1
types/center-align/tslint.json
Normal file
1
types/center-align/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
24
types/changelog-parser/changelog-parser-tests.ts
Normal file
24
types/changelog-parser/changelog-parser-tests.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import parseChangelog = require('changelog-parser');
|
||||
|
||||
const options = {
|
||||
filePath: 'path/to/CHANGELOG.md',
|
||||
removeMarkdown: false
|
||||
};
|
||||
|
||||
const fn = (obj: object): void => {};
|
||||
|
||||
parseChangelog({filePath: 'path/to/CHANGELOG.md'}, (error, result) => {
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
fn(result);
|
||||
});
|
||||
|
||||
parseChangelog(options, (error, result) => {});
|
||||
|
||||
parseChangelog({filePath: 'path/to/CHANGELOG.md'}, (error) => {});
|
||||
|
||||
parseChangelog(options).then((result) => {});
|
||||
|
||||
parseChangelog('path/to/CHANGELOG.md').then((result) => {});
|
||||
25
types/changelog-parser/index.d.ts
vendored
Normal file
25
types/changelog-parser/index.d.ts
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
// Type definitions for changelog-parser 2.7
|
||||
// Project: https://github.com/hypermodules/changelog-parser
|
||||
// Definitions by: Adam Zerella <https://github.com/adamzerella>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
interface Options {
|
||||
/**
|
||||
* Path to changelog file.
|
||||
*/
|
||||
filePath: string;
|
||||
/**
|
||||
* Removes the markdown markup from the changelog entries by default.
|
||||
* You can change its value to false to keep the markdown.
|
||||
*/
|
||||
removeMarkdown: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change log parser for node.
|
||||
*/
|
||||
declare function parseChangelog(options: Partial<Options>|string,
|
||||
callback?: (error: string|null, result: object) => void): Promise<object>;
|
||||
|
||||
export = parseChangelog;
|
||||
@@ -6,8 +6,8 @@
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
@@ -18,7 +18,6 @@
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"elastic-apm-node-tests.ts",
|
||||
"start.d.ts"
|
||||
"changelog-parser-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/changelog-parser/tslint.json
Normal file
1
types/changelog-parser/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -620,6 +620,7 @@ function test_filter() {
|
||||
allowed = filter.allow('rule', 'name', false);
|
||||
|
||||
var apply: boolean = filter.applyTo(CKEDITOR.htmlParser.fragment.fromHtml('string'), true, false, 1);
|
||||
apply = filter.applyTo(new CKEDITOR.htmlParser.element('name', null));
|
||||
apply = filter.applyTo(new CKEDITOR.htmlParser.element('name', null), true, false, 1);
|
||||
|
||||
var checked: boolean = filter.check(style);
|
||||
|
||||
2
types/ckeditor/index.d.ts
vendored
2
types/ckeditor/index.d.ts
vendored
@@ -1436,7 +1436,7 @@ declare namespace CKEDITOR {
|
||||
addFeature(feature: feature): boolean;
|
||||
addTransformations(transformations: Array<Array<string | filter.transformation>>): void;
|
||||
allow(newRules: filter.allowedContentRules, featureName?: string, overrideCustom?: boolean): boolean;
|
||||
applyTo(fragment: htmlParser.fragment | htmlParser.element, toHrml: boolean, transformOnly: boolean, enterMode: number): boolean;
|
||||
applyTo(fragment: htmlParser.fragment | htmlParser.element, toHtml?: boolean, transformOnly?: boolean, enterMode?: number): boolean;
|
||||
check(test: filter.contentRule, applyTransformations?: boolean, strictCheck?: boolean): boolean;
|
||||
checkFeature(feature: feature): boolean;
|
||||
clone(): filter;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
// TODO
|
||||
"dt-header": false
|
||||
"npm-naming": false,
|
||||
"dt-header": false
|
||||
}
|
||||
}
|
||||
|
||||
38
types/connect-history-api-fallback/index.d.ts
vendored
38
types/connect-history-api-fallback/index.d.ts
vendored
@@ -10,26 +10,28 @@ import { Url } from 'url';
|
||||
|
||||
import * as core from "express-serve-static-core";
|
||||
|
||||
declare function historyApiFallback(options?: Options): core.RequestHandler;
|
||||
declare namespace historyApiFallback {}
|
||||
export = historyApiFallback;
|
||||
|
||||
interface Options {
|
||||
disableDotRule?: true;
|
||||
htmlAcceptHeaders?: string[];
|
||||
index?: string;
|
||||
logger?: typeof console.log;
|
||||
rewrites?: Rewrite[];
|
||||
verbose?: boolean;
|
||||
}
|
||||
declare function historyApiFallback(options?: historyApiFallback.Options): core.RequestHandler;
|
||||
|
||||
interface Context {
|
||||
match: RegExpMatchArray;
|
||||
parsedUrl: Url;
|
||||
}
|
||||
type RewriteTo = (context: Context) => string;
|
||||
declare namespace historyApiFallback {
|
||||
interface Options {
|
||||
disableDotRule?: true;
|
||||
htmlAcceptHeaders?: string[];
|
||||
index?: string;
|
||||
logger?: typeof console.log;
|
||||
rewrites?: Rewrite[];
|
||||
verbose?: boolean;
|
||||
}
|
||||
|
||||
interface Rewrite {
|
||||
from: RegExp;
|
||||
to: string | RegExp | RewriteTo;
|
||||
interface Context {
|
||||
match: RegExpMatchArray;
|
||||
parsedUrl: Url;
|
||||
}
|
||||
type RewriteTo = (context: Context) => string;
|
||||
|
||||
interface Rewrite {
|
||||
from: RegExp;
|
||||
to: string | RegExp | RewriteTo;
|
||||
}
|
||||
}
|
||||
|
||||
4
types/countries-and-timezones/index.d.ts
vendored
4
types/countries-and-timezones/index.d.ts
vendored
@@ -16,9 +16,9 @@ export interface Timezone {
|
||||
countries: string[];
|
||||
}
|
||||
|
||||
export function getAllCountries(): Country[];
|
||||
export function getAllCountries(): {[key: string]: Country};
|
||||
|
||||
export function getAllTimezones(): Timezone[];
|
||||
export function getAllTimezones(): {[key: string]: Timezone};
|
||||
|
||||
export function getCountriesForTimezone(timezoneId: string): Country[];
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"npm-naming": false,
|
||||
"dt-header": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ const mixedObjectArray = [
|
||||
];
|
||||
|
||||
const mixedObjectOrUndefinedArray = [...mixedObjectArray, undefined];
|
||||
const mixedObjectArrayLike = mixedObjectArray as ArrayLike<MixedObject>;
|
||||
const mixedObjectArrayLike = mixedObjectArray as Iterable<MixedObject>;
|
||||
|
||||
let typedArray = Uint8Array.from(numbersArray);
|
||||
let readonlyNumbersArray = numbersArray as ReadonlyArray<number>;
|
||||
@@ -81,55 +81,55 @@ const readonlyDateArray = dateArray as ReadonlyArray<Date>;
|
||||
const readonlyMixedObjectArray = mixedObjectArray as ReadonlyArray<MixedObject>;
|
||||
const readonlyMixedObjectOrUndefinedArray = mixedObjectOrUndefinedArray as ReadonlyArray<MixedObject | undefined>;
|
||||
|
||||
function accessorMixedObjectToNum(datum: MixedObject, index: number, array: ArrayLike<MixedObject>): number {
|
||||
function accessorMixedObjectToNum(datum: MixedObject, index: number, array: Iterable<MixedObject>): number {
|
||||
return datum.num;
|
||||
}
|
||||
|
||||
function accessorMixedObjectToStr(datum: MixedObject, index: number, array: ArrayLike<MixedObject>): string {
|
||||
function accessorMixedObjectToStr(datum: MixedObject, index: number, array: Iterable<MixedObject>): string {
|
||||
return datum.str;
|
||||
}
|
||||
|
||||
function accessorMixedObjectToNumeric(datum: MixedObject, index: number, array: ArrayLike<MixedObject>): NumCoercible {
|
||||
function accessorMixedObjectToNumeric(datum: MixedObject, index: number, array: Iterable<MixedObject>): NumCoercible {
|
||||
return datum.numeric;
|
||||
}
|
||||
|
||||
function accessorMixedObjectToDate(datum: MixedObject, index: number, array: ArrayLike<MixedObject>): Date {
|
||||
function accessorMixedObjectToDate(datum: MixedObject, index: number, array: Iterable<MixedObject>): Date {
|
||||
return datum.date;
|
||||
}
|
||||
|
||||
function accessorMixedObjectToNumOrUndefined(datum: MixedObject | undefined, index: number, array: ArrayLike<MixedObject | undefined>): number | undefined | null {
|
||||
function accessorMixedObjectToNumOrUndefined(datum: MixedObject | undefined, index: number, array: Iterable<MixedObject | undefined>): number | undefined | null {
|
||||
return datum ? datum.num : undefined;
|
||||
}
|
||||
|
||||
function accessorMixedObjectToStrOrUndefined(datum: MixedObject | undefined, index: number, array: ArrayLike<MixedObject>): string | undefined | null {
|
||||
function accessorMixedObjectToStrOrUndefined(datum: MixedObject | undefined, index: number, array: Iterable<MixedObject>): string | undefined | null {
|
||||
return datum ? datum.str : undefined;
|
||||
}
|
||||
|
||||
function accessorLikeMixedObjectToNum(datum: MixedObject, index: number, array: ArrayLike<MixedObject>): number {
|
||||
function accessorLikeMixedObjectToNum(datum: MixedObject, index: number, array: Iterable<MixedObject>): number {
|
||||
return datum.num;
|
||||
}
|
||||
|
||||
function accessorLikeMixedObjectToStr(datum: MixedObject, index: number, array: ArrayLike<MixedObject>): string {
|
||||
function accessorLikeMixedObjectToStr(datum: MixedObject, index: number, array: Iterable<MixedObject>): string {
|
||||
return datum.str;
|
||||
}
|
||||
|
||||
function accessorLikeMixedObjectToNumeric(datum: MixedObject, index: number, array: ArrayLike<MixedObject>): NumCoercible {
|
||||
function accessorLikeMixedObjectToNumeric(datum: MixedObject, index: number, array: Iterable<MixedObject>): NumCoercible {
|
||||
return datum.numeric;
|
||||
}
|
||||
|
||||
function accessorLikeMixedObjectToDate(datum: MixedObject, index: number, array: ArrayLike<MixedObject>): Date {
|
||||
function accessorLikeMixedObjectToDate(datum: MixedObject, index: number, array: Iterable<MixedObject>): Date {
|
||||
return datum.date;
|
||||
}
|
||||
|
||||
function accessorLikeMixedObjectToNumOrUndefined(datum: MixedObject | undefined, index: number, array: ArrayLike<MixedObject | undefined>): number | undefined | null {
|
||||
function accessorLikeMixedObjectToNumOrUndefined(datum: MixedObject | undefined, index: number, array: Iterable<MixedObject | undefined>): number | undefined | null {
|
||||
return datum ? datum.num : undefined;
|
||||
}
|
||||
|
||||
function accessorLikeMixedObjectToStrOrUndefined(datum: MixedObject | undefined, index: number, array: ArrayLike<MixedObject>): string | undefined | null {
|
||||
function accessorLikeMixedObjectToStrOrUndefined(datum: MixedObject | undefined, index: number, array: Iterable<MixedObject>): string | undefined | null {
|
||||
return datum ? datum.str : undefined;
|
||||
}
|
||||
|
||||
function accessorReadOnlyMixedObjectToNumOrUndefined(datum: MixedObject | undefined, index: number, array: ArrayLike<MixedObject | undefined>): number | undefined | null {
|
||||
function accessorReadOnlyMixedObjectToNumOrUndefined(datum: MixedObject | undefined, index: number, array: Iterable<MixedObject | undefined>): number | undefined | null {
|
||||
return datum ? datum.num : undefined;
|
||||
}
|
||||
|
||||
@@ -485,6 +485,12 @@ num = mixedObjectDateBisectorObject.right(readonlyMixedObjectArray, new Date(201
|
||||
num = mixedObjectDateBisectorObject.right(readonlyMixedObjectArray, new Date(2015, 3, 14), 1);
|
||||
num = mixedObjectDateBisectorObject.right(readonlyMixedObjectArray, new Date(2015, 3, 14), 3, 4);
|
||||
|
||||
// quickselect
|
||||
numbersArray = d3Array.quickselect(numbersArray, 3);
|
||||
numbersArray = d3Array.quickselect(numbersArray, 3, 0);
|
||||
numbersArray = d3Array.quickselect(numbersArray, 3, 0, 5);
|
||||
numbersArray = d3Array.quickselect(numbersArray, 3, 0, 5, d3Array.descending);
|
||||
|
||||
// ascending() -----------------------------------------------------------------
|
||||
|
||||
num = d3Array.ascending(undefined, 20);
|
||||
@@ -536,6 +542,23 @@ mergedArray = d3Array.merge([testArray1, [15, 30]]); // fails, type mismatch
|
||||
mergedArray = d3Array.merge(readonlyTestArrays); // inferred type
|
||||
mergedArray = d3Array.merge<MixedObject>(readonlyTestArrays); // explicit type
|
||||
|
||||
interface ObjDefinition {
|
||||
name: string;
|
||||
amount: string;
|
||||
date: string;
|
||||
}
|
||||
|
||||
const objArray: ObjDefinition[] = [
|
||||
{ name: "jim", amount: "34.0", date: "11/12/2015" },
|
||||
{ name: "carl", amount: "120.11", date: "11/12/2015" },
|
||||
{ name: "stacy", amount: "12.01", date: "01/04/2016" },
|
||||
{ name: "stacy", amount: "34.05", date: "01/04/2016" }
|
||||
];
|
||||
|
||||
const grouped: Map<string, ObjDefinition[]> = d3Array.group(objArray, d => d.name);
|
||||
const rolledup: Map<string, number> = d3Array.rollup(objArray, d => d.length, d => d.name);
|
||||
const rolledup2: Map<string, string> = d3Array.rollup(objArray, d => d.map(u => u.name).join(' '), d => d.name);
|
||||
|
||||
// cross() ---------------------------------------------------------------------
|
||||
|
||||
let crossed: Array<[string, number]>;
|
||||
@@ -780,7 +803,7 @@ histoMixedObject_Date = histoMixedObject_Date.domain(timeScale.domain()); // fai
|
||||
domainFnDate = histoMixedObject_Date.domain();
|
||||
histoMixedObject_DateOrUndefined = histoMixedObject_DateOrUndefined.domain([new Date(2014, 3, 15), new Date(2017, 4, 15)]);
|
||||
histoMixedObject_DateOrUndefined = histoMixedObject_DateOrUndefined.domain([domain[0], domain[domain.length]]);
|
||||
histoMixedObject_DateOrUndefined = histoMixedObject_DateOrUndefined.domain((values) => [values[0]!, values[values.length]!]);
|
||||
histoMixedObject_DateOrUndefined = histoMixedObject_DateOrUndefined.domain((values) => [values[0]!, values[values.length]!]);
|
||||
|
||||
// thresholds(...) -------------------------------------------------------------
|
||||
|
||||
@@ -935,8 +958,3 @@ num = d3Array.thresholdScott(readonlyNumbersArray, -1, 234);
|
||||
num = d3Array.thresholdSturges(numbersArray);
|
||||
num = d3Array.thresholdSturges(typedArray);
|
||||
num = d3Array.thresholdSturges(readonlyNumbersArray);
|
||||
|
||||
// Deprecated ==================================================================
|
||||
|
||||
const histDeprecatedNumber: d3Array.HistogramGenerator<MixedObject, number> = d3Array.histogram<MixedObject, number>();
|
||||
const histDeprecatedDate: d3Array.HistogramGenerator<MixedObject, Date> = d3Array.histogram<MixedObject, Date>();
|
||||
|
||||
163
types/d3-array/index.d.ts
vendored
163
types/d3-array/index.d.ts
vendored
@@ -1,13 +1,14 @@
|
||||
// Type definitions for D3JS d3-array module 1.2
|
||||
// Type definitions for D3JS d3-array module 2.0
|
||||
// Project: https://github.com/d3/d3-array, https://d3js.org/d3-array
|
||||
// Definitions by: Alex Ford <https://github.com/gustavderdrache>
|
||||
// Boris Yankov <https://github.com/borisyankov>
|
||||
// Tom Wanzek <https://github.com/tomwanzek>
|
||||
// denisname <https://github.com/denisname>
|
||||
// denisname <https://github.com/denisname>,
|
||||
// Hugues Stefanski <https://github.com/ledragon>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
// Last module patch version validated against: 1.2.1
|
||||
// Last module patch version validated against: 2.0.3
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Shared Types and Interfaces
|
||||
@@ -32,128 +33,128 @@ export interface Numeric {
|
||||
/**
|
||||
* Return the maximum value in the array of strings using natural order.
|
||||
*/
|
||||
export function max(array: ArrayLike<string>): string | undefined;
|
||||
export function max(array: Iterable<string>): string | undefined;
|
||||
|
||||
/**
|
||||
* Return the maximum value in the array of numbers using natural order.
|
||||
*/
|
||||
export function max<T extends Numeric>(array: ArrayLike<T>): T | undefined;
|
||||
export function max<T extends Numeric>(array: Iterable<T>): T | undefined;
|
||||
|
||||
/**
|
||||
* Return the maximum value in the array using natural order and a projection function to map values to strings.
|
||||
*/
|
||||
export function max<T>(array: ArrayLike<T>, accessor: (datum: T, index: number, array: ArrayLike<T>) => string | undefined | null): string | undefined;
|
||||
export function max<T>(array: Iterable<T>, accessor: (datum: T, index: number, array: Iterable<T>) => string | undefined | null): string | undefined;
|
||||
|
||||
/**
|
||||
* Return the maximum value in the array using natural order and a projection function to map values to easily-sorted values.
|
||||
*/
|
||||
export function max<T, U extends Numeric>(array: ArrayLike<T>, accessor: (datum: T, index: number, array: ArrayLike<T>) => U | undefined | null): U | undefined;
|
||||
export function max<T, U extends Numeric>(array: Iterable<T>, accessor: (datum: T, index: number, array: Iterable<T>) => U | undefined | null): U | undefined;
|
||||
|
||||
/**
|
||||
* Return the minimum value in the array using natural order.
|
||||
*/
|
||||
export function min(array: ArrayLike<string>): string | undefined;
|
||||
export function min(array: Iterable<string>): string | undefined;
|
||||
|
||||
/**
|
||||
* Return the minimum value in the array using natural order.
|
||||
*/
|
||||
export function min<T extends Numeric>(array: ArrayLike<T>): T | undefined;
|
||||
export function min<T extends Numeric>(array: Iterable<T>): T | undefined;
|
||||
|
||||
/**
|
||||
* Return the minimum value in the array using natural order.
|
||||
*/
|
||||
export function min<T>(array: ArrayLike<T>, accessor: (datum: T, index: number, array: ArrayLike<T>) => string | undefined | null): string | undefined;
|
||||
export function min<T>(array: Iterable<T>, accessor: (datum: T, index: number, array: Iterable<T>) => string | undefined | null): string | undefined;
|
||||
|
||||
/**
|
||||
* Return the minimum value in the array using natural order.
|
||||
*/
|
||||
export function min<T, U extends Numeric>(array: ArrayLike<T>, accessor: (datum: T, index: number, array: ArrayLike<T>) => U | undefined | null): U | undefined;
|
||||
export function min<T, U extends Numeric>(array: Iterable<T>, accessor: (datum: T, index: number, array: Iterable<T>) => U | undefined | null): U | undefined;
|
||||
|
||||
/**
|
||||
* Return the min and max simultaneously.
|
||||
*/
|
||||
export function extent(array: ArrayLike<string>): [string, string] | [undefined, undefined];
|
||||
export function extent(array: Iterable<string>): [string, string] | [undefined, undefined];
|
||||
|
||||
/**
|
||||
* Return the min and max simultaneously.
|
||||
*/
|
||||
export function extent<T extends Numeric>(array: ArrayLike<T>): [T, T] | [undefined, undefined];
|
||||
export function extent<T extends Numeric>(array: Iterable<T>): [T, T] | [undefined, undefined];
|
||||
|
||||
/**
|
||||
* Return the min and max simultaneously.
|
||||
*/
|
||||
export function extent<T>(array: ArrayLike<T>, accessor: (datum: T, index: number, array: ArrayLike<T>) => string | undefined | null): [string, string] | [undefined, undefined];
|
||||
export function extent<T>(array: Iterable<T>, accessor: (datum: T, index: number, array: Iterable<T>) => string | undefined | null): [string, string] | [undefined, undefined];
|
||||
|
||||
/**
|
||||
* Return the min and max simultaneously.
|
||||
*/
|
||||
export function extent<T, U extends Numeric>(array: ArrayLike<T>, accessor: (datum: T, index: number, array: ArrayLike<T>) => U | undefined | null): [U, U] | [undefined, undefined];
|
||||
export function extent<T, U extends Numeric>(array: Iterable<T>, accessor: (datum: T, index: number, array: Iterable<T>) => U | undefined | null): [U, U] | [undefined, undefined];
|
||||
|
||||
/**
|
||||
* Return the mean of an array of numbers
|
||||
*/
|
||||
export function mean<T extends Numeric>(array: ArrayLike<T | undefined | null>): number | undefined;
|
||||
export function mean<T extends Numeric>(array: Iterable<T | undefined | null>): number | undefined;
|
||||
|
||||
/**
|
||||
* Return the mean of an array of numbers
|
||||
*/
|
||||
export function mean<T>(array: ArrayLike<T>, accessor: (datum: T, index: number, array: ArrayLike<T>) => number | undefined | null): number | undefined;
|
||||
export function mean<T>(array: Iterable<T>, accessor: (datum: T, index: number, array: Iterable<T>) => number | undefined | null): number | undefined;
|
||||
|
||||
/**
|
||||
* Return the median of an array of numbers
|
||||
*/
|
||||
export function median<T extends Numeric>(array: ArrayLike<T | undefined | null>): number | undefined;
|
||||
export function median<T extends Numeric>(array: Iterable<T | undefined | null>): number | undefined;
|
||||
|
||||
/**
|
||||
* Return the median of an array of numbers
|
||||
*/
|
||||
export function median<T>(array: ArrayLike<T>, accessor: (element: T, i: number, array: ArrayLike<T>) => number | undefined | null): number | undefined;
|
||||
export function median<T>(array: Iterable<T>, accessor: (element: T, i: number, array: Iterable<T>) => number | undefined | null): number | undefined;
|
||||
|
||||
/**
|
||||
* Returns the p-quantile of an array of numbers
|
||||
*/
|
||||
export function quantile<T extends Numeric>(array: ArrayLike<T | undefined | null>, p: number): number | undefined;
|
||||
export function quantile<T extends Numeric>(array: Iterable<T | undefined | null>, p: number): number | undefined;
|
||||
|
||||
export function quantile<T>(array: ArrayLike<T>, p: number, accessor: (element: T, i: number, array: ArrayLike<T>) => number | undefined | null): number | undefined;
|
||||
export function quantile<T>(array: Iterable<T>, p: number, accessor: (element: T, i: number, array: Iterable<T>) => number | undefined | null): number | undefined;
|
||||
|
||||
/**
|
||||
* Compute the sum of an array of numbers.
|
||||
*/
|
||||
export function sum<T extends Numeric>(array: ArrayLike<T | undefined | null>): number;
|
||||
export function sum<T extends Numeric>(array: Iterable<T | undefined | null>): number;
|
||||
|
||||
/**
|
||||
* Compute the sum of an array, using the given accessor to convert values to numbers.
|
||||
*/
|
||||
export function sum<T>(array: ArrayLike<T>, accessor: (datum: T, index: number, array: ArrayLike<T>) => number | undefined | null): number;
|
||||
export function sum<T>(array: Iterable<T>, accessor: (datum: T, index: number, array: Iterable<T>) => number | undefined | null): number;
|
||||
|
||||
/**
|
||||
* Compute the standard deviation, defined as the square root of the bias-corrected variance, of the given array of numbers.
|
||||
*/
|
||||
export function deviation<T extends Numeric>(array: ArrayLike<T | undefined | null>): number | undefined;
|
||||
export function deviation<T extends Numeric>(array: Iterable<T | undefined | null>): number | undefined;
|
||||
|
||||
/**
|
||||
* Compute the standard deviation, defined as the square root of the bias-corrected variance, of the given array,
|
||||
* using the given accessor to convert values to numbers.
|
||||
*/
|
||||
export function deviation<T>(array: ArrayLike<T>, accessor: (datum: T, index: number, array: ArrayLike<T>) => number | undefined | null): number | undefined;
|
||||
export function deviation<T>(array: Iterable<T>, accessor: (datum: T, index: number, array: Iterable<T>) => number | undefined | null): number | undefined;
|
||||
|
||||
/**
|
||||
* Compute an unbiased estimator of the population variance of the given array of numbers.
|
||||
*/
|
||||
export function variance<T extends Numeric>(array: ArrayLike<T | undefined | null>): number | undefined;
|
||||
export function variance<T extends Numeric>(array: Iterable<T | undefined | null>): number | undefined;
|
||||
|
||||
/**
|
||||
* Compute an unbiased estimator of the population variance of the given array,
|
||||
* using the given accessor to convert values to numbers.
|
||||
*/
|
||||
export function variance<T>(array: ArrayLike<T>, accessor: (datum: T, index: number, array: ArrayLike<T>) => number | undefined | null): number | undefined;
|
||||
export function variance<T>(array: Iterable<T>, accessor: (datum: T, index: number, array: Iterable<T>) => number | undefined | null): number | undefined;
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// Searching Arrays
|
||||
// --------------------------------------------------------------------------------------
|
||||
|
||||
export function scan(array: ArrayLike<number>, comparator?: (a: number, b: number) => number): number | undefined;
|
||||
export function scan<T>(array: ArrayLike<T>, comparator: (a: T, b: T) => number): number | undefined;
|
||||
export function scan(array: Iterable<number>, comparator?: (a: number, b: number) => number): number | undefined;
|
||||
export function scan<T>(array: Iterable<T>, comparator: (a: T, b: T) => number): number | undefined;
|
||||
|
||||
export function bisectLeft(array: ArrayLike<number>, x: number, lo?: number, hi?: number): number;
|
||||
export function bisectLeft(array: ArrayLike<string>, x: string, lo?: number, hi?: number): number;
|
||||
@@ -173,6 +174,44 @@ export interface Bisector<T, U> {
|
||||
export function bisector<T, U>(comparator: (a: T, b: U) => number): Bisector<T, U>;
|
||||
export function bisector<T, U>(accessor: (x: T) => U): Bisector<T, U>;
|
||||
|
||||
/**
|
||||
* Rearranges items so that all items in the [left, k] are the smallest. The k-th element will have the (k - left + 1)-th smallest value in [left, right].
|
||||
*
|
||||
* @param array The array to partially sort (in place).
|
||||
* @param k The middle index for partial sorting.
|
||||
*/
|
||||
export function quickselect<T>(array: ArrayLike<T>, k: number): T[];
|
||||
|
||||
/**
|
||||
* Rearranges items so that all items in the [left, k] are the smallest. The k-th element will have the (k - left + 1)-th smallest value in [left, right].
|
||||
*
|
||||
* @param array The array to partially sort (in place).
|
||||
* @param k The middle index for partial sorting.
|
||||
* @param left The left index of the range to sort.
|
||||
*/
|
||||
export function quickselect<T>(array: ArrayLike<T>, k: number, left: number): T[];
|
||||
|
||||
/**
|
||||
* Rearranges items so that all items in the [left, k] are the smallest. The k-th element will have the (k - left + 1)-th smallest value in [left, right].
|
||||
*
|
||||
* @param array The array to partially sort (in place).
|
||||
* @param k The middle index for partial sorting.
|
||||
* @param left The left index of the range to sort.
|
||||
* @param right The right index.
|
||||
*/
|
||||
export function quickselect<T>(array: ArrayLike<T>, k: number, left: number, right: number): T[];
|
||||
|
||||
/**
|
||||
* Rearranges items so that all items in the [left, k] are the smallest. The k-th element will have the (k - left + 1)-th smallest value in [left, right].
|
||||
*
|
||||
* @param array The array to partially sort (in place).
|
||||
* @param k The middle index for partial sorting.
|
||||
* @param left The left index of the range to sort.
|
||||
* @param right The right index.
|
||||
* @param compare The compare function.
|
||||
*/
|
||||
export function quickselect<T>(array: ArrayLike<T>, k: number, left: number, right: number, compare: (a: Primitive | undefined, b: Primitive | undefined) => number): T[];
|
||||
|
||||
// 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).
|
||||
@@ -189,6 +228,22 @@ export function descending(a: Primitive | undefined, b: Primitive | undefined):
|
||||
// Transforming Arrays
|
||||
// --------------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Groups the specified array of values into a Map from key to array of value.
|
||||
* @param a The array to group.
|
||||
* @param key The key function.
|
||||
*/
|
||||
export function group<TObject, TKey>(a: Iterable<TObject>, key: (value: TObject) => TKey): Map<TKey, TObject[]>;
|
||||
|
||||
/**
|
||||
* Groups and reduces the specified array of values into a Map from key to value.
|
||||
*
|
||||
* @param a The array to group.
|
||||
* @param reduce The reduce function.
|
||||
* @param key The key function.
|
||||
*/
|
||||
export function rollup<TObject, TKey, TReduce>(a: Iterable<TObject>, reduce: (value: TObject[]) => TReduce, key: (value: TObject) => TKey): Map<TKey, TReduce>;
|
||||
|
||||
/**
|
||||
* Returns the Cartesian product of the two arrays a and b.
|
||||
* For each element i in the specified array a and each element j in the specified array b, in order,
|
||||
@@ -197,7 +252,7 @@ export function descending(a: Primitive | undefined, b: Primitive | undefined):
|
||||
* @param a First input array.
|
||||
* @param b Second input array.
|
||||
*/
|
||||
export function cross<S, T>(a: ArrayLike<S>, b: ArrayLike<T>): Array<[S, T]>;
|
||||
export function cross<S, T>(a: Iterable<S>, b: Iterable<T>): Array<[S, T]>;
|
||||
|
||||
/**
|
||||
* Returns the Cartesian product of the two arrays a and b.
|
||||
@@ -208,12 +263,12 @@ export function cross<S, T>(a: ArrayLike<S>, b: ArrayLike<T>): Array<[S, T]>;
|
||||
* @param b Second input array.
|
||||
* @param reducer A reducer function taking as input an element from "a" and "b" and returning a reduced value.
|
||||
*/
|
||||
export function cross<S, T, U>(a: ArrayLike<S>, b: ArrayLike<T>, reducer: (a: S, b: T) => U): U[];
|
||||
export function cross<S, T, U>(a: Iterable<S>, b: Iterable<T>, reducer: (a: S, b: T) => U): U[];
|
||||
|
||||
/**
|
||||
* Merges the specified arrays into a single array.
|
||||
*/
|
||||
export function merge<T>(arrays: ArrayLike<ArrayLike<T>>): T[];
|
||||
export function merge<T>(arrays: Iterable<Iterable<T>>): T[];
|
||||
|
||||
/**
|
||||
* For each adjacent pair of elements in the specified array, returns a new array of tuples of elements i and i - 1.
|
||||
@@ -221,7 +276,7 @@ export function merge<T>(arrays: ArrayLike<ArrayLike<T>>): T[];
|
||||
*
|
||||
* @param array Array of input elements
|
||||
*/
|
||||
export function pairs<T>(array: ArrayLike<T>): Array<[T, T]>;
|
||||
export function pairs<T>(array: Iterable<T>): Array<[T, T]>;
|
||||
/**
|
||||
* For each adjacent pair of elements in the specified array, in order, invokes the specified reducer function passing the element i and element i - 1.
|
||||
* Returns the resulting array of pair-wise reduced elements.
|
||||
@@ -230,7 +285,7 @@ export function pairs<T>(array: ArrayLike<T>): Array<[T, T]>;
|
||||
* @param array Array of input elements
|
||||
* @param reducer A reducer function taking as input to adjacent elements of the input array and returning a reduced value.
|
||||
*/
|
||||
export function pairs<T, U>(array: ArrayLike<T>, reducer: (a: T, b: T) => U): U[];
|
||||
export function pairs<T, U>(array: Iterable<T>, reducer: (a: T, b: T) => U): U[];
|
||||
|
||||
/**
|
||||
* Returns a permutation of the specified array using the specified array of indexes.
|
||||
@@ -351,36 +406,6 @@ export type ThresholdNumberArrayGenerator<Value extends number | undefined> =
|
||||
export type ThresholdDateArrayGenerator<Value extends Date | undefined> =
|
||||
(values: ArrayLike<Value>, min: Date, max: Date) => Value[];
|
||||
|
||||
/**
|
||||
* @deprecated Use ThresholdNumberArrayGenerator or ThresholdDateArrayGenerator.
|
||||
*/
|
||||
export type ThresholdArrayGenerator = ThresholdNumberArrayGenerator<number>;
|
||||
|
||||
/**
|
||||
* @deprecated Use `HistogramGeneratorNumber<Datum, Value>` for `number` values and `HistogramGeneratorDate<Datum, Value> for `Date` values.
|
||||
*/
|
||||
export interface HistogramGenerator<Datum, Value extends number | Date | undefined> {
|
||||
(data: ArrayLike<Datum>): Array<Bin<Datum, Value>>;
|
||||
|
||||
value(): (d: Datum, i: number, data: ArrayLike<Datum>) => Value;
|
||||
value(valueAccessor: (d: Datum, i: number, data: ArrayLike<Datum>) => Value): this;
|
||||
|
||||
domain(): (values: ArrayLike<Value>) => [Value, Value] | [undefined, undefined];
|
||||
domain(domain: [Value, Value]): this;
|
||||
domain(domainAccessor: (values: ArrayLike<Value>) => [Value, Value] | [undefined, undefined]): this;
|
||||
|
||||
/**
|
||||
* Set the array of values to be used as thresholds in determining the bins.
|
||||
*
|
||||
* Any threshold values outside the domain are ignored. The first bin.x0 is always equal to the minimum domain value,
|
||||
* and the last bin.x1 is always equal to the maximum domain value.
|
||||
*
|
||||
* @param thresholds Array of threshold values used for binning. The elements must
|
||||
* be of the same type as the materialized values of the histogram.
|
||||
*/
|
||||
thresholds(thresholds: ArrayLike<Value>): this;
|
||||
}
|
||||
|
||||
export interface HistogramCommon<Datum, Value extends number | Date | undefined> {
|
||||
(data: ArrayLike<Datum>): Array<Bin<Datum, Value>>;
|
||||
|
||||
@@ -419,9 +444,9 @@ export interface HistogramGeneratorDate<Datum, Value extends Date | undefined> e
|
||||
}
|
||||
|
||||
export interface HistogramGeneratorNumber<Datum, Value extends number | undefined> extends HistogramCommon<Datum, Value> {
|
||||
domain(): (values: ArrayLike<Value>) => [number, number] | [undefined, undefined];
|
||||
domain(): (values: Iterable<Value>) => [number, number] | [undefined, undefined];
|
||||
domain(domain: [number, number]): this;
|
||||
domain(domainAccessor: (values: ArrayLike<Value>) => [number, number] | [undefined, undefined]): this;
|
||||
domain(domainAccessor: (values: Iterable<Value>) => [number, number] | [undefined, undefined]): this;
|
||||
|
||||
thresholds(): ThresholdCountGenerator<Value> | ThresholdNumberArrayGenerator<Value>;
|
||||
/**
|
||||
@@ -475,12 +500,6 @@ export function histogram(): HistogramGeneratorNumber<number, number>;
|
||||
export function histogram<Datum, Value extends number | undefined>(): HistogramGeneratorNumber<Datum, Value>;
|
||||
export function histogram<Datum, Value extends Date | undefined>(): HistogramGeneratorDate<Datum, Value>;
|
||||
|
||||
/**
|
||||
* @deprecated Do not use Value generic which mixes number and Date types. Use either number or Date
|
||||
* (in combination with undefined, as applicable) to obtain a type-specific histogram generator.
|
||||
*/
|
||||
export function histogram<Datum, Value extends number | Date | undefined>(): HistogramGenerator<Datum, Value>;
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// Histogram Thresholds
|
||||
// --------------------------------------------------------------------------------------
|
||||
|
||||
941
types/d3-array/v1/d3-array-tests.ts
Normal file
941
types/d3-array/v1/d3-array-tests.ts
Normal file
@@ -0,0 +1,941 @@
|
||||
/**
|
||||
* Typescript definition tests for d3/d3-array module
|
||||
*
|
||||
* Note: These tests are intended to test the definitions only
|
||||
* in the sense of typing and call signature consistency. They
|
||||
* are not intended as functional tests.
|
||||
*/
|
||||
|
||||
import * as d3Array from 'd3-array';
|
||||
import { scaleTime } from 'd3-scale';
|
||||
import { timeYear } from 'd3-time';
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Preparatory Steps
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
class NumCoercible {
|
||||
a: number;
|
||||
|
||||
constructor(a: number) {
|
||||
this.a = a;
|
||||
}
|
||||
valueOf() {
|
||||
return this.a;
|
||||
}
|
||||
}
|
||||
|
||||
class MixedObject {
|
||||
num: number;
|
||||
str: string;
|
||||
numeric: NumCoercible;
|
||||
date: Date;
|
||||
|
||||
constructor(a: number, date: Date) {
|
||||
this.num = a;
|
||||
this.str = a.toString();
|
||||
this.numeric = new NumCoercible(a);
|
||||
this.date = date;
|
||||
}
|
||||
}
|
||||
|
||||
let num: number;
|
||||
let undef: undefined;
|
||||
let mixedObject: MixedObject;
|
||||
|
||||
let numOrUndefined: number | undefined;
|
||||
let strOrUndefined: string | undefined;
|
||||
let numericOrUndefined: NumCoercible | undefined;
|
||||
let dateOrUndefined: Date | undefined;
|
||||
let mixedObjectOrUndefined: MixedObject | undefined;
|
||||
let numOrUndefinedExtent: [number, number] | [undefined, undefined];
|
||||
let strOrUndefinedExtent: [string, string] | [undefined, undefined];
|
||||
let numericOrUndefinedExtent: [NumCoercible, NumCoercible] | [undefined, undefined];
|
||||
let dateMixedOrUndefined: [Date, Date] | [undefined, undefined];
|
||||
let mixedOrUndefinedExtent: [d3Array.Primitive | NumCoercible, d3Array.Primitive | NumCoercible] | [undefined, undefined];
|
||||
let dateOrUndefinedExtent: [Date, Date] | [undefined, undefined];
|
||||
|
||||
let numbersArray = [10, 20, 30, 40, 50];
|
||||
const numbersOrUndefinedArray = [10, 20, undefined, null, 40, 50];
|
||||
let stringyNumbersArray = ['10', '20', '30', '40', '50'];
|
||||
const numericArray = [new NumCoercible(10), new NumCoercible(20), new NumCoercible(30), new NumCoercible(40), new NumCoercible(50)];
|
||||
let dateArray = [new Date(2016, 6, 1), new Date(2016, 7, 30), new Date(2015, 3, 15)];
|
||||
|
||||
const mixedObjectArray = [
|
||||
new MixedObject(10, new Date(2016, 6, 1)),
|
||||
new MixedObject(20, new Date(2016, 7, 30)),
|
||||
new MixedObject(30, new Date(2015, 3, 15)),
|
||||
new MixedObject(40, new Date(2014, 3, 15)),
|
||||
new MixedObject(50, new Date(2017, 4, 15))
|
||||
];
|
||||
|
||||
const mixedObjectOrUndefinedArray = [...mixedObjectArray, undefined];
|
||||
const mixedObjectArrayLike = mixedObjectArray as ArrayLike<MixedObject>;
|
||||
|
||||
let typedArray = Uint8Array.from(numbersArray);
|
||||
let readonlyNumbersArray = numbersArray as ReadonlyArray<number>;
|
||||
const readonlyNumbersOrUndefinedArray = numbersOrUndefinedArray as ReadonlyArray<number>;
|
||||
const readonlyStringyNumbersArray = stringyNumbersArray as ReadonlyArray<string>;
|
||||
const readonlyNumericArray = numericArray as ReadonlyArray<NumCoercible>;
|
||||
const readonlyDateArray = dateArray as ReadonlyArray<Date>;
|
||||
const readonlyMixedObjectArray = mixedObjectArray as ReadonlyArray<MixedObject>;
|
||||
const readonlyMixedObjectOrUndefinedArray = mixedObjectOrUndefinedArray as ReadonlyArray<MixedObject | undefined>;
|
||||
|
||||
function accessorMixedObjectToNum(datum: MixedObject, index: number, array: ArrayLike<MixedObject>): number {
|
||||
return datum.num;
|
||||
}
|
||||
|
||||
function accessorMixedObjectToStr(datum: MixedObject, index: number, array: ArrayLike<MixedObject>): string {
|
||||
return datum.str;
|
||||
}
|
||||
|
||||
function accessorMixedObjectToNumeric(datum: MixedObject, index: number, array: ArrayLike<MixedObject>): NumCoercible {
|
||||
return datum.numeric;
|
||||
}
|
||||
|
||||
function accessorMixedObjectToDate(datum: MixedObject, index: number, array: ArrayLike<MixedObject>): Date {
|
||||
return datum.date;
|
||||
}
|
||||
|
||||
function accessorMixedObjectToNumOrUndefined(datum: MixedObject | undefined, index: number, array: ArrayLike<MixedObject | undefined>): number | undefined | null {
|
||||
return datum ? datum.num : undefined;
|
||||
}
|
||||
|
||||
function accessorMixedObjectToStrOrUndefined(datum: MixedObject | undefined, index: number, array: ArrayLike<MixedObject>): string | undefined | null {
|
||||
return datum ? datum.str : undefined;
|
||||
}
|
||||
|
||||
function accessorLikeMixedObjectToNum(datum: MixedObject, index: number, array: ArrayLike<MixedObject>): number {
|
||||
return datum.num;
|
||||
}
|
||||
|
||||
function accessorLikeMixedObjectToStr(datum: MixedObject, index: number, array: ArrayLike<MixedObject>): string {
|
||||
return datum.str;
|
||||
}
|
||||
|
||||
function accessorLikeMixedObjectToNumeric(datum: MixedObject, index: number, array: ArrayLike<MixedObject>): NumCoercible {
|
||||
return datum.numeric;
|
||||
}
|
||||
|
||||
function accessorLikeMixedObjectToDate(datum: MixedObject, index: number, array: ArrayLike<MixedObject>): Date {
|
||||
return datum.date;
|
||||
}
|
||||
|
||||
function accessorLikeMixedObjectToNumOrUndefined(datum: MixedObject | undefined, index: number, array: ArrayLike<MixedObject | undefined>): number | undefined | null {
|
||||
return datum ? datum.num : undefined;
|
||||
}
|
||||
|
||||
function accessorLikeMixedObjectToStrOrUndefined(datum: MixedObject | undefined, index: number, array: ArrayLike<MixedObject>): string | undefined | null {
|
||||
return datum ? datum.str : undefined;
|
||||
}
|
||||
|
||||
function accessorReadOnlyMixedObjectToNumOrUndefined(datum: MixedObject | undefined, index: number, array: ArrayLike<MixedObject | undefined>): number | undefined | null {
|
||||
return datum ? datum.num : undefined;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Test Statistics
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// max() -----------------------------------------------------------------------
|
||||
|
||||
// without accessors
|
||||
|
||||
numOrUndefined = d3Array.max(numbersArray);
|
||||
strOrUndefined = d3Array.max(stringyNumbersArray);
|
||||
numericOrUndefined = d3Array.max(numericArray);
|
||||
dateOrUndefined = d3Array.max(dateArray);
|
||||
|
||||
// ArrayLike test cases
|
||||
|
||||
numOrUndefined = d3Array.max(typedArray);
|
||||
numOrUndefined = d3Array.max(readonlyNumbersOrUndefinedArray);
|
||||
strOrUndefined = d3Array.max(readonlyStringyNumbersArray);
|
||||
numericOrUndefined = d3Array.max(readonlyNumericArray);
|
||||
dateOrUndefined = d3Array.max(readonlyDateArray);
|
||||
|
||||
// with accessors
|
||||
|
||||
numOrUndefined = d3Array.max(mixedObjectArray, accessorMixedObjectToNum);
|
||||
strOrUndefined = d3Array.max(mixedObjectArray, accessorMixedObjectToStr);
|
||||
numericOrUndefined = d3Array.max(mixedObjectArray, accessorMixedObjectToNumeric);
|
||||
dateOrUndefined = d3Array.max(mixedObjectArray, accessorMixedObjectToDate);
|
||||
numOrUndefined = d3Array.max(mixedObjectArray, accessorMixedObjectToNumOrUndefined);
|
||||
strOrUndefined = d3Array.max(mixedObjectArray, accessorMixedObjectToStrOrUndefined);
|
||||
numOrUndefined = d3Array.max(readonlyMixedObjectOrUndefinedArray, accessorReadOnlyMixedObjectToNumOrUndefined);
|
||||
|
||||
numOrUndefined = d3Array.max(mixedObjectArrayLike, accessorLikeMixedObjectToNum);
|
||||
numOrUndefined = d3Array.max(mixedObjectArray, accessorLikeMixedObjectToNum);
|
||||
numOrUndefined = d3Array.max(mixedObjectArray, accessorReadOnlyMixedObjectToNumOrUndefined);
|
||||
|
||||
numOrUndefined = d3Array.max(mixedObjectArray, (d) => {
|
||||
const l: MixedObject = d;
|
||||
return l.num;
|
||||
});
|
||||
|
||||
strOrUndefined = d3Array.max(mixedObjectArray, (d) => {
|
||||
const l: MixedObject = d;
|
||||
return l.str;
|
||||
});
|
||||
|
||||
// $ExpectError
|
||||
numOrUndefined = d3Array.max(readonlyNumbersArray, (d, i, a) => { a.push(3); return 0; });
|
||||
|
||||
// min() -----------------------------------------------------------------------
|
||||
|
||||
// without accessors
|
||||
|
||||
numOrUndefined = d3Array.min(numbersArray);
|
||||
strOrUndefined = d3Array.min(stringyNumbersArray);
|
||||
numericOrUndefined = d3Array.min(numericArray);
|
||||
dateOrUndefined = d3Array.min(dateArray);
|
||||
|
||||
// ArrayLike test cases
|
||||
|
||||
numOrUndefined = d3Array.min(typedArray);
|
||||
numOrUndefined = d3Array.min(readonlyNumbersOrUndefinedArray);
|
||||
strOrUndefined = d3Array.min(readonlyStringyNumbersArray);
|
||||
numericOrUndefined = d3Array.min(readonlyNumericArray);
|
||||
dateOrUndefined = d3Array.min(readonlyDateArray);
|
||||
|
||||
// with accessors
|
||||
|
||||
numOrUndefined = d3Array.min(mixedObjectArray, accessorMixedObjectToNum);
|
||||
strOrUndefined = d3Array.min(mixedObjectArray, accessorMixedObjectToStr);
|
||||
numericOrUndefined = d3Array.min(mixedObjectArray, accessorMixedObjectToNumeric);
|
||||
dateOrUndefined = d3Array.min(mixedObjectArray, accessorMixedObjectToDate);
|
||||
numOrUndefined = d3Array.min(mixedObjectArray, accessorMixedObjectToNumOrUndefined);
|
||||
strOrUndefined = d3Array.min(mixedObjectArray, accessorMixedObjectToStrOrUndefined);
|
||||
numOrUndefined = d3Array.min(readonlyMixedObjectOrUndefinedArray, accessorReadOnlyMixedObjectToNumOrUndefined);
|
||||
|
||||
// extent() --------------------------------------------------------------------
|
||||
|
||||
// without accessors
|
||||
|
||||
numOrUndefinedExtent = d3Array.extent(numbersArray);
|
||||
strOrUndefinedExtent = d3Array.extent(stringyNumbersArray);
|
||||
numericOrUndefinedExtent = d3Array.extent(numericArray);
|
||||
dateOrUndefinedExtent = d3Array.extent(dateArray);
|
||||
|
||||
// ArrayLike test cases
|
||||
|
||||
numOrUndefinedExtent = d3Array.extent(typedArray);
|
||||
numOrUndefinedExtent = d3Array.extent(readonlyNumbersOrUndefinedArray);
|
||||
strOrUndefinedExtent = d3Array.extent(readonlyStringyNumbersArray);
|
||||
numericOrUndefinedExtent = d3Array.extent(readonlyNumericArray);
|
||||
dateOrUndefinedExtent = d3Array.extent(readonlyDateArray);
|
||||
|
||||
// with accessors
|
||||
|
||||
numOrUndefinedExtent = d3Array.extent(mixedObjectArray, accessorMixedObjectToNum);
|
||||
strOrUndefinedExtent = d3Array.extent(mixedObjectArray, accessorMixedObjectToStr);
|
||||
mixedOrUndefinedExtent = d3Array.extent(mixedObjectArray, accessorMixedObjectToNumeric);
|
||||
dateMixedOrUndefined = d3Array.extent(mixedObjectArray, accessorMixedObjectToDate);
|
||||
numOrUndefinedExtent = d3Array.extent(mixedObjectArray, accessorMixedObjectToNumOrUndefined);
|
||||
strOrUndefinedExtent = d3Array.extent(mixedObjectArray, accessorMixedObjectToStrOrUndefined);
|
||||
numOrUndefinedExtent = d3Array.extent(readonlyMixedObjectOrUndefinedArray, accessorReadOnlyMixedObjectToNumOrUndefined);
|
||||
|
||||
// mean() ----------------------------------------------------------------------
|
||||
|
||||
numOrUndefined = d3Array.mean(numbersArray);
|
||||
numOrUndefined = d3Array.mean(numericArray);
|
||||
numOrUndefined = d3Array.mean(numbersOrUndefinedArray);
|
||||
|
||||
numOrUndefined = d3Array.mean(typedArray);
|
||||
numOrUndefined = d3Array.mean(readonlyNumbersOrUndefinedArray);
|
||||
numOrUndefined = d3Array.mean(readonlyNumericArray);
|
||||
numOrUndefined = d3Array.mean(readonlyNumbersOrUndefinedArray);
|
||||
|
||||
numOrUndefined = d3Array.mean(mixedObjectArray, accessorMixedObjectToNum);
|
||||
numOrUndefined = d3Array.mean(mixedObjectOrUndefinedArray, accessorMixedObjectToNumOrUndefined);
|
||||
numOrUndefined = d3Array.mean(readonlyMixedObjectOrUndefinedArray, accessorReadOnlyMixedObjectToNumOrUndefined);
|
||||
|
||||
// median() --------------------------------------------------------------------
|
||||
|
||||
numOrUndefined = d3Array.median(numbersArray);
|
||||
numOrUndefined = d3Array.median(numericArray);
|
||||
numOrUndefined = d3Array.median(numbersOrUndefinedArray);
|
||||
|
||||
numOrUndefined = d3Array.median(typedArray);
|
||||
numOrUndefined = d3Array.median(readonlyNumbersArray);
|
||||
numOrUndefined = d3Array.median(readonlyNumericArray);
|
||||
numOrUndefined = d3Array.median(readonlyNumbersOrUndefinedArray);
|
||||
|
||||
numOrUndefined = d3Array.median(mixedObjectArray, accessorMixedObjectToNum);
|
||||
numOrUndefined = d3Array.median(mixedObjectOrUndefinedArray, accessorMixedObjectToNumOrUndefined);
|
||||
numOrUndefined = d3Array.median(readonlyMixedObjectOrUndefinedArray, accessorReadOnlyMixedObjectToNumOrUndefined);
|
||||
|
||||
// quantile() ------------------------------------------------------------------
|
||||
|
||||
numOrUndefined = d3Array.quantile(numbersArray, 0.5);
|
||||
numOrUndefined = d3Array.quantile(numericArray, 0.5);
|
||||
numOrUndefined = d3Array.quantile(numbersOrUndefinedArray, 0.5);
|
||||
|
||||
numOrUndefined = d3Array.quantile(typedArray, 0.5);
|
||||
numOrUndefined = d3Array.quantile(readonlyNumbersArray, 0.5);
|
||||
numOrUndefined = d3Array.quantile(readonlyNumericArray, 0.5);
|
||||
numOrUndefined = d3Array.quantile(readonlyNumbersOrUndefinedArray, 0.5);
|
||||
|
||||
numOrUndefined = d3Array.quantile(mixedObjectArray, 0.5, accessorMixedObjectToNum);
|
||||
numOrUndefined = d3Array.quantile(mixedObjectOrUndefinedArray, 0.5, accessorMixedObjectToNumOrUndefined);
|
||||
numOrUndefined = d3Array.quantile(readonlyMixedObjectOrUndefinedArray, 0.5, accessorReadOnlyMixedObjectToNumOrUndefined);
|
||||
|
||||
// sum() -----------------------------------------------------------------------
|
||||
|
||||
numOrUndefined = d3Array.sum(numbersArray);
|
||||
numOrUndefined = d3Array.sum(numericArray);
|
||||
numOrUndefined = d3Array.sum(numbersOrUndefinedArray);
|
||||
|
||||
numOrUndefined = d3Array.sum(typedArray);
|
||||
numOrUndefined = d3Array.sum(readonlyNumbersArray);
|
||||
numOrUndefined = d3Array.sum(readonlyNumericArray);
|
||||
numOrUndefined = d3Array.sum(readonlyNumbersOrUndefinedArray);
|
||||
|
||||
numOrUndefined = d3Array.sum(mixedObjectArray, accessorMixedObjectToNum);
|
||||
numOrUndefined = d3Array.sum(mixedObjectOrUndefinedArray, accessorMixedObjectToNumOrUndefined);
|
||||
numOrUndefined = d3Array.sum(readonlyMixedObjectOrUndefinedArray, accessorReadOnlyMixedObjectToNumOrUndefined);
|
||||
|
||||
// deviation() -----------------------------------------------------------------
|
||||
|
||||
numOrUndefined = d3Array.deviation(numbersArray);
|
||||
numOrUndefined = d3Array.deviation(numericArray);
|
||||
numOrUndefined = d3Array.deviation(numbersOrUndefinedArray);
|
||||
|
||||
numOrUndefined = d3Array.deviation(typedArray);
|
||||
numOrUndefined = d3Array.deviation(readonlyNumbersArray);
|
||||
numOrUndefined = d3Array.deviation(readonlyNumericArray);
|
||||
numOrUndefined = d3Array.deviation(readonlyNumbersOrUndefinedArray);
|
||||
|
||||
numOrUndefined = d3Array.deviation(mixedObjectArray, accessorMixedObjectToNum);
|
||||
numOrUndefined = d3Array.deviation(mixedObjectOrUndefinedArray, accessorMixedObjectToNumOrUndefined);
|
||||
numOrUndefined = d3Array.deviation(readonlyMixedObjectOrUndefinedArray, accessorReadOnlyMixedObjectToNumOrUndefined);
|
||||
|
||||
// variance() ------------------------------------------------------------------
|
||||
|
||||
numOrUndefined = d3Array.variance(numbersArray);
|
||||
numOrUndefined = d3Array.variance(numericArray);
|
||||
numOrUndefined = d3Array.variance(numbersOrUndefinedArray);
|
||||
|
||||
numOrUndefined = d3Array.variance(typedArray);
|
||||
numOrUndefined = d3Array.variance(readonlyNumbersArray);
|
||||
numOrUndefined = d3Array.variance(readonlyNumericArray);
|
||||
numOrUndefined = d3Array.variance(readonlyNumbersOrUndefinedArray);
|
||||
|
||||
numOrUndefined = d3Array.variance(mixedObjectArray, accessorMixedObjectToNum);
|
||||
numOrUndefined = d3Array.variance(mixedObjectOrUndefinedArray, accessorMixedObjectToNumOrUndefined);
|
||||
numOrUndefined = d3Array.variance(readonlyMixedObjectOrUndefinedArray, accessorReadOnlyMixedObjectToNumOrUndefined);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Test Searching Arrays
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
numbersArray = [0, 2, 3, 4, 7, 8];
|
||||
stringyNumbersArray = ['0', '2', '3', '4', '7', '8'];
|
||||
dateArray = [new Date(2010, 1, 1), new Date(2011, 1, 1), new Date(2012, 1, 1), new Date(2013, 1, 1)];
|
||||
typedArray = Uint8Array.from(numbersArray);
|
||||
|
||||
// scan() ----------------------------------------------------------------------
|
||||
|
||||
numOrUndefined = d3Array.scan(numbersArray);
|
||||
numOrUndefined = d3Array.scan(typedArray);
|
||||
numOrUndefined = d3Array.scan(readonlyNumbersArray);
|
||||
|
||||
numOrUndefined = d3Array.scan(mixedObjectArray, (a, b) => {
|
||||
const aElem: MixedObject = a;
|
||||
const bElem: MixedObject = b;
|
||||
return a.num - b.num;
|
||||
});
|
||||
|
||||
numOrUndefined = d3Array.scan(readonlyMixedObjectArray, (a, b) => {
|
||||
const aElem: MixedObject = a;
|
||||
const bElem: MixedObject = b;
|
||||
return a.num - b.num;
|
||||
});
|
||||
|
||||
numOrUndefined = d3Array.scan(mixedObjectOrUndefinedArray, (a, b) => {
|
||||
const aElem: MixedObject | undefined = a;
|
||||
const bElem: MixedObject | undefined = b;
|
||||
return a && b ? a.num - b.num : NaN;
|
||||
});
|
||||
|
||||
numOrUndefined = d3Array.scan(readonlyMixedObjectOrUndefinedArray, (a, b) => {
|
||||
const aElem: MixedObject | undefined = a;
|
||||
const bElem: MixedObject | undefined = b;
|
||||
return a && b ? a.num - b.num : NaN;
|
||||
});
|
||||
|
||||
// bisectLeft() ----------------------------------------------------------------
|
||||
|
||||
num = d3Array.bisectLeft(numbersArray, 4);
|
||||
num = d3Array.bisectLeft(numbersArray, 4, 1);
|
||||
num = d3Array.bisectLeft(numbersArray, 4, 1, 4);
|
||||
|
||||
num = d3Array.bisectLeft(stringyNumbersArray, '21');
|
||||
num = d3Array.bisectLeft(stringyNumbersArray, '21', 1);
|
||||
num = d3Array.bisectLeft(stringyNumbersArray, '21', 1, 4);
|
||||
|
||||
num = d3Array.bisectLeft(dateArray, new Date(2011, 2, 1));
|
||||
num = d3Array.bisectLeft(dateArray, new Date(2011, 2, 1), 1);
|
||||
num = d3Array.bisectLeft(dateArray, new Date(2011, 2, 1), 1, 2);
|
||||
|
||||
num = d3Array.bisectLeft(typedArray, 4);
|
||||
num = d3Array.bisectLeft(typedArray, 4, 1);
|
||||
num = d3Array.bisectLeft(typedArray, 4, 1, 4);
|
||||
|
||||
num = d3Array.bisectLeft(readonlyNumbersArray, 4);
|
||||
num = d3Array.bisectLeft(readonlyNumbersArray, 4, 1);
|
||||
num = d3Array.bisectLeft(readonlyNumbersArray, 4, 1, 4);
|
||||
|
||||
num = d3Array.bisectLeft(readonlyStringyNumbersArray, '21');
|
||||
num = d3Array.bisectLeft(readonlyStringyNumbersArray, '21', 1);
|
||||
num = d3Array.bisectLeft(readonlyStringyNumbersArray, '21', 1, 4);
|
||||
|
||||
num = d3Array.bisectLeft(readonlyDateArray, new Date(2011, 2, 1));
|
||||
num = d3Array.bisectLeft(readonlyDateArray, new Date(2011, 2, 1), 1);
|
||||
num = d3Array.bisectLeft(readonlyDateArray, new Date(2011, 2, 1), 1, 2);
|
||||
|
||||
// bisectRight() ---------------------------------------------------------------
|
||||
|
||||
num = d3Array.bisectRight(numbersArray, 4);
|
||||
num = d3Array.bisectRight(numbersArray, 4, 1);
|
||||
num = d3Array.bisectRight(numbersArray, 4, 1, 4);
|
||||
|
||||
num = d3Array.bisectRight(stringyNumbersArray, '21');
|
||||
num = d3Array.bisectRight(stringyNumbersArray, '21', 1);
|
||||
num = d3Array.bisectRight(stringyNumbersArray, '21', 1, 4);
|
||||
|
||||
num = d3Array.bisectRight(dateArray, new Date(2011, 2, 1));
|
||||
num = d3Array.bisectRight(dateArray, new Date(2011, 2, 1), 1);
|
||||
num = d3Array.bisectRight(dateArray, new Date(2011, 2, 1), 1, 2);
|
||||
|
||||
num = d3Array.bisectRight(typedArray, 4);
|
||||
num = d3Array.bisectRight(typedArray, 4, 1);
|
||||
num = d3Array.bisectRight(typedArray, 4, 1, 4);
|
||||
|
||||
num = d3Array.bisectRight(readonlyNumbersArray, 4);
|
||||
num = d3Array.bisectRight(readonlyNumbersArray, 4, 1);
|
||||
num = d3Array.bisectRight(readonlyNumbersArray, 4, 1, 4);
|
||||
|
||||
num = d3Array.bisectRight(readonlyStringyNumbersArray, '21');
|
||||
num = d3Array.bisectRight(readonlyStringyNumbersArray, '21', 1);
|
||||
num = d3Array.bisectRight(readonlyStringyNumbersArray, '21', 1, 4);
|
||||
|
||||
num = d3Array.bisectRight(readonlyDateArray, new Date(2011, 2, 1));
|
||||
num = d3Array.bisectRight(readonlyDateArray, new Date(2011, 2, 1), 1);
|
||||
num = d3Array.bisectRight(readonlyDateArray, new Date(2011, 2, 1), 1, 2);
|
||||
|
||||
// bisect() --------------------------------------------------------------------
|
||||
|
||||
num = d3Array.bisect(numbersArray, 4);
|
||||
num = d3Array.bisect(numbersArray, 4, 1);
|
||||
num = d3Array.bisect(numbersArray, 4, 1, 4);
|
||||
|
||||
num = d3Array.bisect(stringyNumbersArray, '21');
|
||||
num = d3Array.bisect(stringyNumbersArray, '21', 1);
|
||||
num = d3Array.bisect(stringyNumbersArray, '21', 1, 4);
|
||||
|
||||
num = d3Array.bisect(dateArray, new Date(2011, 2, 1));
|
||||
num = d3Array.bisect(dateArray, new Date(2011, 2, 1), 1);
|
||||
num = d3Array.bisect(dateArray, new Date(2011, 2, 1), 1, 2);
|
||||
|
||||
num = d3Array.bisect(typedArray, 4);
|
||||
num = d3Array.bisect(typedArray, 4, 1);
|
||||
num = d3Array.bisect(typedArray, 4, 1, 4);
|
||||
|
||||
num = d3Array.bisect(readonlyNumbersArray, 4);
|
||||
num = d3Array.bisect(readonlyNumbersArray, 4, 1);
|
||||
num = d3Array.bisect(readonlyNumbersArray, 4, 1, 4);
|
||||
|
||||
num = d3Array.bisect(readonlyStringyNumbersArray, '21');
|
||||
num = d3Array.bisect(readonlyStringyNumbersArray, '21', 1);
|
||||
num = d3Array.bisect(readonlyStringyNumbersArray, '21', 1, 4);
|
||||
|
||||
num = d3Array.bisect(readonlyDateArray, new Date(2011, 2, 1));
|
||||
num = d3Array.bisect(readonlyDateArray, new Date(2011, 2, 1), 1);
|
||||
num = d3Array.bisect(readonlyDateArray, new Date(2011, 2, 1), 1, 2);
|
||||
|
||||
// bisector() ------------------------------------------------------------------
|
||||
|
||||
mixedObjectArray.sort((a, b) => a.date.valueOf() - b.date.valueOf());
|
||||
|
||||
let mixedObjectDateBisectorObject: d3Array.Bisector<MixedObject, Date>;
|
||||
|
||||
// define using accessor
|
||||
mixedObjectDateBisectorObject = d3Array.bisector<MixedObject, Date>(el => el.date);
|
||||
|
||||
// define using comparator
|
||||
mixedObjectDateBisectorObject = d3Array.bisector<MixedObject, Date>((el, x) =>
|
||||
el.date.valueOf() - x.valueOf());
|
||||
|
||||
// bisect left
|
||||
num = mixedObjectDateBisectorObject.left(mixedObjectArray, new Date(2015, 3, 14));
|
||||
num = mixedObjectDateBisectorObject.left(mixedObjectArray, new Date(2015, 3, 14), 1);
|
||||
num = mixedObjectDateBisectorObject.left(mixedObjectArray, new Date(2015, 3, 14), 3, 4);
|
||||
|
||||
num = mixedObjectDateBisectorObject.left(readonlyMixedObjectArray, new Date(2015, 3, 14));
|
||||
num = mixedObjectDateBisectorObject.left(readonlyMixedObjectArray, new Date(2015, 3, 14), 1);
|
||||
num = mixedObjectDateBisectorObject.left(readonlyMixedObjectArray, new Date(2015, 3, 14), 3, 4);
|
||||
|
||||
// bisect right
|
||||
num = mixedObjectDateBisectorObject.right(mixedObjectArray, new Date(2015, 3, 14));
|
||||
num = mixedObjectDateBisectorObject.right(mixedObjectArray, new Date(2015, 3, 14), 1);
|
||||
num = mixedObjectDateBisectorObject.right(mixedObjectArray, new Date(2015, 3, 14), 3, 4);
|
||||
|
||||
num = mixedObjectDateBisectorObject.right(readonlyMixedObjectArray, new Date(2015, 3, 14));
|
||||
num = mixedObjectDateBisectorObject.right(readonlyMixedObjectArray, new Date(2015, 3, 14), 1);
|
||||
num = mixedObjectDateBisectorObject.right(readonlyMixedObjectArray, new Date(2015, 3, 14), 3, 4);
|
||||
|
||||
// ascending() -----------------------------------------------------------------
|
||||
|
||||
num = d3Array.ascending(undefined, 20);
|
||||
num = d3Array.ascending(10, 20);
|
||||
num = d3Array.ascending('10', '20');
|
||||
num = d3Array.ascending(new Date(2016, 6, 13), new Date(2016, 6, 14));
|
||||
|
||||
// descending() ----------------------------------------------------------------
|
||||
|
||||
num = d3Array.descending(undefined, 20);
|
||||
num = d3Array.descending(10, 20);
|
||||
num = d3Array.descending('10', '20');
|
||||
num = d3Array.descending(new Date(2016, 6, 13), new Date(2016, 6, 14));
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Test Transforming Arrays
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// merge() ---------------------------------------------------------------------
|
||||
|
||||
const testArray1 = [
|
||||
new MixedObject(10, new Date(2016, 6, 1)),
|
||||
new MixedObject(20, new Date(2016, 7, 30)),
|
||||
new MixedObject(30, new Date(2015, 3, 15)),
|
||||
new MixedObject(40, new Date(2014, 3, 15)),
|
||||
new MixedObject(50, new Date(2017, 4, 15))
|
||||
];
|
||||
|
||||
const testArray2 = [
|
||||
new MixedObject(40, new Date(2016, 3, 1)),
|
||||
new MixedObject(50, new Date(2016, 9, 30)),
|
||||
];
|
||||
|
||||
let testArrays: MixedObject[][] = [testArray1, testArray2];
|
||||
|
||||
const readonlyTestArray1 = testArray1 as ReadonlyArray<MixedObject>;
|
||||
const readonlyTestArray2 = testArray2 as ReadonlyArray<MixedObject>;
|
||||
const readonlyTestArrays = [testArray1, testArray2] as ReadonlyArray<ReadonlyArray<MixedObject>>;
|
||||
|
||||
let mergedArray: MixedObject[];
|
||||
|
||||
mergedArray = d3Array.merge(testArrays); // inferred type
|
||||
mergedArray = d3Array.merge<MixedObject>(testArrays); // explicit type
|
||||
// $ExpectError
|
||||
mergedArray = d3Array.merge<MixedObject>([[10, 40, 30], [15, 30]]); // fails, type mismatch
|
||||
// $ExpectError
|
||||
mergedArray = d3Array.merge([testArray1, [15, 30]]); // fails, type mismatch
|
||||
|
||||
mergedArray = d3Array.merge(readonlyTestArrays); // inferred type
|
||||
mergedArray = d3Array.merge<MixedObject>(readonlyTestArrays); // explicit type
|
||||
|
||||
// cross() ---------------------------------------------------------------------
|
||||
|
||||
let crossed: Array<[string, number]>;
|
||||
|
||||
const chars = ['x', 'y'];
|
||||
const nums = [1, 2];
|
||||
|
||||
crossed = d3Array.cross(chars, nums);
|
||||
crossed = d3Array.cross<string, number>(chars, nums);
|
||||
|
||||
let strArray: string[] = d3Array.cross<number, number, string>([2, 3], [5, 6], (a, b) => (a + b) + 'px');
|
||||
strArray = d3Array.cross([2, 3], [5, 6], (a, b) => {
|
||||
const aa: number = a;
|
||||
const bb: number = b;
|
||||
return (aa + bb) + 'px';
|
||||
});
|
||||
|
||||
const readonlyChars = chars as ReadonlyArray<string>;
|
||||
const readonlyNums = new Uint8Array(nums);
|
||||
|
||||
crossed = d3Array.cross(readonlyChars, readonlyNums);
|
||||
crossed = d3Array.cross<string, number>(readonlyChars, readonlyNums);
|
||||
|
||||
strArray = d3Array.cross<number, number, string>([2, 3] as ReadonlyArray<number>, new Uint8ClampedArray([5, 6]), (a, b) => (a + b) + 'px');
|
||||
strArray = d3Array.cross([2, 3] as ReadonlyArray<number>, new Uint8ClampedArray([5, 6]), (a, b) => {
|
||||
const aa: number = a;
|
||||
const bb: number = b;
|
||||
return (aa + bb) + 'px';
|
||||
});
|
||||
|
||||
d3Array.cross(new Uint8Array([1, 2, 3, 4, 5]), new Uint8Array([10, 20, 30, 40, 50]));
|
||||
|
||||
// pairs() ---------------------------------------------------------------------
|
||||
|
||||
let pairs: Array<[MixedObject, MixedObject]>;
|
||||
|
||||
pairs = d3Array.pairs(mergedArray);
|
||||
|
||||
numbersArray = d3Array.pairs<MixedObject, number>(mergedArray, (a, b) => b.num - a.num);
|
||||
numbersArray = d3Array.pairs(mergedArray, (a, b) => {
|
||||
const aa: MixedObject = a;
|
||||
const bb: MixedObject = b;
|
||||
return bb.num - aa.num;
|
||||
});
|
||||
|
||||
const readonlyMergedArray = mergedArray as ReadonlyArray<MixedObject>;
|
||||
pairs = d3Array.pairs(readonlyMergedArray);
|
||||
|
||||
numbersArray = d3Array.pairs<MixedObject, number>(readonlyMergedArray, (a, b) => b.num - a.num);
|
||||
numbersArray = d3Array.pairs(readonlyMergedArray, (a, b) => {
|
||||
const aa: MixedObject = a;
|
||||
const bb: MixedObject = b;
|
||||
return bb.num - aa.num;
|
||||
});
|
||||
|
||||
// permute() -------------------------------------------------------------------
|
||||
|
||||
// getting a permutation of array elements
|
||||
mergedArray = d3Array.permute(mergedArray, [1, 0, 2, 5, 3, 4, 6]);
|
||||
mergedArray = d3Array.permute(readonlyMergedArray, [1, 0, 2, 5, 3, 4, 6]);
|
||||
mergedArray = d3Array.permute(readonlyMergedArray, nums);
|
||||
|
||||
// Getting an ordered array with object properties
|
||||
|
||||
const testObject = {
|
||||
val: 10,
|
||||
name: 'Test',
|
||||
when: new Date(),
|
||||
more: [10, 30, 40]
|
||||
};
|
||||
|
||||
const p1: Array<number | string | Date | number[]> = d3Array.permute(testObject, ['name', 'val', 'when', 'more']);
|
||||
const p2: Array<number | string | Date | number[]> = d3Array.permute(testObject, ['when', 'more']);
|
||||
// $ExpectError
|
||||
const p3 = d3Array.permute(testObject, ['when', 'unknown']);
|
||||
|
||||
// range() ---------------------------------------------------------------------
|
||||
|
||||
numbersArray = d3Array.range(10);
|
||||
numbersArray = d3Array.range(1, 10);
|
||||
numbersArray = d3Array.range(1, 10, 0.5);
|
||||
|
||||
// shuffle() -------------------------------------------------------------------
|
||||
|
||||
mergedArray = d3Array.shuffle(mergedArray);
|
||||
mergedArray = d3Array.shuffle(mergedArray, 1);
|
||||
mergedArray = d3Array.shuffle(mergedArray, 1, 3);
|
||||
// $ExpectError
|
||||
mergedArray = d3Array.shuffle(readonlyMergedArray); // fails, shuffle mutates input array in-place
|
||||
|
||||
// Test each TypedArray explicitly. Can't use ArrayLike in this case because shuffle is mutable and ArrayLike would include ReadonlyArray
|
||||
const resultInt8: Int8Array = d3Array.shuffle(new Int8Array(numbersArray));
|
||||
const resultUint8: Uint8Array = d3Array.shuffle(new Uint8Array(numbersArray));
|
||||
const resultUint8Clamped: Uint8ClampedArray = d3Array.shuffle(new Uint8ClampedArray(numbersArray));
|
||||
const resultInt16: Int16Array = d3Array.shuffle(new Int16Array(numbersArray));
|
||||
const resultUint6: Uint16Array = d3Array.shuffle(new Uint16Array(numbersArray));
|
||||
const resultInt32: Int32Array = d3Array.shuffle(new Int32Array(numbersArray));
|
||||
const resultUint32: Uint32Array = d3Array.shuffle(new Uint32Array(numbersArray));
|
||||
const resultFloat32: Float32Array = d3Array.shuffle(new Float32Array(numbersArray));
|
||||
const resultFloat64: Float64Array = d3Array.shuffle(new Float64Array(numbersArray));
|
||||
|
||||
// ticks() ---------------------------------------------------------------------
|
||||
|
||||
numbersArray = d3Array.ticks(1, 10, 5);
|
||||
|
||||
// tickIncrement() ------------------------------------------------------------------
|
||||
|
||||
let numDiff: number = d3Array.tickIncrement(1, 10, 5);
|
||||
|
||||
// tickStep() ------------------------------------------------------------------
|
||||
|
||||
numDiff = d3Array.tickStep(1, 10, 5);
|
||||
|
||||
// transpose() -----------------------------------------------------------------
|
||||
|
||||
testArrays = d3Array.transpose([testArray1, testArray2]);
|
||||
testArrays = d3Array.transpose([readonlyTestArray1, readonlyTestArray2] as ReadonlyArray<ReadonlyArray<MixedObject>>);
|
||||
|
||||
// zip() -----------------------------------------------------------------------
|
||||
|
||||
testArrays = d3Array.zip(testArray1, testArray2);
|
||||
testArrays = d3Array.zip(readonlyTestArray1, readonlyTestArray2);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Test Histogram
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
const timeScale = scaleTime();
|
||||
|
||||
// Create histogram generator ==================================================
|
||||
|
||||
// number - number
|
||||
let histoNumber_Number: d3Array.HistogramGeneratorNumber<number, number>;
|
||||
histoNumber_Number = d3Array.histogram();
|
||||
histoNumber_Number = d3Array.histogram<number, number>();
|
||||
|
||||
// MixedObject - number | undefined
|
||||
let histoMixed_NumberOrUndefined: d3Array.HistogramGeneratorNumber<MixedObject, number | undefined>;
|
||||
histoMixed_NumberOrUndefined = d3Array.histogram<MixedObject, number | undefined>();
|
||||
|
||||
// MixedObject | undefined - number | undefined
|
||||
let histoMixedOrUndefined_NumberOrUndefined: d3Array.HistogramGeneratorNumber<MixedObject | undefined, number | undefined>;
|
||||
histoMixedOrUndefined_NumberOrUndefined = d3Array.histogram<MixedObject | undefined, number | undefined>();
|
||||
|
||||
// MixedObject | undefined - number
|
||||
let histoMixedOrUndefined_Number: d3Array.HistogramGeneratorNumber<MixedObject | undefined, number>;
|
||||
histoMixedOrUndefined_Number = d3Array.histogram<MixedObject | undefined, number>();
|
||||
|
||||
// MixedObject - Date
|
||||
let histoMixedObject_Date: d3Array.HistogramGeneratorDate<MixedObject, Date>;
|
||||
histoMixedObject_Date = d3Array.histogram<MixedObject, Date>();
|
||||
|
||||
// MixedObject - Date | undefined
|
||||
let histoMixedObject_DateOrUndefined: d3Array.HistogramGeneratorDate<MixedObject, Date | undefined>;
|
||||
histoMixedObject_DateOrUndefined = d3Array.histogram<MixedObject, Date | undefined>();
|
||||
|
||||
let defaultHistogram: d3Array.HistogramGeneratorNumber<number, number>;
|
||||
defaultHistogram = d3Array.histogram();
|
||||
|
||||
// Configure histogram generator ===============================================
|
||||
|
||||
// value(...) ------------------------------------------------------------------
|
||||
|
||||
let valueAccessorFn: (d: MixedObject, i: number, data: MixedObject[]) => Date;
|
||||
valueAccessorFn = histoMixedObject_Date.value();
|
||||
|
||||
type valueAccessor<D, V> = (d: D, i: number, data: D[]) => V;
|
||||
|
||||
// number - number
|
||||
const valueFnNumber_Number: valueAccessor<number, number> = histoNumber_Number.value();
|
||||
histoNumber_Number = histoNumber_Number.value((d: number, i: number, data: ArrayLike<number>) => {
|
||||
return d - num;
|
||||
});
|
||||
|
||||
// MixedObject - number | undefined
|
||||
const valueFnMixedObject_NumberOrUndefined: valueAccessor<MixedObject, number | undefined> = histoMixed_NumberOrUndefined.value();
|
||||
histoMixed_NumberOrUndefined = histoMixed_NumberOrUndefined.value((d: MixedObject, i: number, data: ArrayLike<MixedObject>) => {
|
||||
return d.str === "NA" ? undefined : d.num;
|
||||
});
|
||||
|
||||
// MixedObject | undefined - number | undefined
|
||||
const valueFnMixedOrUndefined_NumberOrUndefined: valueAccessor<MixedObject | undefined, number | undefined> = histoMixedOrUndefined_NumberOrUndefined.value();
|
||||
histoMixedOrUndefined_NumberOrUndefined = histoMixedOrUndefined_NumberOrUndefined.value((d: MixedObject | undefined, i: number, data: ArrayLike<MixedObject | undefined>) => {
|
||||
return d ? d.num : undefined;
|
||||
});
|
||||
|
||||
// MixedObject | undefined - number
|
||||
const valueFnMixedOrUndefined_Number: valueAccessor<MixedObject | undefined, number> = histoMixedOrUndefined_Number.value();
|
||||
histoMixedOrUndefined_Number = histoMixedOrUndefined_Number.value((d: MixedObject | undefined, i: number, data: ArrayLike<MixedObject | undefined>) => {
|
||||
return d ? d.num : 0;
|
||||
});
|
||||
|
||||
// MixedObject - Date
|
||||
const valueFnMixedObject_Date: valueAccessor<MixedObject, Date> = histoMixedObject_Date.value();
|
||||
histoMixedObject_Date = histoMixedObject_Date.value((d: MixedObject, i: number, data: ArrayLike<MixedObject>) => {
|
||||
return d.date;
|
||||
});
|
||||
|
||||
// MixedObject - Date | undefined
|
||||
const valueFnMixedObject_DateOrUndefined: valueAccessor<MixedObject, Date | undefined> = histoMixedObject_DateOrUndefined.value();
|
||||
histoMixedObject_DateOrUndefined = histoMixedObject_DateOrUndefined.value((d: MixedObject, i: number, data: ArrayLike<MixedObject>) => {
|
||||
return d.date;
|
||||
});
|
||||
|
||||
// domain(...) -----------------------------------------------------------------
|
||||
|
||||
const domain = timeScale.domain();
|
||||
let domainFnNumber: (array: number[]) => [number, number] | [undefined, undefined];
|
||||
let domainFnNumberOrUndef: (array: Array<number | undefined>) => [number, number] | [undefined, undefined];
|
||||
let domainFnDate: (values: Date[]) => [Date, Date];
|
||||
|
||||
// number - number
|
||||
domainFnNumber = histoNumber_Number.domain();
|
||||
histoNumber_Number = histoNumber_Number.domain([0, 100]);
|
||||
histoNumber_Number = histoNumber_Number.domain(d3Array.extent);
|
||||
|
||||
// MixedObject - number | undefined
|
||||
domainFnNumber = histoNumber_Number.domain();
|
||||
histoMixed_NumberOrUndefined = histoMixed_NumberOrUndefined.domain([0, 100]);
|
||||
histoMixed_NumberOrUndefined = histoMixed_NumberOrUndefined.domain(d3Array.extent);
|
||||
|
||||
// MixedObject | undefined - number | undefined
|
||||
domainFnNumberOrUndef = histoMixedOrUndefined_NumberOrUndefined.domain();
|
||||
histoMixedOrUndefined_NumberOrUndefined = histoMixedOrUndefined_NumberOrUndefined.domain([0, 100]);
|
||||
histoMixedOrUndefined_NumberOrUndefined = histoMixedOrUndefined_NumberOrUndefined.domain(d3Array.extent);
|
||||
|
||||
// MixedObject | undefined - number
|
||||
domainFnNumber = histoMixedOrUndefined_Number.domain();
|
||||
histoMixedOrUndefined_Number = histoMixedOrUndefined_Number.domain([0, 100]);
|
||||
histoMixedOrUndefined_Number = histoMixedOrUndefined_Number.domain(d3Array.extent);
|
||||
|
||||
// MixedObject - Date
|
||||
domainFnDate = histoMixedObject_Date.domain();
|
||||
histoMixedObject_Date = histoMixedObject_Date.domain([new Date(2014, 3, 15), new Date(2017, 4, 15)]);
|
||||
histoMixedObject_Date = histoMixedObject_Date.domain([domain[0], domain[domain.length]]);
|
||||
histoMixedObject_Date = histoMixedObject_Date.domain((values) => [values[0], values[values.length]]);
|
||||
// $ExpectError
|
||||
histoMixedObject_Date = histoMixedObject_Date.domain(timeScale.domain()); // fails, as scale domain is an array with possibly more than the two elements expected by histogram
|
||||
|
||||
// MixedObject - Date | undefined
|
||||
domainFnDate = histoMixedObject_Date.domain();
|
||||
histoMixedObject_DateOrUndefined = histoMixedObject_DateOrUndefined.domain([new Date(2014, 3, 15), new Date(2017, 4, 15)]);
|
||||
histoMixedObject_DateOrUndefined = histoMixedObject_DateOrUndefined.domain([domain[0], domain[domain.length]]);
|
||||
histoMixedObject_DateOrUndefined = histoMixedObject_DateOrUndefined.domain((values) => [values[0]!, values[values.length]!]);
|
||||
|
||||
// thresholds(...) -------------------------------------------------------------
|
||||
|
||||
type thresholdsWithUndefinedCont = d3Array.ThresholdCountGenerator;
|
||||
type thresholdsWithUndefinedArray = d3Array.ThresholdNumberArrayGenerator<number | undefined>;
|
||||
|
||||
let thresholds: d3Array.ThresholdCountGenerator<number> | d3Array.ThresholdNumberArrayGenerator<number>;
|
||||
let thresholdsWithUndefined: thresholdsWithUndefinedCont | thresholdsWithUndefinedArray;
|
||||
const thresholdsArray: d3Array.ThresholdNumberArrayGenerator<number> = (x: ArrayLike<number>) => [5, 10, 20];
|
||||
|
||||
let thresholdsDate: d3Array.ThresholdDateArrayGenerator<Date>;
|
||||
let thresholdsDateOrUndefined: d3Array.ThresholdDateArrayGenerator<Date | undefined>;
|
||||
|
||||
// number - number
|
||||
thresholds = histoNumber_Number.thresholds();
|
||||
histoNumber_Number = histoNumber_Number.thresholds(3);
|
||||
histoNumber_Number = histoNumber_Number.thresholds([5, 10, 20]);
|
||||
histoNumber_Number = histoNumber_Number.thresholds(d3Array.thresholdScott);
|
||||
histoNumber_Number = histoNumber_Number.thresholds(thresholdsArray);
|
||||
|
||||
// MixedObject - number | undefined
|
||||
thresholdsWithUndefined = histoMixed_NumberOrUndefined.thresholds();
|
||||
histoMixed_NumberOrUndefined = histoMixed_NumberOrUndefined.thresholds(3);
|
||||
histoMixed_NumberOrUndefined = histoMixed_NumberOrUndefined.thresholds([5, 10, 20]);
|
||||
histoMixed_NumberOrUndefined = histoMixed_NumberOrUndefined.thresholds(d3Array.thresholdScott);
|
||||
|
||||
// MixedObject | undefined - number | undefined
|
||||
thresholdsWithUndefined = histoMixedOrUndefined_NumberOrUndefined.thresholds();
|
||||
histoMixedOrUndefined_NumberOrUndefined = histoMixedOrUndefined_NumberOrUndefined.thresholds(3);
|
||||
histoMixedOrUndefined_NumberOrUndefined = histoMixedOrUndefined_NumberOrUndefined.thresholds([5, 10, 20]);
|
||||
histoMixedOrUndefined_NumberOrUndefined = histoMixedOrUndefined_NumberOrUndefined.thresholds(d3Array.thresholdScott);
|
||||
|
||||
// MixedObject | undefined - number
|
||||
thresholds = histoMixedOrUndefined_Number.thresholds();
|
||||
histoMixedOrUndefined_Number = histoMixedOrUndefined_Number.thresholds(5);
|
||||
histoMixedOrUndefined_Number = histoMixedOrUndefined_Number.thresholds([5, 10, 20]);
|
||||
histoMixedOrUndefined_Number = histoMixedOrUndefined_Number.thresholds(d3Array.thresholdSturges);
|
||||
|
||||
// MixedObject - Date
|
||||
thresholdsDate = histoMixedObject_Date.thresholds();
|
||||
histoMixedObject_Date = histoMixedObject_Date.thresholds([new Date(2015, 11, 15), new Date(2016, 6, 1), new Date(2016, 8, 30)]);
|
||||
histoMixedObject_Date = histoMixedObject_Date.thresholds(timeScale.ticks(timeYear));
|
||||
histoMixedObject_Date = histoMixedObject_Date.thresholds((values: ArrayLike<Date>) => [new Date(2015, 11, 15), new Date(2016, 6, 1), new Date(2016, 8, 30)]);
|
||||
histoMixedObject_Date = histoMixedObject_Date.thresholds((values: ArrayLike<Date>, min: Date, max: Date) => {
|
||||
const thresholds: Date[] = [values[0], values[2], values[4]];
|
||||
return thresholds;
|
||||
});
|
||||
// $ExpectError
|
||||
histoMixedObject_Date = histoMixedObject_Date.thresholds(d3Array.thresholdScott);
|
||||
|
||||
// MixedObject - Date | undefined
|
||||
thresholdsDateOrUndefined = histoMixedObject_DateOrUndefined.thresholds();
|
||||
histoMixedObject_DateOrUndefined = histoMixedObject_DateOrUndefined.thresholds([new Date(2015, 11, 15), new Date(2016, 6, 1), new Date(2016, 8, 30)]);
|
||||
histoMixedObject_DateOrUndefined = histoMixedObject_DateOrUndefined.thresholds(timeScale.ticks(timeYear));
|
||||
histoMixedObject_DateOrUndefined = histoMixedObject_DateOrUndefined.thresholds((values: ArrayLike<Date | undefined>, min: Date, max: Date) => {
|
||||
const thresholds: Date[] = [values[0]!, new Date(2015, 11, 15), values[values.length]!];
|
||||
return thresholds;
|
||||
});
|
||||
|
||||
// Use histogram generator =====================================================
|
||||
|
||||
undef = d3Array.histogram()([])[0].x0 as undefined;
|
||||
undef = d3Array.histogram<number | undefined, number | undefined>()([undefined])[0].x0 as undefined;
|
||||
|
||||
// number - number
|
||||
let binsNumber_Number: Array<d3Array.Bin<number, number>>;
|
||||
binsNumber_Number = histoNumber_Number([-1, 0, 1, 1, 3, 20, 234]);
|
||||
|
||||
let binNumber_Number: d3Array.Bin<number, number>;
|
||||
binNumber_Number = binsNumber_Number[0];
|
||||
|
||||
num = binNumber_Number.length;
|
||||
num = binNumber_Number[0];
|
||||
numOrUndefined = binNumber_Number.x0;
|
||||
numOrUndefined = binNumber_Number.x1;
|
||||
|
||||
// MixedObject - number | undefined
|
||||
let binsNumberMixed_NumberOrUndefined: Array<d3Array.Bin<MixedObject, number | undefined>>;
|
||||
binsNumberMixed_NumberOrUndefined = histoMixed_NumberOrUndefined(mixedObjectArray);
|
||||
|
||||
let binNumberMixed_NumberOrUndefined: d3Array.Bin<MixedObject, number | undefined>;
|
||||
binNumberMixed_NumberOrUndefined = binsNumberMixed_NumberOrUndefined[0];
|
||||
|
||||
num = binNumberMixed_NumberOrUndefined.length;
|
||||
mixedObject = binNumberMixed_NumberOrUndefined[0];
|
||||
numOrUndefined = binNumberMixed_NumberOrUndefined.x0;
|
||||
numOrUndefined = binNumberMixed_NumberOrUndefined.x1;
|
||||
|
||||
// MixedObject | undefined - number | undefined
|
||||
let binsNumberMixedOrUndefined_NumberOrUndefined: Array<d3Array.Bin<MixedObject | undefined, number | undefined>>;
|
||||
binsNumberMixedOrUndefined_NumberOrUndefined = histoMixedOrUndefined_NumberOrUndefined(mixedObjectArray);
|
||||
|
||||
let binNumberMixedOrUndefined_NumberOrUndefined: d3Array.Bin<MixedObject | undefined, number | undefined>;
|
||||
binNumberMixedOrUndefined_NumberOrUndefined = binsNumberMixedOrUndefined_NumberOrUndefined[0];
|
||||
|
||||
num = binNumberMixedOrUndefined_NumberOrUndefined.length;
|
||||
mixedObjectOrUndefined = binNumberMixedOrUndefined_NumberOrUndefined[0];
|
||||
numOrUndefined = binNumberMixedOrUndefined_NumberOrUndefined.x0;
|
||||
numOrUndefined = binNumberMixedOrUndefined_NumberOrUndefined.x1;
|
||||
|
||||
// MixedObject | undefined - number
|
||||
let binsNumberMixedOrUndefined_Number: Array<d3Array.Bin<MixedObject | undefined, number>>;
|
||||
binsNumberMixedOrUndefined_Number = histoMixedOrUndefined_Number(mixedObjectArray);
|
||||
|
||||
let binNumberMixedOrUndefined_Number: d3Array.Bin<MixedObject | undefined, number>;
|
||||
binNumberMixedOrUndefined_Number = binsNumberMixedOrUndefined_Number[0];
|
||||
|
||||
num = binNumberMixedOrUndefined_Number.length;
|
||||
mixedObjectOrUndefined = binNumberMixedOrUndefined_Number[0];
|
||||
numOrUndefined = binNumberMixedOrUndefined_Number.x0;
|
||||
numOrUndefined = binNumberMixedOrUndefined_Number.x1;
|
||||
|
||||
// MixedObject - Date
|
||||
let binsMixedObject_Date: Array<d3Array.Bin<MixedObject, Date>>;
|
||||
binsMixedObject_Date = histoMixedObject_Date(mixedObjectArray);
|
||||
binsMixedObject_Date = histoMixedObject_Date(readonlyMixedObjectArray);
|
||||
|
||||
let binMixedObject_Date: d3Array.Bin<MixedObject, Date>;
|
||||
binMixedObject_Date = binsMixedObject_Date[0];
|
||||
|
||||
num = binMixedObject_Date.length;
|
||||
mixedObject = binMixedObject_Date[0];
|
||||
dateOrUndefined = binMixedObject_Date.x0;
|
||||
dateOrUndefined = binMixedObject_Date.x1;
|
||||
|
||||
// MixedObject - Date | undefined
|
||||
let binsMixedObject_DateOrUndefined: Array<d3Array.Bin<MixedObject, Date | undefined>>;
|
||||
binsMixedObject_DateOrUndefined = histoMixedObject_DateOrUndefined(mixedObjectArray);
|
||||
|
||||
let binMixedObject_DateOrUndefined: d3Array.Bin<MixedObject, Date | undefined>;
|
||||
binMixedObject_DateOrUndefined = binsMixedObject_DateOrUndefined[0];
|
||||
|
||||
num = binMixedObject_DateOrUndefined.length;
|
||||
mixedObject = binMixedObject_DateOrUndefined[0];
|
||||
dateOrUndefined = binMixedObject_DateOrUndefined.x0;
|
||||
dateOrUndefined = binMixedObject_DateOrUndefined.x1;
|
||||
|
||||
// Histogram Thresholds ========================================================
|
||||
|
||||
numbersArray = [-1, 0, 1, 1, 3, 20, 234];
|
||||
typedArray = new Uint8Array(numbersArray);
|
||||
readonlyNumbersArray = numbersArray as ReadonlyArray<number>;
|
||||
|
||||
num = d3Array.thresholdFreedmanDiaconis(numbersArray, -1, 234);
|
||||
num = d3Array.thresholdFreedmanDiaconis(typedArray, -1, 234);
|
||||
num = d3Array.thresholdFreedmanDiaconis(readonlyNumbersArray, -1, 234);
|
||||
|
||||
num = d3Array.thresholdScott(numbersArray, -1, 234);
|
||||
num = d3Array.thresholdScott(typedArray, -1, 234);
|
||||
num = d3Array.thresholdScott(readonlyNumbersArray, -1, 234);
|
||||
|
||||
num = d3Array.thresholdSturges(numbersArray);
|
||||
num = d3Array.thresholdSturges(typedArray);
|
||||
num = d3Array.thresholdSturges(readonlyNumbersArray);
|
||||
|
||||
// Deprecated ==================================================================
|
||||
|
||||
const histDeprecatedNumber: d3Array.HistogramGenerator<MixedObject, number> = d3Array.histogram<MixedObject, number>();
|
||||
const histDeprecatedDate: d3Array.HistogramGenerator<MixedObject, Date> = d3Array.histogram<MixedObject, Date>();
|
||||
547
types/d3-array/v1/index.d.ts
vendored
Normal file
547
types/d3-array/v1/index.d.ts
vendored
Normal file
@@ -0,0 +1,547 @@
|
||||
// Type definitions for D3JS d3-array module 1.2
|
||||
// Project: https://github.com/d3/d3-array
|
||||
// Definitions by: Alex Ford <https://github.com/gustavderdrache>
|
||||
// Boris Yankov <https://github.com/borisyankov>
|
||||
// Tom Wanzek <https://github.com/tomwanzek>
|
||||
// denisname <https://github.com/denisname>,
|
||||
// Hugues Stefanski <https://github.com/ledragon>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
// Last module patch version validated against: 1.2.1
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Shared Types and Interfaces
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Administrivia: JavaScript primitive types and Date
|
||||
*/
|
||||
export type Primitive = number | string | boolean | Date;
|
||||
|
||||
/**
|
||||
* Administrivia: anything with a valueOf(): number method is comparable, so we allow it in numeric operations
|
||||
*/
|
||||
export interface Numeric {
|
||||
valueOf(): number;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// Descriptive Statistics
|
||||
// --------------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Return the maximum value in the array of strings using natural order.
|
||||
*/
|
||||
export function max(array: ArrayLike<string>): string | undefined;
|
||||
|
||||
/**
|
||||
* Return the maximum value in the array of numbers using natural order.
|
||||
*/
|
||||
export function max<T extends Numeric>(array: ArrayLike<T>): T | undefined;
|
||||
|
||||
/**
|
||||
* Return the maximum value in the array using natural order and a projection function to map values to strings.
|
||||
*/
|
||||
export function max<T>(array: ArrayLike<T>, accessor: (datum: T, index: number, array: ArrayLike<T>) => string | undefined | null): string | undefined;
|
||||
|
||||
/**
|
||||
* Return the maximum value in the array using natural order and a projection function to map values to easily-sorted values.
|
||||
*/
|
||||
export function max<T, U extends Numeric>(array: ArrayLike<T>, accessor: (datum: T, index: number, array: ArrayLike<T>) => U | undefined | null): U | undefined;
|
||||
|
||||
/**
|
||||
* Return the minimum value in the array using natural order.
|
||||
*/
|
||||
export function min(array: ArrayLike<string>): string | undefined;
|
||||
|
||||
/**
|
||||
* Return the minimum value in the array using natural order.
|
||||
*/
|
||||
export function min<T extends Numeric>(array: ArrayLike<T>): T | undefined;
|
||||
|
||||
/**
|
||||
* Return the minimum value in the array using natural order.
|
||||
*/
|
||||
export function min<T>(array: ArrayLike<T>, accessor: (datum: T, index: number, array: ArrayLike<T>) => string | undefined | null): string | undefined;
|
||||
|
||||
/**
|
||||
* Return the minimum value in the array using natural order.
|
||||
*/
|
||||
export function min<T, U extends Numeric>(array: ArrayLike<T>, accessor: (datum: T, index: number, array: ArrayLike<T>) => U | undefined | null): U | undefined;
|
||||
|
||||
/**
|
||||
* Return the min and max simultaneously.
|
||||
*/
|
||||
export function extent(array: ArrayLike<string>): [string, string] | [undefined, undefined];
|
||||
|
||||
/**
|
||||
* Return the min and max simultaneously.
|
||||
*/
|
||||
export function extent<T extends Numeric>(array: ArrayLike<T>): [T, T] | [undefined, undefined];
|
||||
|
||||
/**
|
||||
* Return the min and max simultaneously.
|
||||
*/
|
||||
export function extent<T>(array: ArrayLike<T>, accessor: (datum: T, index: number, array: ArrayLike<T>) => string | undefined | null): [string, string] | [undefined, undefined];
|
||||
|
||||
/**
|
||||
* Return the min and max simultaneously.
|
||||
*/
|
||||
export function extent<T, U extends Numeric>(array: ArrayLike<T>, accessor: (datum: T, index: number, array: ArrayLike<T>) => U | undefined | null): [U, U] | [undefined, undefined];
|
||||
|
||||
/**
|
||||
* Return the mean of an array of numbers
|
||||
*/
|
||||
export function mean<T extends Numeric>(array: ArrayLike<T | undefined | null>): number | undefined;
|
||||
|
||||
/**
|
||||
* Return the mean of an array of numbers
|
||||
*/
|
||||
export function mean<T>(array: ArrayLike<T>, accessor: (datum: T, index: number, array: ArrayLike<T>) => number | undefined | null): number | undefined;
|
||||
|
||||
/**
|
||||
* Return the median of an array of numbers
|
||||
*/
|
||||
export function median<T extends Numeric>(array: ArrayLike<T | undefined | null>): number | undefined;
|
||||
|
||||
/**
|
||||
* Return the median of an array of numbers
|
||||
*/
|
||||
export function median<T>(array: ArrayLike<T>, accessor: (element: T, i: number, array: ArrayLike<T>) => number | undefined | null): number | undefined;
|
||||
|
||||
/**
|
||||
* Returns the p-quantile of an array of numbers
|
||||
*/
|
||||
export function quantile<T extends Numeric>(array: ArrayLike<T | undefined | null>, p: number): number | undefined;
|
||||
|
||||
export function quantile<T>(array: ArrayLike<T>, p: number, accessor: (element: T, i: number, array: ArrayLike<T>) => number | undefined | null): number | undefined;
|
||||
|
||||
/**
|
||||
* Compute the sum of an array of numbers.
|
||||
*/
|
||||
export function sum<T extends Numeric>(array: ArrayLike<T | undefined | null>): number;
|
||||
|
||||
/**
|
||||
* Compute the sum of an array, using the given accessor to convert values to numbers.
|
||||
*/
|
||||
export function sum<T>(array: ArrayLike<T>, accessor: (datum: T, index: number, array: ArrayLike<T>) => number | undefined | null): number;
|
||||
|
||||
/**
|
||||
* Compute the standard deviation, defined as the square root of the bias-corrected variance, of the given array of numbers.
|
||||
*/
|
||||
export function deviation<T extends Numeric>(array: ArrayLike<T | undefined | null>): number | undefined;
|
||||
|
||||
/**
|
||||
* Compute the standard deviation, defined as the square root of the bias-corrected variance, of the given array,
|
||||
* using the given accessor to convert values to numbers.
|
||||
*/
|
||||
export function deviation<T>(array: ArrayLike<T>, accessor: (datum: T, index: number, array: ArrayLike<T>) => number | undefined | null): number | undefined;
|
||||
|
||||
/**
|
||||
* Compute an unbiased estimator of the population variance of the given array of numbers.
|
||||
*/
|
||||
export function variance<T extends Numeric>(array: ArrayLike<T | undefined | null>): number | undefined;
|
||||
|
||||
/**
|
||||
* Compute an unbiased estimator of the population variance of the given array,
|
||||
* using the given accessor to convert values to numbers.
|
||||
*/
|
||||
export function variance<T>(array: ArrayLike<T>, accessor: (datum: T, index: number, array: ArrayLike<T>) => number | undefined | null): number | undefined;
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// Searching Arrays
|
||||
// --------------------------------------------------------------------------------------
|
||||
|
||||
export function scan(array: ArrayLike<number>, comparator?: (a: number, b: number) => number): number | undefined;
|
||||
export function scan<T>(array: ArrayLike<T>, comparator: (a: T, b: T) => number): number | undefined;
|
||||
|
||||
export function bisectLeft(array: ArrayLike<number>, x: number, lo?: number, hi?: number): number;
|
||||
export function bisectLeft(array: ArrayLike<string>, x: string, lo?: number, hi?: number): number;
|
||||
export function bisectLeft(array: ArrayLike<Date>, x: Date, lo?: number, hi?: number): number;
|
||||
|
||||
export function bisectRight(array: ArrayLike<number>, x: number, lo?: number, hi?: number): number;
|
||||
export function bisectRight(array: ArrayLike<string>, x: string, lo?: number, hi?: number): number;
|
||||
export function bisectRight(array: ArrayLike<Date>, x: Date, lo?: number, hi?: number): number;
|
||||
|
||||
export const bisect: typeof bisectRight;
|
||||
|
||||
export interface Bisector<T, U> {
|
||||
left(array: ArrayLike<T>, x: U, lo?: number, hi?: number): number;
|
||||
right(array: ArrayLike<T>, x: U, lo?: number, hi?: number): number;
|
||||
}
|
||||
|
||||
export function bisector<T, U>(comparator: (a: T, b: U) => number): Bisector<T, U>;
|
||||
export function bisector<T, U>(accessor: (x: T) => U): Bisector<T, U>;
|
||||
|
||||
/**
|
||||
* Rearranges items so that all items in the [left, k] are the smallest. The k-th element will have the (k - left + 1)-th smallest value in [left, right].
|
||||
*
|
||||
* @param array The array to partially sort (in place).
|
||||
* @param k The middle index for partial sorting.
|
||||
*/
|
||||
export function quickselect<T>(array: ArrayLike<T>, k: number): T[];
|
||||
|
||||
/**
|
||||
* Rearranges items so that all items in the [left, k] are the smallest. The k-th element will have the (k - left + 1)-th smallest value in [left, right].
|
||||
*
|
||||
* @param array The array to partially sort (in place).
|
||||
* @param k The middle index for partial sorting.
|
||||
* @param left The left index of the range to sort.
|
||||
*/
|
||||
export function quickselect<T>(array: ArrayLike<T>, k: number, left: number): T[];
|
||||
|
||||
/**
|
||||
* Rearranges items so that all items in the [left, k] are the smallest. The k-th element will have the (k - left + 1)-th smallest value in [left, right].
|
||||
*
|
||||
* @param array The array to partially sort (in place).
|
||||
* @param k The middle index for partial sorting.
|
||||
* @param left The left index of the range to sort.
|
||||
* @param right The right index.
|
||||
*/
|
||||
export function quickselect<T>(array: ArrayLike<T>, k: number, left: number, right: number): T[];
|
||||
|
||||
/**
|
||||
* Rearranges items so that all items in the [left, k] are the smallest. The k-th element will have the (k - left + 1)-th smallest value in [left, right].
|
||||
*
|
||||
* @param array The array to partially sort (in place).
|
||||
* @param k The middle index for partial sorting.
|
||||
* @param left The left index of the range to sort.
|
||||
* @param right The right index.
|
||||
* @param compare The compare function.
|
||||
*/
|
||||
export function quickselect<T>(array: ArrayLike<T>, k: number, left: number, right: number, compare: (a: Primitive | undefined, b: Primitive | undefined) => number): T[];
|
||||
|
||||
// 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).
|
||||
*/
|
||||
export function ascending(a: Primitive | undefined, b: Primitive | undefined): number;
|
||||
|
||||
// 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).
|
||||
*/
|
||||
export function descending(a: Primitive | undefined, b: Primitive | undefined): number;
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// Transforming Arrays
|
||||
// --------------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Groups the specified array of values into a Map from key to array of value.
|
||||
* @param a The array to group.
|
||||
* @param key The key function.
|
||||
*/
|
||||
export function group<TObject, TKey>(a: ArrayLike<TObject>, key: (value: TObject) => TKey): Map<TKey, TObject[]>;
|
||||
|
||||
/**
|
||||
* Groups and reduces the specified array of values into a Map from key to value.
|
||||
*
|
||||
* @param a The array to group.
|
||||
* @param reduce The reduce function.
|
||||
* @param key The key function.
|
||||
*/
|
||||
export function rollup<TObject, TKey, TReduce>(a: ArrayLike<TObject>, reduce: (value: TObject[]) => TReduce, key: (value: TObject) => TKey): Map<TKey, TReduce>;
|
||||
|
||||
/**
|
||||
* Returns the Cartesian product of the two arrays a and b.
|
||||
* For each element i in the specified array a and each element j in the specified array b, in order,
|
||||
* it creates a two-element array for each pair.
|
||||
*
|
||||
* @param a First input array.
|
||||
* @param b Second input array.
|
||||
*/
|
||||
export function cross<S, T>(a: ArrayLike<S>, b: ArrayLike<T>): Array<[S, T]>;
|
||||
|
||||
/**
|
||||
* Returns the Cartesian product of the two arrays a and b.
|
||||
* For each element i in the specified array a and each element j in the specified array b, in order,
|
||||
* invokes the specified reducer function passing the element i and element j.
|
||||
*
|
||||
* @param a First input array.
|
||||
* @param b Second input array.
|
||||
* @param reducer A reducer function taking as input an element from "a" and "b" and returning a reduced value.
|
||||
*/
|
||||
export function cross<S, T, U>(a: ArrayLike<S>, b: ArrayLike<T>, reducer: (a: S, b: T) => U): U[];
|
||||
|
||||
/**
|
||||
* Merges the specified arrays into a single array.
|
||||
*/
|
||||
export function merge<T>(arrays: ArrayLike<ArrayLike<T>>): T[];
|
||||
|
||||
/**
|
||||
* For each adjacent pair of elements in the specified array, returns a new array of tuples of elements i and i - 1.
|
||||
* Returns the empty array if the input array has fewer than two elements.
|
||||
*
|
||||
* @param array Array of input elements
|
||||
*/
|
||||
export function pairs<T>(array: ArrayLike<T>): Array<[T, T]>;
|
||||
/**
|
||||
* For each adjacent pair of elements in the specified array, in order, invokes the specified reducer function passing the element i and element i - 1.
|
||||
* Returns the resulting array of pair-wise reduced elements.
|
||||
* Returns the empty array if the input array has fewer than two elements.
|
||||
*
|
||||
* @param array Array of input elements
|
||||
* @param reducer A reducer function taking as input to adjacent elements of the input array and returning a reduced value.
|
||||
*/
|
||||
export function pairs<T, U>(array: ArrayLike<T>, reducer: (a: T, b: T) => U): U[];
|
||||
|
||||
/**
|
||||
* Returns a permutation of the specified array using the specified array of indexes.
|
||||
* The returned array contains the corresponding element in array for each index in indexes, in order.
|
||||
* For example, `permute(["a", "b", "c"], [1, 2, 0]) // ["b", "c", "a"]`
|
||||
*/
|
||||
export function permute<T>(array: { [key: number]: T }, keys: ArrayLike<number>): T[];
|
||||
|
||||
/**
|
||||
* Extract the values from an object into an array with a stable order. For example:
|
||||
* `var object = {yield: 27, year: 1931, site: "University Farm"};`
|
||||
* `d3.permute(object, ["site", "yield"]); // ["University Farm", 27]`
|
||||
*/
|
||||
export function permute<T, K extends keyof T>(object: T, keys: ArrayLike<K>): Array<T[K]>;
|
||||
|
||||
/**
|
||||
* Generates a 0-based numeric sequence. The output range does not include 'stop'.
|
||||
*/
|
||||
export function range(stop: number): number[];
|
||||
|
||||
/**
|
||||
* Generates a numeric sequence starting from the given start and stop values. 'step' defaults to 1. The output range does not include 'stop'.
|
||||
*/
|
||||
export function range(start: number, stop: number, step?: number): number[];
|
||||
|
||||
/**
|
||||
* Randomizes the order of the specified array using the Fisher–Yates shuffle.
|
||||
*/
|
||||
export function shuffle<T>(array: T[], lo?: number, hi?: number): T[];
|
||||
export function shuffle(array: Int8Array, lo?: number, hi?: number): Int8Array;
|
||||
export function shuffle(array: Uint8Array, lo?: number, hi?: number): Uint8Array;
|
||||
export function shuffle(array: Uint8ClampedArray, lo?: number, hi?: number): Uint8ClampedArray;
|
||||
export function shuffle(array: Int16Array, lo?: number, hi?: number): Int16Array;
|
||||
export function shuffle(array: Uint16Array, lo?: number, hi?: number): Uint16Array;
|
||||
export function shuffle(array: Int32Array, lo?: number, hi?: number): Int32Array;
|
||||
export function shuffle(array: Uint32Array, lo?: number, hi?: number): Uint32Array;
|
||||
export function shuffle(array: Float32Array, lo?: number, hi?: number): Float32Array;
|
||||
export function shuffle(array: Float64Array, lo?: number, hi?: number): Float64Array;
|
||||
|
||||
/**
|
||||
* Generate an array of approximately count + 1 uniformly-spaced, nicely-rounded values between start and stop (inclusive).
|
||||
* Each value is a power of ten multiplied by 1, 2 or 5. See also d3.tickIncrement, d3.tickStep and linear.ticks.
|
||||
*
|
||||
* Ticks are inclusive in the sense that they may include the specified start and stop values if (and only if) they are exact,
|
||||
* nicely-rounded values consistent with the inferred step. More formally, each returned tick t satisfies start ≤ t and t ≤ stop.
|
||||
*
|
||||
* @param start Start value for ticks
|
||||
* @param stop Stop value for ticks
|
||||
* @param count count + 1 is the approximate number of ticks to be returned by d3.ticks.
|
||||
*/
|
||||
export function ticks(start: number, stop: number, count: number): number[];
|
||||
|
||||
/**
|
||||
* Returns the difference between adjacent tick values if the same arguments were passed to d3.ticks:
|
||||
* a nicely-rounded value that is a power of ten multiplied by 1, 2 or 5.
|
||||
*
|
||||
* Like d3.tickStep, except requires that start is always less than or equal to step, and if the tick step for the given start,
|
||||
* stop and count would be less than one, returns the negative inverse tick step instead.
|
||||
*
|
||||
* This method is always guaranteed to return an integer, and is used by d3.ticks to avoid guarantee that the returned tick values
|
||||
* are represented as precisely as possible in IEEE 754 floating point.
|
||||
*
|
||||
* @param start Start value for ticks
|
||||
* @param stop Stop value for ticks
|
||||
* @param count count + 1 is the approximate number of ticks to be returned by d3.ticks.
|
||||
*/
|
||||
export function tickIncrement(start: number, stop: number, count: number): number;
|
||||
|
||||
/**
|
||||
* Returns the difference between adjacent tick values if the same arguments were passed to d3.ticks:
|
||||
* a nicely-rounded value that is a power of ten multiplied by 1, 2 or 5.
|
||||
*
|
||||
* Note that due to the limited precision of IEEE 754 floating point, the returned value may not be exact decimals;
|
||||
* use d3-format to format numbers for human consumption.
|
||||
*
|
||||
* @param start Start value for ticks
|
||||
* @param stop Stop value for ticks
|
||||
* @param count count + 1 is the approximate number of ticks to be returned by d3.ticks.
|
||||
*/
|
||||
export function tickStep(start: number, stop: number, count: number): number;
|
||||
|
||||
/**
|
||||
* Transpose a matrix provided in Array of Arrays format.
|
||||
*/
|
||||
export function transpose<T>(matrix: ArrayLike<ArrayLike<T>>): T[][];
|
||||
|
||||
/**
|
||||
* Returns an array of arrays, where the ith array contains the ith element from each of the argument arrays.
|
||||
* The returned array is truncated in length to the shortest array in arrays. If arrays contains only a single array, the returned array
|
||||
* contains one-element arrays. With no arguments, the returned array is empty.
|
||||
*/
|
||||
export function zip<T>(...arrays: Array<ArrayLike<T>>): T[][];
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// Histogram
|
||||
// --------------------------------------------------------------------------------------
|
||||
|
||||
export interface Bin<Datum, Value extends number | Date | undefined> extends Array<Datum> {
|
||||
x0: Value | undefined;
|
||||
x1: Value | undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Type definition for threshold generator which returns the count of recommended thresholds
|
||||
*/
|
||||
export type ThresholdCountGenerator<Value extends number | undefined = number | undefined> =
|
||||
(values: ArrayLike<Value>, min: number, max: number) => number;
|
||||
|
||||
/**
|
||||
* Type definition for threshold generator which returns an array of recommended numbers thresholds
|
||||
*/
|
||||
export type ThresholdNumberArrayGenerator<Value extends number | undefined> =
|
||||
(values: ArrayLike<Value>, min: number, max: number) => Value[];
|
||||
|
||||
/**
|
||||
* Type definition for threshold generator which returns an array of recommended dates thresholds
|
||||
*/
|
||||
export type ThresholdDateArrayGenerator<Value extends Date | undefined> =
|
||||
(values: ArrayLike<Value>, min: Date, max: Date) => Value[];
|
||||
|
||||
/**
|
||||
* @deprecated Use ThresholdNumberArrayGenerator or ThresholdDateArrayGenerator.
|
||||
*/
|
||||
export type ThresholdArrayGenerator = ThresholdNumberArrayGenerator<number>;
|
||||
|
||||
/**
|
||||
* @deprecated Use `HistogramGeneratorNumber<Datum, Value>` for `number` values and `HistogramGeneratorDate<Datum, Value> for `Date` values.
|
||||
*/
|
||||
export interface HistogramGenerator<Datum, Value extends number | Date | undefined> {
|
||||
(data: ArrayLike<Datum>): Array<Bin<Datum, Value>>;
|
||||
|
||||
value(): (d: Datum, i: number, data: ArrayLike<Datum>) => Value;
|
||||
value(valueAccessor: (d: Datum, i: number, data: ArrayLike<Datum>) => Value): this;
|
||||
|
||||
domain(): (values: ArrayLike<Value>) => [Value, Value] | [undefined, undefined];
|
||||
domain(domain: [Value, Value]): this;
|
||||
domain(domainAccessor: (values: ArrayLike<Value>) => [Value, Value] | [undefined, undefined]): this;
|
||||
|
||||
/**
|
||||
* Set the array of values to be used as thresholds in determining the bins.
|
||||
*
|
||||
* Any threshold values outside the domain are ignored. The first bin.x0 is always equal to the minimum domain value,
|
||||
* and the last bin.x1 is always equal to the maximum domain value.
|
||||
*
|
||||
* @param thresholds Array of threshold values used for binning. The elements must
|
||||
* be of the same type as the materialized values of the histogram.
|
||||
*/
|
||||
thresholds(thresholds: ArrayLike<Value>): this;
|
||||
}
|
||||
|
||||
export interface HistogramCommon<Datum, Value extends number | Date | undefined> {
|
||||
(data: ArrayLike<Datum>): Array<Bin<Datum, Value>>;
|
||||
|
||||
value(): (d: Datum, i: number, data: ArrayLike<Datum>) => Value;
|
||||
value(valueAccessor: (d: Datum, i: number, data: ArrayLike<Datum>) => Value): this;
|
||||
}
|
||||
|
||||
export interface HistogramGeneratorDate<Datum, Value extends Date | undefined> extends HistogramCommon<Datum, Date> {
|
||||
domain(): (values: ArrayLike<Value>) => [Date, Date];
|
||||
domain(domain: [Date, Date]): this;
|
||||
domain(domainAccessor: (values: ArrayLike<Value>) => [Date, Date]): this;
|
||||
|
||||
thresholds(): ThresholdDateArrayGenerator<Value>;
|
||||
/**
|
||||
* Set the array of values to be used as thresholds in determining the bins.
|
||||
*
|
||||
* Any threshold values outside the domain are ignored. The first bin.x0 is always equal to the minimum domain value,
|
||||
* and the last bin.x1 is always equal to the maximum domain value.
|
||||
*
|
||||
* @param thresholds Array of threshold values used for binning. The elements must
|
||||
* be of the same type as the materialized values of the histogram.
|
||||
*/
|
||||
thresholds(thresholds: ArrayLike<Value>): this;
|
||||
/**
|
||||
* Set a threshold accessor function, which returns the array of values to be used as
|
||||
* thresholds in determining the bins.
|
||||
*
|
||||
* Any threshold values outside the domain are ignored. The first bin.x0 is always equal to the minimum domain value,
|
||||
* and the last bin.x1 is always equal to the maximum domain value.
|
||||
*
|
||||
* @param thresholds A function which accepts as arguments the array of materialized values, and
|
||||
* optionally the domain minimum and maximum. The function calculates and returns the array of values to be used as
|
||||
* thresholds in determining the bins.
|
||||
*/
|
||||
thresholds(thresholds: ThresholdDateArrayGenerator<Value>): this;
|
||||
}
|
||||
|
||||
export interface HistogramGeneratorNumber<Datum, Value extends number | undefined> extends HistogramCommon<Datum, Value> {
|
||||
domain(): (values: ArrayLike<Value>) => [number, number] | [undefined, undefined];
|
||||
domain(domain: [number, number]): this;
|
||||
domain(domainAccessor: (values: ArrayLike<Value>) => [number, number] | [undefined, undefined]): this;
|
||||
|
||||
thresholds(): ThresholdCountGenerator<Value> | ThresholdNumberArrayGenerator<Value>;
|
||||
/**
|
||||
* Divide the domain uniformly into approximately count bins. IMPORTANT: This threshold
|
||||
* setting approach only works, when the materialized values are numbers!
|
||||
*
|
||||
* Any threshold values outside the domain are ignored. The first bin.x0 is always equal to the minimum domain value,
|
||||
* and the last bin.x1 is always equal to the maximum domain value.
|
||||
*
|
||||
* @param count The desired number of uniform bins.
|
||||
*/
|
||||
thresholds(count: number): this;
|
||||
/**
|
||||
* Set a threshold accessor function, which returns the desired number of bins.
|
||||
* Divides the domain uniformly into approximately count bins. IMPORTANT: This threshold
|
||||
* setting approach only works, when the materialized values are numbers!
|
||||
*
|
||||
* Any threshold values outside the domain are ignored. The first bin.x0 is always equal to the minimum domain value,
|
||||
* and the last bin.x1 is always equal to the maximum domain value.
|
||||
*
|
||||
* @param count A function which accepts as arguments the array of materialized values, and
|
||||
* optionally the domain minimum and maximum. The function calculates and returns the suggested
|
||||
* number of bins.
|
||||
*/
|
||||
thresholds(count: ThresholdCountGenerator<Value>): this;
|
||||
/**
|
||||
* Set the array of values to be used as thresholds in determining the bins.
|
||||
*
|
||||
* Any threshold values outside the domain are ignored. The first bin.x0 is always equal to the minimum domain value,
|
||||
* and the last bin.x1 is always equal to the maximum domain value.
|
||||
*
|
||||
* @param thresholds Array of threshold values used for binning. The elements must
|
||||
* be of the same type as the materialized values of the histogram.
|
||||
*/
|
||||
thresholds(thresholds: ArrayLike<Value>): this;
|
||||
/**
|
||||
* Set a threshold accessor function, which returns the array of values to be used as
|
||||
* thresholds in determining the bins.
|
||||
*
|
||||
* Any threshold values outside the domain are ignored. The first bin.x0 is always equal to the minimum domain value,
|
||||
* and the last bin.x1 is always equal to the maximum domain value.
|
||||
*
|
||||
* @param thresholds A function which accepts as arguments the array of materialized values, and
|
||||
* optionally the domain minimum and maximum. The function calculates and returns the array of values to be used as
|
||||
* thresholds in determining the bins.
|
||||
*/
|
||||
thresholds(thresholds: ThresholdNumberArrayGenerator<Value>): this;
|
||||
}
|
||||
|
||||
export function histogram(): HistogramGeneratorNumber<number, number>;
|
||||
export function histogram<Datum, Value extends number | undefined>(): HistogramGeneratorNumber<Datum, Value>;
|
||||
export function histogram<Datum, Value extends Date | undefined>(): HistogramGeneratorDate<Datum, Value>;
|
||||
|
||||
/**
|
||||
* @deprecated Do not use Value generic which mixes number and Date types. Use either number or Date
|
||||
* (in combination with undefined, as applicable) to obtain a type-specific histogram generator.
|
||||
*/
|
||||
export function histogram<Datum, Value extends number | Date | undefined>(): HistogramGenerator<Datum, Value>;
|
||||
|
||||
// --------------------------------------------------------------------------------------
|
||||
// Histogram Thresholds
|
||||
// --------------------------------------------------------------------------------------
|
||||
|
||||
export function thresholdFreedmanDiaconis(values: ArrayLike<number | undefined>, min: number, max: number): number; // of type ThresholdCountGenerator
|
||||
|
||||
export function thresholdScott(values: ArrayLike<number | undefined>, min: number, max: number): number; // of type ThresholdCountGenerator
|
||||
|
||||
export function thresholdSturges(values: ArrayLike<number | undefined>): number; // of type ThresholdCountGenerator
|
||||
29
types/d3-array/v1/tsconfig.json
Normal file
29
types/d3-array/v1/tsconfig.json
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../../",
|
||||
"typeRoots": [
|
||||
"../../"
|
||||
],
|
||||
"types": [],
|
||||
"paths": {
|
||||
"d3-array": [
|
||||
"d3-array/v1"
|
||||
]
|
||||
},
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"d3-array-tests.ts"
|
||||
]
|
||||
}
|
||||
7
types/d3-array/v1/tslint.json
Normal file
7
types/d3-array/v1/tslint.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"unified-signatures": false,
|
||||
"no-unnecessary-generics": false
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
// TODO
|
||||
"npm-naming": false,
|
||||
"dt-header": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,11 @@
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"paths": {
|
||||
"d3-array": [
|
||||
"d3-array/v1"
|
||||
]
|
||||
},
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
|
||||
@@ -19,6 +19,9 @@
|
||||
],
|
||||
"d3": [
|
||||
"d3/v4"
|
||||
],
|
||||
"d3-array": [
|
||||
"d3-array/v1"
|
||||
]
|
||||
},
|
||||
"types": [],
|
||||
|
||||
@@ -13,6 +13,11 @@
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"paths": {
|
||||
"d3-array": [
|
||||
"d3-array/v1"
|
||||
]
|
||||
},
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
|
||||
@@ -29,3 +29,7 @@ extendedLog("Testing this is also an IDebugger.");
|
||||
|
||||
const extendedWithCustomDelimiter: debug1.Debugger = log.extend('with-delim', '.');
|
||||
extendedWithCustomDelimiter("Testing this is an IDebugger, too.");
|
||||
|
||||
debug2.log = console.log.bind(console);
|
||||
const anotherLogger = debug2("DefinitelyTyped:error");
|
||||
anotherLogger("This should be printed to stdout");
|
||||
|
||||
4
types/debug/index.d.ts
vendored
4
types/debug/index.d.ts
vendored
@@ -5,9 +5,10 @@
|
||||
// John McLaughlin <https://github.com/zamb3zi>
|
||||
// Brasten Sager <https://github.com/brasten>
|
||||
// Nicolas Penin <https://github.com/npenin>
|
||||
// Kristian Brünn <https://github.com/kristianmitk>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare var debug: debug.Debug & {debug: debug.Debug, default: debug.Debug};
|
||||
declare var debug: debug.Debug & { debug: debug.Debug; default: debug.Debug };
|
||||
|
||||
export = debug;
|
||||
export as namespace debug;
|
||||
@@ -19,6 +20,7 @@ declare namespace debug {
|
||||
disable: () => string;
|
||||
enable: (namespaces: string) => void;
|
||||
enabled: (namespaces: string) => boolean;
|
||||
log: (...args: any[]) => any;
|
||||
|
||||
names: RegExp[];
|
||||
skips: RegExp[];
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"npm-naming": false,
|
||||
"dt-header": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { DomHandler, DomHandlerOptions, Node } from "domhandler";
|
||||
import { DomHandler, DomHandlerOptions, Node, DomElement } from "domhandler";
|
||||
|
||||
const handler = new DomHandler((error: Error, dom: any) => {
|
||||
const handler = new DomHandler((error: Error, dom: DomElement[]) => {
|
||||
if (error)
|
||||
console.error('There has been an error...');
|
||||
else
|
||||
@@ -8,7 +8,7 @@ const handler = new DomHandler((error: Error, dom: any) => {
|
||||
});
|
||||
handler.ontext = (data: string) => { console.log(data); };
|
||||
handler.onreset = () => { console.log('We have a reset.'); };
|
||||
handler.onerror = (error: Error) => { console.error(Error); };
|
||||
handler.onopentag = (name: string, attribs) => { console.log(name, attribs); };
|
||||
handler.onerror = (error: Error) => { console.error(error); };
|
||||
handler.onopentag = (name: string, attribs: { [s: string]: string }) => { console.log(name, attribs); };
|
||||
|
||||
const dho: DomHandlerOptions = { normalizeWhitespace: true, withDomLvl1: true, withEndIndices: true, withStartIndices: true };
|
||||
|
||||
1
types/domhandler/index.d.ts
vendored
1
types/domhandler/index.d.ts
vendored
@@ -2,7 +2,6 @@
|
||||
// Project: https://github.com/fb55/DomHandler#readme
|
||||
// Definitions by: Johan Davidsson <https://github.com/johandavidson>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
export interface DomHandlerOptions {
|
||||
/***
|
||||
|
||||
1
types/domutils/index.d.ts
vendored
1
types/domutils/index.d.ts
vendored
@@ -2,7 +2,6 @@
|
||||
// Project: https://github.com/FB55/domutils#readme
|
||||
// Definitions by: Johan Davidsson <https://github.com/johandavidson>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
import { DomElement } from "domhandler";
|
||||
/***
|
||||
|
||||
@@ -3,7 +3,7 @@ import dotenv = require("dotenv");
|
||||
const env = dotenv.config();
|
||||
const dbUrl: string | null = env.error || !env.parsed ? null : env.parsed["BASIC"];
|
||||
|
||||
dotenv.load({
|
||||
dotenv.config({
|
||||
path: ".env-example",
|
||||
encoding: "utf8",
|
||||
debug: true
|
||||
|
||||
1
types/dotenv/index.d.ts
vendored
1
types/dotenv/index.d.ts
vendored
@@ -62,4 +62,5 @@ export interface DotenvConfigOutput {
|
||||
*
|
||||
*/
|
||||
export function config(options?: DotenvConfigOptions): DotenvConfigOutput;
|
||||
/** @deprecated since v7.0.0 Use config instead. */
|
||||
export const load: typeof config;
|
||||
|
||||
3
types/draft-js/index.d.ts
vendored
3
types/draft-js/index.d.ts
vendored
@@ -10,6 +10,7 @@
|
||||
// Ulf Schwekendiek <https://github.com/sulf>
|
||||
// Pablo Varela <https://github.com/pablopunk>
|
||||
// Claudio Procida <https://github.com/claudiopro>
|
||||
// Kevin Hawkinson <https://github.com/khawkinson>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
@@ -211,6 +212,8 @@ declare namespace Draft {
|
||||
static isOptionKeyCommand(e: SyntheticKeyboardEvent): boolean;
|
||||
|
||||
static hasCommandModifier(e: SyntheticKeyboardEvent): boolean;
|
||||
|
||||
static isSoftNewlineEvent(e: SyntheticKeyboardEvent): boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
1
types/dwt/Dynamsoft.d.ts
vendored
1
types/dwt/Dynamsoft.d.ts
vendored
@@ -27,6 +27,7 @@ interface dwtEnv {
|
||||
DynamicContainers: string[];
|
||||
DynamicDWTMap: {};
|
||||
GetWebTwain(cid: string): WebTwain;
|
||||
IfInstallDWTModuleWithZIP: boolean;
|
||||
IfUpdateService: boolean;
|
||||
IfUseActiveXForIE10Plus: boolean;
|
||||
JSVersion: string;
|
||||
|
||||
1
types/dwt/index.d.ts
vendored
1
types/dwt/index.d.ts
vendored
@@ -4,6 +4,7 @@
|
||||
// Josh Hall <https://github.com/jbh>
|
||||
// Lincoln Hu <https://github.com/lincoln2018>
|
||||
// Tom Kent <https://github.com/Tom-Dynamsoft>
|
||||
// Dave Sueltenfuss <https://github.com/dsueltenfuss>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.4
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitAny": false,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictFunctionTypes": true,
|
||||
@@ -20,4 +20,4 @@
|
||||
"index.d.ts",
|
||||
"egg-mock-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user