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.
- package/CHANGELOG.md +29 -0
- package/components/index.js +1 -0
- package/components/scroll-aware-content.vue +162 -0
- package/composables/index.js +4 -1
- package/composables/use-intersection-observer.js +67 -0
- package/composables/use-responsiveness.js +61 -0
- package/composables/use-scroll-event.js +97 -0
- package/helpers/array/index.js +1 -0
- package/helpers/array/pick-random.js +24 -0
- package/helpers/array/tests/pick-random.test.js +39 -0
- package/helpers/date/index.js +1 -1
- package/helpers/date/{from-timestamp/index.test.js → tests/format-timestamp.test.js} +1 -1
- package/helpers/date/tests/format.test.js +97 -0
- package/helpers/date/{is-on-same-day/index.test.js → tests/is-on-same-day.test.js} +1 -1
- package/helpers/date/{is-on-same-year/index.test.js → tests/is-on-same-year.test.js} +1 -1
- package/helpers/number/clamp.js +17 -0
- package/helpers/number/index.js +2 -0
- package/helpers/number/random.js +24 -0
- package/helpers/number/tests/clamp.test.js +37 -0
- package/helpers/number/tests/random.test.js +51 -0
- package/helpers/string/{camel-to-dash/index.js → camel-to-dash.js} +2 -2
- package/helpers/string/encode-subscript.js +45 -0
- package/helpers/string/{escape-regex/index.js → escape-regex.js} +1 -1
- package/helpers/string/index.js +1 -0
- package/helpers/string/{camel-to-dash/index.test.js → tests/camel-to-dash.test.js} +1 -1
- package/helpers/string/tests/encode-subscript.test.js +41 -0
- package/helpers/string/{escape-regex/index.test.js → tests/escape-regex.test.js} +1 -1
- package/helpers/string/{trim/index.test.js → tests/trim.test.js} +1 -1
- package/helpers/string/{trim/index.js → trim.js} +3 -3
- package/helpers/time/debounce.js +29 -0
- package/helpers/time/index.js +1 -0
- package/helpers/time/tests/debounce.test.js +58 -0
- package/helpers/types/index.js +3 -0
- package/helpers/types/{is-empty/index.js → is-empty.js} +1 -1
- package/helpers/types/is-map.js +12 -0
- package/helpers/types/is-numeric.js +22 -0
- package/helpers/types/{is-plain-object/index.js → is-plain-object.js} +8 -3
- package/helpers/types/is-set.js +12 -0
- package/helpers/types/{get-type-name/index.test.js → tests/get-type-name.test.js} +2 -2
- package/helpers/types/{is-array/index.test.js → tests/is-array.test.js} +1 -1
- package/helpers/types/{is-empty/index.test.js → tests/is-empty.test.js} +1 -1
- package/helpers/types/tests/is-map.test.js +41 -0
- package/helpers/types/tests/is-numeric.test.js +51 -0
- package/helpers/types/{is-plain-object/index.test.js → tests/is-plain-object.test.js} +1 -1
- package/helpers/types/tests/is-set.test.js +41 -0
- package/helpers/types/tests/is-string.test.js +46 -0
- package/package.json +1 -1
- package/helpers/date/format/README.md +0 -33
- package/helpers/date/format/index.test.js +0 -97
- package/helpers/date/from-timestamp/README.md +0 -14
- package/helpers/date/is-on-same-day/README.md +0 -12
- package/helpers/date/is-on-same-year/README.md +0 -13
- package/helpers/string/camel-to-dash/README.md +0 -24
- package/helpers/string/escape-regex/README.md +0 -12
- package/helpers/string/trim/README.md +0 -66
- package/helpers/types/get-type-name/README.md +0 -11
- package/helpers/types/is-array/README.md +0 -11
- package/helpers/types/is-empty/README.md +0 -35
- package/helpers/types/is-plain-object/README.md +0 -17
- package/helpers/types/is-string/README.md +0 -12
- package/helpers/types/is-string/index.test.js +0 -46
- /package/helpers/date/{from-timestamp/index.js → format-timestamp.js} +0 -0
- /package/helpers/date/{format/index.js → format.js} +0 -0
- /package/helpers/date/{is-on-same-day/index.js → is-on-same-day.js} +0 -0
- /package/helpers/date/{is-on-same-year/index.js → is-on-same-year.js} +0 -0
- /package/helpers/types/{get-type-name/index.js → get-type-name.js} +0 -0
- /package/helpers/types/{is-array/index.js → is-array.js} +0 -0
- /package/helpers/types/{is-string/index.js → is-string.js} +0 -0
@@ -0,0 +1,37 @@
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
2
|
+
import { clamp } from "..";
|
3
|
+
|
4
|
+
describe("clamp()", () =>
|
5
|
+
{
|
6
|
+
it("returns the same value if it is within the min and max range", () =>
|
7
|
+
{
|
8
|
+
expect(clamp(5, 0, 10)).toBe(5);
|
9
|
+
expect(clamp(0, -10, 10)).toBe(0);
|
10
|
+
expect(clamp(9.5, 0, 10)).toBe(9.5);
|
11
|
+
});
|
12
|
+
|
13
|
+
it("clamps the value to the min if it is less than min", () =>
|
14
|
+
{
|
15
|
+
expect(clamp(-5, 0, 10)).toBe(0);
|
16
|
+
expect(clamp(-100, -10, 10)).toBe(-10);
|
17
|
+
});
|
18
|
+
|
19
|
+
it("clamps the value to the max if it is greater than max", () =>
|
20
|
+
{
|
21
|
+
expect(clamp(15, 0, 10)).toBe(10);
|
22
|
+
expect(clamp(99, -10, 10)).toBe(10);
|
23
|
+
});
|
24
|
+
|
25
|
+
it("returns the only possible value if min and max are equal", () =>
|
26
|
+
{
|
27
|
+
expect(clamp(5, 7, 7)).toBe(7);
|
28
|
+
expect(clamp(10, 10, 10)).toBe(10);
|
29
|
+
expect(clamp(-5, -3, -3)).toBe(-3);
|
30
|
+
});
|
31
|
+
|
32
|
+
it("swaps min and max if needed", () =>
|
33
|
+
{
|
34
|
+
expect(clamp(5, 10, 0)).toBe(5);
|
35
|
+
expect(clamp(-5, 3, -3)).toBe(-3);
|
36
|
+
});
|
37
|
+
});
|
@@ -0,0 +1,51 @@
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
2
|
+
import { random } from "..";
|
3
|
+
|
4
|
+
describe("random", () =>
|
5
|
+
{
|
6
|
+
it("should return a number between 0 and 1 by default", () =>
|
7
|
+
{
|
8
|
+
const result = random();
|
9
|
+
expect(result).toBeGreaterThanOrEqual(0);
|
10
|
+
expect(result).toBeLessThanOrEqual(1);
|
11
|
+
expect(Number.isInteger(result)).toBe(true);
|
12
|
+
});
|
13
|
+
|
14
|
+
it("should return float if shouldFloat is true", () =>
|
15
|
+
{
|
16
|
+
const result = random(0, 1, true);
|
17
|
+
expect(result).toBeGreaterThanOrEqual(0);
|
18
|
+
expect(result).toBeLessThanOrEqual(1);
|
19
|
+
expect(Number.isInteger(result)).toBe(false);
|
20
|
+
});
|
21
|
+
|
22
|
+
it("should respect min and max range with integers", () =>
|
23
|
+
{
|
24
|
+
const result = random(5, 10);
|
25
|
+
expect(result).toBeGreaterThanOrEqual(5);
|
26
|
+
expect(result).toBeLessThanOrEqual(10);
|
27
|
+
expect(Number.isInteger(result)).toBe(true);
|
28
|
+
});
|
29
|
+
|
30
|
+
it("should respect min and max range with floats", () =>
|
31
|
+
{
|
32
|
+
const result = random(5, 10, true);
|
33
|
+
expect(result).toBeGreaterThanOrEqual(5);
|
34
|
+
expect(result).toBeLessThanOrEqual(10);
|
35
|
+
});
|
36
|
+
|
37
|
+
it("should always return at least the min value", () =>
|
38
|
+
{
|
39
|
+
for (let i = 0; i < 100; i++)
|
40
|
+
{
|
41
|
+
const result = random(10, 20);
|
42
|
+
expect(result).toBeGreaterThanOrEqual(10);
|
43
|
+
}
|
44
|
+
});
|
45
|
+
|
46
|
+
it("should return exactly min if min and max are both 0", () =>
|
47
|
+
{
|
48
|
+
const result = random(0, 0);
|
49
|
+
expect(result).toBe(0);
|
50
|
+
});
|
51
|
+
});
|
@@ -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
|
+
}
|
package/helpers/string/index.js
CHANGED
@@ -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
|
-
import { escapeRegex } from "
|
2
|
-
import { isEmpty, isArray, isString } from "
|
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.
|
@@ -11,7 +11,7 @@ import { isEmpty, isArray, isString } from "../../types";
|
|
11
11
|
*/
|
12
12
|
export default function trim( input, chars = " " )
|
13
13
|
{
|
14
|
-
if( ! isString( input ) || isEmpty( chars ))
|
14
|
+
if( ! isString( input ) || ( chars !== " " && isEmpty( chars )))
|
15
15
|
{
|
16
16
|
return input;
|
17
17
|
}
|
@@ -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
|
+
});
|
package/helpers/types/index.js
CHANGED
@@ -1,5 +1,8 @@
|
|
1
|
+
export { default as isMap } from "./is-map";
|
2
|
+
export { default as isSet } from "./is-set";
|
1
3
|
export { default as isArray } from "./is-array";
|
2
4
|
export { default as isEmpty } from "./is-empty";
|
3
5
|
export { default as isString } from "./is-string";
|
6
|
+
export { default as isNumeric } from "./is-numeric";
|
4
7
|
export { default as getTypeName } from "./get-type-name";
|
5
8
|
export { default as isPlainObject } from "./is-plain-object";
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { getTypeName } from ".";
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Checks if a given value is a Map.
|
5
|
+
*
|
6
|
+
* @param {any} value - The value to be checked.
|
7
|
+
* @returns {boolean} true if the value is a Map, false otherwise.
|
8
|
+
*/
|
9
|
+
export default function isMap( value )
|
10
|
+
{
|
11
|
+
return getTypeName( value ) === "Map";
|
12
|
+
}
|
@@ -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,5 +1,3 @@
|
|
1
|
-
import { getTypeName } from "../type";
|
2
|
-
|
3
1
|
/**
|
4
2
|
* Checks if the given value is a plain object.
|
5
3
|
*
|
@@ -8,5 +6,12 @@ import { getTypeName } from "../type";
|
|
8
6
|
*/
|
9
7
|
export default function isPlainObject( value )
|
10
8
|
{
|
11
|
-
|
9
|
+
if( typeof value !== "object" || value === null )
|
10
|
+
{
|
11
|
+
return false;
|
12
|
+
}
|
13
|
+
|
14
|
+
const proto = Object.getPrototypeOf( value );
|
15
|
+
|
16
|
+
return proto === Object.prototype || proto === null;
|
12
17
|
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { getTypeName } from ".";
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Checks if a given value is a Set.
|
5
|
+
*
|
6
|
+
* @param {any} value - The value to be checked.
|
7
|
+
* @returns {boolean} true if the value is a Set, false otherwise.
|
8
|
+
*/
|
9
|
+
export default function isSet( value )
|
10
|
+
{
|
11
|
+
return getTypeName( value ) === "Set";
|
12
|
+
}
|
@@ -0,0 +1,41 @@
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
2
|
+
import { isMap } from "..";
|
3
|
+
|
4
|
+
describe("isMap", () =>
|
5
|
+
{
|
6
|
+
it("should return true for Map instances", () =>
|
7
|
+
{
|
8
|
+
expect(isMap(new Map())).toBe(true);
|
9
|
+
const map = new Map();
|
10
|
+
map.set("key", "value");
|
11
|
+
expect(isMap(map)).toBe(true);
|
12
|
+
});
|
13
|
+
|
14
|
+
it("should return false for WeakMap", () =>
|
15
|
+
{
|
16
|
+
expect(isMap(new WeakMap())).toBe(false);
|
17
|
+
});
|
18
|
+
|
19
|
+
it("should return false for plain objects", () =>
|
20
|
+
{
|
21
|
+
expect(isMap({})).toBe(false);
|
22
|
+
expect(isMap({ a: 1 })).toBe(false);
|
23
|
+
});
|
24
|
+
|
25
|
+
it("should return false for arrays", () =>
|
26
|
+
{
|
27
|
+
expect(isMap([])).toBe(false);
|
28
|
+
expect(isMap([1, 2, 3])).toBe(false);
|
29
|
+
});
|
30
|
+
|
31
|
+
it("should return false for other types", () =>
|
32
|
+
{
|
33
|
+
expect(isMap(null)).toBe(false);
|
34
|
+
expect(isMap(undefined)).toBe(false);
|
35
|
+
expect(isMap(42)).toBe(false);
|
36
|
+
expect(isMap("string")).toBe(false);
|
37
|
+
expect(isMap(true)).toBe(false);
|
38
|
+
expect(isMap(Symbol("sym"))).toBe(false);
|
39
|
+
expect(isMap(function () {})).toBe(false);
|
40
|
+
});
|
41
|
+
});
|
@@ -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
|
+
});
|
@@ -0,0 +1,41 @@
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
2
|
+
import { isSet } from "..";
|
3
|
+
|
4
|
+
describe("isSet", () =>
|
5
|
+
{
|
6
|
+
it("should return true for Set instances", () =>
|
7
|
+
{
|
8
|
+
expect(isSet(new Set())).toBe(true);
|
9
|
+
const set = new Set();
|
10
|
+
set.add("key", "value");
|
11
|
+
expect(isSet(set)).toBe(true);
|
12
|
+
});
|
13
|
+
|
14
|
+
it("should return false for WeakSet", () =>
|
15
|
+
{
|
16
|
+
expect(isSet(new WeakSet())).toBe(false);
|
17
|
+
});
|
18
|
+
|
19
|
+
it("should return false for plain objects", () =>
|
20
|
+
{
|
21
|
+
expect(isSet({})).toBe(false);
|
22
|
+
expect(isSet({ a: 1 })).toBe(false);
|
23
|
+
});
|
24
|
+
|
25
|
+
it("should return false for arrays", () =>
|
26
|
+
{
|
27
|
+
expect(isSet([])).toBe(false);
|
28
|
+
expect(isSet([1, 2, 3])).toBe(false);
|
29
|
+
});
|
30
|
+
|
31
|
+
it("should return false for other types", () =>
|
32
|
+
{
|
33
|
+
expect(isSet(null)).toBe(false);
|
34
|
+
expect(isSet(undefined)).toBe(false);
|
35
|
+
expect(isSet(42)).toBe(false);
|
36
|
+
expect(isSet("string")).toBe(false);
|
37
|
+
expect(isSet(true)).toBe(false);
|
38
|
+
expect(isSet(Symbol("sym"))).toBe(false);
|
39
|
+
expect(isSet(function () {})).toBe(false);
|
40
|
+
});
|
41
|
+
});
|
@@ -0,0 +1,46 @@
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
2
|
+
import { isString } from "..";
|
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
|
+
});
|
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.
|
5
|
+
"version": "0.0.5",
|
6
6
|
"workspaces": [
|
7
7
|
"src/*/*"
|
8
8
|
],
|