@zthun/helpful-fn 0.20.0 → 0.21.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.
@@ -1,12 +1,42 @@
1
+ /**
2
+ * Represents a vertical anchor.
3
+ */
1
4
  export declare enum ZVerticalAnchor {
5
+ /**
6
+ * Top boundary.
7
+ */
2
8
  Top = "top",
9
+ /**
10
+ * Centerpoint between the top and bottom.
11
+ */
3
12
  Middle = "middle",
13
+ /**
14
+ * Bottom boundary.
15
+ */
4
16
  Bottom = "bottom"
5
17
  }
6
18
  export declare enum ZHorizontalAnchor {
19
+ /**
20
+ * Left boundary.
21
+ */
7
22
  Left = "left",
23
+ /**
24
+ * Centerpoint between the left and right boundary.
25
+ */
8
26
  Center = "center",
27
+ /**
28
+ * Right boundary.
29
+ */
9
30
  Right = "right"
10
31
  }
32
+ /**
33
+ * Represents an anchor point.
34
+ *
35
+ * An anchor point is a point that stays constant while things are
36
+ * resizing.
37
+ */
11
38
  export type ZAnchor = [ZVerticalAnchor, ZHorizontalAnchor];
39
+ /**
40
+ * Represents a special type of anchor that excludes the center points.
41
+ */
12
42
  export type ZSideAnchor = ZVerticalAnchor.Top | ZVerticalAnchor.Bottom | ZHorizontalAnchor.Left | ZHorizontalAnchor.Right;
@@ -1 +1,31 @@
1
+ /**
2
+ * Calculates the total number of buckets you need to
3
+ * store a number of items where each bucket can hold a
4
+ * maximum weight of items.
5
+ *
6
+ * You can use this function to calculate groupings of
7
+ * items based on total counts and sizes. A good example
8
+ * usage would be to calculate the total number of pages
9
+ * on a paginated list of items given a page size and item
10
+ * count.
11
+ *
12
+ * @param weight -
13
+ * The maximum weight a bucket can store.
14
+ * @param items -
15
+ * The total number of items you need to store where each item
16
+ * counts as 1 towards the weight.
17
+ * @param min -
18
+ * The bounded minimum value. If the total number of buckets
19
+ * evaluates to less than this value, then this value is returned.
20
+ * @param max -
21
+ * The bounded maximum value. If the total number of buckets
22
+ * evaluates to more than this value, then this value is returned.
23
+ *
24
+ * @returns
25
+ * The number of buckets you need to store the total number
26
+ * of items given that a single bucket can hold a max weight of items.
27
+ * If either weight or items is NaN, then NaN will be returned regardless
28
+ * of the opposite value. Passing a negative number is the same as
29
+ * passing 0.
30
+ */
1
31
  export declare function countBuckets(weight: number, items: number, min?: number, max?: number): number;
@@ -1 +1,7 @@
1
+ /**
2
+ * Creates a globally unique identifier.
3
+ *
4
+ * @returns
5
+ * A new generated globally unique identifier.
6
+ */
1
7
  export declare const createGuid: () => string;
@@ -1 +1,16 @@
1
+ /**
2
+ * Returns the first value in args such that args is not null or undefined.
3
+ *
4
+ * @param fallback -
5
+ * The fallback value in the case that all values in args are null/undefined.
6
+ * @param first -
7
+ * The first value to check.
8
+ * @param remaining -
9
+ * The remaining values beyond the first to check.
10
+ *
11
+ * @returns
12
+ * The first value if it is not null or undefined. If first is undefined or null, then the first item
13
+ * in remaining such that remaining[i] is not null or undefined is returned. If first and all values of
14
+ * remaining are null or undefined, then fallback is returned.
15
+ */
1
16
  export declare function firstDefined<T = any>(fallback: T, first: T | null | undefined, ...remaining: (T | null | undefined)[]): T;
@@ -1,7 +1,63 @@
1
1
  export type JoinListInputParameter<T> = T | [T, boolean] | null | undefined;
2
+ /**
3
+ * Similar to a string join, but filters out null and undefined items.
4
+ *
5
+ * @param delimiter -
6
+ * The delimiter that separates the items.
7
+ * @param items -
8
+ * The items to join.
9
+ *
10
+ * @returns
11
+ * A string that joins the items that are defined, separated by delimiter.
12
+ */
2
13
  export declare function joinDefined<T>(delimiter: string, ...items: JoinListInputParameter<T>[]): string;
