repositories
/
e-mobility-charging-stations-simulator.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request #783 from SAP/dependabot/npm_and_yarn/mikro-orm/sqlite-5.8.8
[e-mobility-charging-stations-simulator.git]
/
src
/
utils
/
Utils.ts
diff --git
a/src/utils/Utils.ts
b/src/utils/Utils.ts
index c29f8d156687139aeefb640ae5e0741add8c2924..6a3d30fee9bbcebdc264a6239dfaec8601e1c5eb 100644
(file)
--- a/
src/utils/Utils.ts
+++ b/
src/utils/Utils.ts
@@
-1,4
+1,5
@@
-import { randomBytes, randomInt, randomUUID } from 'node:crypto';
+import { randomBytes, randomInt, randomUUID, webcrypto } from 'node:crypto';
+import { env } from 'node:process';
import { inspect } from 'node:util';
import {
import { inspect } from 'node:util';
import {
@@
-216,11
+217,11
@@
type CloneableData =
type FormatKey = (key: string) => string;
type FormatKey = (key: string) => string;
-
function deepClone
<I extends CloneableData, O extends CloneableData = I>(
+
const deepClone =
<I extends CloneableData, O extends CloneableData = I>(
value: I,
formatKey?: FormatKey,
refs: Map<I, O> = new Map<I, O>(),
value: I,
formatKey?: FormatKey,
refs: Map<I, O> = new Map<I, O>(),
-): O {
+): O
=>
{
const ref = refs.get(value);
if (ref !== undefined) {
return ref;
const ref = refs.get(value);
if (ref !== undefined) {
return ref;
@@
-249,7
+250,7
@@
function deepClone<I extends CloneableData, O extends CloneableData = I>(
);
}
return clone as O;
);
}
return clone as O;
-}
+}
;
export const cloneObject = <T>(object: T): T => {
return deepClone(object as CloneableData) as T;
export const cloneObject = <T>(object: T): T => {
return deepClone(object as CloneableData) as T;
@@
-260,7
+261,7
@@
export const hasOwnProp = (object: unknown, property: PropertyKey): boolean => {
};
export const isCFEnvironment = (): boolean => {
};
export const isCFEnvironment = (): boolean => {
- return !isNullOrUndefined(
process.
env.VCAP_APPLICATION);
+ return !isNullOrUndefined(env.VCAP_APPLICATION);
};
export const isIterable = <T>(obj: T): boolean => {
};
export const isIterable = <T>(obj: T): boolean => {
@@
-354,10
+355,10
@@
export const promiseWithTimeout = async <T>(
/**
* Generates a cryptographically secure random number in the [0,1[ range
*
/**
* Generates a cryptographically secure random number in the [0,1[ range
*
- * @returns
+ * @returns
A number in the [0,1[ range
*/
export const secureRandom = (): number => {
*/
export const secureRandom = (): number => {
- return
randomBytes(4).readUInt32LE()
/ 0x100000000;
+ return
webcrypto.getRandomValues(new Uint32Array(1))[0]
/ 0x100000000;
};
export const JSONStringifyWithMapSupport = (
};
export const JSONStringifyWithMapSupport = (