mark-3 0.0.3 → 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 +29 -0
  2. package/components/index.js +1 -0
  3. package/components/scroll-aware-content.vue +162 -0
  4. package/composables/index.js +4 -1
  5. package/composables/use-intersection-observer.js +67 -0
  6. package/composables/use-responsiveness.js +61 -0
  7. package/composables/use-scroll-event.js +97 -0
  8. package/helpers/array/index.js +1 -0
  9. package/helpers/array/pick-random.js +24 -0
  10. package/helpers/array/tests/pick-random.test.js +39 -0
  11. package/helpers/date/index.js +1 -1
  12. package/helpers/date/{from-timestamp/index.test.js → tests/format-timestamp.test.js} +1 -1
  13. package/helpers/date/tests/format.test.js +97 -0
  14. package/helpers/date/{is-on-same-day/index.test.js → tests/is-on-same-day.test.js} +1 -1
  15. package/helpers/date/{is-on-same-year/index.test.js → tests/is-on-same-year.test.js} +1 -1
  16. package/helpers/number/clamp.js +17 -0
  17. package/helpers/number/index.js +2 -0
  18. package/helpers/number/random.js +24 -0
  19. package/helpers/number/tests/clamp.test.js +37 -0
  20. package/helpers/number/tests/random.test.js +51 -0
  21. package/helpers/string/{camel-to-dash/index.js → camel-to-dash.js} +2 -2
  22. package/helpers/string/encode-subscript.js +45 -0
  23. package/helpers/string/{escape-regex/index.js → escape-regex.js} +1 -1
  24. package/helpers/string/index.js +1 -0
  25. package/helpers/string/{camel-to-dash/index.test.js → tests/camel-to-dash.test.js} +1 -1
  26. package/helpers/string/tests/encode-subscript.test.js +41 -0
  27. package/helpers/string/{escape-regex/index.test.js → tests/escape-regex.test.js} +1 -1
  28. package/helpers/string/{trim/index.test.js → tests/trim.test.js} +1 -1
  29. package/helpers/string/{trim/index.js → trim.js} +3 -3
  30. package/helpers/time/debounce.js +29 -0
  31. package/helpers/time/index.js +1 -0
  32. package/helpers/time/tests/debounce.test.js +58 -0
  33. package/helpers/types/index.js +3 -0
  34. package/helpers/types/{is-empty/index.js → is-empty.js} +1 -1
  35. package/helpers/types/is-map.js +12 -0
  36. package/helpers/types/is-numeric.js +22 -0
  37. package/helpers/types/{is-plain-object/index.js → is-plain-object.js} +8 -3
  38. package/helpers/types/is-set.js +12 -0
  39. package/helpers/types/{get-type-name/index.test.js → tests/get-type-name.test.js} +2 -2
  40. package/helpers/types/{is-array/index.test.js → tests/is-array.test.js} +1 -1
  41. package/helpers/types/{is-empty/index.test.js → tests/is-empty.test.js} +1 -1
  42. package/helpers/types/tests/is-map.test.js +41 -0
  43. package/helpers/types/tests/is-numeric.test.js +51 -0
  44. package/helpers/types/{is-plain-object/index.test.js → tests/is-plain-object.test.js} +1 -1
  45. package/helpers/types/tests/is-set.test.js +41 -0
  46. package/helpers/types/tests/is-string.test.js +46 -0
  47. package/package.json +1 -1
  48. package/helpers/date/format/README.md +0 -33
  49. package/helpers/date/format/index.test.js +0 -97
  50. package/helpers/date/from-timestamp/README.md +0 -14
  51. package/helpers/date/is-on-same-day/README.md +0 -12
  52. package/helpers/date/is-on-same-year/README.md +0 -13
  53. package/helpers/string/camel-to-dash/README.md +0 -24
  54. package/helpers/string/escape-regex/README.md +0 -12
  55. package/helpers/string/trim/README.md +0 -66
  56. package/helpers/types/get-type-name/README.md +0 -11
  57. package/helpers/types/is-array/README.md +0 -11
  58. package/helpers/types/is-empty/README.md +0 -35
  59. package/helpers/types/is-plain-object/README.md +0 -17
  60. package/helpers/types/is-string/README.md +0 -12
  61. package/helpers/types/is-string/index.test.js +0 -46
  62. /package/helpers/date/{from-timestamp/index.js → format-timestamp.js} +0 -0
  63. /package/helpers/date/{format/index.js → format.js} +0 -0
  64. /package/helpers/date/{is-on-same-day/index.js → is-on-same-day.js} +0 -0
  65. /package/helpers/date/{is-on-same-year/index.js → is-on-same-year.js} +0 -0
  66. /package/helpers/types/{get-type-name/index.js → get-type-name.js} +0 -0
  67. /package/helpers/types/{is-array/index.js → is-array.js} +0 -0
  68. /package/helpers/types/{is-string/index.js → is-string.js} +0 -0
