local g=require((game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")):WaitForChild("\078\101\118\101\114\109\111\114\101"))local C=g("\080\114\111\109\105\115\101")return function(g,Q,D)local q=g:FindFirstChild(Q)if q then return C.resolved(q)end return C.new(function(C,q)spawn(function()local S=g:WaitForChild(Q,D)if S then C(S)else q("\084\105\109\101\100 \111\117\116")end end)end)end
--- Warps the WaitForChild API with a promise
-- @module promiseChild

local require = require(game:GetService("ReplicatedStorage"):WaitForChild("Nevermore"))

local Promise = require("Promise")

--- Wraps the :WaitForChild API with a promise
return function(parent, name, timeOut)
	local result = parent:FindFirstChild(name)
	if result then
		return Promise.resolved(result)
	end

	return Promise.new(function(resolve, reject)
		-- Cheaper to do spawn() here than fastSpawn, and we aren't going to get the
		-- resource for another tick anyway
		spawn(function()
			local child = parent:WaitForChild(name, timeOut)

			if child then
				resolve(child)
			else
				reject("Timed out")
			end
		end)
	end)
end