MCPcopy
hub / github.com/tailwindlabs/tailwindcss / get

Function get

packages/tailwindcss/src/compat/plugin-functions.ts:222–242  ·  view source on GitHub ↗
(obj: any, path: string[])

Source from the content-addressed store, hash-verified

220}
221
222function get(obj: any, path: string[]) {
223 for (let i = 0; i < path.length; ++i) {
224 let key = path[i]
225
226 // The key does not exist so concatenate it with the next key.
227 // We use Object.hasOwn to avoid matching inherited prototype properties
228 // (e.g. "constructor", "toString") when traversing config objects.
229 if (obj === null || obj === undefined || typeof obj !== 'object' || !Object.hasOwn(obj, key)) {
230 if (path[i + 1] === undefined) {
231 return undefined
232 }
233
234 path[i + 1] = `${key}-${path[i + 1]}`
235 continue
236 }
237
238 obj = obj[key]
239 }
240
241 return obj
242}
243
244function set(obj: any, path: string[], value: any) {
245 for (let key of path.slice(0, -1)) {

Callers 1

createThemeFnFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected