New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@future-scholars/paperlib-format-pubname-extension

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@future-scholars/paperlib-format-pubname-extension - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

2

dist/main.js

@@ -1,1 +0,1 @@

"use strict";var h=Object.defineProperty;var b=(i,t,e)=>t in i?h(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var c=(i,t)=>h(i,"name",{value:t,configurable:!0});var u=(i,t,e)=>(b(i,typeof t!="symbol"?t+"":t,e),e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=class d{constructor({id:t,defaultPreference:e}){u(this,"id");u(this,"defaultPreference");this.id=t,this.checkPreference(e),this.defaultPreference=e}checkPreference(t){if(typeof t!="object")throw new Error("Preference must be a dict");for(const e in t){if(!t[e].type||!["string","boolean","options","pathpicker"].includes(t[e].type))throw new Error(`Preference ${e} has wrong type ${t[e].type}`);if(!t[e].name)throw new Error(`Preference ${e} has no name`);if(!t[e].description)throw new Error(`Preference ${e} has no description`);if(t[e].value===void 0||t[e].value===null)throw new Error(`Preference ${e} has no default value`);if(t[e].type==="options"&&!t[e].options)throw new Error(`Preference ${e} has no options`)}}};c(d,"PLExtension");let m=d;const p=class p extends m{constructor(){super({id:"@future-scholars/paperlib-format-pubname-extension",defaultPreference:{removeYear:{type:"boolean",name:"Remove year",description:"Remove year string from publication names",value:!0,order:0},customFormat:{type:"string",name:"Custom format",description:"A json string to define your custom format for publication names. If the publication name contains the key, it will be replaced by the value.",value:"",order:1}}});u(this,"disposeCallbacks");this.disposeCallbacks=[]}async initialize(){await PLExtAPI.extensionPreferenceService.register(this.id,this.defaultPreference),this.disposeCallbacks.push(PLAPI.hookService.hookModify("afterScrapeMetadata",this.id,"modifyPubnameHook")),this.disposeCallbacks.push(PLAPI.commandService.on("format_pubnames_event",e=>{this.formatLibrary()})),this.disposeCallbacks.push(PLAPI.commandService.registerExternel({id:"format_pubnames",description:"Format the publication names of your papers.",event:"format_pubnames_event"}))}async dispose(){PLExtAPI.extensionPreferenceService.unregister(this.id),this.disposeCallbacks.forEach(e=>e())}_modifyPubname(e,n,s){for(const o of e)if(n&&(o.publication=o.publication.replace(/\b\d{4}\b/g,"")),s)for(const a in s)o.publication.includes(a)&&(o.publication=s[a]);return e}async modifyPubnameHook(e,n,s){const o=PLExtAPI.extensionPreferenceService.get(this.id,"removeYear"),a=PLExtAPI.extensionPreferenceService.get(this.id,"customFormat");let r;if(a)try{r=JSON.parse(a)}catch(l){PLAPI.logService.error("Error parsing custom format",l,!0,"FormatPubnameExt")}return[this._modifyPubname(e,o,r),n,s]}async formatLibrary(){const e=await PLAPI.paperService.load("","addTime","desc"),n=PLExtAPI.extensionPreferenceService.get(this.id,"removeYear"),s=PLExtAPI.extensionPreferenceService.get(this.id,"customFormat");let o;if(s)try{o=JSON.parse(s)}catch(r){PLAPI.logService.error("Error parsing custom format",r,!0,"FormatPubnameExt")}const a=[];for(const r of e){const l=r.publication,[P]=this._modifyPubname([r],n,o);P.publication!==l&&a.push(P)}for(let r=0;r<a.length;r+=10)await PLAPI.paperService.update(a.slice(r,r+10),!1)}};c(p,"PaperlibFormatPubnameExtension");let f=p;async function y(){const i=new f;return await i.initialize(),i}c(y,"initialize");exports.initialize=y;
"use strict";var b=Object.defineProperty;var y=(a,t,e)=>t in a?b(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e;var l=(a,t)=>b(a,"name",{value:t,configurable:!0});var u=(a,t,e)=>(y(a,typeof t!="symbol"?t+"":t,e),e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=class p{constructor({id:t,defaultPreference:e}){u(this,"id");u(this,"defaultPreference");this.id=t,this.checkPreference(e),this.defaultPreference=e}checkPreference(t){if(typeof t!="object")throw new Error("Preference must be a dict");for(const e in t){if(!t[e].type||!["string","boolean","options","pathpicker"].includes(t[e].type))throw new Error(`Preference ${e} has wrong type ${t[e].type}`);if(!t[e].name)throw new Error(`Preference ${e} has no name`);if(!t[e].description)throw new Error(`Preference ${e} has no description`);if(t[e].value===void 0||t[e].value===null)throw new Error(`Preference ${e} has no default value`);if(t[e].type==="options"&&!t[e].options)throw new Error(`Preference ${e} has no options`)}}};l(p,"PLExtension");let f=p;const h=class h extends f{constructor(){super({id:"@future-scholars/paperlib-format-pubname-extension",defaultPreference:{removeYear:{type:"boolean",name:"Remove year",description:"Remove year string from publication names",value:!0,order:0},customFormat:{type:"string",name:"Custom format",description:"A json string to define your custom format for publication names. If the publication name contains the key, it will be replaced by the value.",value:"",order:1},customExactMatch:{type:"boolean",name:"Exact match",description:"If checked, the custom format will only be applied if the key is an exact match of the publication name.",value:!1,order:2}}});u(this,"disposeCallbacks");this.disposeCallbacks=[]}async initialize(){await PLExtAPI.extensionPreferenceService.register(this.id,this.defaultPreference),this.disposeCallbacks.push(PLAPI.hookService.hookModify("afterScrapeMetadata",this.id,"modifyPubnameHook")),this.disposeCallbacks.push(PLAPI.commandService.on("format_pubnames_event",e=>{this.formatLibrary()})),this.disposeCallbacks.push(PLAPI.commandService.registerExternel({id:"format_pubnames",description:"Format the publication names of your papers.",event:"format_pubnames_event"}))}async dispose(){PLExtAPI.extensionPreferenceService.unregister(this.id),this.disposeCallbacks.forEach(e=>e())}_modifyPubname(e,c,s,n=!1){for(const o of e)if(c&&(o.publication=o.publication.replace(/\s\d{4}\s/g," ").trim()),s)for(const i in s)n?o.publication===i&&(o.publication=s[i]):o.publication.toLowerCase().includes(i.toLowerCase())&&!o.publication.toLowerCase().includes("workshop")&&(o.publication=s[i]);return e}async modifyPubnameHook(e,c,s){const n=PLExtAPI.extensionPreferenceService.get(this.id,"removeYear"),o=PLExtAPI.extensionPreferenceService.get(this.id,"customFormat");let i;if(o)try{i=JSON.parse(o)}catch(m){PLAPI.logService.error("Error parsing custom format",m,!0,"FormatPubnameExt")}const r=PLExtAPI.extensionPreferenceService.get(this.id,"customExactMatch");return[this._modifyPubname(e,n,i,r),c,s]}async formatLibrary(){const e=await PLAPI.paperService.load("","addTime","desc"),c=PLExtAPI.extensionPreferenceService.get(this.id,"removeYear"),s=PLExtAPI.extensionPreferenceService.get(this.id,"customFormat");let n;if(s)try{n=JSON.parse(s)}catch(r){PLAPI.logService.error("Error parsing custom format",r,!0,"FormatPubnameExt")}const o=PLExtAPI.extensionPreferenceService.get(this.id,"customExactMatch"),i=[];for(const r of e){const m=r.publication,[P]=this._modifyPubname([r],c,n,o);P.publication!==m&&i.push(P)}for(let r=0;r<i.length;r+=10)await PLAPI.paperService.update(i.slice(r,r+10),!1)}};l(h,"PaperlibFormatPubnameExtension");let d=h;async function v(){const a=new d;return await a.initialize(),a}l(v,"initialize");exports.initialize=v;
{
"name": "@future-scholars/paperlib-format-pubname-extension",
"version": "0.0.2",
"version": "0.0.3",
"author": "Paperlib",

@@ -5,0 +5,0 @@ "description": "This extension helps you automatically format the publication name. For example: 2017 ABC Conference -> ABC Conference.",

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