Martin Karkowski
d911380511
- Fixes: - helpers.jsonSchemaMethods: -> renamed flatten to nested. - Added: - helpers.descriptors: -> parseFunctionToJsonSchema - helpers.jsonSchemaMethods: -> added `flattenSchema` and `reduceSchema`. This Function will create a nested JSON-Schema.
50 lines
898 B
TypeScript
50 lines
898 B
TypeScript
/**
|
|
* @author Martin Karkowski
|
|
* @email m.karkowski@zema.de
|
|
* @desc [description]
|
|
*/
|
|
|
|
import { v4 } from "uuid";
|
|
import { replaceAll } from "./stringMethods";
|
|
|
|
/**
|
|
* Generates an ID.
|
|
*
|
|
* @author M.Karkowski
|
|
* @export
|
|
* @param {string} [prestring] additional PreString for the Id.
|
|
* @return {*} {string} the Id.
|
|
*/
|
|
/**
|
|
*
|
|
*
|
|
* @author M.Karkowski
|
|
* @export
|
|
* @param {{
|
|
* prestring?: string,
|
|
* useAsVar?: boolean
|
|
* }} [options={}]
|
|
* @return {*} {string}
|
|
*/
|
|
export function generateId(
|
|
options: {
|
|
// PreString for the Var.
|
|
prestring?: string;
|
|
useAsVar?: boolean;
|
|
} = {}
|
|
): string {
|
|
let id = v4();
|
|
|
|
if (options.useAsVar) {
|
|
id = replaceAll(id, "-", "");
|
|
options.prestring =
|
|
typeof options.prestring === "string" ? options.prestring : "_";
|
|
}
|
|
|
|
if (typeof options.prestring === "string") {
|
|
id = options.prestring + id;
|
|
}
|
|
|
|
return id;
|
|
}
|