diffusion
Version:
Diffusion JavaScript client
61 lines (60 loc) • 1.6 kB
JavaScript
;
/**
* @module Topics
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.DescendantQualifier = exports.DQ = exports.canonicalise = exports.split = exports.PATH_SEPARATOR = void 0;
/**
* The topic path separator character.
*/
exports.PATH_SEPARATOR = '/';
/**
* Split a path into parts.
*
* @param path the path
* @return the parts
*/
function split(path) {
return path.split(exports.PATH_SEPARATOR);
}
exports.split = split;
/**
* Provide a canonical representation of a given path, stripping leading and
* trailing path separators
*
* @param path the path
* @returns the canonicalised path
*/
function canonicalise(path) {
if (!path) {
return '';
}
var l = path.length;
var s = l > 0 && path.charAt(0) === exports.PATH_SEPARATOR ? 1 : 0;
var e = l > 1 && path.charAt(l - 1) === exports.PATH_SEPARATOR ? 1 : 0;
return path.substring(s, l - e);
}
exports.canonicalise = canonicalise;
/**
* Minimal representation of DescendantQualifier enum type.
*/
var DQ = /** @class */ (function () {
/**
* Create a DQ instance
*
* @param descendants the match includes descendants
*/
function DQ(descendants) {
this.includesDescendants = descendants;
}
return DQ;
}());
exports.DQ = DQ;
/**
* An enum like object containing descendant qualifiers
*/ // eslint-disable-next-line @typescript-eslint/naming-convention
exports.DescendantQualifier = Object.freeze({
MATCH: new DQ(false),
DESCENDANTS_OF_MATCH: new DQ(true),
MATCH_AND_DESCENDANTS: new DQ(true)
});