UNPKG

@mornya/restful-libs

Version:

The project of wrapped library for RESTful API processing module.

23 lines (22 loc) 848 B
import chalk from 'chalk'; var termColorMap = { black: ['black', 'bgBlack'], darkgray: ['gray', 'bgGray'], white: ['whiteBright', 'bgWhite'], blue: ['blueBright', 'bgBlue'], green: ['greenBright', 'bgGreen'], yellow: ['yellowBright', 'bgYellow'], red: ['redBright', 'bgRed'], }; function getTagBrowser(tagName, color, bgColor) { return [ "%c".concat(tagName), "color:".concat(color, ";background-color:").concat(bgColor, ";border-radius:4px;line-height:1;padding:").concat(tagName.length === 3 ? '3px 10px 2px 9px' : '3px 6px 2px'), ]; } function getTagTerm(tagName, color, bgColor) { return [chalk[termColorMap[color][0]][termColorMap[bgColor][1]](" ".concat(tagName, " "))]; } var isTerm = typeof window === 'undefined'; var getTag = isTerm ? getTagTerm : getTagBrowser; export { getTag };