UNPKG

function-tree

Version:
38 lines 1.2 kB
import Provider from '../Provider'; import { ResolveValue } from '../ResolveValue'; import { Tag } from '../Tag'; export default new Provider({ isTag: function isTag(arg) { if (!(arg instanceof Tag)) { return false; } for (var _len = arguments.length, types = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { types[_key - 1] = arguments[_key]; } if (types.length) { return types.reduce(function (isType, type) { return isType || type === arg.type; }, false); } return true; }, isResolveValue: function isResolveValue(arg) { return arg instanceof ResolveValue; }, value: function value(arg) { var overrides = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; if (arg instanceof ResolveValue) { return arg.getValue(overrides ? Object.assign({}, this.context, overrides) : this.context); } return arg; }, path: function path(arg) { if (arg instanceof Tag) { return arg.getPath(this.context); } throw new Error('You are extracting a path from an argument that is not a Tag.'); } }, { wrap: false }); //# sourceMappingURL=Resolve.js.map