@ntnyq/utils 0.7.2 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -185,6 +185,15 @@ declare function isElementVisibleInViewport(element: HTMLElement, targetWindow?:
185
185
  */
186
186
  declare const isBrowser: () => boolean;
187
187
  //#endregion
188
+ //#region src/file/removeExtension.d.ts
189
+ /**
190
+ * Removes the file extension from a filename.
191
+ *
192
+ * @param filename - The filename to remove the extension from.
193
+ * @returns The filename without the extension.
194
+ */
195
+ declare function removeFileExtension(filename: string): string;
196
+ //#endregion
188
197
  //#region src/html/escape.d.ts
189
198
  /**
190
199
  * Escape html chars
@@ -738,4 +747,4 @@ declare const RE_LINE_COMMENT: RegExp;
738
747
  */
739
748
  declare const RE_BLOCK_COMMENT: RegExp;
740
749
  //#endregion
741
- export { AnyFn, Arrayable, Awaitable, Callable, CleanObjectOptions, Color, CreatePadStringOptions, DeepRequired, GetStringSimilarityOptions, InteropModuleDefault, JsonArray, JsonObject, JsonPrimitive, JsonValue, LiteralUnion, MayBe, Merge, NOOP, NonEmptyObject, NonEmptyString, Nullable, ONE_DAY_MILLSECONDS, ONE_HOUR_MILLSECONDS, ONE_MINUTE_MILLSECONDS, ONE_SECOND_MILLSECONDS, ONE_WEEK_MILLSECONDS, OpenExternalURLOptions, Overwrite, Prettify, PrettifyV2, Primitive, RE_BLOCK_COMMENT, RE_COMMENTS, RE_LINE_COMMENT, RamdomNumberOptions, ResolvedOptions, SPECIAL_CHAR, SortObjectOptions, ThrottleDebounceOptions, ToIntegerOptions, Whitespace, at, cAF, chunk, clamp, cleanObject, createPadString, days, debounce, enhance, ensurePrefix, ensureSuffix, escapeHTML, flattenArrayable, getObjectType, getRoot, getStringLength, getStringSimilarity, hasOwn, hours, interopDefault, intersect, isArray, isArrayEqual, isBigInt, isBoolean, isBrowser, isDeepEqual, isElementVisibleInViewport, isEmptyArray, isEmptyMap, isEmptyObject, isEmptySet, isEmptyString, isEmptyStringOrWhitespace, isError, isFunction, isHTMLElement, isInteger, isIterable, isMap, isNaN, isNativePromise, isNil, isNonEmptyArray, isNonEmptyString, isNull, isNullOrUndefined, isNumber, isNumbericString, isObject, isPromise, isRegExp, isSet, isString, isTruthy, isUndefined, isWhitespaceString, isZero, join, last, mergeArrayable, minutes, noop, omit, once, openExternalURL, pick, rAF, randomHexColor, randomNumber, randomRGBAColor, randomRGBColor, randomString, resolveSubOptions, scrollElementIntoView, seconds, slash, slugify, sortObject, throttle, toArray, toInteger, unescapeHTML, unindent, unique, uniqueBy, waitFor, warnOnce, weeks };
750
+ export { AnyFn, Arrayable, Awaitable, Callable, CleanObjectOptions, Color, CreatePadStringOptions, DeepRequired, GetStringSimilarityOptions, InteropModuleDefault, JsonArray, JsonObject, JsonPrimitive, JsonValue, LiteralUnion, MayBe, Merge, NOOP, NonEmptyObject, NonEmptyString, Nullable, ONE_DAY_MILLSECONDS, ONE_HOUR_MILLSECONDS, ONE_MINUTE_MILLSECONDS, ONE_SECOND_MILLSECONDS, ONE_WEEK_MILLSECONDS, OpenExternalURLOptions, Overwrite, Prettify, PrettifyV2, Primitive, RE_BLOCK_COMMENT, RE_COMMENTS, RE_LINE_COMMENT, RamdomNumberOptions, ResolvedOptions, SPECIAL_CHAR, SortObjectOptions, ThrottleDebounceOptions, ToIntegerOptions, Whitespace, at, cAF, chunk, clamp, cleanObject, createPadString, days, debounce, enhance, ensurePrefix, ensureSuffix, escapeHTML, flattenArrayable, getObjectType, getRoot, getStringLength, getStringSimilarity, hasOwn, hours, interopDefault, intersect, isArray, isArrayEqual, isBigInt, isBoolean, isBrowser, isDeepEqual, isElementVisibleInViewport, isEmptyArray, isEmptyMap, isEmptyObject, isEmptySet, isEmptyString, isEmptyStringOrWhitespace, isError, isFunction, isHTMLElement, isInteger, isIterable, isMap, isNaN, isNativePromise, isNil, isNonEmptyArray, isNonEmptyString, isNull, isNullOrUndefined, isNumber, isNumbericString, isObject, isPromise, isRegExp, isSet, isString, isTruthy, isUndefined, isWhitespaceString, isZero, join, last, mergeArrayable, minutes, noop, omit, once, openExternalURL, pick, rAF, randomHexColor, randomNumber, randomRGBAColor, randomRGBColor, randomString, removeFileExtension, resolveSubOptions, scrollElementIntoView, seconds, slash, slugify, sortObject, throttle, toArray, toInteger, unescapeHTML, unindent, unique, uniqueBy, waitFor, warnOnce, weeks };
package/dist/index.js CHANGED
@@ -223,6 +223,18 @@ function isElementVisibleInViewport(element, targetWindow = window) {
223
223
  */
224
224
  const isBrowser = () => typeof document !== "undefined";
225
225
 
226
+ //#endregion
227
+ //#region src/file/removeExtension.ts
228
+ /**
229
+ * Removes the file extension from a filename.
230
+ *
231
+ * @param filename - The filename to remove the extension from.
232
+ * @returns The filename without the extension.
233
+ */
234
+ function removeFileExtension(filename) {
235
+ return filename.replace(/\.[^/.]+$/, "");
236
+ }
237
+
226
238
  //#endregion
227
239
  //#region src/html/escape.ts
228
240
  const htmlEscapeMap = {
@@ -302,10 +314,10 @@ function cAF(id) {
302
314
  * @module Time
303
315
  */
304
316
  const ONE_SECOND_MILLSECONDS = 1e3;
305
- const ONE_MINUTE_MILLSECONDS = 60 * ONE_SECOND_MILLSECONDS;
306
- const ONE_HOUR_MILLSECONDS = 60 * ONE_MINUTE_MILLSECONDS;
307
- const ONE_DAY_MILLSECONDS = 24 * ONE_HOUR_MILLSECONDS;
308
- const ONE_WEEK_MILLSECONDS = 7 * ONE_DAY_MILLSECONDS;
317
+ const ONE_MINUTE_MILLSECONDS = 60 * 1e3;
318
+ const ONE_HOUR_MILLSECONDS = 60 * 60 * 1e3;
319
+ const ONE_DAY_MILLSECONDS = 24 * 60 * 60 * 1e3;
320
+ const ONE_WEEK_MILLSECONDS = 7 * 24 * 60 * 60 * 1e3;
309
321
  function seconds(count) {
310
322
  return count * ONE_SECOND_MILLSECONDS;
311
323
  }
@@ -753,10 +765,6 @@ function getStringSimilarity(str1, str2, options = {}) {
753
765
 
754
766
  //#endregion
755
767
  //#region src/color/color.ts
756
- const pad2 = createPadString({
757
- length: 2,
758
- char: "0"
759
- });
760
768
  const RE_VALID_HEX_COLOR = /^#(?:[0-9a-f]{6}|[0-9a-f]{3})$/i;
761
769
  function validateHexColor(hex) {
762
770
  if (hex.length !== 4 && hex.length !== 7) return false;
@@ -802,6 +810,10 @@ var Color = class Color {
802
810
  return !this.isDark;
803
811
  }
804
812
  toHexString(isUpperCase = true) {
813
+ const pad2 = createPadString({
814
+ length: 2,
815
+ char: "0"
816
+ });
805
817
  const hexString = `#${pad2(this.red.toString(16))}${pad2(this.green.toString(16))}${pad2(this.blue.toString(16))}`;
806
818
  return isUpperCase ? hexString.toUpperCase() : hexString;
807
819
  }
@@ -1053,4 +1065,4 @@ const RE_LINE_COMMENT = /\/\/.*/;
1053
1065
  const RE_BLOCK_COMMENT = /\/\*[\s\S]*?\*\//g;
1054
1066
 
1055
1067
  //#endregion
1056
- export { Color, NOOP, ONE_DAY_MILLSECONDS, ONE_HOUR_MILLSECONDS, ONE_MINUTE_MILLSECONDS, ONE_SECOND_MILLSECONDS, ONE_WEEK_MILLSECONDS, RE_BLOCK_COMMENT, RE_COMMENTS, RE_LINE_COMMENT, SPECIAL_CHAR, at, cAF, chunk, clamp, cleanObject, createPadString, days, debounce, enhance, ensurePrefix, ensureSuffix, escapeHTML, flattenArrayable, getObjectType, getRoot, getStringLength, getStringSimilarity, hasOwn, hours, interopDefault, intersect, isArray, isArrayEqual, isBigInt, isBoolean, isBrowser, isDeepEqual, isElementVisibleInViewport, isEmptyArray, isEmptyMap, isEmptyObject, isEmptySet, isEmptyString, isEmptyStringOrWhitespace, isError, isFunction, isHTMLElement, isInteger, isIterable, isMap, isNaN, isNativePromise, isNil, isNonEmptyArray, isNonEmptyString, isNull, isNullOrUndefined, isNumber, isNumbericString, isObject, isPromise, isRegExp, isSet, isString, isTruthy, isUndefined, isWhitespaceString, isZero, join, last, mergeArrayable, minutes, noop, omit, once, openExternalURL, pick, rAF, randomHexColor, randomNumber, randomRGBAColor, randomRGBColor, randomString, resolveSubOptions, scrollElementIntoView, seconds, slash, slugify, sortObject, throttle, toArray, toInteger, unescapeHTML, unindent, unique, uniqueBy, waitFor, warnOnce, weeks };
1068
+ export { Color, NOOP, ONE_DAY_MILLSECONDS, ONE_HOUR_MILLSECONDS, ONE_MINUTE_MILLSECONDS, ONE_SECOND_MILLSECONDS, ONE_WEEK_MILLSECONDS, RE_BLOCK_COMMENT, RE_COMMENTS, RE_LINE_COMMENT, SPECIAL_CHAR, at, cAF, chunk, clamp, cleanObject, createPadString, days, debounce, enhance, ensurePrefix, ensureSuffix, escapeHTML, flattenArrayable, getObjectType, getRoot, getStringLength, getStringSimilarity, hasOwn, hours, interopDefault, intersect, isArray, isArrayEqual, isBigInt, isBoolean, isBrowser, isDeepEqual, isElementVisibleInViewport, isEmptyArray, isEmptyMap, isEmptyObject, isEmptySet, isEmptyString, isEmptyStringOrWhitespace, isError, isFunction, isHTMLElement, isInteger, isIterable, isMap, isNaN, isNativePromise, isNil, isNonEmptyArray, isNonEmptyString, isNull, isNullOrUndefined, isNumber, isNumbericString, isObject, isPromise, isRegExp, isSet, isString, isTruthy, isUndefined, isWhitespaceString, isZero, join, last, mergeArrayable, minutes, noop, omit, once, openExternalURL, pick, rAF, randomHexColor, randomNumber, randomRGBAColor, randomRGBColor, randomString, removeFileExtension, resolveSubOptions, scrollElementIntoView, seconds, slash, slugify, sortObject, throttle, toArray, toInteger, unescapeHTML, unindent, unique, uniqueBy, waitFor, warnOnce, weeks };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ntnyq/utils",
3
3
  "type": "module",
4
- "version": "0.7.2",
4
+ "version": "0.8.0",
5
5
  "description": "Common used utils.",
6
6
  "keywords": [
7
7
  "utils"
@@ -30,17 +30,17 @@
30
30
  ],
31
31
  "sideEffects": false,
32
32
  "devDependencies": {
33
- "@ntnyq/eslint-config": "^5.0.0-beta.5",
34
- "@ntnyq/prettier-config": "^2.2.0",
35
- "bumpp": "^10.1.1",
36
- "eslint": "^9.28.0",
33
+ "@ntnyq/eslint-config": "^5.0.0",
34
+ "@ntnyq/prettier-config": "^3.0.1",
35
+ "bumpp": "^10.2.0",
36
+ "eslint": "^9.30.1",
37
37
  "husky": "^9.1.7",
38
38
  "nano-staged": "^0.8.0",
39
39
  "npm-run-all2": "^8.0.4",
40
- "prettier": "^3.5.3",
41
- "tsdown": "^0.12.7",
40
+ "prettier": "^3.6.2",
41
+ "tsdown": "^0.12.9",
42
42
  "typescript": "^5.8.3",
43
- "vitest": "^3.2.2"
43
+ "vitest": "^3.2.4"
44
44
  },
45
45
  "engines": {
46
46
  "node": ">=18.18.0"