cmpstr-cli
Version:
Simple CLI wrapper for the CmpStr package to normalize and compare strings directly via terminal
33 lines • 1.12 kB
JavaScript
/**
* @fileoverview
* Normalize command for CmpStr CLI.
*
* Normalizes the input string using the specified normalization flags.
* Supports both synchronous and asynchronous processing.
*
* @author Paul Köhler (komed3)
* @license MIT
*/
;
import { Normalizer } from 'cmpstr';
import { cfg } from '../utils/config.js';
import { resolveInput } from '../utils/input.js';
import { output } from '../utils/output.js';
/**
* Normalizes the input string according to the specified flags.
*
* @async
* @param {string} input - The input string or file path to normalize.
* @param {Record<string, any>} [opt] - Normalization options.
* @param {Command} cmd - The Commander command instance.
* @returns {Promise<void>}
*/
export async function normalize(input, opt = Object.create(null), cmd) {
const config = await cfg(cmd, opt);
const { async = false, flags = '' } = config;
const text = await resolveInput(input);
output(config, cmd, async
? await Normalizer.normalizeAsync(text, flags)
: Normalizer.normalize(text, flags));
}
//# sourceMappingURL=normalize.js.map