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

eg/show-paths.ts   A

Complexity

Total Complexity 2
Complexity/F 2

Size

Lines of Code 22
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 16
mnd 1
bc 1
fnc 1
dl 0
loc 22
rs 10
bpm 1
cpm 2
noi 0
c 0
b 0
f 0
1
import osPaths from '../dist/cjs/mod.cjs.js'; // ## maint: [2021-02-07; rivy] await resolution of <https://github.com/TypeStrong/ts-node/issues/783> to return to direct TS import
2
3
/* eslint-disable no-console , functional/immutable-data , security/detect-object-injection, security-node/detect-crlf , @typescript-eslint/no-explicit-any */
4
5
function objectEntries(obj: any) {
6
	const map: any = {};
7
	Object.keys(obj).forEach((key) => {
8
		const value = obj[key];
9
		const val = typeof value === 'function' ? value() : value;
10
		map[key] = val;
11
	});
12
	return map;
13
}
14
15
console.log({ osPaths });
16
console.log(objectEntries(osPaths));
17
console.log('home() =', osPaths.home());
18
console.log('temp() =', osPaths.temp());
19
20
process.env.TMPDIR = process.env.TEMP = process.env.TMP = 'temp';
21
console.log(objectEntries(osPaths));
22
23
/* eslint-enable no-console , functional/immutable-data , security/detect-object-injection, security-node/detect-crlf , @typescript-eslint/no-explicit-any*/
24