zavadil-ts-common 1.0.2 → 1.0.4

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.
@@ -0,0 +1,6 @@
1
+ export declare class Lazy<T> {
2
+ private cache?;
3
+ private supplier;
4
+ constructor(supplier: () => T);
5
+ get(): T;
6
+ }
package/dist/index.d.ts CHANGED
@@ -7,7 +7,7 @@ type PagingRequest = {
7
7
  page: number;
8
8
  size: number;
9
9
  search?: string | null;
10
- sorting: SortingRequest;
10
+ sorting?: SortingRequest | null;
11
11
  };
12
12
  type Page<Type> = {
13
13
  totalItems: number;
@@ -7,7 +7,7 @@ export type PagingRequest = {
7
7
  page: number;
8
8
  size: number;
9
9
  search?: string | null;
10
- sorting: SortingRequest;
10
+ sorting?: SortingRequest | null;
11
11
  };
12
12
  export type Page<Type> = {
13
13
  totalItems: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zavadil-ts-common",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Common types and components for Typescript UI apps.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",
@@ -0,0 +1,17 @@
1
+ export class Lazy<T> {
2
+
3
+ private cache?: T;
4
+
5
+ private supplier: () => T;
6
+
7
+ constructor(supplier: () => T) {
8
+ this.supplier = supplier;
9
+ }
10
+
11
+ get(): T {
12
+ if (this.cache === undefined) {
13
+ this.cache = this.supplier();
14
+ }
15
+ return this.cache;
16
+ }
17
+ }
@@ -9,7 +9,7 @@ export type PagingRequest = {
9
9
  page: number;
10
10
  size: number;
11
11
  search?: string | null;
12
- sorting: SortingRequest;
12
+ sorting?: SortingRequest | null;
13
13
  };
14
14
 
15
15
  export type Page<Type> = {