@kitql/helpers
Advanced tools
Comparing version
# @kitql/helpers | ||
## 0.8.10 | ||
### Patch Changes | ||
- [#714](https://github.com/jycouet/kitql/pull/714) | ||
[`53804e4`](https://github.com/jycouet/kitql/commit/53804e44e6ae3ba8e0de54a2de87cae4f4e32437) | ||
Thanks [@jycouet](https://github.com/jycouet)! - add midTrim function | ||
## 0.8.9 | ||
@@ -7,3 +15,5 @@ | ||
- [#629](https://github.com/jycouet/kitql/pull/629) [`f474d6f`](https://github.com/jycouet/kitql/commit/f474d6f7b4a1aefefb5eed9dce98bec226ea0310) Thanks [@jycouet](https://github.com/jycouet)! - bump internals | ||
- [#629](https://github.com/jycouet/kitql/pull/629) | ||
[`f474d6f`](https://github.com/jycouet/kitql/commit/f474d6f7b4a1aefefb5eed9dce98bec226ea0310) | ||
Thanks [@jycouet](https://github.com/jycouet)! - bump internals | ||
@@ -10,0 +20,0 @@ ## 0.8.8 |
@@ -54,2 +54,3 @@ "use strict"; | ||
magentaBright: () => import_colors.magentaBright, | ||
midTrim: () => import_stry.midTrim, | ||
red: () => import_colors.red, | ||
@@ -56,0 +57,0 @@ redBright: () => import_colors.redBright, |
@@ -142,4 +142,3 @@ "use strict"; | ||
let message = `Object can not safely be stringified. Received type ${typeof value2}`; | ||
if (typeof value2 !== "function") | ||
message += ` (${value2.toString()})`; | ||
if (typeof value2 !== "function") message += ` (${value2.toString()})`; | ||
throw new Error(message); | ||
@@ -272,2 +271,3 @@ }; | ||
} | ||
// fallthrough | ||
default: | ||
@@ -377,2 +377,3 @@ return fail ? fail(value) : void 0; | ||
} | ||
// fallthrough | ||
default: | ||
@@ -489,2 +490,3 @@ return fail ? fail(value) : void 0; | ||
} | ||
// fallthrough | ||
default: | ||
@@ -584,2 +586,3 @@ return fail ? fail(value) : void 0; | ||
} | ||
// fallthrough | ||
default: | ||
@@ -586,0 +589,0 @@ return fail ? fail(value) : void 0; |
@@ -21,2 +21,3 @@ "use strict"; | ||
__export(stry_exports, { | ||
midTrim: () => midTrim, | ||
stry: () => stry, | ||
@@ -40,1 +41,11 @@ stry0: () => stry0, | ||
} | ||
function midTrim(str, o) { | ||
const len = o?.len || 21; | ||
if (str.length > len) { | ||
const midStr = o?.midStr || "..."; | ||
const reducedLen = len - midStr.length; | ||
const trimLength = Math.floor(reducedLen / 2); | ||
return `${str.slice(0, trimLength).trim()}${midStr}${str.slice(-trimLength).trim()}`; | ||
} | ||
return str; | ||
} |
export type { Prettify } from './Prettify.js'; | ||
export { sleep } from './sleep.js'; | ||
export { stry, stry0, stryEq } from './stry/stry.js'; | ||
export { stry, stry0, stryEq, midTrim } from './stry/stry.js'; | ||
export { Log } from './Log.js'; | ||
export { bgBlack, bgBlackBright, bgBlue, bgBlueBright, bgCyan, bgCyanBright, bgGreen, bgGreenBright, bgMagenta, bgMagentaBright, bgRed, bgRedBright, bgWhite, bgWhiteBright, bgYellow, bgYellowBright, black, blackBright, blue, blueBright, bold, cyan, cyanBright, dim, gray, green, greenBright, hidden, inverse, italic, magenta, magentaBright, red, redBright, reset, strikethrough, underline, white, whiteBright, yellow, yellowBright, } from './colors/index.js'; |
export { sleep } from './sleep.js'; | ||
export { stry, stry0, stryEq } from './stry/stry.js'; | ||
export { stry, stry0, stryEq, midTrim } from './stry/stry.js'; | ||
export { Log } from './Log.js'; | ||
export { bgBlack, bgBlackBright, bgBlue, bgBlueBright, bgCyan, bgCyanBright, bgGreen, bgGreenBright, bgMagenta, bgMagentaBright, bgRed, bgRedBright, bgWhite, bgWhiteBright, bgYellow, bgYellowBright, black, blackBright, blue, blueBright, bold, cyan, cyanBright, dim, gray, green, greenBright, hidden, inverse, italic, magenta, magentaBright, red, redBright, reset, strikethrough, underline, white, whiteBright, yellow, yellowBright, } from './colors/index.js'; |
@@ -14,1 +14,5 @@ /** | ||
export declare function stryEq(obj1: object | null | undefined, obj2: object | null | undefined): boolean; | ||
export declare function midTrim(str: string, o?: { | ||
len?: number; | ||
midStr?: string; | ||
}): string; |
@@ -27,1 +27,11 @@ /** | ||
} | ||
export function midTrim(str, o) { | ||
const len = o?.len || 21; | ||
if (str.length > len) { | ||
const midStr = o?.midStr || '...'; | ||
const reducedLen = len - midStr.length; | ||
const trimLength = Math.floor(reducedLen / 2); | ||
return `${str.slice(0, trimLength).trim()}${midStr}${str.slice(-trimLength).trim()}`; | ||
} | ||
return str; | ||
} |
@@ -12,3 +12,3 @@ { | ||
], | ||
"version": "0.8.9", | ||
"version": "0.8.10", | ||
"license": "MIT", | ||
@@ -30,6 +30,6 @@ "type": "module", | ||
".": { | ||
"types": "./esm/index.d.ts", | ||
"require": "./cjs/index.js", | ||
"types": "./esm/index.d.ts", | ||
"default": "./esm/index.js", | ||
"svelte": "./esm/index.js" | ||
"svelte": "./esm/index.js", | ||
"default": "./esm/index.js" | ||
} | ||
@@ -36,0 +36,0 @@ }, |
108199
1.12%2588
1.13%