* Generate a key string that identifies a element within a set. * * @param {*} element A element that could contain a manual key. * @param {number} index Index that is used if a manual key is not provided. * @return {string}
(element: any, index: number)
| 70 | * @return {string} |
| 71 | */ |
| 72 | function getElementKey(element: any, index: number): string { |
| 73 | // Do some typechecking here since we call this blindly. We want to ensure |
| 74 | // that we don't block potential future ES APIs. |
| 75 | if (typeof element === 'object' && element !== null && element.key != null) { |
| 76 | // Explicit key |
| 77 | if (__DEV__) { |
| 78 | checkKeyStringCoercion(element.key); |
| 79 | } |
| 80 | return escape('' + element.key); |
| 81 | } |
| 82 | // Implicit key determined by the index in the set |
| 83 | return index.toString(36); |
| 84 | } |
| 85 | |
| 86 | function resolveThenable<T>(thenable: Thenable<T>): T { |
| 87 | switch (thenable.status) { |
no test coverage detected