($, key)
| 2 | const PRIMER_DATA_QUERY = 'script#__PRIMER_DATA__' |
| 3 | |
| 4 | function getScriptData($, key) { |
| 5 | const data = $(key) |
| 6 | if (!data.length === 1) { |
| 7 | throw new Error(`Not exactly 1 element match for '${key}'. Found ${data.length}`) |
| 8 | } |
| 9 | return JSON.parse(data.get()[0].children[0].data) |
| 10 | } |
| 11 | |
| 12 | export const getNextData = ($) => getScriptData($, NEXT_DATA_QUERY) |
| 13 | export const getPrimerData = ($) => getScriptData($, PRIMER_DATA_QUERY) |
no outgoing calls
no test coverage detected