Skip to content
This repository has been archived by the owner on May 23, 2022. It is now read-only.

Commit

Permalink
refactor: adjust file structure.
Browse files Browse the repository at this point in the history
  • Loading branch information
pikadun committed Apr 30, 2021
1 parent 8e6a7dd commit 2df1466
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "Redis client for node, support resp3 and redis6.",
"repository": {
"type": "git",
"url": "https://github.com/pikadun/redis"
"url": "https://github.com/camarojs/redis"
},
"license": "MIT",
"scripts": {
Expand Down
3 changes: 2 additions & 1 deletion src/client/baseClient.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Socket } from 'net';
import { ProtoVer } from '../types';
import commands from '../command/commands.json';
import ParserV2 from '../parser/parser.v2';
import ParserV3 from '../parser/parser.v3';
Expand All @@ -12,6 +11,8 @@ export interface IClientOptions {
password?: string;
}

export type ProtoVer = 2 | 3;

export abstract class BaseClient {
private socket = new Socket();
private parser: ParserV2 | ParserV3;
Expand Down
13 changes: 1 addition & 12 deletions src/types.ts → src/library/redisError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,4 @@ export class RedisError extends Error {
super();
this.name = 'Redis Reply Error';
}
}

export class VerbatimString extends String {
constructor(
public format: string,
value: string
) {
super(value);
}
}

export type ProtoVer = 2 | 3;
}
8 changes: 8 additions & 0 deletions src/library/verbatimString.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export class VerbatimString extends String {
constructor(
public format: string,
value: string
) {
super(value);
}
}
3 changes: 2 additions & 1 deletion src/parser/baseParser.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { EventEmitter } from 'events';
import { ProtoVer, RedisError } from '../types';
import { ProtoVer } from '../client/baseClient';
import { RedisError } from '../library/redisError';

export default abstract class BaseParser extends EventEmitter {
constructor(
Expand Down
3 changes: 2 additions & 1 deletion src/parser/parser.v3.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import BaseParser from './baseParser';
import { RedisError, VerbatimString } from '../types';
import { RedisError } from '../library/redisError';
import { VerbatimString } from '../library/verbatimString';

class Parser extends BaseParser {
constructor() {
Expand Down
3 changes: 2 additions & 1 deletion test/parser.v3.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { strictEqual } from 'assert';
import { describe, it } from 'mocha';
import { RedisError, VerbatimString } from '../src/types';
import { RedisError } from '../src/library/redisError';
import { VerbatimString } from '../src/library/verbatimString';
import Parser from '../src/parser/parser.v3';

const parser = new Parser();
Expand Down

0 comments on commit 2df1466

Please sign in to comment.