Passed
Push — next ( b7c15f...ff7ad3 )
by Roy
02:54 queued 01:36
created

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

Complexity

Conditions 2

Size

Total Lines 9
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

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