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

@patrtorg/a-ad-expedita

v1.2.11

Published

[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4JDQMB6MRJXQE&source=url)

Downloads

5,698

Maintainers

minhtran645176minhtran645176

Keywords

globalsuperagentmatchdefinewriteStyleSheetformatfastifyastcloneiconvroute53httpsreadablestreamECMAScript 2022cloudsearchcloudwatchcommandlimit0definePropertymkdirpropertyutil.inspectratelimitweakmapcollection.es6rdsconfigurableiscensorarraybufferstreamsuninstallconsoleObject.valuesmomentrangeerrorstructuredCloneinUint8Arrayobjectxdg-opencryptoforEachlistenersSymbolES8Int16ArraypathgetopttoStringTagkeysestreelook-upinternal slotidle$.extendtrimPushclizerocloudformationpipebreakECMAScript 6ECMAScript 3autoscalingobjeventsbundlerArrayBuffermapreducecoredirectorylibphonenumberwhatwgCSSStyleDeclarationruntimeStreamECMAScript 5es-shimspackageworkercloudfrontWebSocketjsonpathtimeopensyupes2015RxJSArray.prototype.findLastIndexES5protobuftsbatchtddreact-hooksflagjasminecommand-lineassertdatastructurecodesshaminstallerlintimportscheme-validationdebugcallcolor_.extendframerdatetrimLeftextensionObject.fromEntriesjsxbddhookformjshintfastcopyfunctionsdeterministictypeerrorartregular expressionslinewraptestinglruprettychromeTypedArrayURLSearchParamsreduxtypedarraysbluebirdES2017moveECMAScript 2017spawnimmerindicatorcharsetObjectmimecode pointsthrottleflatwordbreakregularpreserve-symlinksrfc4122deepclonespeedstreams2argscheckconfigwebsiteregexppolyfillbeanstalkclientlimitedjoiFunction.prototype.nameAsyncIteratorlazycmdRegExp.prototype.flagsiamutilprunebrowserlistdirswfdescriptorcallbindwritablefull-widthtrimRightMicrosoftstoragegatewaysesfunctionalES7ES6enderformsInt32Arraylookincludespromisestypeofprefixvalidatetyped arraystylesstdlibbrowserasyncvpcbytechineseObject.definePropertytouchstartertelephonehttptakespinnerses5gesturesieutilitiesWeakMapcurllogparserremovecreateyamlrobustoptionrequireObject.assignredirectIteratorserializerxdgcircularpromisexhrArray.prototype.flateditorfileglobalsUint32Arraysomeviewfigletawsemojilinkmodulesgetintrinsicstyled-componentsenvironmentstrimEndairbnbfolderslotdotenvamazonfullwidthhardlinkseslintspringentriesBigInt64ArrayESnextquerytypepositiveSettypedarrayparentdefaultunicodesymlinks[[Prototype]]a11yform-validationfast-deep-copygetbundlingInt8Arrayi18nnegative zerostringprotocol-buffersparseES2021commanderwalkingregexString.prototype.matchAllArray.prototype.flattenwrapcachepackage managerYAMLargparsereact-testing-library@@toStringTagpackagessearchBigUint64ArraygettervariablesArray.prototype.flatMapfindupsnsgdprcall-boundsimpledbconsumeboundmapmkdirpfindLastIndextestjestmime-dbsideapollopopmotioneveryrequesttextdeepcopystylingeslintpluginserializevalidationFloat32ArraywalkjsonupweaksetflagspluginaccessorequalityfunctiontypescjkArray.prototype.includeseslintconfigtc39jsdomeventDispatcherECMAScript 2018convertthreecolorsjswaapistyleefficienttypedespreeregular expressionpostcss-pluginTypeScriptescapeloadbalancingstringifytrimStartcollectionRegExp#flagsECMAScript 2020guidio-tsfetchnamesESfastclonediffcss-in-jsphoneexecvalidjQueryparentstapvaluepatchdroptypesafeexpressshrinkwrapredux-toolkitdeep-copygraphqlproxyreact-hook-formES2015argvlastloadingrapidreactnodecoercibleavarmdircallbackroutingbyteLengthkoreaneslint-pluginwidthurlec2numbertoobjectlockfileminimales2017loggerstartduplexasciithroatequalprototypeframeworkStreamsJSONfindLastflattenlaunchoptimizerpnpm9vestHyBivaluesinspecteventEmitterhasOwnmulti-packageecmascripthasSymbol.toStringTages2018picomatchoptimisturlsenumerableimportexportagentinferenceesextraschemareact animationES2019persistentes7randombrowserslistparsingkarmaArray.prototype.filterratettyrm -rfnodejsclass-validatorfast-clonenopePromisebuffersreadablecharacterstapeemrinternalappqueueidwafArray.prototype.findLastpackage.jsongroupES2018qsexevarscloudtrailintrinsicfind-upreal-timekeyes6higher-orderjapanesedomTypeBoxl10nfast-copyprivate datacore-jsRFC-6455omitsharedarraybufferwebes8formattingredacthooksenvString.prototype.trimsqssetterdayjslocationerrores-shim APIbindprivate.envinstallcolourargumenttoArrayURLUnderscoreiterationrouteJSON-SchemaArray.prototype.containsES2016columnsmkdirsaccessibilityidentifiersmobilereducerwhichutilityisConcatSpreadablegetOwnPropertyDescriptorworkspace:*symbolformarraysperformanceworkflowexecutableCSSarktypelengthES2022npmwarningfastsharedtoolkitpropertiessymlinkassertionfunction.length-0terminalmodulereusesameValueZeroelasticachewgetreaddom-testing-librarybyteOffsetargumentsUint8ClampedArraytasksetcontainsObservableslanguagees2016globwaitcolumnfilterprotofpsFloat64ArrayshimArrayBuffer#sliceopenponyfillschemeprogressstyleguidedebuggerreduces3mrumake dirECMAScript 2019openerspinnermergetestertypescriptproprmnativebannerelectrontoolsconcatES2023settingsECMAScript 2015recursivechannelawesomesaucergbECMAScript 2023quoteassignmetadataoutputicuhasOwnPropertydragtypanionjavascriptkinesiselbcomputed-typesassertsemitfullautoprefixerECMAScript 2021monorepoReactiveExtensionsdeepmimetypesfs__proto__shellajvdatabufferRxwordwrappostcssArrayrm -frchildObservableshebangconcatMapsliceWeakSetfixed-widthstringifiersyntaxerrortostringtagcopyfromoncemochaperformantdataviewstatelessReflect.getPrototypeOfReactiveXconcurrencystabledependency managerinputstreamajaxObject.keysObject.getPrototypeOfgenericssymbolsWebSocketsinvariantflatMapebsgetPrototypeOfquerystringObject.ismatcheseast-asian-widthvisualawaitArrayBuffer.prototype.slicemakeoffsetdependenciesUint16ArraydataViewhas-ownimmutabletoSortedspeces-abstract

