Huge News!Announcing our $40M Series B led by Abstract Ventures.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.4 to 0.0.5

2

dist/main.js

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

"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;
"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,!0)}};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.4",
"version": "0.0.5",
"author": "Paperlib",

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

"@types/node": "16.18.1",
"paperlib-api": "^0.1.2",
"paperlib-api": "^0.1.5",
"prettier": "^3.1.1",

@@ -23,0 +23,0 @@ "prettier-plugin-organize-imports": "^3.2.4",

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