MCPcopy Index your code
hub / github.com/github/docs / getScriptData

Function getScriptData

tests/helpers/script-data.js:4–10  ·  view source on GitHub ↗
($, key)

Source from the content-addressed store, hash-verified

2const PRIMER_DATA_QUERY = 'script#__PRIMER_DATA__'
3
4function 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
12export const getNextData = ($) => getScriptData($, NEXT_DATA_QUERY)
13export const getPrimerData = ($) => getScriptData($, PRIMER_DATA_QUERY)

Callers 2

getNextDataFunction · 0.85
getPrimerDataFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected