Completed
Push — master ( cdadad...8d09a6 )
by Dimas
36:02 queued 17:12
created

libs/typings/node/util.d.ts   F

Complexity

Total Complexity 93
Complexity/F 1

Size

Lines of Code 195
Function Count 93

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 172
dl 0
loc 195
rs 2
c 0
b 0
f 0
wmc 93
mnd 0
bc 0
fnc 93
bpm 0
cpm 1
noi 0

64 Functions

Rating   Name   Duplication   Size   Complexity  
A util.d.ts ➔ isArray 0 2 1
A util.d.ts ➔ callbackify 0 2 1
A util.d.ts ➔ isGeneratorFunction 0 1 1
A util.d.ts ➔ isUint8Array 0 1 1
A util.d.ts ➔ isAnyArrayBuffer 0 1 1
A util.d.ts ➔ format 0 1 1
A util.d.ts ➔ isSetIterator 0 1 1
A util.d.ts ➔ isRegExp 0 2 1
A util.d.ts ➔ isNativeError 0 1 1
A util.d.ts ➔ isWeakSet 0 1 1
A util.d.ts ➔ isInt8Array 0 1 1
A util.d.ts ➔ isStringObject 0 1 1
A util.d.ts ➔ isInt16Array 0 1 1
A util.d.ts ➔ isDate 0 2 1
A util.d.ts ➔ debuglog 0 1 1
A util.d.ts ➔ formatWithOptions 0 1 1
A util.d.ts ➔ isUint32Array 0 1 1
A util.d.ts ➔ isInt32Array 0 1 1
A util.d.ts ➔ inspect 0 1 1
A util.d.ts ➔ isFloat32Array 0 1 1
A util.d.ts ➔ isModuleNamespaceObject 0 1 1
A TextEncoder.encode 0 1 1
A util.d.ts ➔ isBoolean 0 2 1
A util.d.ts ➔ isError 0 2 1
A util.d.ts ➔ isBoxedPrimitive 0 1 1
A util.d.ts ➔ isTypedArray 0 1 1
A util.d.ts ➔ isGeneratorObject 0 1 1
A util.d.ts ➔ isUint16Array 0 1 1
A util.d.ts ➔ isDataView 0 1 1
A util.d.ts ➔ isNumber 0 2 1
A TextEncoder.encodeInto 0 1 1
A util.d.ts ➔ isMapIterator 0 1 1
A TextDecoder.decode 0 4 1
A util.d.ts ➔ log 0 2 1
A util.d.ts ➔ isBuffer 0 2 1
A util.d.ts ➔ inherits 0 1 1
A util.d.ts ➔ isUint8ClampedArray 0 1 1
A util.d.ts ➔ isPrimitive 0 2 1
A util.d.ts ➔ promisify 0 2 1
A util.d.ts ➔ isUndefined 0 2 1
A util.d.ts ➔ isAsyncFunction 0 1 1
A util.d.ts ➔ isArrayBufferView 0 1 1
A util.d.ts ➔ isNullOrUndefined 0 2 1
A util.d.ts ➔ isSharedArrayBuffer 0 1 1
A util.d.ts ➔ isFloat64Array 0 1 1
A util.d.ts ➔ isObject 0 2 1
A util.d.ts ➔ isArrayBuffer 0 1 1
A util.d.ts ➔ isProxy 0 1 1
A util.d.ts ➔ isExternal 0 1 1
A util.d.ts ➔ isFunction 0 2 1
A util.d.ts ➔ isSet 0 1 1
A util.d.ts ➔ isString 0 2 1
A util.d.ts ➔ isWeakMap 0 1 1
A util.d.ts ➔ isSymbolObject 0 1 1
A util.d.ts ➔ isBooleanObject 0 1 1
A util.d.ts ➔ isSymbol 0 2 1
A util.d.ts ➔ isMap 0 1 1
A util.d.ts ➔ isArgumentsObject 0 1 1
A util.d.ts ➔ isNull 0 2 1
A util.d.ts ➔ isWebAssemblyCompiledModule 0 1 1
A util.d.ts ➔ deprecate 0 1 1
A util.d.ts ➔ isDeepStrictEqual 0 1 1
A util.d.ts ➔ isPromise 0 1 1
A util.d.ts ➔ isNumberObject 0 1 1

