1.0.1 • Published 8 months ago

@openally/auto-url v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
8 months ago

Requirements

Getting Started

This package is available in the Node Package Repository and can be easily installed with npm or yarn.

$ npm i @openally/auto-url
# or
$ yarn add @openally/auto-url

Usage example

import autoURL from "@openally/auto-url";

const myURL = autoURL(
  "https://www.google.fr",
  { foo: "bar" },
  { foo: (value) => value.toUpperCase() }
);

// https://google.fr/?foo=BAR
console.log(myURL.href);

API

export type autoURLTransformCallback = (value: string) => string;
export type autoURLTransformConfig<T extends string> = Record<T, autoURLTransformCallback>;

function autoURL<T extends string>(
  source: string | URL,
  payload?: Record<T, any> | Iterable<[T, any]>,
  transformersConfig: autoURLTransformConfig<T>
): URL

License

MIT

1.0.1

8 months ago

1.0.0

8 months ago