UNPKG

backpack-ui

Version:
20 lines (16 loc) 717 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var uniformString = function uniformString(string) { return "" + string.toString().toLowerCase().trim().replace(/ /gi, "-"); }; var sanitize = function sanitize(el) { return typeof el === "string" || typeof el === "number" ? uniformString(el) : "default"; }; var createQAHook = function createQAHook(hook) { var fallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "fallback"; var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "unknown"; return hook ? sanitize(hook) + "-" + sanitize(type) : sanitize(fallback) + "-" + sanitize(type); }; exports.default = createQAHook;