How to use the tldts-core.getEmptyResult function in tldts-core

To help you get started, we’ve selected a few tldts-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github remusao / tldts / packages / tldts-experimental / index.ts View on Github external
import { FLAG, getEmptyResult, IOptions, IResult, parseImpl, resetResult } from 'tldts-core';
import suffixLookup from './src/packed-hashes';

// For all methods but 'parse', it does not make sense to allocate an object
// every single time to only return the value of a specific attribute. To avoid
// this un-necessary allocation, we use a global object which is re-used.
const RESULT: IResult = getEmptyResult();

export function parse(url: string, options: Partial = {}): IResult {
  return parseImpl(url, FLAG.ALL, suffixLookup, options, getEmptyResult());
}

export function getHostname(
  url: string,
  options: Partial = {},
): string | null {
  resetResult(RESULT);
  return parseImpl(url, FLAG.HOSTNAME, suffixLookup, options, RESULT).hostname;
}

export function getPublicSuffix(
  url: string,
  options: Partial = {},
github remusao / tldts / packages / tldts / index.ts View on Github external
import { FLAG, getEmptyResult, IOptions, IResult, parseImpl, resetResult } from 'tldts-core';
import suffixLookup from './src/suffix-trie';

// For all methods but 'parse', it does not make sense to allocate an object
// every single time to only return the value of a specific attribute. To avoid
// this un-necessary allocation, we use a global object which is re-used.
const RESULT: IResult = getEmptyResult();

export function parse(url: string, options: Partial = {}): IResult {
  return parseImpl(url, FLAG.ALL, suffixLookup, options, getEmptyResult());
}

export function getHostname(
  url: string,
  options: Partial = {},
): string | null {
  resetResult(RESULT);
  return parseImpl(url, FLAG.HOSTNAME, suffixLookup, options, RESULT).hostname;
}

export function getPublicSuffix(
  url: string,
  options: Partial = {},

tldts-core

tldts core primitives (internal module)

MIT
Latest version published 4 days ago

Package Health Score

83 / 100
Full package analysis

Similar packages