mark-3 0.0.4 → 0.0.5

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.
Files changed (68) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/components/index.js +1 -0
  3. package/components/scroll-aware-content.vue +162 -0
  4. package/composables/index.js +2 -0
  5. package/composables/use-intersection-observer.js +67 -0
  6. package/composables/use-scroll-event.js +97 -0
  7. package/helpers/array/index.js +1 -0
  8. package/helpers/array/pick-random.js +24 -0
  9. package/helpers/array/tests/pick-random.test.js +39 -0
  10. package/helpers/date/index.js +1 -1
  11. package/helpers/date/{from-timestamp/index.test.js → tests/format-timestamp.test.js} +1 -1
  12. package/helpers/date/tests/format.test.js +97 -0
  13. package/helpers/date/{is-on-same-day/index.test.js → tests/is-on-same-day.test.js} +1 -1
  14. package/helpers/date/{is-on-same-year/index.test.js → tests/is-on-same-year.test.js} +1 -1
  15. package/helpers/number/clamp.js +17 -0
  16. package/helpers/number/index.js +2 -0
  17. package/helpers/number/random.js +24 -0
  18. package/helpers/number/tests/clamp.test.js +37 -0
  19. package/helpers/number/tests/random.test.js +51 -0
  20. package/helpers/string/{camel-to-dash/index.js → camel-to-dash.js} +2 -2
  21. package/helpers/string/encode-subscript.js +45 -0
  22. package/helpers/string/{escape-regex/index.js → escape-regex.js} +1 -1
  23. package/helpers/string/index.js +1 -0
  24. package/helpers/string/{camel-to-dash/index.test.js → tests/camel-to-dash.test.js} +1 -1
  25. package/helpers/string/tests/encode-subscript.test.js +41 -0
  26. package/helpers/string/{escape-regex/index.test.js → tests/escape-regex.test.js} +1 -1
  27. package/helpers/string/{trim/index.test.js → tests/trim.test.js} +1 -1
  28. package/helpers/string/{trim/index.js → trim.js} +2 -2
  29. package/helpers/time/debounce.js +29 -0
  30. package/helpers/time/index.js +1 -0
  31. package/helpers/time/tests/debounce.test.js +58 -0
  32. package/helpers/types/index.js +1 -0
  33. package/helpers/types/{is-empty/index.js → is-empty.js} +1 -1
  34. package/helpers/types/{is-map/index.js → is-map.js} +1 -1
  35. package/helpers/types/is-numeric.js +22 -0
  36. package/helpers/types/{is-set/index.js → is-set.js} +1 -1
  37. package/helpers/types/{get-type-name/index.test.js → tests/get-type-name.test.js} +2 -2
  38. package/helpers/types/{is-array/index.test.js → tests/is-array.test.js} +1 -1
  39. package/helpers/types/{is-empty/index.test.js → tests/is-empty.test.js} +1 -1
  40. package/helpers/types/{is-map/index.test.js → tests/is-map.test.js} +1 -1
  41. package/helpers/types/tests/is-numeric.test.js +51 -0
  42. package/helpers/types/{is-plain-object/index.test.js → tests/is-plain-object.test.js} +1 -1
  43. package/helpers/types/{is-set/index.test.js → tests/is-set.test.js} +1 -1
  44. package/helpers/types/{is-string/index.test.js → tests/is-string.test.js} +1 -1
  45. package/package.json +1 -1
  46. package/helpers/date/format/README.md +0 -33
  47. package/helpers/date/format/index.test.js +0 -97
  48. package/helpers/date/from-timestamp/README.md +0 -14
  49. package/helpers/date/is-on-same-day/README.md +0 -12
  50. package/helpers/date/is-on-same-year/README.md +0 -13
  51. package/helpers/string/camel-to-dash/README.md +0 -24
  52. package/helpers/string/escape-regex/README.md +0 -12
  53. package/helpers/string/trim/README.md +0 -66
  54. package/helpers/types/get-type-name/README.md +0 -11
  55. package/helpers/types/is-array/README.md +0 -11
  56. package/helpers/types/is-empty/README.md +0 -35
  57. package/helpers/types/is-map/README.md +0 -15
  58. package/helpers/types/is-plain-object/README.md +0 -17
  59. package/helpers/types/is-set/README.md +0 -15
  60. package/helpers/types/is-string/README.md +0 -12
  61. /package/helpers/date/{from-timestamp/index.js → format-timestamp.js} +0 -0
  62. /package/helpers/date/{format/index.js → format.js} +0 -0
  63. /package/helpers/date/{is-on-same-day/index.js → is-on-same-day.js} +0 -0
  64. /package/helpers/date/{is-on-same-year/index.js → is-on-same-year.js} +0 -0
  65. /package/helpers/types/{get-type-name/index.js → get-type-name.js} +0 -0
  66. /package/helpers/types/{is-array/index.js → is-array.js} +0 -0
  67. /package/helpers/types/{is-plain-object/index.js → is-plain-object.js} +0 -0
  68. /package/helpers/types/{is-string/index.js → is-string.js} +0 -0
