UNPKG

@apollo/core-schema

Version:
27 lines 1.05 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.scopeNameFor = exports.toPrefixed = exports.getPrefix = void 0; function getPrefix(name, sep = '__') { const idx = name.indexOf(sep); if (idx === -1) return [null, name]; return [name.substr(0, idx), name.substr(idx + sep.length)]; } exports.getPrefix = getPrefix; function toPrefixed(path) { if (path[0] == null) return unAt(path[1]); return path[0] + '__' + unAt(path[1]); } exports.toPrefixed = toPrefixed; const AT = '@'.charCodeAt(0); const unAt = (val) => val.charCodeAt(0) === AT ? val.slice(1) : val; function scopeNameFor(node, name) { var _a; if (name === void 0) { name = (_a = node.name) === null || _a === void 0 ? void 0 : _a.value; } if (node.kind === 'Directive' || node.kind === 'DirectiveDefinition') return '@' + (name !== null && name !== void 0 ? name : ''); return name !== null && name !== void 0 ? name : ''; } exports.scopeNameFor = scopeNameFor; //# sourceMappingURL=names.js.map