npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@tinkoff/url

v0.10.3

Published

Utilities to work with urls. Based on standard implementation of [URL](https://url.spec.whatwg.org/#url-class) and [URLSearchParams](https://url.spec.whatwg.org/#interface-urlsearchparams), in case environment does not support these object polyfills shoul

Downloads

5,416

Readme

@tinkoff/url

Utilities to work with urls. Based on standard implementation of URL and URLSearchParams, in case environment does not support these object polyfills should be used, e.g. core-js.

Api

parse

Parses url and returns object of class URL with additional property query which represents searchParams as a simple object.

import { parse } from '@tinkoff/url';

const url = parse('https://tinkoff.ru/test/?a=1&b=2#abc');

url.protocol; // => :https
url.href; // => https://tinkoff.ru/test/?a=1&b=2#abc
url.origin; // => https://tinkoff.ru
url.pathname; // => /test/
url.hash; // => #abc
url.query; // => { a: '1', b: '2' }

rawParse

Same as parse but instead of returning wrapper for URL returns raw URL object

resolve

Computes absolute url for relative url of base value

import { resolve } from '@tinkoff/url';

resolve('//tinkoff.ru', './test123'); // => http://tinkoff.ru/test123
resolve('//tinkoff.ru/a/b/c/', '../../test'); // => http://tinkoff.ru/a/test
resolve('https://tinkoff.ru/a/b/c/?test=123#abc', '.././test/?me=123#123'); // => https://tinkoff.ru/a/b/test/?me=123#123

resolveUrl

Computes absolute url for relative url of base value. Unlike resolve can accept string or URL and return URL wrapper

rawResolveUrl

Same as resolveUrl but instead of returning wrapper for URL returns raw URL object

isAbsoluteUrl

Checks that passed string is absolute url

isInvalidUrl

Checks that passed string represents invalid url

import { isAbsoluteUrl } from '@tinkoff/url';

isAbsoluteUrl('https://www.exmaple.com'); // true - secure http absolute URL
isAbsoluteUrl('//cdn.example.com/lib.js'); // true - protocol-relative absolute URL
isAbsoluteUrl('/myfolder/test.txt'); // false - relative URL

convertRawUrl

Returns handy wrapper for URL in form of plain object with some additional fields

rawAssignUrl

Allows to set parameters to passed raw URL object (passed URL-object will be changed)