@hyperlane-xyz/utils
Version:
General utilities and types for the Hyperlane network
18 lines • 541 B
JavaScript
import { parse as yamlParse } from 'yaml';
import { rootLogger } from './logging.js';
import { failure, success } from './result.js';
export function tryParseJsonOrYaml(input) {
try {
if (input.startsWith('{')) {
return success(JSON.parse(input));
}
else {
return success(yamlParse(input));
}
}
catch (error) {
rootLogger.error('Error parsing JSON or YAML', error);
return failure('Input is not valid JSON or YAML');
}
}
//# sourceMappingURL=yaml.js.map