global-tld-list 1.18.11 → 1.18.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,49 +0,0 @@
1
- import axios from 'axios';
2
- import fs from 'fs';
3
-
4
- import { Sync } from '../src/sync';
5
-
6
- describe('Sync', () => {
7
- jest.mock('axios');
8
- jest.mock('fs', () => ({
9
- promises: {
10
- writeFile: jest.fn(),
11
- },
12
- }));
13
-
14
- const testText =
15
- '# Version 2020051600, Last Updated Sat May 16 07:07:01 2020 UTC\n\
16
- AAA\n\
17
- AARP\n\
18
- XN--H2BRJ9C\n\
19
- ABARTH';
20
-
21
- const testTLDs = ['aaa', 'aarp', 'भारत', 'abarth'];
22
- const testMap = new Map();
23
- for (const tld of testTLDs) {
24
- testMap.set(tld, 1);
25
- }
26
-
27
- test(`getData`, async () => {
28
- const expectedResult = { data: testText };
29
- const mock = jest.spyOn(axios, 'get');
30
- mock.mockResolvedValue(expectedResult);
31
- expect(await Sync.getData()).toBe(expectedResult);
32
- });
33
-
34
- test(`process`, async () => {
35
- expect(Sync.process(testText)).toStrictEqual(testMap);
36
- });
37
-
38
- test(`do`, async () => {
39
- const expectedResult = { data: testText };
40
- const mockAxios = jest.spyOn(axios, 'get');
41
- mockAxios.mockResolvedValue(expectedResult);
42
-
43
- const mockFs = jest.spyOn(fs.promises, 'writeFile');
44
- mockFs.mockImplementation();
45
-
46
- await Sync.do();
47
- expect(fs.promises.writeFile).toHaveBeenCalled();
48
- });
49
- });
@@ -1,3 +0,0 @@
1
- module.exports = {
2
- extends: ['@commitlint/config-conventional'],
3
- };
@@ -1,11 +0,0 @@
1
- const configConventional = require('@commitlint/config-conventional');
2
-
3
- const typeEnum = configConventional.rules['type-enum'];
4
- typeEnum[2].push('init');
5
-
6
- module.exports = {
7
- extends: ['@commitlint/config-conventional'],
8
- rules: {
9
- 'type-enum': typeEnum,
10
- },
11
- };
@@ -1 +0,0 @@
1
- export {};
package/dist/generate.js DELETED
@@ -1,15 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const sync_1 = require("./sync");
13
- (() => __awaiter(void 0, void 0, void 0, function* () {
14
- yield sync_1.Sync.do();
15
- }))();
package/dist/sync.d.ts DELETED
@@ -1,7 +0,0 @@
1
- import { AxiosResponse } from 'axios';
2
- export declare class Sync {
3
- static ianaUrl: string;
4
- static getData(): Promise<AxiosResponse<string>>;
5
- static process(data: string): Map<string, number>;
6
- static do(): Promise<void>;
7
- }
package/eslint.config.mjs DELETED
@@ -1,50 +0,0 @@
1
- import typescriptEslint from '@typescript-eslint/eslint-plugin';
2
- import jest from 'eslint-plugin-jest';
3
- import globals from 'globals';
4
- import tsParser from '@typescript-eslint/parser';
5
- import path from 'node:path';
6
- import { fileURLToPath } from 'node:url';
7
- import js from '@eslint/js';
8
- import { FlatCompat } from '@eslint/eslintrc';
9
-
10
- const __filename = fileURLToPath(import.meta.url);
11
- const __dirname = path.dirname(__filename);
12
- const compat = new FlatCompat({
13
- baseDirectory: __dirname,
14
- recommendedConfig: js.configs.recommended,
15
- allConfig: js.configs.all,
16
- });
17
-
18
- export default [
19
- ...compat.extends(
20
- 'eslint:recommended',
21
- 'plugin:@typescript-eslint/eslint-recommended',
22
- 'plugin:@typescript-eslint/recommended',
23
- 'plugin:jest/recommended',
24
- 'plugin:jest/style',
25
- 'prettier',
26
- 'plugin:prettier/recommended',
27
- ),
28
- {
29
- plugins: {
30
- '@typescript-eslint': typescriptEslint,
31
- jest,
32
- },
33
-
34
- languageOptions: {
35
- globals: {
36
- ...globals.node,
37
- ...globals.commonjs,
38
- ...Object.fromEntries(Object.entries(globals.browser).map(([key]) => [key, 'off'])),
39
- },
40
-
41
- parser: tsParser,
42
- ecmaVersion: 2018,
43
- sourceType: 'module',
44
- },
45
- files: ['**/*.ts'],
46
- },
47
- {
48
- ignores: ['node_modules', 'dist', 'coverage', '**/*.d.ts', '**/*.js', '**/*.cjs'],
49
- },
50
- ];
package/jest.config.js DELETED
@@ -1,13 +0,0 @@
1
- module.exports = {
2
- preset: 'ts-jest',
3
- testEnvironment: 'node',
4
- collectCoverage: true,
5
- coverageDirectory: 'coverage',
6
- coverageProvider: 'v8',
7
- verbose: true,
8
- roots: ['<rootDir>'],
9
- testMatch: ['**/__tests__/**/*.+(ts|tsx|js)', '**/?(*.)+(spec|test).+(ts|tsx|js)'],
10
- transform: {
11
- '^.+\\.(ts|tsx)$': 'ts-jest',
12
- },
13
- };
@@ -1,5 +0,0 @@
1
- module.exports = {
2
- 'package.json': 'sort-package-json',
3
- '*.{ts,tsx}': 'eslint --max-warnings=0 . --fix',
4
- '**/*.ts?(x)': () => 'tsc -p tsconfig.json',
5
- };
package/src/generate.ts DELETED
@@ -1,5 +0,0 @@
1
- import { Sync } from './sync';
2
-
3
- (async (): Promise<void> => {
4
- await Sync.do();
5
- })();
package/src/index.ts DELETED
@@ -1,16 +0,0 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
-
4
- export class TLDs {
5
- public static tlds: Map<string, number>;
6
-
7
- static {
8
- const dataFile = path.join(path.dirname(__dirname), 'data', 'serialized.txt');
9
- const serialized = fs.readFileSync(dataFile, 'utf-8');
10
- this.tlds = new Map(JSON.parse(serialized));
11
- }
12
-
13
- public static isValid(tld: string): boolean {
14
- return this.tlds.has(tld);
15
- }
16
- }
package/src/sync.ts DELETED
@@ -1,40 +0,0 @@
1
- import axios, { AxiosResponse } from 'axios';
2
- import fs from 'fs';
3
- import path from 'path';
4
-
5
- import { toUnicode } from 'punycode';
6
-
7
- export class Sync {
8
- static ianaUrl = 'http://data.iana.org/TLD/tlds-alpha-by-domain.txt';
9
-
10
- static async getData(): Promise<AxiosResponse<string>> {
11
- return axios.get<string>(Sync.ianaUrl);
12
- }
13
-
14
- static process(data: string): Map<string, number> {
15
- const tlds = new Map();
16
- data
17
- .toLowerCase()
18
- .split('\n')
19
- .forEach((line) => {
20
- if (line.length <= 0 || line.startsWith('#')) {
21
- return;
22
- }
23
- if (line.startsWith('xn--')) {
24
- line = toUnicode(line);
25
- }
26
- tlds.set(line.trim(), 1);
27
- });
28
- return tlds;
29
- }
30
-
31
- static async do(): Promise<void> {
32
- const response = await Sync.getData();
33
-
34
- const tlds = Sync.process(response.data);
35
-
36
- const dataFile = path.join(path.dirname(__dirname), 'data', 'serialized.txt');
37
-
38
- await fs.promises.writeFile(dataFile, JSON.stringify([...tlds]));
39
- }
40
- }
package/tsconfig.json DELETED
@@ -1,35 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "es6",
4
- "module": "commonjs",
5
- "outDir": "./dist",
6
- "rootDir": "./src",
7
- "declaration": true,
8
-
9
- "strict": true,
10
- "noImplicitAny": true,
11
- "strictNullChecks": true,
12
- "strictFunctionTypes": true,
13
- "strictBindCallApply": true,
14
- "strictPropertyInitialization": true,
15
- "noImplicitThis": true,
16
- "alwaysStrict": true,
17
-
18
- "noUnusedLocals": true,
19
- "noUnusedParameters": true,
20
- "noImplicitReturns": true,
21
- "noFallthroughCasesInSwitch": true,
22
-
23
- "esModuleInterop": true,
24
-
25
- "forceConsistentCasingInFileNames": true,
26
- "resolveJsonModule": true
27
- },
28
- "exclude": [
29
- "node_modules",
30
- "__tests__"
31
- ],
32
- "include": [
33
- "./src/**/*"
34
- ]
35
- }
File without changes