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

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

Complexity

Total Complexity 2
Complexity/F 2

Size

Lines of Code 39
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 39
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.CDN.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://cdn.jsdelivr.net/gh/rivy/js.os-paths@latest/src/mod.deno.ts';
8
// import osPaths from 'https://cdn.jsdelivr.net/gh/rivy/js.os-paths/src/mod.deno.ts';
9
// import osPaths from 'https://cdn.jsdelivr.net/gh/rivy/js.os-paths@6/src/mod.deno.ts';
10
// import osPaths from 'https://cdn.jsdelivr.net/gh/rivy/[email protected]/src/mod.deno.ts';
11
// import osPaths from 'https://cdn.jsdelivr.net/gh/rivy/js.os-paths@2d5924e692617a575c8a73c9fb611e93085c4339/src/mod.deno.ts';
12
13
// create a local reference to refer to `Deno` (for better linting without need for multiple `// @ts-ignore` directives)
14
// @ts-ignore
15
const deno = Deno;
16
17
function objectEntries(obj: any) {
18
	const map: any = {};
19
	Object.keys(obj).forEach((key) => {
20
		const value = obj[key];
21
		const val = typeof value === 'function' ? value() : value;
22
		map[key] = val;
23
	});
24
	return map;
25
}
26
27
console.log({ osPaths });
28
console.log(objectEntries(osPaths));
29
console.log('home() =', osPaths.home());
30
console.log('temp() =', osPaths.temp());
31
32
deno.env.set('TEMP', 'temp');
33
deno.env.set('TMPDIR', 'tmpdir');
34
deno.env.set('TMP', 'tmp');
35
console.log(objectEntries(osPaths));
36
37
deno.env.set('TEMP', 'NEW');
38
console.log(objectEntries(osPaths));
39
40
/* 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 */
41