Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const code = codeFromLibrary(library);
const key = `${code}:${deprecatedAPI}:${replacement}`;
if (!postedWarnings[key]) {
postedWarnings[key] = true;
}
if (!currentVersion ||
!versionToRemove ||
compareVersions(currentVersion, versionToRemove) >= 0) {
let message = `\`${deprecatedAPI}\` has been removed`;
if (versionToRemove) {
message = `${message} as of version "${versionToRemove}"`;
}
if (replacement && replacement.length) {
message = `${message} please migrate to: \`${replacement}\``;
}
throw new CodedError(`ERR_DEPRECATED_API`, prependLibrary(library, message));
}
let message = `\`${deprecatedAPI}\` has been deprecated`;
if (replacement && replacement.length) {
message = `${message} in favor of \`${replacement}\``;
}
if (versionToRemove && versionToRemove.length) {
message = `${message} and will be removed in version "${versionToRemove}"`;
}
console.warn(prependLibrary(library, message));
}
function prependLibrary(library, message) {
}
if (
!currentVersion ||
!versionToRemove ||
compareVersions(currentVersion, versionToRemove) >= 0
) {
let message = `\`${deprecatedAPI}\` has been removed`;
if (versionToRemove) {
message = `${message} as of version "${versionToRemove}"`;
}
if (replacement && replacement.length) {
message = `${message} please migrate to: \`${replacement}\``;
}
throw new CodedError(`ERR_DEPRECATED_API`, prependLibrary(library, message));
}
let message = `\`${deprecatedAPI}\` has been deprecated`;
if (replacement && replacement.length) {
message = `${message} in favor of \`${replacement}\``;
}
if (versionToRemove && versionToRemove.length) {
message = `${message} and will be removed in version "${versionToRemove}"`;
}
console.warn(prependLibrary(library, message));
}