@picgo/store 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/coverage/clover.xml +2 -2
- package/coverage/lcov-report/index.html +1 -1
- package/coverage/lcov-report/src/DBStore.ts.html +1 -1
- package/coverage/lcov-report/src/JSONStore.ts.html +1 -1
- package/coverage/lcov-report/src/adapters/JSONAdapter.ts.html +2 -2
- package/coverage/lcov-report/src/adapters/ZlibAdapter.ts.html +1 -1
- package/coverage/lcov-report/src/adapters/index.html +1 -1
- package/coverage/lcov-report/src/index.html +1 -1
- package/coverage/lcov-report/src/types/index.html +1 -1
- package/coverage/lcov-report/src/types/index.ts.html +1 -1
- package/coverage/lcov-report/src/utils/index.html +1 -1
- package/coverage/lcov-report/src/utils/metaInfoHelper.ts.html +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## :tada: 2.0.1 (2022-06-12)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### :sparkles: Features
|
|
5
|
+
|
|
6
|
+
* not compress json data ([ef8adb6](https://github.com/Molunerfinn/typescript-node-template/commit/ef8adb6))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### :bug: Bug Fixes
|
|
10
|
+
|
|
11
|
+
* github action build error ([b4fe0ac](https://github.com/Molunerfinn/typescript-node-template/commit/b4fe0ac))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
1
15
|
# :tada: 2.0.0 (2022-06-11)
|
|
2
16
|
|
|
3
17
|
|
package/coverage/clover.xml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<coverage generated="
|
|
3
|
-
<project timestamp="
|
|
2
|
+
<coverage generated="1655022765464" clover="3.2.0">
|
|
3
|
+
<project timestamp="1655022765464" name="All files">
|
|
4
4
|
<metrics statements="168" coveredstatements="168" conditionals="71" coveredconditionals="68" methods="44" coveredmethods="44" elements="283" coveredelements="280" complexity="0" loc="168" ncloc="168" packages="4" files="6" classes="6"/>
|
|
5
5
|
<package name="src">
|
|
6
6
|
<metrics statements="94" coveredstatements="94" conditionals="45" coveredconditionals="42" methods="24" coveredmethods="24"/>
|
|
@@ -139,7 +139,7 @@
|
|
|
139
139
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
140
140
|
Code coverage generated by
|
|
141
141
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
142
|
-
at Sun Jun 12 2022
|
|
142
|
+
at Sun Jun 12 2022 08:32:45 GMT+0000 (Coordinated Universal Time)
|
|
143
143
|
</div>
|
|
144
144
|
</div>
|
|
145
145
|
<script src="prettify.js"></script>
|
|
@@ -492,7 +492,7 @@ export {
|
|
|
492
492
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
493
493
|
Code coverage generated by
|
|
494
494
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
495
|
-
at Sun Jun 12 2022
|
|
495
|
+
at Sun Jun 12 2022 08:32:45 GMT+0000 (Coordinated Universal Time)
|
|
496
496
|
</div>
|
|
497
497
|
</div>
|
|
498
498
|
<script src="../prettify.js"></script>
|
|
@@ -219,7 +219,7 @@ export {
|
|
|
219
219
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
220
220
|
Code coverage generated by
|
|
221
221
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
222
|
-
at Sun Jun 12 2022
|
|
222
|
+
at Sun Jun 12 2022 08:32:45 GMT+0000 (Coordinated Universal Time)
|
|
223
223
|
</div>
|
|
224
224
|
</div>
|
|
225
225
|
<script src="../prettify.js"></script>
|
|
@@ -122,7 +122,7 @@ export class JSONAdapter {
|
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
write (obj: any): void {
|
|
125
|
-
this.adapter.write(json.stringify(obj))
|
|
125
|
+
this.adapter.write(json.stringify(obj, null, 2))
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
</pre></td></tr></table></pre>
|
|
@@ -132,7 +132,7 @@ export class JSONAdapter {
|
|
|
132
132
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
133
133
|
Code coverage generated by
|
|
134
134
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
135
|
-
at Sun Jun 12 2022
|
|
135
|
+
at Sun Jun 12 2022 08:32:45 GMT+0000 (Coordinated Universal Time)
|
|
136
136
|
</div>
|
|
137
137
|
</div>
|
|
138
138
|
<script src="../../prettify.js"></script>
|
|
@@ -297,7 +297,7 @@ export {
|
|
|
297
297
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
298
298
|
Code coverage generated by
|
|
299
299
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
300
|
-
at Sun Jun 12 2022
|
|
300
|
+
at Sun Jun 12 2022 08:32:45 GMT+0000 (Coordinated Universal Time)
|
|
301
301
|
</div>
|
|
302
302
|
</div>
|
|
303
303
|
<script src="../../prettify.js"></script>
|
|
@@ -109,7 +109,7 @@
|
|
|
109
109
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
110
110
|
Code coverage generated by
|
|
111
111
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
112
|
-
at Sun Jun 12 2022
|
|
112
|
+
at Sun Jun 12 2022 08:32:45 GMT+0000 (Coordinated Universal Time)
|
|
113
113
|
</div>
|
|
114
114
|
</div>
|
|
115
115
|
<script src="../../prettify.js"></script>
|
|
@@ -109,7 +109,7 @@
|
|
|
109
109
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
110
110
|
Code coverage generated by
|
|
111
111
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
112
|
-
at Sun Jun 12 2022
|
|
112
|
+
at Sun Jun 12 2022 08:32:45 GMT+0000 (Coordinated Universal Time)
|
|
113
113
|
</div>
|
|
114
114
|
</div>
|
|
115
115
|
<script src="../prettify.js"></script>
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
95
95
|
Code coverage generated by
|
|
96
96
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
97
|
-
at Sun Jun 12 2022
|
|
97
|
+
at Sun Jun 12 2022 08:32:45 GMT+0000 (Coordinated Universal Time)
|
|
98
98
|
</div>
|
|
99
99
|
</div>
|
|
100
100
|
<script src="../../prettify.js"></script>
|
|
@@ -204,7 +204,7 @@ export interface IJSON {
|
|
|
204
204
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
205
205
|
Code coverage generated by
|
|
206
206
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
207
|
-
at Sun Jun 12 2022
|
|
207
|
+
at Sun Jun 12 2022 08:32:45 GMT+0000 (Coordinated Universal Time)
|
|
208
208
|
</div>
|
|
209
209
|
</div>
|
|
210
210
|
<script src="../../prettify.js"></script>
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
95
95
|
Code coverage generated by
|
|
96
96
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
97
|
-
at Sun Jun 12 2022
|
|
97
|
+
at Sun Jun 12 2022 08:32:45 GMT+0000 (Coordinated Universal Time)
|
|
98
98
|
</div>
|
|
99
99
|
</div>
|
|
100
100
|
<script src="../../prettify.js"></script>
|
|
@@ -192,7 +192,7 @@ export {
|
|
|
192
192
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
193
193
|
Code coverage generated by
|
|
194
194
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
195
|
-
at Sun Jun 12 2022
|
|
195
|
+
at Sun Jun 12 2022 08:32:45 GMT+0000 (Coordinated Universal Time)
|
|
196
196
|
</div>
|
|
197
197
|
</div>
|
|
198
198
|
<script src="../../prettify.js"></script>
|
package/dist/index.js
CHANGED
|
@@ -13,5 +13,5 @@ MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
|
13
13
|
See the Apache Version 2.0 License for specific language governing permissions
|
|
14
14
|
and limitations under the License.
|
|
15
15
|
***************************************************************************** */
|
|
16
|
-
function c(t,e,i,r){var a,s=arguments.length,n=s<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,e,i,r);else for(var o=t.length-1;o>=0;o--)(a=t[o])&&(n=(s<3?a(n):s>3?a(e,i,n):a(e,i))||n);return s>3&&n&&Object.defineProperty(e,i,n),n}const d=r.promisify(i.readFile);class l{constructor(t,e,i){this.readCount=0,this.dbPath=t,this.collectionName=e,this.errorList=i}async read(){this.readCount++;const t={[this.collectionName]:[],[`__${this.collectionName}_KEY__`]:{}};return new Promise(async(e,r)=>{if(i.existsSync(this.dbPath)){const i=await d(this.dbPath);a.gunzip(i,(i,r)=>{if(i)return console.error(i),this.errorList.push(i),e(t);const s=a.strFromU8(r);try{const t=JSON.parse(s);return e(t)}catch(i){return console.error(i),this.errorList.push(i),e(t)}})}else{const i=Buffer.from(JSON.stringify(t));a.gzip(i,async(i,a)=>{if(i)return r(i);await s(this.dbPath,Buffer.from(a)),e(t)})}})}async write(t){return new Promise((e,i)=>{t=Buffer.from(JSON.stringify(t)),a.gzip(t,async(t,r)=>{if(t)return i(t);await s(this.dbPath,Buffer.from(r)),e()})})}}var h,u;function f(t){return function(e,i,r){const a=r.value;r.value=async function(...e){t===u.createMany?e=[e=(e=e[0]).map(t=>y(t))]:t===u.create?e[0]=y(e[0]):e[1].updatedAt=Date.now();return await a.call(this,...e)}}}function y(t){return t.id||(t.id=function(t="",e=""){for(e=t="";t++<36;e+=51*t&52?(15^t?8^Math.random()*(20^t?16:4):4).toString(16):"-");return e}()),t.createdAt||(t.createdAt=Date.now(),t.updatedAt=Date.now()),t}!function(t){t.inited="inited",t.loaded="loaded",t.started="started",t.stopped="stopped"}(h||(h={})),function(t){t[t.createMany=0]="createMany",t[t.create=1]="create",t[t.update=2]="update"}(u||(u={}));class p{constructor(t,i){if(this.hasRead=!1,this.errorList=[],!t||!i)throw Error("Please provide valid dbPath or collectionName");this.collectionName=i,this.collectionKey=`__${i}_KEY__`,this.adapter=new l(t,i,this.errorList),this.db=new e.Low(this.adapter)}getAdapter(){return this.adapter}async read(t=!1){return!t&&this.hasRead||(this.hasRead=!0,await this.db.read()),this.db.data}async get(t){let e=(await this.getCollection()).slice();const i=e.length;return void 0!==t&&("desc"===t.orderBy&&(e=e.reverse()),"number"==typeof t.offset&&t.offset>=0&&(e=e.slice(t.offset)),"number"==typeof t.limit&&t.limit>0&&(e=e.slice(0,t.limit))),{total:i,data:e}}async getCollection(){var t;return null===(t=await this.read())||void 0===t?void 0:t[this.collectionName]}async getCollectionKey(t){return(await this.getCollectionKeyMap())[t]}async getCollectionKeyMap(){var t;return null===(t=await this.read())||void 0===t?void 0:t[this.collectionKey]}async setCollectionKey(t){await this.read();this.db.data[this.collectionKey][t]=1}async insert(t,e=!0){const i=t.id;return await this.getCollectionKey(i)?(await this.updateById(i,t),t):((await this.getCollection()).push(t),await this.setCollectionKey(i),e&&await this.db.write(),t)}async insertMany(t){for(const e of t)await this.insert(e,!1);return await this.db.write(),t}async updateById(t,e){const i=await this.getCollection();if(await this.getCollectionKey(t)){const r=i.find(e=>e.id===t);return Object.assign(r,e),await this.db.write(),!0}return!1}async getById(t){return(await this.getCollection()).find(e=>e.id===t)}async removeById(t){const e=await this.getCollection(),i=await this.getCollectionKeyMap(),r=e.findIndex(e=>e.id===t);-1!==r&&(e.splice(r,1),delete i[t],await this.db.write())}async overwrite(t){return await this.read(),this.db.data[this.collectionName]=[],this.db.data[this.collectionKey]={},await this.insertMany(t)}}c([f(u.create)],p.prototype,"insert",null),c([f(u.createMany)],p.prototype,"insertMany",null),c([f(u.update)],p.prototype,"updateById",null);class w{constructor(t){this.adapter=new e.TextFileSync(t)}read(){const t=this.adapter.read();return null===t?{}:n.parse(t)}write(t){this.adapter.write(n.stringify(t))}}class b extends e.LowSync{constructor(){super(...arguments),this.chain=o.chain(this).get("data")}}exports.DBStore=p,exports.JSONStore=class{constructor(t){if(this.hasRead=!1,!t)throw Error("Please provide valid dbPath");const e=new w(t);this.db=new b(e),this.read()}read(t=!1){return!t&&this.hasRead||(this.hasRead=!0,this.db.read()),this.db.data}get(t=""){return this.db.chain.get(t).value()}set(t,e){this.db.chain.set(t,e).value(),this.db.write()}has(t){return this.db.chain.has(t).value()}unset(t,e){const i=this.db.chain.get(t).unset(e).value();return this.db.write(),i}};
|
|
16
|
+
function c(t,e,i,r){var a,s=arguments.length,n=s<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,e,i,r);else for(var o=t.length-1;o>=0;o--)(a=t[o])&&(n=(s<3?a(n):s>3?a(e,i,n):a(e,i))||n);return s>3&&n&&Object.defineProperty(e,i,n),n}const d=r.promisify(i.readFile);class l{constructor(t,e,i){this.readCount=0,this.dbPath=t,this.collectionName=e,this.errorList=i}async read(){this.readCount++;const t={[this.collectionName]:[],[`__${this.collectionName}_KEY__`]:{}};return new Promise(async(e,r)=>{if(i.existsSync(this.dbPath)){const i=await d(this.dbPath);a.gunzip(i,(i,r)=>{if(i)return console.error(i),this.errorList.push(i),e(t);const s=a.strFromU8(r);try{const t=JSON.parse(s);return e(t)}catch(i){return console.error(i),this.errorList.push(i),e(t)}})}else{const i=Buffer.from(JSON.stringify(t));a.gzip(i,async(i,a)=>{if(i)return r(i);await s(this.dbPath,Buffer.from(a)),e(t)})}})}async write(t){return new Promise((e,i)=>{t=Buffer.from(JSON.stringify(t)),a.gzip(t,async(t,r)=>{if(t)return i(t);await s(this.dbPath,Buffer.from(r)),e()})})}}var h,u;function f(t){return function(e,i,r){const a=r.value;r.value=async function(...e){t===u.createMany?e=[e=(e=e[0]).map(t=>y(t))]:t===u.create?e[0]=y(e[0]):e[1].updatedAt=Date.now();return await a.call(this,...e)}}}function y(t){return t.id||(t.id=function(t="",e=""){for(e=t="";t++<36;e+=51*t&52?(15^t?8^Math.random()*(20^t?16:4):4).toString(16):"-");return e}()),t.createdAt||(t.createdAt=Date.now(),t.updatedAt=Date.now()),t}!function(t){t.inited="inited",t.loaded="loaded",t.started="started",t.stopped="stopped"}(h||(h={})),function(t){t[t.createMany=0]="createMany",t[t.create=1]="create",t[t.update=2]="update"}(u||(u={}));class p{constructor(t,i){if(this.hasRead=!1,this.errorList=[],!t||!i)throw Error("Please provide valid dbPath or collectionName");this.collectionName=i,this.collectionKey=`__${i}_KEY__`,this.adapter=new l(t,i,this.errorList),this.db=new e.Low(this.adapter)}getAdapter(){return this.adapter}async read(t=!1){return!t&&this.hasRead||(this.hasRead=!0,await this.db.read()),this.db.data}async get(t){let e=(await this.getCollection()).slice();const i=e.length;return void 0!==t&&("desc"===t.orderBy&&(e=e.reverse()),"number"==typeof t.offset&&t.offset>=0&&(e=e.slice(t.offset)),"number"==typeof t.limit&&t.limit>0&&(e=e.slice(0,t.limit))),{total:i,data:e}}async getCollection(){var t;return null===(t=await this.read())||void 0===t?void 0:t[this.collectionName]}async getCollectionKey(t){return(await this.getCollectionKeyMap())[t]}async getCollectionKeyMap(){var t;return null===(t=await this.read())||void 0===t?void 0:t[this.collectionKey]}async setCollectionKey(t){await this.read();this.db.data[this.collectionKey][t]=1}async insert(t,e=!0){const i=t.id;return await this.getCollectionKey(i)?(await this.updateById(i,t),t):((await this.getCollection()).push(t),await this.setCollectionKey(i),e&&await this.db.write(),t)}async insertMany(t){for(const e of t)await this.insert(e,!1);return await this.db.write(),t}async updateById(t,e){const i=await this.getCollection();if(await this.getCollectionKey(t)){const r=i.find(e=>e.id===t);return Object.assign(r,e),await this.db.write(),!0}return!1}async getById(t){return(await this.getCollection()).find(e=>e.id===t)}async removeById(t){const e=await this.getCollection(),i=await this.getCollectionKeyMap(),r=e.findIndex(e=>e.id===t);-1!==r&&(e.splice(r,1),delete i[t],await this.db.write())}async overwrite(t){return await this.read(),this.db.data[this.collectionName]=[],this.db.data[this.collectionKey]={},await this.insertMany(t)}}c([f(u.create)],p.prototype,"insert",null),c([f(u.createMany)],p.prototype,"insertMany",null),c([f(u.update)],p.prototype,"updateById",null);class w{constructor(t){this.adapter=new e.TextFileSync(t)}read(){const t=this.adapter.read();return null===t?{}:n.parse(t)}write(t){this.adapter.write(n.stringify(t,null,2))}}class b extends e.LowSync{constructor(){super(...arguments),this.chain=o.chain(this).get("data")}}exports.DBStore=p,exports.JSONStore=class{constructor(t){if(this.hasRead=!1,!t)throw Error("Please provide valid dbPath");const e=new w(t);this.db=new b(e),this.read()}read(t=!1){return!t&&this.hasRead||(this.hasRead=!0,this.db.read()),this.db.data}get(t=""){return this.db.chain.get(t).value()}set(t,e){this.db.chain.set(t,e).value(),this.db.write()}has(t){return this.db.chain.has(t).value()}unset(t,e){const i=this.db.chain.get(t).unset(e).value();return this.db.write(),i}};
|
|
17
17
|
//# sourceMappingURL=index.js.map
|