tsu 1.0.2 → 1.1.2

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/package.json CHANGED
@@ -1,46 +1,47 @@
1
1
  {
2
2
  "name": "tsu",
3
- "version": "1.0.2",
3
+ "version": "1.1.2",
4
4
  "description": "A collection of TypeScript utilities.",
5
- "scripts": {
6
- "start": "tsdx watch",
7
- "build": "tsdx build",
8
- "test": "tsdx test",
9
- "lint": "tsdx lint",
10
- "prepare": "tsdx build",
11
- "docs:dev": "vuepress dev docs",
12
- "docs:build": "vuepress build docs"
13
- },
5
+ "author": "eb3n",
14
6
  "repository": {
15
7
  "type": "git",
16
8
  "url": "git+https://gitlab.com/eb3n/tsu.git"
17
9
  },
18
- "main": "dist/index.js",
19
- "module": "dist/tsu.esm.js",
20
- "typings": "dist/index.d.ts",
10
+ "license": "MIT",
11
+ "scripts": {
12
+ "build": "tsup src/index.ts --format cjs,esm --dts --clean",
13
+ "watch": "yarn build -- --watch src",
14
+ "test": "jest",
15
+ "prepublishOnly": "yarn test && yarn build",
16
+ "docs:dev": "vuepress dev docs",
17
+ "docs:build": "vuepress build docs"
18
+ },
19
+ "main": "./dist/index.js",
20
+ "module": "./dist/index.mjs",
21
+ "types": "./dist/index.d.ts",
21
22
  "files": [
22
- "dist",
23
- "src"
23
+ "dist"
24
24
  ],
25
- "engines": {
26
- "node": ">=10"
27
- },
28
- "author": "eb3n",
29
- "license": "MIT",
30
- "publishConfig": {
31
- "access": "public"
25
+ "exports": {
26
+ ".": {
27
+ "require": "./dist/index.js",
28
+ "import": "./dist/index.mjs",
29
+ "types": "./dist/index.d.ts"
30
+ }
32
31
  },
33
32
  "devDependencies": {
34
- "@typescript-eslint/eslint-plugin": "^4.29.1",
35
- "@typescript-eslint/parser": "^4.29.1",
36
- "eslint": "^7.32.0",
37
- "eslint-config-prettier": "^8.3.0",
38
- "eslint-plugin-prettier": "^3.4.0",
39
- "prettier": "^2.3.2",
40
- "tsdx": "^0.14.1",
41
- "tslib": "^2.3.0",
42
- "typescript": "^4.3.5",
43
- "vue": "^3.2.4",
44
- "vuepress": "^2.0.0-beta.24"
45
- }
33
+ "@types/jest": "^27.4.1",
34
+ "@typescript-eslint/eslint-plugin": "^5.14.0",
35
+ "@typescript-eslint/parser": "^5.14.0",
36
+ "eslint": "^8.10.0",
37
+ "eslint-config-prettier": "^8.5.0",
38
+ "eslint-plugin-prettier": "^4.0.0",
39
+ "jest": "^27.5.1",
40
+ "prettier": "^2.5.1",
41
+ "ts-jest": "^27.1.3",
42
+ "tsup": "^5.12.0",
43
+ "typescript": "^4.6.2",
44
+ "vuepress": "^2.0.0-beta.41"
45
+ },
46
+ "dependencies": {}
46
47
  }
