Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ckirby/opera-info

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ckirby/opera-info - npm Package Compare versions

Comparing version 1.3.3 to 1.3.4

1

dist/anonymizer.d.ts
import type { OperaData, TargetOpera } from "./types.js";
export declare function anonymize(hint: string, opera: Partial<TargetOpera> & OperaData): Promise<string>;
export declare function anonymizeComposer(composer: string, target: string): string;
export declare function makeTitlePattern(titles: string[], flags?: string): RegExp;
export declare function anonymizeTitle(titles: string[], target: string, replacement?: string): string;
export declare function capitalize(source: string, target: string): string;

8

dist/anonymizer.js

@@ -36,3 +36,3 @@ import re from "@ckirby/block-re";

}
export function anonymizeTitle(titles, target, replacement = "this opera") {
export function makeTitlePattern(titles, flags = "g") {
const patterns = titles.map((title) => {

@@ -42,4 +42,6 @@ const [first, ...rest] = title.split(/,\s+/);

});
const composerPattern = RegExp(patterns.join("|"), "g");
target = target.replace(composerPattern, replacement);
return RegExp(patterns.join("|"), flags);
}
export function anonymizeTitle(titles, target, replacement = "this opera") {
target = target.replace(makeTitlePattern(titles), replacement);
target = target.replace(re `/(?<=\b${replacement})'s?(?!\w)/`, "'s");

@@ -46,0 +48,0 @@ target = target.replace(re `/(?:an?|the)\sopera\s(?=${replacement})/`, "");

import sbd from "sbd";
import { listString } from "@ckirby/mr-lister";
import { anonymize, anonymizeComposer } from "./anonymizer.js";
import { anonymize, anonymizeComposer, makeTitlePattern, } from "./anonymizer.js";
export async function makeHints(opera) {

@@ -45,7 +45,12 @@ const composerHints = await makeComposerHints(opera);

}
const extract = await anonymize(getText(div), opera);
const sentences = sbd.sentences(capitalize(extract, "the composer"), {
const titlePattern = makeTitlePattern(opera.titles);
const titleAmongCaps = new RegExp(`[A-Z]\\w+ ${titlePattern.source}|${titlePattern.source} [A-Z]\\w+`);
const sentences = sbd
.sentences(getText(div), {
newline_boundaries: true,
});
return sentences
})
.filter((s) => !titleAmongCaps.test(s));
const hints = await Promise.all(sentences.map((s) => anonymize(s, opera)));
return hints
.map((s) => s.replace(/^the\b/, "The"))
.map((s) => s.replace(/^He\b/, "The composer"))

@@ -60,7 +65,13 @@ .map((s) => s.replace(/^His\b/, "The composer's"));

}
const extract = (await anonymize(getText(div), opera)).replace(/, sometimes called this opera,/g, "");
const sentences = sbd.sentences(capitalize(extract, "this opera"), {
const titlePattern = makeTitlePattern(opera.titles);
const titleAmongCaps = new RegExp(`[A-Z]\\w+ ${titlePattern.source}|${titlePattern.source} [A-Z]\\w+`);
const sentences = sbd
.sentences(getText(div), {
newline_boundaries: true,
});
return sentences;
})
.filter((s) => !titleAmongCaps.test(s));
const hints = await Promise.all(sentences.map((s) => anonymize(s, opera)));
return hints
.map((s) => s.replace(/^this\b/, "This"))
.map((s) => s.replace(/, sometimes called this opera,/g, ""));
}

@@ -67,0 +78,0 @@ function getText(el) {

{
"name": "@ckirby/opera-info",
"version": "1.3.3",
"version": "1.3.4",
"description": "information about operas",

@@ -5,0 +5,0 @@ "type": "module",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc