mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-21 00:52:55 +00:00
committed by
Karl-Philipp Wulfert
parent
7ef29ef56d
commit
1ae3beb347
@@ -13,15 +13,17 @@
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* A recursive partial object
|
||||
*
|
||||
* Copied from https://stackoverflow.com/a/51365037
|
||||
*/
|
||||
/**
|
||||
* A recursive partial object
|
||||
*
|
||||
* Copied from https://stackoverflow.com/a/51365037
|
||||
*/
|
||||
import {Transport, VerifiableTransport} from './Transport';
|
||||
|
||||
export type RecursivePartial<T> = {
|
||||
[P in keyof T]?: T[P] extends Array<infer U> ?
|
||||
Array<RecursivePartial<U>> :
|
||||
T[P] extends object ? RecursivePartial<T[P]> : T[P];
|
||||
Array<RecursivePartial<U>> :
|
||||
T[P] extends object ? RecursivePartial<T[P]> : T[P];
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -47,3 +49,35 @@ export function deleteUndefinedProperties(obj: any) {
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if environment is Node.js
|
||||
*/
|
||||
export function isNodeEnvironment(): boolean {
|
||||
return Object.prototype.toString.call(typeof process !== 'undefined' ? process : 0) === '[object process]';
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if environment is productive
|
||||
*/
|
||||
export function isProductiveEnvironment(): boolean {
|
||||
return typeof process.env === 'object'
|
||||
&& typeof process.env.NODE_ENV !== 'undefined'
|
||||
&& process.env.NODE_ENV === 'production';
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if environment is Node.js and productive
|
||||
*/
|
||||
export function isProductiveNodeEnvironment(): boolean {
|
||||
return isNodeEnvironment() && isProductiveEnvironment();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a transport is a verifiable transport
|
||||
*
|
||||
* @param transport Transport to check
|
||||
*/
|
||||
export function isTransportWithVerification(transport: Transport): transport is VerifiableTransport {
|
||||
return transport instanceof VerifiableTransport;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user