This commit is contained in:
Terry Mun
2019-01-04 21:02:16 +01:00
26 changed files with 617 additions and 9 deletions
+4 -1
View File
@@ -18,6 +18,7 @@ declare namespace OSS {
internal?: boolean; // access OSS with aliyun internal network or not, default is false. If your servers are running on aliyun too, you can set true to save lot of money.
secure?: boolean; // instruct OSS client to use HTTPS (secure: true) or HTTP (secure: false) protocol.
timeout?: string | number; // instance level timeout for all operations, default is 60s
cname?: boolean; // use custom domain name
}
interface Bucket {
@@ -29,7 +30,7 @@ declare namespace OSS {
type StorageType = "Standard" | "IA" | "Archive";
type ACLType = "public-read-write" | "public-read" | "and private";
type ACLType = "public-read-write" | "public-read" | "private";
type HTTPMethods = "GET" | "POST" | "DELETE" | "PUT";
@@ -174,6 +175,7 @@ declare namespace OSS {
mime?: string; // custom mime, will send with Content-Type entity header
meta?: UserMeta; // user meta, will send with x-oss-meta- prefix string e.g.: { uid: 123, pid: 110 }
callback: ObjectCallback;
headers?: object;
}
interface PutObjectResult {
@@ -188,6 +190,7 @@ declare namespace OSS {
mime: string; // custom mime, will send with Content-Type entity header
meta: UserMeta;
callback: ObjectCallback;
headers?: object;
}
interface AppendObjectOptions {
+2 -2
View File
@@ -1,3 +1,3 @@
import * as cn from "./index";
import classNames = require('./index');
export function bind(styles: Record<string, string>): typeof cn;
export function bind(styles: Record<string, string>): typeof classNames;
+1 -1
View File
@@ -6,7 +6,7 @@
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
+1 -1
View File
@@ -43,7 +43,7 @@ declare namespace Router {
strict?: boolean;
}
export interface IRouterContext {
export interface IRouterContext extends Koa.Context {
/**
* url params
*/
+4
View File
@@ -49,6 +49,10 @@ const match = router.match('/users/:id', 'GET');
let layer: Router.Layer
let layerOptions: Router.ILayerOptions
const mw: Router.IMiddleware = (ctx: Router.IRouterContext, next: () => Promise<any>) => {
ctx.body = "Ok";
};
app.use(router.routes());
app.use(router.allowedMethods());
+47
View File
@@ -0,0 +1,47 @@
// Type definitions for @loadable/component 5.2
// Project: https://github.com/smooth-code/loadable-components
// Definitions by: Martynas Kadiša <https://github.com/martynaskadisa>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
import * as React from 'react';
export interface DefaultImportedComponent<P> {
default: React.ComponentType<P>;
}
export type DefaultComponent<P> = React.ComponentType<P> | DefaultImportedComponent<P>;
export interface Options {
fallback?: JSX.Element;
}
export type LoadableComponent<T> = React.ComponentType<T & { fallback?: JSX.Element }>;
export type LoadableLibrary<TModule> = React.ComponentType<{
fallback?: JSX.Element;
children?: (module: TModule) => React.ReactNode;
ref?: React.Ref<TModule>;
}> &
TModule;
declare function lib<T>(
loadFn: (props: object) => Promise<T>,
options?: Options
): LoadableLibrary<T>;
declare function loadableFunc<T>(
loadFn: (props: T) => Promise<DefaultComponent<T>>,
options?: Options
): LoadableComponent<T>;
declare const loadable: typeof loadableFunc & { lib: typeof lib };
export default loadable;
export namespace lazy {
function lib<TModule>(loadFn: (props: object) => Promise<TModule>): LoadableLibrary<TModule>;
}
export function lazy<T>(loadFn: (props: T) => Promise<DefaultComponent<T>>): LoadableComponent<T>;
export function loadableReady(done?: () => any): Promise<void>;
@@ -0,0 +1,117 @@
import * as React from 'react';
import loadable, { lazy, loadableReady } from '@loadable/component';
const TestComponent: React.SFC<{ foo: string }> = () => <>test</>;
function defaultImportComponentLoader() {
return new Promise<{ default: typeof TestComponent }>(resolve => resolve({ default: TestComponent }));
}
function importComponentLoader() {
return new Promise<typeof TestComponent>(resolve => resolve(TestComponent));
}
const lib = {
getTestObj: () => ({ bar: 'bar', foo: 'foo' })
};
function defaultImportLibLoader() {
return new Promise<{ default: typeof lib }>(resolve => resolve(({ default: lib })));
}
function importLibLoader() {
return new Promise<typeof lib>(resolve => resolve(lib));
}
// loadable
{
// Should infer props from imported component with default export
const LoadableDefaultComponent = loadable(defaultImportComponentLoader);
<LoadableDefaultComponent foo="test-prop" />;
// Should infer props from imported component without default export
const LoadableComponent = loadable(importComponentLoader);
<LoadableComponent foo="test-prop" />;
// Should allow passing JSX element to fallback in options
loadable(defaultImportComponentLoader, { fallback: <div>loading...</div> });
// Should allow passing `fallback` prop to loadable component
<LoadableComponent foo="test" fallback={<div>loading...</div>} />;
}
// lazy
{
// Should infer props from imported component with default export
const LazyDefaultComponent = lazy(defaultImportComponentLoader);
<LazyDefaultComponent foo="test" />;
// Should infer props from imported component without default export
const LazyComponent = lazy(importComponentLoader);
<LazyDefaultComponent foo="test" />;
// Should allow passing fallback prop
<LazyComponent foo="test" fallback={<div>loading...</div>} />;
}
// loadable.lib
{
// Should infer types from module with default export and reflect them in children render prop
const LoadableDefaultLibrary = loadable.lib(defaultImportLibLoader);
<LoadableDefaultLibrary>
{({ default: { getTestObj } }) => getTestObj().foo}
</LoadableDefaultLibrary>;
// Should infer types from module without default export and reflect them in children render prop
const LoadableLibrary = loadable.lib(importLibLoader);
<LoadableLibrary>
{({ getTestObj }) => getTestObj().foo}
</LoadableLibrary>;
// Should allow passing fallback JSX element
loadable.lib(importLibLoader, { fallback: <div>loading lib...</div> });
// Should allow passing fallback prop
<LoadableLibrary fallback={<div>Loading library...</div>}>
{({ getTestObj }) => getTestObj().foo}
</LoadableLibrary>;
// Should reflect inferred types from module in ref
const ref = React.createRef<typeof LoadableLibrary>();
<LoadableLibrary ref={ref} />;
ref.current!.getTestObj().foo;
}
// lazy.lib
{
// Should infer types from module with default export and reflect them in children render prop
const LazyDefaultLibrary = lazy.lib(defaultImportLibLoader);
<LazyDefaultLibrary>
{({ default: { getTestObj } }) => getTestObj().foo}
</LazyDefaultLibrary>;
// Should infer types from module without default export and reflect them in children render prop
const LazyLibrary = lazy.lib(importLibLoader);
<LazyLibrary>
{({ getTestObj }) => getTestObj().foo}
</LazyLibrary>;
// Should allow passing fallback prop
<LazyLibrary fallback={<div>Loading library...</div>}>
{({ getTestObj }) => getTestObj().foo}
</LazyLibrary>;
// Should reflect inferred types from module in ref
const ref = React.createRef<typeof LazyLibrary>();
<LazyLibrary ref={ref} />;
ref.current!.getTestObj().foo;
}
// loadableReady
{
// Should allow passing callback argument
loadableReady(() => {});
// Should return a promise
loadableReady().then(() => {});
}
+29
View File
@@ -0,0 +1,29 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"jsx": "react",
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"paths": {
"@loadable/component": [
"loadable__component"
]
},
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"loadable__component-tests.tsx"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+1
View File
@@ -24,6 +24,7 @@ declare namespace Mark {
acrossElements?: boolean;
caseSensitive?: boolean;
ignoreJoiners?: boolean;
ignorePunctuation?: string[];
wildcards?: 'disabled' | 'enabled' | 'withSpaces';
each?(element: Element): void;
+180
View File
@@ -0,0 +1,180 @@
// Type definitions for Navigator.Permissions 0.1
// Project: https://developer.mozilla.org/en-US/docs/Web/API/Permissions
// Definitions by: Vince Varga <https://github.com/vargavince91>, MindDoc <https://github.com/minddocdev>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
/**
* Namespace for `navigator.permissions` type definitions.
*
* As the Permissions API is only supported by Firefox and Chrome
* https://caniuse.com/#feat=permissions-api
* the TypeScript team has not yet added it to lib.dom.d.ts
* https://github.com/Microsoft/TypeScript/issues/24923
* In the meantime, these type definitions can be used.
*
* The documentation is based on the MDN web docs
* https://developer.mozilla.org/en-US/docs/Web/API/Permissions
*/
declare namespace NavigatorPermissions {
/**
* Permission state values.
*/
type PermissionState =
'granted' |
'denied' |
'prompt';
/**
* The `PermissionStatus` interface of the Permissions API provides the state
* of an object and an event handler for monitoring changes to said state.
*
* This is an experimental technology
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/PermissionStatus}
*/
interface PermissionStatus extends EventTarget {
/**
* Returns the state of a requested permission.
*/
readonly state: PermissionState;
/**
* Returns the state of a requested permission.
* Later versions of the specification replace this with
* `PermissionStatus.state`.
* @deprecated
*/
readonly status: PermissionState;
/**
* An event called whenever `PermissionStatus.status` changes.
*/
onchange: ((this: this, event: Event) => any) | null;
}
/**
* Permission name options.
*/
type PermissionName =
'accelerometer' |
'accessibility-events' |
'ambient-light-sensor' |
'background-sync' |
'camera' |
'clipboard-read' |
'clipboard-write' |
'geolocation' |
'gyroscope' |
'magnetometer' |
'microphone' |
'midi' |
'notifications' |
'payment-handler' |
'persistent-storage' |
'push';
/**
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Permissions/query}
*/
interface PermissionDescriptor<N extends PermissionName> {
/**
* The name of the API whose permissions you want to query.
*
* Please, be aware, that not all of these are supported in every browser
* that supports the Permissions API. For example, in Firefox you can't query
* the `'microphone'` or `'camera'` and it'll throw `TypeError`
*/
name: N;
}
interface PushPermissionDescriptor extends PermissionDescriptor<'push'> {
/**
* Indicates whether you want to show a notification for every message
* or be able to send silent push
* notifications. The default is `false`. Not supported in Firefox.
*/
userVisibleOnly?: boolean;
}
interface MidiPermissionDescriptor extends PermissionDescriptor<'midi'> {
/**
* Indicates whether you need and/or receive system exclusive
* messages. The default is false.
*/
sysex?: boolean;
}
// Map permission names to correctly typed descriptors.
interface NameDescriptorMap {
// ??? Question ???:
// Is there a better way to handle this case and remove repeated code,
// something like
// <N extends PermissionName, D extends PermissionDescriptor<N>> {
// [n in N]: D; // this line to cover all basic cases
// // and the custom permission descriptors for midi and push
// }
'accelerometer': PermissionDescriptor<'accelerometer'>;
'accessibility-events': PermissionDescriptor<'accessibility-events'>;
'ambient-light-sensor': PermissionDescriptor<'ambient-light-sensor'>;
'background-sync': PermissionDescriptor<'background-sync'>;
'camera': PermissionDescriptor<'camera'>;
'clipboard-read': PermissionDescriptor<'clipboard-read'>;
'clipboard-write': PermissionDescriptor<'clipboard-write'>;
'geolocation': PermissionDescriptor<'geolocation'>;
'gyroscope': PermissionDescriptor<'gyroscope'>;
'magnetometer': PermissionDescriptor<'magnetometer'>;
'microphone': PermissionDescriptor<'microphone'>;
'notifications': PermissionDescriptor<'notifications'>;
'payment-handler': PermissionDescriptor<'payment-handler'>;
'persistent-storage': PermissionDescriptor<'persistent-storage'>;
// These permission descriptors support extra properties
'midi': MidiPermissionDescriptor;
'push': PushPermissionDescriptor;
}
/**
* The `Permissions` interface of the Permissions API provides the core
* Permission API functionality, such as methods for querying and
* revoking permissions.
*
* This is an experimental technology.
*
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Permissions}
*/
interface Permissions {
/**
* The `Permissions.query()` method of the `Permissions` interface returns
* the state of a user permission on the global scope.
* @param permissionDescriptor object that sets
* options for the query operation consisting of a comma-separated list
* of name-value pairs.
* (Is comma-separated list really supported? It is mentioned in the docs, but does not work).
* @returns the user permission status for a given API.
* @throws `TypeError` Retrieving the `PermissionDescriptor` information
* failed in some way, or the permission doesn't exist or is currently
* unsupported (e.g. `midi`, or `push` with `userVisibleOnly`).
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Permissions/query}
*/
query(permissionDescriptor: NameDescriptorMap[keyof NameDescriptorMap]): Promise<PermissionStatus>;
/**
* The `Permissions.revoke()` method of the `Permissions` interface reverts a
* currently set permission back to its default state, which is usually `prompt`.
*
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Permissions/revoke}
*/
revoke(permissionDescriptor: NameDescriptorMap[keyof NameDescriptorMap]): Promise<PermissionStatus>;
}
/**
* Navigator type definition with possible `permissions` API support.
*
* This interface adds the `permissions` property to the navigator.
*/
interface NavigatorPermissions extends Navigator {
/**
* Provides the core Permission API functionality, such as querying and revoking permissions.
*
* The typing takes into account that the feature is not widely supported,
* making code using this API more secure by forcing considering the `undefined` case.
*/
permissions?: Permissions;
}
}
@@ -0,0 +1,45 @@
// Here are some examples for Navigator.Permissions types.
// Open it in your IDE with TypeScript support and observe the types and documentation help
// that this module provides
// Navigator from lib.dom might have permissions
const nav = navigator as NavigatorPermissions.NavigatorPermissions;
async function exampleQueryAndEventListeners() {
// Force users to check for undefined as the feature is not widely supported
if (typeof nav.permissions === 'undefined') { return; }
const permissionsStatus = await nav.permissions.query({ name: 'camera' });
// Possible state values are known to users:
const isDenied = permissionsStatus.state === 'denied';
// if compared to any non-valid value, it warns
// const tsShouldWarn = permissionsStatus.state === 'can you see the warning?';
permissionsStatus.addEventListener('change', (event) => {
console.log('permission state changed');
// I couldn't find a way to set the EventTarget's type to PermissionStatus
console.log('new PermissionStatus', event.target);
});
}
function exampleQueryOptions() {
// Force users to check for undefined as the feature is not widely supported
if (typeof nav.permissions === 'undefined') { return; }
// query method checks if the name is a valid permission name
nav.permissions.query({ name: 'camera' });
// Other names would cause type errors
// nav.permissions.query({ name: 'invalid name' });
// When permission name is 'push', userVisibleOnly property is also supported
nav.permissions.query({ name: 'push', userVisibleOnly: true });
// For other names, it would fail:
// nav.permissions.query({ name: 'camera', userVisibleOnly: true });
// When permission name is 'midi', sysex property is also supported
nav.permissions.query({ name: 'midi', sysex: true });
// For other names, it would fail:
// nav.permissions.query({ name: 'camera', sysex: true });
}
function exampleIgnoreUndefinedCheck() {
// Using the ! after permissions will let you bypass the undefined-check
nav.permissions!.query({ name: 'microphone' });
}
+24
View 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",
"navigator-permissions-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+13 -2
View File
@@ -367,8 +367,19 @@ export interface PathCommand {
* UTIL CLASSES
******************************************/
export type BoundingBox = () => any;
// TODO add methods
export class BoundingBox {
x1: number;
y1: number;
x2: number;
y2: number;
isEmpty(): boolean;
addPoint(x: number, y: number): void;
addX(x: number): void;
addY(y: number): void;
addBezier(x0: number, y0: number, x1: number, y1: number, x2: number, y2: number, x: number, y: number): void;
addQuad(x0: number, y0: number, x1: number, y1: number, x: number, y: number): void;
}
export interface Encoding {
charset: string;
+2
View File
@@ -113,6 +113,8 @@ aPath.extend(aPath);
aPath.extend(aPath.commands);
aPath.extend(aPath.getBoundingBox());
const pathBBox: opentype.BoundingBox = aPath.getBoundingBox();
pathBBox.addQuad(1, 1, 1, 1, 1, 1);
const yDist = pathBBox.y2 - pathBBox.y1;
aPath.draw(ctx);
const pathData: string = aPath.toPathData(7);
const pathSvg: string = aPath.toSVG(7);
+4 -1
View File
@@ -1,4 +1,4 @@
// Type definitions for react-modal 3.6
// Type definitions for react-modal 3.8
// Project: https://github.com/reactjs/react-modal
// Definitions by: Rajab Shakirov <https://github.com/radziksh>,
// Drew Noakes <https://github.com/drewnoakes>,
@@ -64,6 +64,9 @@ declare namespace ReactModal {
/* Function that will be run after the modal has opened. */
onAfterOpen?(): void;
/* Function that will be run after the modal has closed. */
onAfterClose?(): void;
/* Function that will be run when the modal is requested to be closed, prior to actually closing. */
onRequestClose?(event: (MouseEvent | KeyboardEvent)): void;
+2
View File
@@ -12,6 +12,7 @@ class ExampleOfUsingReactModal extends React.Component {
overlayRef: HTMLDivElement;
render() {
const onAfterOpenFn = () => { };
const onAfterCloseFn = () => { };
const onRequestCloseFn = () => { };
const customStyle = {
overlay: {
@@ -59,6 +60,7 @@ class ExampleOfUsingReactModal extends React.Component {
<ReactModal
isOpen={true}
onAfterOpen={onAfterOpenFn}
onAfterClose={onAfterCloseFn}
onRequestClose={onRequestCloseFn}
contentLabel="demo label"
closeTimeoutMS={1000}
+2
View File
@@ -100,6 +100,7 @@ declare namespace request {
files: any;
forbidden: boolean;
get(header: string): string;
get(header: 'Set-Cookie'): string[];
header: any;
info: boolean;
links: object;
@@ -148,6 +149,7 @@ declare namespace request {
serialize(serializer: Serializer): this;
set(field: object): this;
set(field: string, val: string): this;
set(field: 'Cookie', val: string[]): this;
timeout(ms: number | { deadline?: number, response?: number }): this;
type(val: string): this;
unset(field: string): this;
+12
View File
@@ -83,6 +83,12 @@ request
.set({ 'API-Key': 'foobar', Accept: 'application/json' })
.end(callback);
// Setting cookie header
request
.get('/search')
.set('Cookie', ['name1=value1; Domain=.test.com; Path=/', 'name2=value2; Domain=.test.com; Path=/'])
.end(callback);
// GET requests
request
.get('/search')
@@ -198,6 +204,12 @@ request('/search')
const charset: string = res.charset;
});
// Getting response 'Set-Cookie'
request('/search')
.end((res: request.Response) => {
const setCookie: string[] = res.get('Set-Cookie');
});
// Custom parsers
request
.post('/search')
+54
View File
@@ -0,0 +1,54 @@
// Type definitions for terser-webpack-plugin 1.2
// Project: https://github.com/webpack-contrib/terser-webpack-plugin
// Definitions by: Daniel Schopf <https://github.com/Danscho>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.0
import { Plugin } from 'webpack';
import { MinifyOptions } from 'terser';
import webpack = require('webpack');
export = TerserPlugin;
declare class TerserPlugin extends Plugin {
constructor(opts?: TerserPlugin.TerserPluginOptions);
}
declare namespace TerserPlugin {
interface MinifyResult {
error: any;
map: any;
code: any;
warnings: any;
extractedComments: any;
}
interface ExtractCommentOptions {
condition: boolean | string | RegExp | ExtractCommentFn | object;
filename?: string | FormatFn;
banner?: boolean | string | FormatFn;
}
type ExtractCommentFn = (node: any, comment: any) => (boolean | object);
type FormatFn = (input: string) => string;
interface TerserPluginOptions {
test?: string | RegExp | Array<string | RegExp>;
include?: string | RegExp | Array<string | RegExp>;
exclude?: string | RegExp | Array<string | RegExp>;
chunkFilter?: (chunk: webpack.compilation.Chunk) => boolean;
cache?: boolean | string;
cacheKeys?: (defaultCacheKeys: any, file: any) => object;
parallel?: boolean | number;
sourceMap?: boolean;
minify?: (file: any, sourceMap: any) => MinifyResult;
terserOptions?: MinifyOptions;
extractComments?: boolean
| string
| RegExp
| ExtractCommentFn
| ExtractCommentOptions;
warningsFilter?: (warning: any, source: any) => boolean;
}
}
@@ -0,0 +1,36 @@
import * as webpack from 'webpack';
import * as TerserPlugin from "terser-webpack-plugin";
const compiler = webpack({
plugins: [
new TerserPlugin(),
],
});
const compilerOptions = webpack({
plugins: [
new TerserPlugin({
// Uncomment lines below for cache invalidation correctly
cache: true,
cacheKeys: (defaultCacheKeys) => {
delete defaultCacheKeys.terser;
return {
...defaultCacheKeys,
'uglify-js': require('uglify-js/package.json').version,
};
},
minify: (file, sourceMap) => {
// https://github.com/mishoo/UglifyJS2#minify-options
const uglifyJsOptions = {
/* your `uglify-js` package options */
};
return require('uglify-js').minify(file, uglifyJsOptions);
},
include: /src\//,
exclude: /node_modules\//,
sourceMap: true,
terserOptions: { mangle: true }
}),
],
});
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"terser-webpack-plugin-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+6 -1
View File
@@ -1,6 +1,9 @@
// Type definitions for url-parse 1.4
// Project: https://github.com/unshiftio/url-parse
// Definitions by: Pavlo Chernenko <https://github.com/ChernenkoPaul>, Hari Sivaramakrishnan <https://github.com/harisiva>, Dmitry Dushkin <https://github.com/DimitryDushkin>
// Definitions by: Pavlo Chernenko <https://github.com/ChernenkoPaul>
// Hari Sivaramakrishnan <https://github.com/harisiva>
// Dmitry Dushkin <https://github.com/DimitryDushkin>
// David Golightly <https://github.com/davidgoli>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
@@ -41,7 +44,9 @@ interface URLParse {
}
declare const URLParse: {
new(address: string, parser?: boolean | URLParse.QueryParser): URLParse;
new(address: string, location?: string | object, parser?: boolean | URLParse.QueryParser): URLParse;
(address: string, parser?: boolean | URLParse.QueryParser): URLParse;
(address: string, location?: string | object, parser?: boolean | URLParse.QueryParser): URLParse;
extractProtocol(url: string): {
+5
View File
@@ -3,8 +3,13 @@ const parse = URL;
new URL('foo/bar', 'https://github.com/');
new URL('foo/bar', 'https://github.com/', (query: string) => ({ query }));
new URL('foo/bar', 'https://github.com/', true);
parse('foo/bar', 'https://github.com/');
parse('foo/bar', 'https://github.com/', (query: string) => ({ query }));
const result = parse('foo/bar?baz=quux', true);
if (result.query.baz !== 'quux') {
throw new Error('bad query parsing');
}
const url1: URL = new URL('https://github.com/foo/bar?baz=true');
url1.hash;