Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nodenext compatibility #54

Merged
merged 2 commits into from
Dec 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions index.d.ts

This file was deleted.

6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,11 +278,15 @@ function parse (uri, opts) {
return parsed
}

module.exports = {
const fastUri = {
normalize,
resolve,
resolveComponents,
equal,
serialize,
parse
}

module.exports = fastUri
module.exports.default = fastUri
module.exports.fastUri = fastUri
11 changes: 0 additions & 11 deletions index.test-d.ts

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "2.1.0",
"main": "index.js",
"type": "commonjs",
"types": "index.d.ts",
"types": "types/index.d.ts",
"license": "MIT",
"author": "Vincent Le Goff <[email protected]> (https://github.com/zekth)",
"repository": {
Expand Down
Empty file removed types/.gitkeep
Empty file.
53 changes: 53 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
type FastUri = typeof fastUri

declare namespace fastUri {
export interface URIComponent {
scheme?: string;
userinfo?: string;
host?: string;
port?: number | string;
path?: string;
query?: string;
fragment?: string;
reference?: string;
error?: string;
}
export interface Options {
scheme?: string;
reference?: string;
unicodeSupport?: boolean;
domainHost?: boolean;
absolutePath?: boolean;
tolerant?: boolean;
}

/**
* @deprecated Use Options instead
*/
export type options = Options
/**
* @deprecated Use URIComponent instead
*/
export type URIComponents = URIComponent

export function normalize(uri: string, opts?: Options): string;
export function normalize(uri: URIComponent, opts?: Options): URIComponent;
export function normalize(uri: any, opts?: Options): any;

export function resolve(baseURI: string, relativeURI: string, options?: Options): string

export function resolveComponent(base: URIComponent, relative: URIComponent, options?: Options, skipNormalization?: boolean): URIComponent

export function parse(uri: string, opts?: Options): URIComponent;

export function serialize(component: URIComponent, opts?: Options): string;

export function equal(uriA: string, uriB: string): boolean;

export function resolve(base: string, path: string): string;

export const fastUri: FastUri
export { fastUri as default }
}

export = fastUri
17 changes: 17 additions & 0 deletions types/index.test-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import uri, { URIComponents, URIComponent, Options, options } from "..";
import { expectDeprecated, expectType } from "tsd";

const parsed = uri.parse("foo");
expectType<URIComponents>(parsed);
const parsed2 = uri.parse("foo", {
domainHost: true,
scheme: 'https',
unicodeSupport: false
})
expectType<URIComponents>(parsed2);

expectType<URIComponent>({} as URIComponents)
expectDeprecated({} as URIComponents)

expectType<Options>({} as options)
expectDeprecated({} as options)