@@ -1,5 +1,5 @@
1
- import { trim } from "..";
2
- import { isString } from "../../types";
1
+ import { trim } from ".";
2
+ import { isString } from "../types";
3
3
 
4
4
  /**
5
5
  * Converts a camelCase string to dash-case.
@@ -0,0 +1,45 @@
1
+ const map =
2
+ {
3
+ 0: "₀", 1: "₁", 2: "₂", 3: "₃", 4: "₄", 5: "₅", 6: "₆", 7: "₇", 8: "₈", 9: "₉",
4
+ a: "ₐ", e: "ₑ", h: "ₕ", k: "ₖ", l: "ₗ", m: "ₘ", n: "ₙ", o: "ₒ", p: "ₚ", s: "ₛ",
5
+ t: "ₜ", "+": "₊", "-": "₋", "=": "₌", "(": "₍", ")": "₎",
6
+ }
7
+
8
+ /**
9
+ * Converts a given string into its subscript equivalent, if available.
10
+ *
11
+ * @param {string} str - The string to be converted.
12
+ * @param {boolean} [rollbackWhenMismatch=true] If true, returns the original string
13
+ * a character is not in the map.
14
+ * @returns {string} The subscript representation of the string if it exists in the
15
+ * map, otherwise the original string.
16
+ */
17
+ export default function encodeSubscript( str, rollbackWhenMismatch = true )
18
+ {
19
+ if( typeof str !== "string" )
20
+ {
21
+ return str;
22
+ }
23
+
24
+ if( rollbackWhenMismatch )
25
+ {
26
+ let stack = "";
27
+
28
+ for( let char of str )
29
+ {
30
+ if( ! ( char in map ))
31
+ {
32
+ return str;
33
+ }
34
+
35
+ stack += map[ char ];
36
+ }
37
+
38
+ return stack;
39
+ }
40
+
41
+ return str
42
+ .split( "" )
43
+ .map( char => map[ char ] || char )
44
+ .join( "" );
45
+ }
@@ -1,4 +1,4 @@
1
- import { isString } from "../../types";
1
+ import { isString } from "../types";
2
2
 