How to fix   Complexity   

Complexity

Complex classes like libs/typings/node/util.d.ts often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

1
declare module "util" {
2
    interface InspectOptions extends NodeJS.InspectOptions { }
3
    type Style = 'special' | 'number' | 'bigint' | 'boolean' | 'undefined' | 'null' | 'string' | 'symbol' | 'date' | 'regexp' | 'module';
4
    type CustomInspectFunction = (depth: number, options: InspectOptionsStylized) => string;
5
    interface InspectOptionsStylized extends InspectOptions {
6
        stylize(text: string, styleType: Style): string;
7
    }
8
    function format(format: any, ...param: any[]): string;
9
    function formatWithOptions(inspectOptions: InspectOptions, format: string, ...param: any[]): string;
10
    /** @deprecated since v0.11.3 - use a third party module instead. */
11
    function log(string: string): void;
12
    function inspect(object: any, showHidden?: boolean, depth?: number | null, color?: boolean): string;
13
    function inspect(object: any, options: InspectOptions): string;
14
    namespace inspect {
15
        let colors: NodeJS.Dict<[number, number]>;
16
        let styles: {
17
            [K in Style]: string
18
        };
19
        let defaultOptions: InspectOptions;
20
        /**
21
         * Allows changing inspect settings from the repl.
22
         */
23
        let replDefaults: InspectOptions;
24
        const custom: unique symbol;
25
    }
26
    /** @deprecated since v4.0.0 - use `Array.isArray()` instead. */
27
    function isArray(object: any): object is any[];
28
    /** @deprecated since v4.0.0 - use `util.types.isRegExp()` instead. */
29
    function isRegExp(object: any): object is RegExp;
30
    /** @deprecated since v4.0.0 - use `util.types.isDate()` instead. */
31
    function isDate(object: any): object is Date;
32
    /** @deprecated since v4.0.0 - use `util.types.isNativeError()` instead. */
33
    function isError(object: any): object is Error;
34
    function inherits(constructor: any, superConstructor: any): void;
35
    function debuglog(key: string): (msg: string, ...param: any[]) => void;
36
    /** @deprecated since v4.0.0 - use `typeof value === 'boolean'` instead. */
37
    function isBoolean(object: any): object is boolean;
38
    /** @deprecated since v4.0.0 - use `Buffer.isBuffer()` instead. */
39
    function isBuffer(object: any): object is Buffer;
40
    /** @deprecated since v4.0.0 - use `typeof value === 'function'` instead. */
41
    function isFunction(object: any): boolean;
42
    /** @deprecated since v4.0.0 - use `value === null` instead. */
43
    function isNull(object: any): object is null;
44
    /** @deprecated since v4.0.0 - use `value === null || value === undefined` instead. */
45
    function isNullOrUndefined(object: any): object is null | undefined;
46
    /** @deprecated since v4.0.0 - use `typeof value === 'number'` instead. */
47
    function isNumber(object: any): object is number;
48
    /** @deprecated since v4.0.0 - use `value !== null && typeof value === 'object'` instead. */
49
    function isObject(object: any): boolean;
50
    /** @deprecated since v4.0.0 - use `(typeof value !== 'object' && typeof value !== 'function') || value === null` instead. */
51
    function isPrimitive(object: any): boolean;
52
    /** @deprecated since v4.0.0 - use `typeof value === 'string'` instead. */
53
    function isString(object: any): object is string;
54
    /** @deprecated since v4.0.0 - use `typeof value === 'symbol'` instead. */
55
    function isSymbol(object: any): object is symbol;
56
    /** @deprecated since v4.0.0 - use `value === undefined` instead. */
57
    function isUndefined(object: any): object is undefined;
58
    function deprecate<T extends Function>(fn: T, message: string, code?: string): T;
59
    function isDeepStrictEqual(val1: any, val2: any): boolean;
60
61
    function callbackify(fn: () => Promise<void>): (callback: (err: NodeJS.ErrnoException) => void) => void;
62
    function callbackify<TResult>(fn: () => Promise<TResult>): (callback: (err: NodeJS.ErrnoException, result: TResult) => void) => void;
63
    function callbackify<T1>(fn: (arg1: T1) => Promise<void>): (arg1: T1, callback: (err: NodeJS.ErrnoException) => void) => void;
64
    function callbackify<T1, TResult>(fn: (arg1: T1) => Promise<TResult>): (arg1: T1, callback: (err: NodeJS.ErrnoException, result: TResult) => void) => void;
65
    function callbackify<T1, T2>(fn: (arg1: T1, arg2: T2) => Promise<void>): (arg1: T1, arg2: T2, callback: (err: NodeJS.ErrnoException) => void) => void;
66
    function callbackify<T1, T2, TResult>(fn: (arg1: T1, arg2: T2) => Promise<TResult>): (arg1: T1, arg2: T2, callback: (err: NodeJS.ErrnoException | null, result: TResult) => void) => void;
67
    function callbackify<T1, T2, T3>(fn: (arg1: T1, arg2: T2, arg3: T3) => Promise<void>): (arg1: T1, arg2: T2, arg3: T3, callback: (err: NodeJS.ErrnoException) => void) => void;
68
    function callbackify<T1, T2, T3, TResult>(
69
        fn: (arg1: T1, arg2: T2, arg3: T3) => Promise<TResult>): (arg1: T1, arg2: T2, arg3: T3, callback: (err: NodeJS.ErrnoException | null, result: TResult) => void) => void;
70
    function callbackify<T1, T2, T3, T4>(
71
        fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<void>): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: NodeJS.ErrnoException) => void) => void;
72
    function callbackify<T1, T2, T3, T4, TResult>(
73
        fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<TResult>): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: NodeJS.ErrnoException | null, result: TResult) => void) => void;
74
    function callbackify<T1, T2, T3, T4, T5>(
75
        fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<void>): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err: NodeJS.ErrnoException) => void) => void;
76
    function callbackify<T1, T2, T3, T4, T5, TResult>(
77
        fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<TResult>,
78
    ): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err: NodeJS.ErrnoException | null, result: TResult) => void) => void;
79
    function callbackify<T1, T2, T3, T4, T5, T6>(
80
        fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6) => Promise<void>,
81
    ): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, callback: (err: NodeJS.ErrnoException) => void) => void;
82
    function callbackify<T1, T2, T3, T4, T5, T6, TResult>(
83
        fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6) => Promise<TResult>
84
    ): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, arg6: T6, callback: (err: NodeJS.ErrnoException | null, result: TResult) => void) => void;
85
86
    interface CustomPromisifyLegacy<TCustom extends Function> extends Function {
87
        __promisify__: TCustom;
88
    }
89
90
    interface CustomPromisifySymbol<TCustom extends Function> extends Function {
91
        [promisify.custom]: TCustom;
92
    }
93
94
    type CustomPromisify<TCustom extends Function> = CustomPromisifySymbol<TCustom> | CustomPromisifyLegacy<TCustom>;
95
96
    function promisify<TCustom extends Function>(fn: CustomPromisify<TCustom>): TCustom;
97
    function promisify<TResult>(fn: (callback: (err: any, result: TResult) => void) => void): () => Promise<TResult>;
98
    function promisify(fn: (callback: (err?: any) => void) => void): () => Promise<void>;
99
    function promisify<T1, TResult>(fn: (arg1: T1, callback: (err: any, result: TResult) => void) => void): (arg1: T1) => Promise<TResult>;
100
    function promisify<T1>(fn: (arg1: T1, callback: (err?: any) => void) => void): (arg1: T1) => Promise<void>;
101
    function promisify<T1, T2, TResult>(fn: (arg1: T1, arg2: T2, callback: (err: any, result: TResult) => void) => void): (arg1: T1, arg2: T2) => Promise<TResult>;
102
    function promisify<T1, T2>(fn: (arg1: T1, arg2: T2, callback: (err?: any) => void) => void): (arg1: T1, arg2: T2) => Promise<void>;
103
    function promisify<T1, T2, T3, TResult>(fn: (arg1: T1, arg2: T2, arg3: T3, callback: (err: any, result: TResult) => void) => void):
104
        (arg1: T1, arg2: T2, arg3: T3) => Promise<TResult>;
