(array: Object)
| 19 | const PRIMITIVE_ARRAY = 2; // Primitive values only |
| 20 | const ENTRIES_ARRAY = 3; // Tuple arrays of string and value (like Headers, Map, etc) |
| 21 | function getArrayKind(array: Object): 0 | 1 | 2 | 3 { |
| 22 | let kind: 0 | 1 | 2 | 3 = EMPTY_ARRAY; |
| 23 | for (let i = 0; i < array.length; i++) { |
| 24 | const value = array[i]; |
| 25 | if (typeof value === 'object' && value !== null) { |
| 26 | if ( |
| 27 | isArray(value) && |
| 28 | value.length === 2 && |
| 29 | typeof value[0] === 'string' |
| 30 | ) { |
| 31 | // Key value tuple |
| 32 | if (kind !== EMPTY_ARRAY && kind !== ENTRIES_ARRAY) { |
| 33 | return COMPLEX_ARRAY; |
| 34 | } |
| 35 | kind = ENTRIES_ARRAY; |
| 36 | } else { |
| 37 | return COMPLEX_ARRAY; |
| 38 | } |
| 39 | } else if (typeof value === 'function') { |
| 40 | return COMPLEX_ARRAY; |
| 41 | } else if (typeof value === 'string' && value.length > 50) { |
| 42 | return COMPLEX_ARRAY; |
| 43 | } else if (kind !== EMPTY_ARRAY && kind !== PRIMITIVE_ARRAY) { |
| 44 | return COMPLEX_ARRAY; |
| 45 | } else { |
| 46 | kind = PRIMITIVE_ARRAY; |
| 47 | } |
| 48 | } |
| 49 | return kind; |
| 50 | } |
| 51 | |
| 52 | export function addObjectToProperties( |
| 53 | object: Object, |
no test coverage detected