@vocollege/app 0.0.157 → 0.0.158

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.
@@ -34,7 +34,7 @@ export declare const wrapPromise: (promise: any) => {
34
34
  };
35
35
  export declare const downloadFile: (url: string) => void;
36
36
  export declare const orderByPosition: (a: any, b: any) => 1 | -1 | 0;
37
- export declare const orderByField: (a: any, b: any, field: string) => 1 | -1 | 0;
37
+ export declare const orderByField: (a: any, b: any, field: string, descending?: boolean) => 1 | -1 | 0;
38
38
  export declare const shortenText: (str: string, limit?: number, stripHtml?: boolean, addEllipsis?: boolean) => string;
39
39
  export declare const getImageContact: (item: any, width?: number, height?: number) => string;
40
40
  export declare const getImage: (item: any, width: number, height: number, field?: string) => string;
@@ -238,12 +238,13 @@ var orderByPosition = function (a, b) {
238
238
  return 0;
239
239
  };
240
240
  exports.orderByPosition = orderByPosition;
241
- var orderByField = function (a, b, field) {
241
+ var orderByField = function (a, b, field, descending) {
242
+ if (descending === void 0) { descending = false; }
242
243
  if (a[field] < b[field]) {
243
- return -1;
244
+ return descending ? 1 : -1;
244
245
  }
245
246
  if (a[field] > b[field]) {
246
- return 1;
247
+ return descending ? -1 : 1;
247
248
  }
248
249
  return 0;
249
250
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vocollege/app",
3
- "version": "0.0.157",
3
+ "version": "0.0.158",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -194,12 +194,17 @@ export const orderByPosition = (a: any, b: any) => {
194
194
  return 0;
195
195
  };
196
196
 
197
- export const orderByField = (a: any, b: any, field: string) => {
197
+ export const orderByField = (
198
+ a: any,
199
+ b: any,
200
+ field: string,
201
+ descending = false
202
+ ) => {
198
203
  if (a[field] < b[field]) {
199
- return -1;
204
+ return descending ? 1 : -1;
200
205
  }
201
206
  if (a[field] > b[field]) {
202
- return 1;
207
+ return descending ? -1 : 1;
203
208
  }
204
209
  return 0;
205
210
  };
@@ -286,7 +291,7 @@ export const parseState = (state: any, initialState: any) => {
286
291
  export const changeObj = (obj: any, key: string, value: any): {} => {
287
292
  let keys = key.split(".");
288
293
  return keys.reduce((acc, v, i) => {
289
- if (i == keys.length -1) acc[v] = value;
294
+ if (i == keys.length - 1) acc[v] = value;
290
295
  return acc[v];
291
296
  }, obj);
292
297
  };