src: extract several constants to constants.js
This commit is contained in:
parent
7d05b60557
commit
95fc5cb208
3
src/constants.js
Normal file
3
src/constants.js
Normal file
@ -0,0 +1,3 @@
|
||||
export const PIPE_ENCODE = 1;
|
||||
export const PIPE_DECODE = -1;
|
||||
export const MAX_BUFFERED_SIZE = 512 * 1024; // 512KB
|
@ -1,5 +1,6 @@
|
||||
import EventEmitter from 'events';
|
||||
import {getPresetClassByName, IPresetStatic} from '../presets';
|
||||
import {PIPE_ENCODE} from '../constants';
|
||||
import {kebabCase} from '../utils';
|
||||
|
||||
const staticPresetCache = new Map(/* 'ClassName': <preset> */);
|
||||
@ -25,9 +26,6 @@ function createPreset(name, params = {}) {
|
||||
return preset;
|
||||
}
|
||||
|
||||
export const PIPE_ENCODE = 1;
|
||||
export const PIPE_DECODE = -1;
|
||||
|
||||
/**
|
||||
* abstraction of middleware
|
||||
*/
|
||||
|
@ -1,5 +1,6 @@
|
||||
import EventEmitter from 'events';
|
||||
import {Middleware, PIPE_ENCODE} from './middleware';
|
||||
import {Middleware} from './middleware';
|
||||
import {PIPE_ENCODE} from '../constants';
|
||||
import {PRESET_FAILED} from '../presets/defs';
|
||||
import {logger} from '../utils';
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import EventEmitter from 'events';
|
||||
import {Pipe} from './pipe';
|
||||
import {PIPE_ENCODE, PIPE_DECODE} from './middleware';
|
||||
import {PIPE_ENCODE, PIPE_DECODE} from '../constants';
|
||||
import {logger} from '../utils';
|
||||
|
||||
import {
|
||||
|
@ -13,7 +13,7 @@ import {
|
||||
getCurrentTimestampInt,
|
||||
EVP_BytesToKey
|
||||
} from '../utils';
|
||||
import {PIPE_DECODE, PIPE_ENCODE} from '../core/middleware';
|
||||
import {PIPE_DECODE, PIPE_ENCODE} from '../constants';
|
||||
|
||||
const readFile = promisify(fs.readFile);
|
||||
const MAX_TIME_DIFF = 30; // seconds
|
||||
|
@ -1,6 +1,6 @@
|
||||
import net from 'net';
|
||||
import {Inbound, Outbound} from './defs';
|
||||
import {PIPE_ENCODE, PIPE_DECODE} from '../core';
|
||||
import {MAX_BUFFERED_SIZE, PIPE_ENCODE, PIPE_DECODE} from '../constants';
|
||||
import {logger, getRandomInt} from '../utils';
|
||||
import {
|
||||
CONNECT_TO_REMOTE,
|
||||
@ -13,8 +13,6 @@ import {
|
||||
PRESET_RESUME_SEND
|
||||
} from '../presets/defs';
|
||||
|
||||
const MAX_BUFFERED_SIZE = 512 * 1024; // 512KB
|
||||
|
||||
export class TcpInbound extends Inbound {
|
||||
|
||||
_socket = null;
|
||||
|
@ -1,6 +1,6 @@
|
||||
import dgram from 'dgram';
|
||||
import {Inbound, Outbound} from './defs';
|
||||
import {PIPE_ENCODE, PIPE_DECODE} from '../core';
|
||||
import {PIPE_ENCODE, PIPE_DECODE} from '../constants';
|
||||
import {CONNECT_TO_REMOTE, CONNECTION_CLOSED, PRESET_FAILED} from '../presets';
|
||||
import {logger} from '../utils';
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user