Passed
Push — next ( ddaeb9 )
by Roy
01:29
created

show-paths.remote.CDN.deno.ts ➔ objectEntries   A

Complexity

Conditions 2

Size

Total Lines 9
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 8
dl 0
loc 9
rs 10
c 0
b 0
f 0
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@2d5924e692617a575c8a73c9fb611e93085c4339/src/mod.deno.ts';
8
// import osPaths from 'https://cdn.jsdelivr.net/gh/rivy/js.os-paths@latest/src/mod.deno.ts';
9
// import osPaths from 'https://cdn.jsdelivr.net/gh/rivy/[email protected]/src/mod.deno.ts';
10
11
// create a local reference to refer to `Deno` (for better linting without need for multiple `// @ts-ignore` directives)
12
// @ts-ignore
13
const deno = Deno;
14
15
function objectEntries(obj: any) {
16
	const map: any = {};
17
	Object.keys(obj).forEach((key) => {
18
		const value = obj[key];
19
		const val = typeof value === 'function' ? value() : value;
20
		map[key] = val;
21
	});
22
	return map;
23
}
24
25
console.log({ osPaths });
26
console.log(objectEntries(osPaths));
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