@alanszp/core 9.0.0 → 10.0.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.
@@ -6,3 +6,9 @@ export declare function getPageObject<T extends Paginable<true>>(object: T): {
6
6
  skip: number;
7
7
  take: number;
8
8
  };
9
+ /**
10
+ * Assigns the page and pageSize keys to the target object
11
+ * @param target Paginable Input
12
+ * @param source Paginable Source
13
+ */
14
+ export declare function assignPaginableKeys<T extends Paginable<false>, K extends Partial<Paginable<false>>>(target: T, source: K): void;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getPageObject = void 0;
3
+ exports.assignPaginableKeys = exports.getPageObject = void 0;
4
4
  function getPageObject(object) {
5
5
  return {
6
6
  skip: (object.page - 1) * object.pageSize,
@@ -8,4 +8,15 @@ function getPageObject(object) {
8
8
  };
9
9
  }
10
10
  exports.getPageObject = getPageObject;
11
+ /**
12
+ * Assigns the page and pageSize keys to the target object
13
+ * @param target Paginable Input
14
+ * @param source Paginable Source
15
+ */
16
+ function assignPaginableKeys(target, source) {
17
+ // Mind the || operator, it's on purpose to avoid the 0 value (cause falsy value)
18
+ target.page = Number.parseInt(source.page, 10) || 1;
19
+ target.pageSize = Number.parseInt(source.pageSize, 10) || 100;
20
+ }
21
+ exports.assignPaginableKeys = assignPaginableKeys;
11
22
  //# sourceMappingURL=Paginable.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Paginable.js","sourceRoot":"","sources":["../../src/lists/Paginable.ts"],"names":[],"mappings":";;;AAKA,SAAgB,aAAa,CAA4B,MAAS;IAChE,OAAO;QACL,IAAI,EAAE,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,QAAQ;QACzC,IAAI,EAAE,MAAM,CAAC,QAAQ;KACtB,CAAC;AACJ,CAAC;AALD,sCAKC"}
1
+ {"version":3,"file":"Paginable.js","sourceRoot":"","sources":["../../src/lists/Paginable.ts"],"names":[],"mappings":";;;AAKA,SAAgB,aAAa,CAA4B,MAAS;IAChE,OAAO;QACL,IAAI,EAAE,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,QAAQ;QACzC,IAAI,EAAE,MAAM,CAAC,QAAQ;KACtB,CAAC;AACJ,CAAC;AALD,sCAKC;AAED;;;;GAIG;AACH,SAAgB,mBAAmB,CAGjC,MAAS,EAAE,MAAS;IACpB,iFAAiF;IACjF,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAc,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;IAC9D,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAkB,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC;AAC1E,CAAC;AAPD,kDAOC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alanszp/core",
3
- "version": "9.0.0",
3
+ "version": "10.0.0",
4
4
  "description": "Alan's core TS/JS lib.",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -18,5 +18,5 @@
18
18
  "prepack": "yarn run build",
19
19
  "yalc-publish": "yarn run yalc publish"
20
20
  },
21
- "gitHead": "8af112076306ffc2fe14b6056aad1f26908a9394"
21
+ "gitHead": "e06d4fec832847519814bcf472fdc9fff9ef0829"
22
22
  }
@@ -9,3 +9,17 @@ export function getPageObject<T extends Paginable<true>>(object: T) {
9
9
  take: object.pageSize,
10
10
  };
11
11
  }
12
+
13
+ /**
14
+ * Assigns the page and pageSize keys to the target object
15
+ * @param target Paginable Input
16
+ * @param source Paginable Source
17
+ */
18
+ export function assignPaginableKeys<
19
+ T extends Paginable<false>,
20
+ K extends Partial<Paginable<false>>
21
+ >(target: T, source: K): void {
22
+ // Mind the || operator, it's on purpose to avoid the 0 value (cause falsy value)
23
+ target.page = Number.parseInt(source.page as string, 10) || 1;
24
+ target.pageSize = Number.parseInt(source.pageSize as string, 10) || 100;
25
+ }