* Normalize an object to match a struct. * * @param {String, Object} oid - The oid string or instance. * @return {Object} An Oid instance.
(options, Ctor)
| 7 | * @return {Object} An Oid instance. |
| 8 | */ |
| 9 | function normalizeOptions(options, Ctor) { |
| 10 | if (!options) { |
| 11 | return null; |
| 12 | } |
| 13 | |
| 14 | if (options instanceof Ctor) { |
| 15 | return options; |
| 16 | } |
| 17 | |
| 18 | var instance = new Ctor(); |
| 19 | |
| 20 | Object.keys(options).forEach(function(key) { |
| 21 | if (typeof options[key] !== "undefined") { |
| 22 | instance[key] = options[key]; |
| 23 | } |
| 24 | }); |
| 25 | |
| 26 | return instance; |
| 27 | } |
| 28 | |
| 29 | NodeGit.Utils.normalizeOptions = normalizeOptions; |
no outgoing calls
no test coverage detected
searching dependent graphs…