Passed
Push — master ( c61efe...c9bfc4 )
by Roy
01:46
created

eg/show-paths.remote.deno.ts   A

Complexity

Total Complexity 2
Complexity/F 2

Size

Lines of Code 35
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 25
mnd 1
bc 1
fnc 1
dl 0
loc 35
rs 10
bpm 1
cpm 2
noi 0
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A show-paths.remote.deno.ts ➔ objectEntries 0 9 2
1
/* eslint-env es6, deno */
2
// # spell-checker:ignore Deno
3
4
/* eslint-disable no-console , functional/immutable-data , security/detect-object-injection, security-node/detect-crlf , @typescript-eslint/ban-ts-comment , @typescript-eslint/no-explicit-any */
5
6
// @ts-ignore
7
import osPaths from 'https://deno.land/x/[email protected]/src/mod.deno.ts';
8
9
// create a local reference to refer to `Deno` (for better linting without need for multiple `// @ts-ignore` directives)
10
// @ts-ignore
11
const deno = Deno;
12
13
function objectEntries(obj: any) {
14
	const map: any = {};
15
	Object.keys(obj).forEach((key) => {
16
		const value = obj[key];
17
		const val = typeof value === 'function' ? value() : value;
18
		map[key] = val;
19
	});
20
	return map;
21
}
22
23
console.log({ osPaths });
24
console.log(objectEntries(osPaths));
25
console.log('home() =', osPaths.home());
26
console.log('temp() =', osPaths.temp());
27
28
deno.env.set('TEMP', 'temp');
29
deno.env.set('TMPDIR', 'tmpdir');
30
deno.env.set('TMP', 'tmp');
31
console.log(objectEntries(osPaths));
32
33
deno.env.set('TEMP', 'NEW');
34
console.log(objectEntries(osPaths));
35
36
/* eslint-enable no-console , functional/immutable-data , security/detect-object-injection, security-node/detect-crlf , @typescript-eslint/ban-ts-comment , @typescript-eslint/no-explicit-any */
37