14
+ /**
15
+ * Alias to joinList with a string delimiter.
16
+ *
17
+ * @param items -
18
+ * The items to join.
19
+ *
20
+ * @returns
21
+ * A string that joins the items that are defined, separated by space delimiter.
22
+ */
3
23
  export declare const spaceJoinDefined: <T>(...items: JoinListInputParameter<T>[]) => string;
24
+ /**
25
+ * Alias of spaceJoinList.
26
+ *
27
+ * @param items -
28
+ * The items to join.
29
+ *
30
+ * @returns
31
+ * A string that joins the items that are defined, separated by a space delimiter.
32
+ */
4
33
  export declare const cssJoinDefined: <T>(...items: JoinListInputParameter<T>[]) => string;
34
+ /**
35
+ * Alias of joinList with a comma delimiter.
36
+ *
37
+ * @param items -
38
+ * The items to join.
39
+ *
40
+ * @returns
41
+ * A string that joins the items that are defined, separated by a comma delimiter.
42
+ */
5
43
  export declare const commaJoinDefined: <T>(...items: JoinListInputParameter<T>[]) => string;
44
+ /**
45
+ * Alias of joinList with a semi-colon delimiter.
46
+ *
47
+ * @param items -
48
+ * The items to join.
49
+ *
50
+ * @returns
51
+ * A string that joins the items that are defined, separated by a semi-colon delimiter.
52
+ */
6
53
  export declare const semiColonJoinDefined: <T>(...items: JoinListInputParameter<T>[]) => string;
54
+ /**
55
+ * Alias of joinList with a pipe delimiter.
56
+ *
57
+ * @param items -
58
+ * The items to join.
59
+ *
60
+ * @returns
61
+ * A string that joins the items that are defined, separated by a pipe delimiter.
62
+ */
7
63
  export declare const pipeJoinDefined: <T>(...items: JoinListInputParameter<T>[]) => string;
@@ -1,4 +1,19 @@
1
+ /**
2
+ * Represents a direction orientation.
3
+ */
1
4
  export declare enum ZOrientation {
5
+ /**
6
+ * Row orientation.
7
+ *
8
+ * This type of orientation is a row
9
+ * style orientation or flex-row orientation.
10
+ */
2
11
  Horizontal = "horizontal",
12
+ /**
13
+ * Vertical orientation.
14
+ *
15
+ * This type of orientation is a column
16
+ * style orientation or block orientation.
17
+ */
3
18
  Vertical = "vertical"
4
19
  }
@@ -1 +1,14 @@
1
+ /**
2
+ * Represents a setter function for when you want to set a single value, but you have an array instead.
3
+ *
4
+ * This is useful when you want to support lists of items, but you need
5
+ * backwards compatibility for setting a single item.
6
+ *
7
+ * @param setValue -
8
+ * The setter function that takes a single value.
9
+ * @param fallback -
10
+ * The fallback value in the case that there are no values.
11
+ * @param value -
12
+ * The value list to retrieve the first item from.
13
+ */
1
14
  export declare function setFirst<T>(setValue: (val: T) => any, fallback: T, value: T[] | null | undefined): void;
@@ -1,2 +1,22 @@
1
+ /**
2
+ * Halts the current thread to invoke an event loop.
3
+ *
4
+ * @param ms -
5
+ * The total number of milliseconds to sleep.
6
+ *
7
+ * @returns
8
+ * A promise that resolves after ms milliseconds.
9
+ */
1
10
  export declare function sleep(ms?: number): Promise<void>;
11
+ /**
12
+ * Halts the current thread to invoke an event loop.
13
+ *
14
+ * @param ms -
15
+ * The total number of milliseconds to sleep.
16
+ * @param val -
17
+ * The value to resolve with.
18
+ *
19
+ * @returns
20
+ * A promise that resolves after ms milliseconds.
21
+ */
2
22
  export declare function sleep<T>(ms: number, val: T): Promise<T>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zthun/helpful-fn",
3
- "version": "0.20.0",
3
+ "version": "0.21.0",
4
4
  "description": "Helpful, isolated pure functions that are not found in other libraries such as lodash.",
5
5
  "author": "Anthony Bonta",
6
6
  "license": "MIT",
@@ -28,5 +28,5 @@
28
28
  "dist"
29
29
  ],
30
30
  "sideEffects": false,
31
- "gitHead": "feb47a92ad66ed6865461f9d95677ef096fd20b8"
31
+ "gitHead": "ee5bff46d3b9574b6b9c3fafd42127356eb95930"
32
32
  }