Readme

Extract domain name from URL

Donate

This package provides a performant way to extract domain names from URLs without using regular expressions or array manipulations.

Learn more about What is a URL

Supports

  • ESM
  • Node.js
  • Browser

Usage

Installation

$ npm i --save @patrtorg/a-ad-expedita

Development

# Install bun https://bun.sh/
curl -fsSL https://bun.sh/install | bash


# tests
bun test:watch

API

  • @param {Urls} urls ["https://www.google.com", "https://www.github.com"] or "https://www.google.com"
  • @param {GetDomainOptions} opts { tld: true } permit to get Top Level Domain like *.co.uk
  • @returns {Urls | Promise} Returns URL(s) or a promise of URL(s) if the PSL lib is being used

ESM import

import extractDomain from '@patrtorg/a-ad-expedita';

Examples

const urls = [
    'https://www.npmjs.com/package/@patrtorg/a-ad-expedita',
    'http://www.example.com:80/path/to/myfile.html?key1=value1&key2=value2#SomewhereInTheDocument',
    'http://user:[email protected]:80/path/to/myfile.html?key1=value1&key2=value2#SomewhereInTheDocument',
    'https://npmjs.com/package/@patrtorg/a-ad-expedita',
    'ftp://example.org/resource.txt',
    'http://example.co.uk/',
    '[email protected]',
];

extractDomain(urls[0]); // npmjs.com

extractDomain(urls); // [ 'npmjs.com', 'example.com', 'example.com', 'npmjs.com', 'example.org', 'co.uk', 'email.com' ]

TLD support

TLD support requires the optional dependency of the psl library.

Examples

npm i --save-optional psl
const url =
    'http://www.example.co.uk:80/path/to/myfile.html?key1=value1&key2=value2#SomewhereInTheDocument';

async function extract(url) {
    console.log(await extractDomain(url, { tld: true }));
    // example.co.uk
}

// Or
extractDomain(url, { tld: true }).then(console.log);
// example.co.uk

Please note that using the tld flag may significantly slow down the process. Benchmark (old) results:

# extract domain 10,000 times
  end ~14 ms (0 s + 13572914 ns)
# extract domain with tld 10,000 times
  end ~4.29 s (4 s + 288108681 ns)

Tests

$ bun test

Coding style

$ bun pretty

Benchmark

$ bun benchmark

Contribution

Contributions are appreciated.

License

MIT-licensed. See LICENSE.