@contrail/util 1.0.51 → 1.0.53

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.
@@ -11,6 +11,16 @@ interface CacheOptions {
11
11
  cacheName: string;
12
12
  }
13
13
  export declare function getAllWithCaching<T>(getAllFunc: () => Promise<T[]>, options: CacheOptions): Promise<T[]>;
14
+ declare type DyanmoQuery = {
15
+ TableName: string;
16
+ ExpressionAttributeValues: {
17
+ [key: string]: any;
18
+ };
19
+ FilterExpression: string;
20
+ };
21
+ export declare function scanDynamo(query: DyanmoQuery): AsyncGenerator<{
22
+ [key: string]: any;
23
+ }[]>;
14
24
  export declare function pushData<T>(data: DynamoDBItem<T>[], tableName: string): Promise<void>;
15
25
  export declare function flattenDynamoItem<T>(item: DynamoDBItem<T>): FlatDynamoItem<T>;
16
26
  export {};
@@ -44,7 +44,7 @@ var __rest = (this && this.__rest) || function (s, e) {
44
44
  return t;
45
45
  };
46
46
  Object.defineProperty(exports, "__esModule", { value: true });
47
- exports.flattenDynamoItem = exports.pushData = exports.getAllWithCaching = exports.getAll = void 0;
47
+ exports.flattenDynamoItem = exports.pushData = exports.scanDynamo = exports.getAllWithCaching = exports.getAll = void 0;
48
48
  const aws = require('aws-sdk');
49
49
  const ddt = require('dynamodb-data-types');
50
50
  const fs_1 = require("fs");
@@ -146,6 +146,7 @@ function scanDynamo(query) {
146
146
  } while (lastEvaluatedKey);
147
147
  });
148
148
  }
149
+ exports.scanDynamo = scanDynamo;
149
150
  function pushData(data, tableName) {
150
151
  return __awaiter(this, void 0, void 0, function* () {
151
152
  const ddb = new aws.DynamoDB({ apiVersion: '2012-08-10', region: 'us-east-1' });
@@ -7,6 +7,7 @@ export { ObjectDiff } from './compareDeep/compareDeep';
7
7
  export declare class ObjectUtil {
8
8
  static getByPath(obj: any, path: string, def?: any): any;
9
9
  static setByPath(obj: any, path: string, value: any): void;
10
+ static chunk(array: any[], size: number): any[];
10
11
  static isObject: typeof isObject;
11
12
  static mergeDeep: typeof mergeDeep;
12
13
  static cloneDeep: typeof cloneDeep;
@@ -30,6 +30,13 @@ class ObjectUtil {
30
30
  }
31
31
  o[a[0]] = value;
32
32
  }
33
+ static chunk(array, size) {
34
+ const chunked = [];
35
+ for (let i = 0; i < array.length; i = i + size) {
36
+ chunked.push(array.slice(i, i + size));
37
+ }
38
+ return chunked;
39
+ }
33
40
  }
34
41
  exports.ObjectUtil = ObjectUtil;
35
42
  ObjectUtil.isObject = isObject_1.isObject;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/util",
3
- "version": "1.0.51",
3
+ "version": "1.0.53",
4
4
  "description": "General javascript utilities",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",