Skip to content

Commit

Permalink
re
Browse files Browse the repository at this point in the history
  • Loading branch information
sanchezzzhak committed Sep 16, 2024
1 parent 83cdd61 commit e903753
Show file tree
Hide file tree
Showing 14 changed files with 31 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
node_modules
.nyc_output
coverage/
dist
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import CLIENT_PARSER_LIST from './parser/const/client-parser';
import MOBILE_BROWSER_LIST from './parser/client/browser-short-mobile';
// helpers
import * as helper from './parser/helper';
import * as module from 'module';

const { hasUserAgentClientHintsFragment, hasDeviceModelByClientHints, attr } = helper;

Expand Down Expand Up @@ -1075,4 +1076,4 @@ export class DeviceDetector {
);
}

}
}
6 changes: 5 additions & 1 deletion src/parser/abstract-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,18 @@ function fixStringVersion(result) {

const collectionMap = {};

export class AbstractParser {
export default class AbstractParser {

public fixtureFile: string|null;
public versionTruncation: number|null;
public type: string;
public maxUserAgentSize: number| null;
public collectionLength: number| null;

constructor() {
/* */
}

get collection() {
if (!this.hasLoadCollection()) {
return null;
Expand Down
2 changes: 1 addition & 1 deletion src/parser/bot-parser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AbstractParser} from './abstract-parser';
import AbstractParser from './abstract-parser';
import { ResultBot } from '../index';

export class BotParser extends AbstractParser {
Expand Down
2 changes: 1 addition & 1 deletion src/parser/client-abstract-parser.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { IndexerClient } from './client/indexer-client';

import { AbstractParser } from './abstract-parser';
import AbstractParser from './abstract-parser';
import { JSONObject, ResultClientHints } from '../client-hints';
import { ResultClient } from '../index';

Expand Down
6 changes: 3 additions & 3 deletions src/parser/client/hints/app-hints.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import {AbstractParser} from '../../abstract-parser';
import AbstractParser from '../../abstract-parser';
import { ResultClientHints } from '../../../client-hints';

export class AppHints extends AbstractParser
Expand All @@ -11,14 +11,14 @@ export class AppHints extends AbstractParser
}

parse(clientHints: ResultClientHints) {
let appId = clientHints.app;
const appId = clientHints.app;
if (!appId) {
return null;
}
if (this.collection[appId] === void 0) {
return null;
}
let name = this.collection[appId];
const name = this.collection[appId];
return {
name: String(name)
};
Expand Down
2 changes: 1 addition & 1 deletion src/parser/client/hints/browser-hints.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {AbstractParser} from '../../abstract-parser';
import AbstractParser from '../../abstract-parser';
import { ResultClientHints } from '../../../client-hints';

export class BrowserHints extends AbstractParser
Expand Down
2 changes: 1 addition & 1 deletion src/parser/device-abstract-parser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {AbstractParser} from './abstract-parser';
import AbstractParser from './abstract-parser';
import * as helper from './helper';

import COLLECTION_BRAND_IDS from './device/brand-short';
Expand Down
5 changes: 3 additions & 2 deletions src/parser/device/alias-device.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import {ResultAliasDevice } from '../../index';
import {AbstractParser } from '../abstract-parser';
import AbstractParser from '../abstract-parser';


import * as helper from './../helper';
import BRAND_SHORTS from './brand-short';

const COLLECTION_BRAND_LIST = helper.revertObject(require('./brand-short'));
const COLLECTION_BRAND_LIST = helper.revertObject(BRAND_SHORTS);

const createReplaceBrandRegexp = () => {
const escapeeChars = [/\+/gi, /\./gi];
Expand Down
2 changes: 1 addition & 1 deletion src/parser/device/info-device.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AbstractParser } from '../abstract-parser';
import AbstractParser from '../abstract-parser';


import {DataPacker} from '../../data-packer';
Expand Down
2 changes: 1 addition & 1 deletion src/parser/os-parser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {AbstractParser} from './abstract-parser'
import AbstractParser from './abstract-parser'
import * as helper from './helper';

import * as OS_SYSTEMS from './os/os_systems';
Expand Down
2 changes: 1 addition & 1 deletion src/parser/vendor-fragment-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as helper from './helper';

import BRAND_SHORTS from './device/brand-short';
import { ResultVendor } from '../index';
import { AbstractParser } from './abstract-parser';
import AbstractParser from './abstract-parser';

const COLLECTION_BRAND_LIST = helper.revertObject(BRAND_SHORTS);

Expand Down
7 changes: 5 additions & 2 deletions tests/abstract-parser.spec.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
const AbstractParser = require('../parser/abstract-parser')
const AbstractParser = require('../dist/cjs/parser/abstract-parser')
const { should, assert, expect } = require('chai');

console.log(AbstractParser);

describe('tests AbstractParser', function () {
let parser = new AbstractParser;

let parser = new AbstractParser();
it('AbstractParser::getBaseRegExp', () => {
let regex = 'ASUS_Z012DE';
expect(parser.getBaseRegExp(regex).test('ASUS_Z012DE')).to.equal(true);
Expand Down
6 changes: 5 additions & 1 deletion tsconfig-cjs.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"compilerOptions": {
"module": "commonjs",
"outDir": "dist/cjs",
"target": "esnext"
"target": "esnext",
// "noImplicitAny": false,
// "skipLibCheck": true,
// "resolveJsonModule": true,
// "esModuleInterop": true
}
}

0 comments on commit e903753

Please sign in to comment.