MCPcopy Create free account
hub / github.com/codecombat/codecombat / getByPath

Function getByPath

app/core/utils.js:691–700  ·  view source on GitHub ↗
(target, path)

Source from the content-addressed store, hash-verified

689}
690
691const getByPath = function (target, path) {
692 if (!target) { throw new Error('Expected an object to match a query against, instead got null') }
693 const pieces = path.split('.')
694 let obj = target
695 for (const piece of Array.from(pieces)) {
696 if (!(piece in obj)) { return undefined }
697 obj = obj[piece]
698 }
699 return obj
700}
701
702const isID = id => _.isString(id) && (id.length === 24) && (__guard__(id.match(/[a-f0-9]/gi), x1 => x1.length) === 24)
703

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected