MCPcopy Index your code
hub / github.com/nodegit/nodegit / lookupWrapper

Function lookupWrapper

lib/utils/lookup_wrapper.js:11–37  ·  view source on GitHub ↗

* Wraps a method so that you can pass in either a string, OID or the object * itself and you will always get back a promise that resolves to the object. * @param {Object} objectType The object type that you're expecting to receive. * @param {Function} lookupFunction The function to do the lookup fo

(objectType, lookupFunction)

Source from the content-addressed store, hash-verified

9* @return {Function}
10*/
11function lookupWrapper(objectType, lookupFunction) {
12 lookupFunction = lookupFunction || objectType.lookup;
13
14 return function(repo, id, callback) {
15 if (id instanceof objectType) {
16 return Promise.resolve(id).then(function(obj) {
17 obj.repo = repo;
18
19 if (typeof callback === "function") {
20 callback(null, obj);
21 }
22
23 return obj;
24 }, callback);
25 }
26
27 return lookupFunction(repo, id).then(function(obj) {
28 obj.repo = repo;
29
30 if (typeof callback === "function") {
31 callback(null, obj);
32 }
33
34 return obj;
35 }, callback);
36 };
37}
38
39NodeGit.Utils.lookupWrapper = lookupWrapper;

Callers 1

remote.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…