@@ -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
- ```
@@ -1,66 +0,0 @@
1
- # trim
2
- A small utility function to trim specific characters from both ends of a string.
3
-
4
- Unlike the native `String.prototype.trim()` which only removes whitespace, this function lets you specify exactly which characters to trim — including special characters or a list of them.
5
-
6
- ---
7
-
8
- ## Features
9
- - Trim custom characters from the **start and end** of a string
10
- - Accepts either a **single character string** or an **array of characters**
11
- - Automatically escapes special regex characters
12
- - Ignores non-string input safely
13
-
14
- ---
15
-
16
- ## Usage
17
- ```js
18
- import { trim } from "mark-3/helpers/string";
19
-
20
- // Default whitespace trim
21
- trim(" Hello world ");
22
- // => "Hello world"
23
-
24
- // Trim specific character
25
- trim("---Hello---", "-");
26
- // => "Hello"
27
-
28
- // Trim multiple characters
29
- trim("..//Hello//..", [".", "/"]);
30
- // => "Hello"
31
-
32
- // No trim if input is not a string
33
- trim(42, "-");
34
- // => 42
35
-
36
- // Empty trim characters (returns input as-is)
37
- trim("text", "");
38
- // => "text"
39
-
40
- // trim characters as a pattern
41
- trim(":::text:::_", ":::" );
42
- // => "text:::_"
43
- ```
44
-
45
- ---
46
-
47
- ## Parameters
48
- ```ts
49
- trim(input: string, chars?: string | string[]): string
50
- ```
51
-
52
- | Name | Type | Default | Description |
53
- | ----- | -------------------- | ------- | --------------------------------------- |
54
- | input | `string` | — | The string to be trimmed |
55
- | chars | `string \| string[]` | `" "` | The character(s) to trim from both ends |
56
-
57
- If chars is a string of multiple characters, each character will be treated individually and removed if present at the start or end.
58
-
59
- **Behavior Details**
60
- If chars is an array: All characters in the array will be treated as individual characters to trim.
61
-
62
- If chars is a string:
63
- * A single-character string: trimmed directly like a single items array.
64
- * A multi-character string: each character as a whole.
65
-
66
- All special characters like ., *, +, ^ are automatically escaped — no need to handle them manually.
@@ -1,11 +0,0 @@
1
- # getTypeName
2
- Returns the name of a variable's type.
3
-
4
- ---
5
-
6
- ## Usage
7
- ```js
8
- import { getTypeName } from "mark-3/helpers/types";
9
-
10
- getTypeName({}); // 'Object'
11
- ```
@@ -1,11 +0,0 @@
1
- # isArray
2
- Checks if a value is an array.
3
-
4
- ---
5
-
6
- ## Usage
7
- ```js
8
- import { isArray } from "mark-3/helpers/types";
9
-
10
- isArray([ 1, 2, 3 ]); // true
11
- ```
@@ -1,35 +0,0 @@
1
- # isEmpty
2
- Checks if the given variable is empty.
3
-
4
- If the variable is an object, it is considered empty if it has no keys.
5
- If the variable is an array, it is considered empty if it has no elements.
6
- If the variable is a map or a set, it is considered empty if it has no size.
7
- If the variable is a string, it is considered empty if it is trimmed to be an empty string.
8
- If the variable is undefined or null, it is considered empty.
9
-
10
- Otherwise, it is not considered empty.
11
-
12
- ---
13
-
14
- ## Usage
15
-
16
- ```js
17
- import { isEmpty } from 'mark-3/helpers/types/isEmpty';
18
-
19
- isEmpty( '' ); // true
20
- isEmpty( ' ' ); // true
21
- isEmpty([]); // true
22
- isEmpty({}); // true
23
- isEmpty( new Map()); // true
24
- isEmpty( new Set()); // true
25
- isEmpty( null ); // true
26
- isEmpty( undefined ); // true
27
-
28
- isEmpty( 'foo' ); // false
29
- isEmpty([ 'foo' ]); // false
30
- isEmpty({ foo: 'bar' }); // false
31
- isEmpty( new Map([ 'foo', 'bar' ])); // false
32
- isEmpty( new Set([ 'foo' ])); // false
33
- isEmpty({ foo: 'bar' }); // false
34
- isEmpty(() => {}); // false
35
- ```
@@ -1,17 +0,0 @@
1
- # isPlainObject
2
- A utility function to check if a value is a plain object.
3
-
4
- ## Usage
5
- ```js
6
- import { isPlainObject } from "mark-3/helpers/types";
7
-
8
- isPlainObject({}); // true
9
- isPlainObject({ a: 1 }); // true
10
- isPlainObject(Object.create(null)); // true
11
- isPlainObject([]); // false
12
- isPlainObject(null); // false
13
- isPlainObject(new Date()); // false
14
- isPlainObject(function(){}); // false
15
- isPlainObject(new Map()); // false
16
- isPlainObject(new ( class MyClass{})()); // false
17
- ```
@@ -1,12 +0,0 @@
1
- # isString
2
- Checks if a value is a string.
3
-
4
- ---
5
-
6
- ## Usage
7
- ```js
8
- import { isString } from "mark-3/helpers/types";
9
-
10
- isString( "foo" ); // true
11
- isString(1); // false
12
- ```
@@ -1,46 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import isString from './isString'; // dosya yolunu kendi yapına göre düzenle
3
-
4
- describe('isString', () => {
5
- it('should return true for a normal string', () => {
6
- expect(isString('hello')).toBe(true);
7
- });
8
-
9
- it('should return true for an empty string', () => {
10
- expect(isString('')).toBe(true);
11
- });
12
-
13
- it('should return false for a String object', () => {
14
- // typeof new String('abc') === 'object'
15
- expect(isString(new String('abc'))).toBe(false);
16
- });
17
-
18
- it('should return false for a number', () => {
19
- expect(isString(123)).toBe(false);
20
- });
21
-
22
- it('should return false for null', () => {
23
- expect(isString(null)).toBe(false);
24
- });
25
-
26
- it('should return false for undefined', () => {
27
- expect(isString(undefined)).toBe(false);
28
- });
29
-
30
- it('should return false for an object', () => {
31
- expect(isString({})).toBe(false);
32
- });
33
-
34
- it('should return false for an array', () => {
35
- expect(isString(['a', 'b'])).toBe(false);
36
- });
37
-
38
- it('should return false for a boolean', () => {
39
- expect(isString(true)).toBe(false);
40
- expect(isString(false)).toBe(false);
41
- });
42
-
43
- it('should return false for a function', () => {
44
- expect(isString(() => {})).toBe(false);
45
- });
46
- });
File without changes