@hashgraph/solo
Version:
An opinionated CLI tool to deploy and manage private Hedera Networks.
33 lines • 1.15 kB
JavaScript
// SPDX-License-Identifier: Apache-2.0
import { IllegalArgumentError } from '../../business/errors/illegal-argument-error.js';
import { StringEx } from '../../business/utils/string-ex.js';
export class EnvironmentKeyFormatter {
static _instance;
separator = StringEx.UNDERSCORE;
constructor() { }
normalize(key) {
if (StringEx.isEmpty(key)) {
return key;
}
return StringEx.camelCaseToKebab(key).trim().toUpperCase().replaceAll(StringEx.PERIOD, this.separator);
}
split(key) {
if (!key || key.trim().length === 0) {
throw new IllegalArgumentError('key must not be null or undefined');
}
return key.split(this.separator);
}
join(...parts) {
if (!parts || parts.length === 0) {
return null;
}
return parts.join(this.separator);
}
static instance() {
if (!EnvironmentKeyFormatter._instance) {
EnvironmentKeyFormatter._instance = new EnvironmentKeyFormatter();
}
return EnvironmentKeyFormatter._instance;
}
}
//# sourceMappingURL=environment-key-formatter.js.map