Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public handleMoniker(moniker: Moniker): void {
if (moniker.kind !== MonikerKind.import || moniker.scheme !== TscMoniker.scheme) {
return;
}
this.ensureIdGenerator(moniker.id);
emit(moniker);
const tscMoniker = TscMoniker.parse(moniker.identifier);
if (!TscMoniker.hasPath(tscMoniker)) {
return;
}
let parts = tscMoniker.path.split('/');
let packagePath: string | undefined;
let monikerPath: string | undefined;
for (let i = parts.length - 1; i >= 0; i--) {
let part = parts[i];
if (part === 'node_modules') {
// End is exclusive and one for the name
const packageIndex = i + (parts[i + 1].startsWith('@') ? 3 : 2);
export function compare(m1: MonikerData, m2: MonikerData): number {
let result = Strings.compare(m1.identifier, m2.identifier);
if (result !== 0) {
return result;
}
result = Strings.compare(m1.scheme, m2.scheme);
if (result !== 0) {
return result;
}
if (m1.kind === m2.kind) {
return 0;
}
const k1 = m1.kind !== undefined ? m1.kind : MonikerKind.import;
const k2 = m2.kind !== undefined ? m2.kind : MonikerKind.import;
if (k1 === MonikerKind.import && k2 === MonikerKind.export) {
return -1;
}
if (k1 === MonikerKind.export && k2 === MonikerKind.import) {
return 1;
}
return 0;
}
export function compare(m1: MonikerData, m2: MonikerData): number {
let result = Strings.compare(m1.identifier, m2.identifier);
if (result !== 0) {
return result;
}
result = Strings.compare(m1.scheme, m2.scheme);
if (result !== 0) {
return result;
}
if (m1.kind === m2.kind) {
return 0;
}
const k1 = m1.kind !== undefined ? m1.kind : MonikerKind.import;
const k2 = m2.kind !== undefined ? m2.kind : MonikerKind.import;
if (k1 === MonikerKind.import && k2 === MonikerKind.export) {
return -1;
}
if (k1 === MonikerKind.export && k2 === MonikerKind.import) {
return 1;
}
return 0;
}
export function compare(m1: MonikerData, m2: MonikerData): number {
let result = Strings.compare(m1.identifier, m2.identifier);
if (result !== 0) {
return result;
}
result = Strings.compare(m1.scheme, m2.scheme);
if (result !== 0) {
return result;
}
if (m1.kind === m2.kind) {
return 0;
}
const k1 = m1.kind !== undefined ? m1.kind : MonikerKind.import;
const k2 = m2.kind !== undefined ? m2.kind : MonikerKind.import;
if (k1 === MonikerKind.import && k2 === MonikerKind.export) {
return -1;
}
if (k1 === MonikerKind.export && k2 === MonikerKind.import) {
return 1;
}
return 0;
}
if (result !== 0) {
return result;
}
result = Strings.compare(m1.scheme, m2.scheme);
if (result !== 0) {
return result;
}
if (m1.kind === m2.kind) {
return 0;
}
const k1 = m1.kind !== undefined ? m1.kind : MonikerKind.import;
const k2 = m2.kind !== undefined ? m2.kind : MonikerKind.import;
if (k1 === MonikerKind.import && k2 === MonikerKind.export) {
return -1;
}
if (k1 === MonikerKind.export && k2 === MonikerKind.import) {
return 1;
}
return 0;
}