UNPKG

simulacra

Version:

Data-binding function for the DOM.

40 lines (30 loc) 964 B
'use strict' module.exports = featureCheck /** * Check if capabilities are available, or throw an error. * * @param {*} globalScope */ function featureCheck (globalScope, features) { var i, j, k, l, feature, path for (i = 0, j = features.length; i < j; i++) { path = features[i] if (typeof path[0] === 'string') { feature = globalScope for (k = 0, l = path.length; k < l; k++) { if (!(path[k] in feature)) throw new Error('Missing ' + path.slice(0, k + 1).join('.') + ' feature which is required.') feature = feature[path[k]] } } else { feature = path[0] for (k = 1, l = path.length; k < l; k++) { if (k > 1) feature = feature[path[k]] if (typeof feature === 'undefined') throw new Error('Missing ' + path[0].name + path.slice(1, k + 1).join('.') + ' feature which is required.') } } } }