3
3
  /**
4
4
  * Escapes special characters in a string to be used in a regular expression.
@@ -1,3 +1,4 @@
1
1
  export { default as trim } from "./trim";
2
2
  export { default as escapeRegex } from "./escape-regex";
3
3
  export { default as camelToDash } from "./camel-to-dash";
4
+ export { default as encodeSubscript } from "./encode-subscript";
@@ -1,5 +1,5 @@
1
1
  import { describe, it, expect } from "vitest";
2
- import camelToDash from ".";
2
+ import { camelToDash } from "..";
3
3
 
4
4
  describe( "camelToDash", () =>
5
5
  {
@@ -0,0 +1,41 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import { encodeSubscript } from "..";
3
+
4
+ describe("encodeSubscript", () =>
5
+ {
6
+ it("converts full match to subscript", () =>
7
+ {
8
+ expect(encodeSubscript("h2o")).toBe("ₕ₂ₒ");
9
+ expect(encodeSubscript("123")).toBe("₁₂₃");
10
+ });
11
+
12
+ it("returns original string if any character mismatches and rollbackWhenMismatch is true", () =>
13
+ {
14
+ expect(encodeSubscript("H2O")).toBe("H2O"); // 'H' and 'O' not in map
15
+ expect(encodeSubscript("x+2")).toBe("x+2"); // 'x' not in map
16
+ });
17
+
18
+ it("fallbacks partially when rollbackWhenMismatch is false", () =>
19
+ {
20
+ expect(encodeSubscript("x+2", false)).toBe("x₊₂");
21
+ expect(encodeSubscript("H2O", false)).toBe("H₂O");
22
+ });
23
+
24
+ it("returns non-string inputs as-is", () =>
25
+ {
26
+ expect(encodeSubscript(null)).toBe(null);
27
+ expect(encodeSubscript(undefined)).toBe(undefined);
28
+ expect(encodeSubscript(123)).toBe(123);
29
+ expect(encodeSubscript({})).toEqual({});
30
+ });
31
+
32
+ it("handles empty string correctly", () =>
33
+ {
34
+ expect(encodeSubscript("")).toBe("");
35
+ });
36
+
37
+ it("works with symbols like + - ( )", () =>
38
+ {
39
+ expect(encodeSubscript("2+(3-1)", false)).toBe("₂₊₍₃₋₁₎");
40
+ });
41
+ });
@@ -1,5 +1,5 @@
1
1
  import { describe, it, expect } from "vitest";
2
- import escapeRegex from ".";
2
+ import { escapeRegex } from "..";
3
3
 
4
4
  describe( "escapeRegex", () =>
5
5
  {
@@ -1,5 +1,5 @@
1
1
  import { describe, it, expect } from "vitest";
2
- import trim from ".";
2
+ import { trim } from "..";
3
3
 
4
4
  describe( "trim", () =>
5
5
  {
@@ -1,5 +1,5 @@
1
- import { escapeRegex } from "..";
2
- import { isEmpty, isArray, isString } from "../../types";
1
+ import { escapeRegex } from ".";
2
+ import { isEmpty, isArray, isString } from "../types";
3
3
 
4
4
  /**
5
5
  * Trims the specified characters from the beginning and end of a string.
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Debounce a function call to prevent it from being called too often.
3
+ *
4
+ * This is useful for functions that are called on every
5
+ * frame, such as onScroll. This will ensure that the function
6
+ * is only called at most once every `delay` milliseconds.
7
+ *
8
+ * @example
9
+ * const debounced = debounce(() =>
10
+ * console.log( "Hello" ),
11
+ * 1000
12
+ * );
13
+ *
14
+ * window.addEventListener( "scroll", debounced );
15
+ *
16
+ * @param {function} callback The function to debounce.
17
+ * @param {number} delay The delay in milliseconds.
18
+ * @returns {function}
19
+ */
20
+ export default function debounce( callback, delay = 200 )
21
+ {
22
+ let timer;
23
+
24
+ return function debounceWrapper( ...args )
25
+ {
26
+ clearTimeout( timer );
27
+ timer = setTimeout( callback.bind( this, ...args ), delay );
28
+ }
29
+ }
@@ -0,0 +1 @@
1
+ export { default as debounce } from "./debounce";
@@ -0,0 +1,58 @@
1
+ import { describe, it, expect, vi } from "vitest";
2
+ import { debounce } from "..";
3
+
4
+ describe("debounce", () =>
5
+ {
6
+ it("should call the callback after the delay", async () =>
7
+ {
8
+ const callback = vi.fn();
9
+ const delay = 100;
10
+ const debouncedFn = debounce(callback, delay);
11
+
12
+ debouncedFn();
13
+ expect(callback).not.toHaveBeenCalled();
14
+
15
+ // wait delay + 20ms
16
+ await new Promise((r) => setTimeout(r, delay + 20));
17
+
18
+ expect(callback).toHaveBeenCalledTimes(1);
19
+ });
20
+
21
+ it("should call the callback only once if called multiple times quickly", async () =>
22
+ {
23
+ const callback = vi.fn();
24
+ const delay = 100;
25
+ const debouncedFn = debounce(callback, delay);
26
+
27
+ debouncedFn();
28
+ debouncedFn();
29
+ debouncedFn();
30
+
31
+ expect(callback).not.toHaveBeenCalled();
32
+
33
+ await new Promise((r) => setTimeout(r, delay + 20));
34
+
35
+ expect(callback).toHaveBeenCalledTimes(1);
36
+ });
37
+
38
+ it("should pass arguments and context correctly", async () =>
39
+ {
40
+ const callback = vi.fn(function (a, b)
41
+ {
42
+ // 'this' should be the wrapper's this context
43
+ expect(this).toEqual({ foo: "bar" });
44
+ expect(a).toBe(1);
45
+ expect(b).toBe(2);
46
+ });
47
+
48
+ const delay = 50;
49
+ const debouncedFn = debounce(callback, delay);
50
+
51
+ // call with context and arguments
52
+ debouncedFn.call({ foo: "bar" }, 1, 2);
53
+
54
+ await new Promise((r) => setTimeout(r, delay + 20));
55
+
56
+ expect(callback).toHaveBeenCalledTimes(1);
57
+ });
58
+ });
@@ -3,5 +3,6 @@ export { default as isSet } from "./is-set";
3
3
  export { default as isArray } from "./is-array";