package/dist/array.d.ts DELETED
@@ -1,96 +0,0 @@
1
- import type { Arrayable, Nullable } from './types';
2
- /**
3
- * Removes the first n items of an array.
4
- *
5
- * @param n - The number of items to remove.
6
- * @param array - The array.
7
- * @returns The remaining items.
8
- */
9
- export declare function drop<T>(n: number, array: readonly T[]): T[];
10
- /**
11
- * Returns the first item of an array.
12
- *
13
- * @param array - The array.
14
- * @returns The first item.
15
- */
16
- export declare function head<T>(array: readonly T[]): T;
17
- /**
18
- * Returns all but the last item of an array.
19
- *
20
- * @param array - The array.
21
- * @returns The array without the last item.
22
- */
23
- export declare function init<T>(array: readonly T[]): T[];
24
- /**
25
- * Returns the last item of an array.
26
- *
27
- * @param array - The array.
28
- * @returns The last item.
29
- */
30
- export declare function last<T>(array: readonly T[]): T;
31
- /**
32
- * Returns the maximum number of an array.
33
- *
34
- * @param array - The array of numbers.
35
- * @returns The maximum number.
36
- */
37
- export declare function max(array: readonly number[]): number | undefined;
38
- /**
39
- * Returns the minimum number of an array.
40
- *
41
- * @param array - The array of numbers.
42
- * @returns The minimum number.
43
- */
44
- export declare function min(array: readonly number[]): number | undefined;
45
- /**
46
- * Splits an array into two based on a predicate function.
47
- *
48
- * @param filter - The predicate function.
49
- * @param array - The array.
50
- * @returns The array split in two.
51
- */
52
- export declare function partition<T>(filter: (x: T, idx: number, arr: readonly T[]) => boolean, array: readonly T[]): [T[], T[]];
53
- /**
54
- * Splits an array into two at a given index.
55
- *
56
- * @param i - The position to split at.
57
- * @param array - The array.
58
- * @returns The array split in two.
59
- */
60
- export declare function splitAt<T>(i: number, array: readonly T[]): [T[], T[]];
61
- /**
62
- * Returns the sum of the numbers of an array.
63
- *
64
- * @param array - The array of numbers.
65
- * @returns The sum.
66
- */
67
- export declare function sum(array: readonly number[]): number;
68
- /**
69
- * Returns all but the first item of an array.
70
- *
71
- * @param array - The array.
72
- * @returns The array without the first item.
73
- */
74
- export declare function tail<T>(array: readonly T[]): T[];
75
- /**
76
- * Returns the first n items of an array.
77
- *
78
- * @param n - The number of items to return.
79
- * @param array - The array.
80
- * @returns The first n items.
81
- */
82
- export declare function take<T>(n: number, array: readonly T[]): T[];
83
- /**
84
- * Wraps a single value of an array, if not already an array.
85
- *
86
- * @param maybeArray - The value to wrap, or the existing array.
87
- * @returns The item wrapped in an array, or the provided array.
88
- */
89
- export declare function toArray<T>(maybeArray: Nullable<Arrayable<T>>): T[];
90
- /**
91
- * Removes duplicate primitive values from an array.
92
- *
93
- * @param array - The array.
94
- * @returns The array without duplicated primitive values.
95
- */
96
- export declare function uniq<T>(array: readonly T[]): T[];
@@ -1,24 +0,0 @@
1
- import type { Fn, VoidFn } from './types';
2
- /**
3
- * Prevents a function from running until it hasn't been called for a certain time period.
4
- *
5
- * @param fn - The function.
6
- * @param delay - The time period (in ms).
7
- * @returns The debounced function.
8
- */
9
- export declare function debounce(fn: Fn, delay: number): VoidFn;
10
- /**
11
- * Optimises subsequent calls of a function by caching return values.
12
- *
13
- * @param fn - The function.
14
- * @returns The memoized function.
15
- */
16
- export declare function memoize<T>(fn: Fn<T>): Fn<T>;
17
- /**
18
- * Prevents a function from running for some time period after it was last called.
19
- *
20
- * @param fn - The function.
21
- * @param limit - The time period.
22
- * @returns The throttled function.
23
- */
24
- export declare function throttle(fn: Fn, limit: number): VoidFn;
package/dist/is.d.ts DELETED
@@ -1,63 +0,0 @@
1
- import type { Fn, Obj } from './types';
2
- /**
3
- * Identifies if a value is an array.
4
- *
5
- * @param val - The value.
6
- * @returns If the value is an array.
7
- */
8
- export declare function isArray(val: unknown): val is any[];
9
- /**
10
- * Identifies if a value is a boolean.
11
- *
12
- * @param val - The value.
13
- * @returns If the value is a boolean.
14
- */
15
- export declare function isBoolean(val: unknown): val is boolean;
16
- /**
17
- * Identifies if the code is being run in the browser.
18
- *
19
- * @returns If the code is being run on a browser.
20
- */
21
- export declare function isBrowser(): boolean;
22
- /**
23
- * Identifies if a value is defined.
24
- *
25
- * @param val - The value.
26
- * @returns If the value is defined.
27
- */
28
- export declare function isDefined<T = unknown>(val?: T): val is T;
29
- /**
30
- * Identifies if a value is a function.
31
- *
32
- * @param val - The value.
33
- * @returns If the value is a function.
34
- */
35
- export declare function isFunction<T extends Fn>(val: unknown): val is T;
36
- /**
37
- * Identifies if a value is a number.
38
- *
39
- * @param val - The value.
40
- * @returns If the value is a number.
41
- */
42
- export declare function isNumber(val: unknown): val is number;
43
- /**
44
- * Identifies if a value is an object.
45
- *
46
- * @param val - The value.
47
- * @returns If the value is an object.
48
- */
49
- export declare function isObject(val: unknown): val is Obj;
50
- /**
51
- * Identifies if a value is a string.
52
- *
53
- * @param val - The value.
54
- * @returns If the value is a string.
55
- */
56
- export declare function isString(val: unknown): val is string;
57
- /**
58
- * Identifies if a value is the global window.
59
- *
60
- * @param val - The value.
61
- * @returns If the value is the global window.
62
- */
63
- export declare function isWindow(val: unknown): val is Window;
package/dist/maths.d.ts DELETED
@@ -1,37 +0,0 @@
1
- /**
2
- * Identifies if a number is even.
3
- *
4
- * @param n - The number.
5
- * @returns If the number is even.
6
- */
7
- export declare function isEven(n: number): boolean;
8
- /**
9
- * Identifies if a number is odd.
10
- *
11
- * @param n - The number.
12
- * @returns If the number is odd.
13
- */
14
- export declare function isOdd(n: number): boolean;
15
- /**
16
- * Opinionated implementation of modulo (%).
17
- *
18
- * @param n - The dividend.
19
- * @param m - The divisor.
20
- * @returns The remainder of dividing n by m.
21
- */
22
- export declare function modulo(n: number, m: number): number;
23
- /**
24
- * Generates a random integer between bounds.
25
- *
26
- * @param max - The exclusive maximum bound.
27
- * @param min - The inclusive minimum bound.
28
- * @returns The random integer.
29
- */
30
- export declare function randomNumber(max: number, min?: number): number;
31
- /**
32
- * Rolls an n-sided die.
33
- *
34
- * @param n - The number of sides on the die.
35
- * @returns If the die roll was 0.
36
- */
37
- export declare function randomChance(n: number): boolean;
package/dist/misc.d.ts DELETED
@@ -1,13 +0,0 @@
1
- /**
2
- * Does nothing.
3
- *
4
- * @returns Nothing.
5
- */
6
- export declare function noop(): void;
7
- /**
8
- * Halts program execution for a specified time.
9
- *
10
- * @param duration - The time to wait (in ms).
11
- * @returns The halting promise.
12
- */
13
- export declare function sleep(duration: number): Promise<void>;
package/dist/object.d.ts DELETED
@@ -1,10 +0,0 @@
1
- import type { Obj } from './types';
2
- declare type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
3
- /**
4
- * Recursively merges multiple objects into one.
5
- *
6
- * @param objects - The objects to merge.
7
- * @returns The merged object.
8
- */
9
- export declare function deepMerge<T extends Obj<any>[]>(...objects: T): UnionToIntersection<T[number]>;
10
- export {};
package/dist/scroll.d.ts DELETED
@@ -1,17 +0,0 @@
1
- declare type ScrollConfig = {
2
- to: Element | string | number;
3
- offset?: number;
4
- duration?: number;
5
- container?: Element | string | null;
6
- };
7
- /**
8
- * Scrolls the page or provided container to a target element or y-coordinate.
9
- *
10
- * @param config - The scroll config.
11
- * @param config.to - The scroll target.
12
- * @param config.offset - The offset from the scroll target (in px).
13
- * @param config.duration - The scroll duration (in ms).
14
- * @param config.container - The container to scroll in.
15
- */
16
- export declare function scroll({ to, offset, duration, container }: ScrollConfig): void;
17
- export {};
package/dist/string.d.ts DELETED
@@ -1,59 +0,0 @@
1
- /**
2
- * Capitalises the first letter of one word, or all words, in a string.
3
- *
4
- * @param str - The string.
5
- * @param allWords - If all words should be capitalised.
6
- * @returns The capitalised string.
7
- */
8
- export declare function capitalise(str: string, allWords?: boolean): string;
9
- /**
10
- * Separates a string into an array of characters.
11
- *
12
- * @param str - The string.
13
- * @returns The string's characters.
14
- */
15
- export declare function chars(str: string): string[];
16
- /**
17
- * Identifies strings which only contain whitespace.
18
- *
19
- * @param str - The string.
20
- * @returns If the string is blank.
21
- */
22
- export declare function isBlank(str: string): boolean;
23
- /**
24
- * Identifies empty strings.
25
- *
26
- * @param str - The string.
27
- * @returns If the string is empty.
28
- */
29
- export declare function isEmpty(str: string): boolean;
30
- /**
31
- * Converts a kebab case string to camel case.
32
- *
33
- * @param str - The kebab case string.
34
- * @returns The camel case string.
35
- */
36
- export declare function toCamel(str: string): string;
37
- /**
38
- * Converts a camel case string to kebab case.
39
- *
40
- * @param str - The camel case string.
41
- * @returns The kebab case string.
42
- */
43
- export declare function toKebab(str: string): string;
44
- /**
45
- * Converts a string which contains a number to the number itself.
46
- *
47
- * @param str - The string.
48
- * @returns The number.
49
- */
50
- export declare function toNumber(str: string): number;
51
- /**
52
- * Truncates a string to a provided length.
53
- *
54
- * @param str - The string.
55
- * @param length - The length.
56
- * @param truncateStr - The prefix to apply after truncation.
57
- * @returns The truncated string.
58
- */
59
- export declare function truncate(str: string, length: number, truncateStr?: string): string;