ddbitemsizer
Version:
Get the byte size of your DynamoDB input.
54 lines (53 loc) • 1.4 kB
TypeScript
export declare class DynamoDbItemSizer {
/**
* @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html#HowItWorks.DataTypeDescriptors
*/
ddbDataTypeKeys: string[];
/**
* @description Gets the approximate byte size for a DynamoDB input.
* @example
* ```
* import { DynamoDbItemSizer } from 'ddbitemsizer';
*
* const itemSizer = new DynamoDbItemSizer();
*
* itemSize.get({
* key: {
* S: 'Hello World'
* }
* });
*```
*/
get(object: Record<string, any>): number;
private bytesForValue;
/**
* @description Check if this a nested, DynamoDB-style object with a data-typed key.
*/
private getStructure;
private isValueAnObject;
private isKeyReserved;
/**
* @description Get a cleaned type for the input key.
*/
private getType;
private isString;
private isNumber;
private isBinary;
private isBoolean;
private isNull;
private isSet;
/**
* @description Get the size of the input.
*/
private getSize;
private stringSize;
private numberSize;
private removeTrailingZeroes;
private binarySize;
private booleanOrNullSize;
private stringSetSize;
private numberSetSize;
private binarySetSize;
private listSetSize;
private mapSize;
}