4
4
  export { default as isEmpty } from "./is-empty";
5
5
  export { default as isString } from "./is-string";
6
+ export { default as isNumeric } from "./is-numeric";
6
7
  export { default as getTypeName } from "./get-type-name";
7
8
  export { default as isPlainObject } from "./is-plain-object";
@@ -1,4 +1,4 @@
1
- import { isString, isArray, isMap, isSet, isPlainObject } from "..";
1
+ import { isString, isArray, isMap, isSet, isPlainObject } from ".";
2
2
 
3
3
  /**
4
4
  * Checks if the given variable is empty.
@@ -1,4 +1,4 @@
1
- import { getTypeName } from "..";
1
+ import { getTypeName } from ".";
2
2
 
3
3
  /**
4
4
  * Checks if a given value is a Map.
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Checks if a value is numeric or can be converted to a number.
3
+ *
4
+ * @param {any} value - The value to be checked.
5
+ * @returns {boolean} true if the value is numeric, false otherwise.
6
+ */
7
+ export default function isNumeric( value )
8
+ {
9
+ if( typeof value === "number" )
10
+ {
11
+ return ! isNaN( value ) && isFinite( value );
12
+ }
13
+
14
+ if( typeof value === "string" )
15
+ {
16
+ return value.trim() !== "" &&
17
+ ! isNaN( Number( value )) &&
18
+ isFinite( Number( value ));
19
+ }
20
+
21
+ return false;
22
+ }
@@ -1,4 +1,4 @@
1
- import { getTypeName } from "..";
1
+ import { getTypeName } from ".";
2
2
 
3
3
  /**
4
4
  * Checks if a given value is a Set.
@@ -1,7 +1,7 @@
1
1
  import { describe, it, expect } from "vitest";
2
- import getTypeName from ".";
2
+ import { getTypeName } from "..";
3
3
 
4
- describe( "type", () =>
4
+ describe( "getTypeName", () =>
5
5
  {
6
6
  it( 'should return "String" for a string', () =>
7
7
  {
@@ -1,5 +1,5 @@
1
1
  import { describe, it, expect } from "vitest";
2
- import isArray from ".";
2
+ import { isArray } from "..";
3
3
 
4
4
  describe( "isArray", () =>
5
5
  {
@@ -1,5 +1,5 @@
1
1
  import { describe, it, expect } from "vitest";
2
- import isEmpty from ".";
2
+ import { isEmpty } from "../index";
3
3
 
4
4
  describe( "isEmpty", () =>
5
5
  {
@@ -1,5 +1,5 @@
1
1
  import { describe, it, expect } from "vitest";
2
- import isMap from ".";
2
+ import { isMap } from "..";
3
3
 
4
4
  describe("isMap", () =>
5
5
  {
@@ -0,0 +1,51 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import { isNumeric } from "..";
3
+
4
+ describe("isNumeric function", () =>
5
+ {
6
+ it("should return true for numeric numbers", () =>
7
+ {
8
+ expect(isNumeric(0)).toBe(true);
9
+ expect(isNumeric(123)).toBe(true);
10
+ expect(isNumeric(-456)).toBe(true);
11
+ expect(isNumeric(1e4)).toBe(true);
12
+ expect(isNumeric(3.14)).toBe(true);
13
+ });
14
+
15
+ it("should return false for NaN and Infinity numbers", () =>
16
+ {
17
+ expect(isNumeric(NaN)).toBe(false);
18
+ expect(isNumeric(Infinity)).toBe(false);
19
+ expect(isNumeric(-Infinity)).toBe(false);
20
+ });
21
+
22
+ it("should return true for numeric strings", () =>
23
+ {
24
+ expect(isNumeric("0")).toBe(true);
25
+ expect(isNumeric("123")).toBe(true);
26
+ expect(isNumeric("-456")).toBe(true);
27
+ expect(isNumeric("1e4")).toBe(true);
28
+ expect(isNumeric("3.14")).toBe(true);
29
+ expect(isNumeric(" 42 ")).toBe(true);
30
+ });
31
+
32
+ it("should return false for non-numeric strings", () =>
33
+ {
34
+ expect(isNumeric("")).toBe(false);
35
+ expect(isNumeric(" ")).toBe(false);
36
+ expect(isNumeric("abc")).toBe(false);
37
+ expect(isNumeric("123abc")).toBe(false);
38
+ expect(isNumeric("Infinity")).toBe(false);
39
+ });
40
+
41
+ it("should return false for other data types", () =>
42
+ {
43
+ expect(isNumeric(null)).toBe(false);
44
+ expect(isNumeric(undefined)).toBe(false);
45
+ expect(isNumeric(true)).toBe(false);
46
+ expect(isNumeric(false)).toBe(false);
47
+ expect(isNumeric({})).toBe(false);
48
+ expect(isNumeric([])).toBe(false);
49
+ expect(isNumeric(() => {})).toBe(false);
50
+ });
51
+ });
@@ -1,5 +1,5 @@
1
1
  import { describe, it, expect } from "vitest";
2
- import isPlainObject from ".";
2
+ import { isPlainObject } from "..";
3
3
 
4
4
  describe("isPlainObject", () =>
5
5
  {
@@ -1,5 +1,5 @@
1
1
  import { describe, it, expect } from "vitest";
2
- import isSet from ".";
2
+ import { isSet } from "..";
3
3
 
4
4
  describe("isSet", () =>
5
5
  {
@@ -1,5 +1,5 @@
1
1
  import { describe, it, expect } from "vitest";
2
- import isString from ".";
2
+ import { isString } from "..";
3
3
 
4
4
  describe("isString", () => {
5
5
  it("should return true for a normal string", () => {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "mark-3",
3
3
  "description": "Modular collection of reusable JavaScript helpers, utilities, and Vue components. Built for maintainability, performance, and clarity.",
4
4
  "private": false,
5
- "version": "0.0.4",
5
+ "version": "0.0.5",
6
6
  "workspaces": [
7
7
  "src/*/*"
8
8
  ],
@@ -1,33 +0,0 @@
1
- # format
2
- A lightweight and flexible date formatting utility for JavaScript and TypeScript. This helper formats Date objects using PHP-style tokens like Y, m, d, H, i, and more. It supports both short and long month names with locale-aware formatting via Intl.DateTimeFormat.
3
-
4
- Built with simplicity and clarity in mind — no external dependencies, easy to use, fully typed.
5
-
6
- ---
7
-
8
- ## Usage
9
- ```ts
10
- import { format } from '@mark-3/helpers/date';
11
-
12
- format( new Date, "Y-m-d H:i:s" );
13
- // 2022-01-01 22:00:00 (mysql datetime format)
14
-
15
- format( new Date, "j MM, H:i", "tr" );
16
- // 1 Temmuz, 22:00
17
- ```
18
-
19
- ---
20
-
21
- ## 💡 Supported Tokens
22
- `d`: 01-31 (zero-padded day)
23
- `j`: 1-31 (non-padded day)
24
- `m`: 01-12 (zero-padded month)
25
- `n`: 1-12 (non-padded month)
26
- `M`: Jan–Dec (short month name, localized)
27
- `MM`: January–December (long month name, localized)
28
- `y`: 00-99 (two-digit year)
29
- `Y`: 0000-9999 (full year)
30
- `H`: 00-23 (zero-padded hour, 24h)
31
- `G`: 0-23 (hour, 24h)
32
- `i`: 00-59 (minutes)
33
- `s`: 00-59 (seconds)
@@ -1,97 +0,0 @@
1
- import { describe, it, expect } from "vitest";
2
- import formatDate from "./index";
3
-
4
- describe( "formatDate", () =>
5
- {
6
- const date = new Date( "2025-12-21T22:10:05" );
7
-
8
- it( "formats full year (Y)", () =>
9
- {
10
- expect( formatDate( date, "Y" )).toBe( "2025" );
11
- });
12
-
13
- it( "formats short year (y)", () =>
14
- {
15
- expect( formatDate( date, "y" )).toBe( "25" );
16
- });
17
-
18
- it( "formats zero-padded month (m)", () =>
19
- {
20
- expect( formatDate( date, "m" )).toBe( "12" );
21
- });
22
-
23
- it( "formats non-padded month (n)", () =>
24
- {
25
- expect( formatDate( date, "n" )).toBe( "12" );
26
- });
27
-
28
- it( "formats short month name (M)", () =>
29
- {
30
- expect( formatDate( date, "M" )).toBe( "Dec" );
31
- });
32
-
33
- it( "formats full month name (MM)", () =>
34
- {
35
- expect( formatDate( date, "MM" )).toBe( "December" );
36
- });
37
-
38
- it( "formats day padded (d)", () =>
39
- {
40
- expect( formatDate( date, "d" )).toBe( "21" );
41
- });
42
-
43
- it( "formats day non-padded (j)", () =>
44
- {
45
- expect( formatDate( date, "j" )).toBe( "21" );
46
- });
47
-
48
- it( "formats zero-padded hour (H)", () =>
49
- {
50
- expect( formatDate( date, "H" )).toBe( "22" );
51
- });
52
-
53
- it( "formats non-padded hour (G)", () =>
54
- {
55
- expect( formatDate( date, "G" )).toBe( "22" );
56
- });
57
-
58
- it( "formats minutes (i)", () =>
59
- {
60
- expect( formatDate( date, "i" )).toBe( "10" );
61
- });
62
-
63
- it( "formats seconds (s)", () =>
64
- {
65
- expect( formatDate( date, "s" )).toBe( "05" );
66
- });
67
-
68
- it( "formats a custom pattern", () =>
69
- {
70
- expect( formatDate( date, "d.m.Y H:i" )).toBe( "21.12.2025 22:10" );
71
- });
72
-
73
- it( "supports localized short month (M) in TR", () =>
74
- {
75
- expect( formatDate( date, "M", "tr" )).toBe( "Ara" ); // Aralık
76
- });
77
-
78
- it( "supports localized long month (MM) in TR", () =>
79
- {
80
- expect( formatDate( date, "MM", "tr" )).toBe( "Aralık" );
81
- });
82
-
83
- it( "returns empty string for empty pattern", () =>
84
- {
85
- expect( formatDate( date, "" )).toBe( "" );
86
- });
87
-
88
- it( "leaves unknown tokens as-is", () =>
89
- {
90
- expect( formatDate( date, "[foo] Y" )).toBe( "[foo] 2025" );
91
- });
92
-
93
- it( "mixes plain text and tokens", () =>
94
- {
95
- expect( formatDate( date, "d MM Y, H:i" )).toBe( "21 December 2025, 22:10" );
96
- });
97
- });
@@ -1,14 +0,0 @@
1
- # fromTimestamp
2
- This function handles both seconds and milliseconds timestamps by checking the length of the number.
3
-
4
- If the `timestamp` is less than `1e11`, it's assumed to be in seconds and is converted to milliseconds. If the conversion results in an invalid `Date` object, the function returns the provided `defaultValue`
5
- or `undefined` if no default is specified.
6
-
7
- ---
8
-
9
- ## Usage
10
- ```ts
11
- import fromTimestamp from '@mark-3/helpers-date-from-timestamp';
12
-
13
- const result = fromTimestamp( 1753634780845 );
14
- ```
@@ -1,12 +0,0 @@
1
- # isOnSameDay
2
- A lightweight utility to check whether two JavaScript `Date` objects are in the same calendar day.
3
-
4
- ---
5
-
6
- ## Usage
7
- ```ts
8
- import isOnSameDay from '@mark-3/helpers-date-is-on-same-day';
9
-
10
- const result = isOnSameDay( new Date( '2022-01-01' ), new Date( '2022-12-31' ));
11
- // false
12
- ```
@@ -1,13 +0,0 @@
1
- # isOnSameYear
2
- A lightweight utility to check whether two JavaScript `Date` objects are in the same calendar year.
3
-
4
- ---
5
-
6
- ## Usage
7
-
8
- ```ts
9
- import isOnSameYear from '@mark-3/helpers-date-is-on-same-year';
10
-
11
- const result = isOnSameYear( new Date( '2022-01-01' ), new Date( '2022-12-31' ));
12
- // true
13
- ```
@@ -1,24 +0,0 @@
1
- # camelToDash
2
- Converts a camelCase string to dash-case.
3
-
4
- * replaces uppercase letters with a dash followed by the lowercase equivalent
5
- * removes leading and trailing dashes
6
- * if the input is not a string, returns it unchanged
7
-
8
- ---
9
-
10
- ## Usage
11
- ```js
12
- import { camelToDash } from "mark-3/helpers/string";
13
-
14
- camelToDash("helloWorld"); // "hello-world"
15
- camelToDash("backgroundColor"); // "background-color"
16
- camelToDash("already-dashed"); // "already-dashed"
17
- camelToDash("already---dashed"); // "already---dashed"
18
- camelToDash("MyComponent"); // "my-component"
19
- camelToDash("XMLHttpRequest"); // "x-m-l-http-request"
20
- camelToDash("someValue123"); // "some-value123"
21
- camelToDash("---EdgeCase---"); // "edge-case"
22
- camelToDash(42); // 42
23
- camelToDash(null); // null
24
- ```
@@ -1,12 +0,0 @@
1
- # escapeRegex
2
- Escapes special characters in a string to be used in a regular expression.
3
-
4
- ---
5
-
6
- ## Usage
7
- ```js
8
- import { escapeRegex } from "mark-3/helpers/string";
9
-
10
- escapeRegex( "foo" ); // => "foo"
11
- escapeRegex( "foo*" ); // => "foo\*"
12
- ```