(text, element)
| 535 | } |
| 536 | |
| 537 | export function getTextWidth(text, element) { |
| 538 | // re-use canvas object for better performance |
| 539 | const canvas = getTextWidth.canvas || (getTextWidth.canvas = document.createElement('canvas')); |
| 540 | |
| 541 | const context = canvas.getContext('2d'); |
| 542 | context.font = window.getComputedStyle(element, null).getPropertyValue('font'); |
| 543 | const metrics = context.measureText(text); |
| 544 | return metrics.width; |
| 545 | } |
| 546 | |
| 547 | export function toMap(elements, keyExtractor, valueExtractor) { |
| 548 | return elements.reduce( |
nothing calls this directly
no outgoing calls
no test coverage detected