105
    function promisify<T1, T2, T3>(fn: (arg1: T1, arg2: T2, arg3: T3, callback: (err?: any) => void) => void): (arg1: T1, arg2: T2, arg3: T3) => Promise<void>;
106
    function promisify<T1, T2, T3, T4, TResult>(
107
        fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: any, result: TResult) => void) => void,
108
    ): (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<TResult>;
109
    function promisify<T1, T2, T3, T4>(fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err?: any) => void) => void):
110
        (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<void>;
111
    function promisify<T1, T2, T3, T4, T5, TResult>(
112
        fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err: any, result: TResult) => void) => void,
113
    ): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<TResult>;
114
    function promisify<T1, T2, T3, T4, T5>(
115
        fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err?: any) => void) => void,
116
    ): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<void>;
117
    function promisify(fn: Function): Function;
118
    namespace promisify {
119
        const custom: unique symbol;
120
    }
121
122
    namespace types {
123
        function isAnyArrayBuffer(object: any): boolean;
124
        function isArgumentsObject(object: any): object is IArguments;
125
        function isArrayBuffer(object: any): object is ArrayBuffer;
126
        function isArrayBufferView(object: any): object is ArrayBufferView;
127
        function isAsyncFunction(object: any): boolean;
128
        function isBooleanObject(object: any): object is Boolean;
129
        function isBoxedPrimitive(object: any): object is (Number | Boolean | String | Symbol /* | Object(BigInt) | Object(Symbol) */);
130
        function isDataView(object: any): object is DataView;
131
        function isDate(object: any): object is Date;
132
        function isExternal(object: any): boolean;
133
        function isFloat32Array(object: any): object is Float32Array;
134
        function isFloat64Array(object: any): object is Float64Array;
135
        function isGeneratorFunction(object: any): boolean;
136
        function isGeneratorObject(object: any): boolean;
137
        function isInt8Array(object: any): object is Int8Array;
138
        function isInt16Array(object: any): object is Int16Array;
139
        function isInt32Array(object: any): object is Int32Array;
140
        function isMap(object: any): boolean;
141
        function isMapIterator(object: any): boolean;
142
        function isModuleNamespaceObject(value: any): boolean;
143
        function isNativeError(object: any): object is Error;
144
        function isNumberObject(object: any): object is Number;
145
        function isPromise(object: any): boolean;
146
        function isProxy(object: any): boolean;
147
        function isRegExp(object: any): object is RegExp;
148
        function isSet(object: any): boolean;
149
        function isSetIterator(object: any): boolean;
150
        function isSharedArrayBuffer(object: any): boolean;
151
        function isStringObject(object: any): boolean;
152
        function isSymbolObject(object: any): boolean;
153
        function isTypedArray(object: any): object is NodeJS.TypedArray;
154
        function isUint8Array(object: any): object is Uint8Array;
155
        function isUint8ClampedArray(object: any): object is Uint8ClampedArray;
156
        function isUint16Array(object: any): object is Uint16Array;
157
        function isUint32Array(object: any): object is Uint32Array;
158
        function isWeakMap(object: any): boolean;
159
        function isWeakSet(object: any): boolean;
160
        function isWebAssemblyCompiledModule(object: any): boolean;
161
    }
162
163
    class TextDecoder {
164
        readonly encoding: string;
165
        readonly fatal: boolean;
166
        readonly ignoreBOM: boolean;
167
        constructor(
168
          encoding?: string,
169
          options?: { fatal?: boolean; ignoreBOM?: boolean }
170
        );
171
        decode(
172
          input?: NodeJS.ArrayBufferView | ArrayBuffer | null,
173
          options?: { stream?: boolean }
174
        ): string;
175
    }
176
177
    interface EncodeIntoResult {
178
        /**
179
         * The read Unicode code units of input.
180
         */
181
182
        read: number;
183
        /**
184
         * The written UTF-8 bytes of output.
185
         */
186
        written: number;
187
    }
188
189
    class TextEncoder {
190
        readonly encoding: string;
191
        encode(input?: string): Uint8Array;
192
        encodeInto(input: string, output: Uint8Array): EncodeIntoResult;
193
    }
194
}
195