UNPKG

@biruni/capacitor-preferences

Version:

(Al-Biruni) @capacitor/preferences utility

1 lines 1.2 kB
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,r=require("@biruni/core/plugin"),t=require("@capacitor/preferences"),s=(e,r,t)=>{if(!r.has(e))throw TypeError("Cannot "+t)},n=(e,r,t)=>new Promise(((s,n)=>{var i=e=>{try{o(t.next(e))}catch(e){n(e)}},a=e=>{try{o(t.throw(e))}catch(e){n(e)}},o=e=>e.done?s(e.value):Promise.resolve(e.value).then(i,a);o((t=t.apply(e,r)).next())}));class i extends r.BiruniPlugin{constructor(r){var i,a,o,c;super(),this.type="persister",this.name="capacitor/preferences",((e,r,t)=>{if(r.has(e))throw TypeError("Cannot add the same private member more than once");r instanceof WeakSet?r.add(e):r.set(e,t)})(this,e,void 0),this.preprocess=()=>n(this,null,(function*(){return(yield t.Preferences.get({key:this.namespace})).value})),this.postprocess=e=>n(this,null,(function*(){return yield t.Preferences.set({key:this.name,value:e}),e})),i=this,a=e,o=t.Preferences,s(i,a,"write to private field"),c?c.call(i,o):a.set(i,o),r&&((e,r,t)=>(s(e,r,"read from private field"),t?t.call(e):r.get(e)))(this,e).configure(r)}}e=new WeakMap;const a=e=>new i(e);exports.default=a,exports.PreferencesPlugin=a,exports.preferences=a;//# sourceMappingURL=mod.js.map