File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,14 +8,14 @@ export type RawAttribute<T> = T extends { value: any } | { unit: any } ? Attribu
88
99export type Attributes = Record < string , TypedAttributeValue > ;
1010
11- export type AttributeValueType = string | number | boolean | Array < unknown > ;
11+ export type AttributeValueType = string | number | boolean | Array < string > | Array < number > | Array < boolean > ;
1212
1313type AttributeTypeMap = {
1414 string : string ;
1515 integer : number ;
1616 double : number ;
1717 boolean : boolean ;
18- array : Array < unknown > ;
18+ array : Array < string > | Array < number > | Array < boolean > ;
1919} ;
2020
2121/* Generates a type from the AttributeTypeMap like:
@@ -143,14 +143,10 @@ export function estimateTypedAttributesSizeInBytes(attributes: Attributes | unde
143143 weight += ( attr . unit ?. length ?? 0 ) * 2 ;
144144 const val = attr . value ;
145145
146- if ( Array . isArray ( val ) && isPrimitive ( val [ 0 ] ) ) {
146+ if ( Array . isArray ( val ) ) {
147147 // Assumption: Individual array items have the same type and roughly the same size
148148 // probably not always true but allows us to cut down on runtime
149149 weight += estimatePrimitiveSizeInBytes ( val [ 0 ] ) * val . length ;
150- } else if ( Array . isArray ( val ) && ! isPrimitive ( val [ 0 ] ) ) {
151- // Fallback for arrays with non-primitive values (e.g. objects)
152- // Again (to cut down on runtime), we intentionally don't traverse the full hierarchy
153- weight += fallbackWeight * val . length ;
154150 } else if ( isPrimitive ( val ) ) {
155151 weight += estimatePrimitiveSizeInBytes ( val ) ;
156152 } else {
You can’t perform that action at this time.
0 commit comments