flat-cache 2.0.1 → 3.0.4

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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
  > A stupidly simple key/value storage using files to persist the data
3
3
 
4
4
  [![NPM Version](http://img.shields.io/npm/v/flat-cache.svg?style=flat)](https://npmjs.org/package/flat-cache)
5
- [![Build Status](http://img.shields.io/travis/royriojas/flat-cache.svg?style=flat)](https://travis-ci.org/royriojas/flat-cache)
5
+ [![Build Status](https://api.travis-ci.org/royriojas/flat-cache.svg?branch=master)](https://travis-ci.org/royriojas/flat-cache)
6
6
 
7
7
  ## install
8
8
 
package/changelog.md CHANGED
@@ -1,23 +1,113 @@
1
1
 
2
2
  # flat-cache - Changelog
3
+ ## v3.0.4
4
+ - **Refactoring**
5
+ - add files by name to the list of exported files - [89a2698]( https://github.com/royriojas/flat-cache/commit/89a2698 ), [Roy Riojas](https://github.com/Roy Riojas), 08/11/2020 02:35:39
6
+
7
+
8
+ ## v3.0.3
9
+ - **Bug Fixes**
10
+ - Fix wrong eslint command - [f268e42]( https://github.com/royriojas/flat-cache/commit/f268e42 ), [Roy Riojas](https://github.com/Roy Riojas), 08/11/2020 02:15:04
11
+
12
+
13
+ ## v3.0.2
14
+ - **Refactoring**
15
+ - Update the files paths - [6983a80]( https://github.com/royriojas/flat-cache/commit/6983a80 ), [Roy Riojas](https://github.com/Roy Riojas), 08/11/2020 01:58:39
16
+
17
+
18
+ - Move code to src/ - [18ed6e8]( https://github.com/royriojas/flat-cache/commit/18ed6e8 ), [Roy Riojas](https://github.com/Roy Riojas), 08/11/2020 01:57:17
19
+
20
+
21
+ - Change eslint-cache location - [beed74c]( https://github.com/royriojas/flat-cache/commit/beed74c ), [Roy Riojas](https://github.com/Roy Riojas), 08/11/2020 01:48:32
22
+
23
+
24
+ ## v3.0.1
25
+ - **Refactoring**
26
+ - Remove unused deps - [8c6d9dc]( https://github.com/royriojas/flat-cache/commit/8c6d9dc ), [Roy Riojas](https://github.com/Roy Riojas), 08/11/2020 01:43:29
27
+
28
+
29
+ ## v3.0.0
30
+ - **Refactoring**
31
+ - Fix engines - [52b824c]( https://github.com/royriojas/flat-cache/commit/52b824c ), [Roy Riojas](https://github.com/Roy Riojas), 08/11/2020 01:01:52
32
+
33
+
34
+ - **Other changes**
35
+ - Replace write with combination of mkdir and writeFile ([#49](https://github.com/royriojas/flat-cache/issues/49)) - [ef48276]( https://github.com/royriojas/flat-cache/commit/ef48276 ), [Bogdan Chadkin](https://github.com/Bogdan Chadkin), 08/11/2020 00:17:15
36
+
37
+ Node v10 introduced a great "recursive" option for mkdir which allows to
38
+ get rid from mkdirp package and easily rewrite "write" package usage
39
+ with two function calls.
40
+
41
+ https://nodejs.org/api/fs.html#fs_fs_mkdir_path_options_callback
42
+ - Added a testcase for clearAll ([#48](https://github.com/royriojas/flat-cache/issues/48)) - [45b51ca]( https://github.com/royriojas/flat-cache/commit/45b51ca ), [Aaron Chen](https://github.com/Aaron Chen), 21/05/2020 08:40:03
43
+
44
+
45
+ - requet node>=10 - [a5c482c]( https://github.com/royriojas/flat-cache/commit/a5c482c ), [yumetodo](https://github.com/yumetodo), 10/04/2020 23:14:53
46
+
47
+ thanks @SuperITMan
48
+
49
+ - Update README.md - [29fe40b]( https://github.com/royriojas/flat-cache/commit/29fe40b ), [Roy Riojas](https://github.com/Roy Riojas), 10/04/2020 20:08:05
50
+
51
+
52
+ - reduce vulnerability to 1 - [e9db1b2]( https://github.com/royriojas/flat-cache/commit/e9db1b2 ), [yumetodo](https://github.com/yumetodo), 30/03/2020 11:10:43
53
+
54
+
55
+ - reduce vulnerabilities dependencies to 8 - [b58d196]( https://github.com/royriojas/flat-cache/commit/b58d196 ), [yumetodo](https://github.com/yumetodo), 30/03/2020 10:54:56
56
+
57
+
58
+ - use prettier instead of esbeautifier - [03b1db7]( https://github.com/royriojas/flat-cache/commit/03b1db7 ), [yumetodo](https://github.com/yumetodo), 30/03/2020 10:27:14
59
+
60
+
61
+ - update proxyquire - [c2f048d]( https://github.com/royriojas/flat-cache/commit/c2f048d ), [yumetodo](https://github.com/yumetodo), 30/03/2020 10:16:16
62
+
63
+
64
+ - update flatted and mocha - [a0e56da]( https://github.com/royriojas/flat-cache/commit/a0e56da ), [yumetodo](https://github.com/yumetodo), 30/03/2020 09:46:45
65
+
66
+ mocha > mkdirp is updated
67
+ istanble >>> optimist > minimist is not updated
68
+
69
+ - drop support node.js < 10 in develop - [beba691]( https://github.com/royriojas/flat-cache/commit/beba691 ), [yumetodo](https://github.com/yumetodo), 18/03/2020 01:31:09
70
+
71
+ see mkdirp
72
+
73
+ - npm aufit fix(still remains) - [ce166cb]( https://github.com/royriojas/flat-cache/commit/ce166cb ), [yumetodo](https://github.com/yumetodo), 18/03/2020 01:18:08
74
+
75
+ 37 vulnerabilities required manual review and could not be updated
76
+
77
+ - updtate sinon - [9f2d1b6]( https://github.com/royriojas/flat-cache/commit/9f2d1b6 ), [yumetodo](https://github.com/yumetodo), 18/03/2020 01:17:51
78
+
79
+
80
+ - apply eslint-plugin-mocha - [07343b5]( https://github.com/royriojas/flat-cache/commit/07343b5 ), [yumetodo](https://github.com/yumetodo), 13/03/2020 22:17:21
81
+
82
+
83
+ - Less strint version check ([#44](https://github.com/royriojas/flat-cache/issues/44)) - [92aca1c]( https://github.com/royriojas/flat-cache/commit/92aca1c ), [Wojciech Maj](https://github.com/Wojciech Maj), 13/11/2019 16:18:25
84
+
85
+ * Use ^ version matching for production dependencies
86
+
87
+ * Run npm audit fix
88
+
89
+ - **Bug Fixes**
90
+ - update dependencies and use eslint directly - [73fbed2]( https://github.com/royriojas/flat-cache/commit/73fbed2 ), [yumetodo](https://github.com/yumetodo), 18/03/2020 01:17:27
91
+
92
+
3
93
  ## v2.0.1
4
94
  - **Refactoring**
5
- - upgrade node modules to latest versions - [6402ed3]( https://github.com/royriojas/flat-cache/commit/6402ed3 ), [Roy Riojas](https://github.com/Roy Riojas), 08/01/2019 21:47:05
95
+ - upgrade node modules to latest versions - [6402ed3]( https://github.com/royriojas/flat-cache/commit/6402ed3 ), [Roy Riojas](https://github.com/Roy Riojas), 08/01/2019 18:47:05
6
96
 
7
97
 
8
98
  ## v2.0.0
9
99
  - **Bug Fixes**
10
- - upgrade package.json lock file - [8d21c7b]( https://github.com/royriojas/flat-cache/commit/8d21c7b ), [Roy Riojas](https://github.com/Roy Riojas), 08/01/2019 20:03:13
100
+ - upgrade package.json lock file - [8d21c7b]( https://github.com/royriojas/flat-cache/commit/8d21c7b ), [Roy Riojas](https://github.com/Roy Riojas), 08/01/2019 17:03:13
11
101
 
12
102
 
13
- - Use the same versions of node_js that eslint use - [8d23379]( https://github.com/royriojas/flat-cache/commit/8d23379 ), [Roy Riojas](https://github.com/Roy Riojas), 08/01/2019 19:25:11
103
+ - Use the same versions of node_js that eslint use - [8d23379]( https://github.com/royriojas/flat-cache/commit/8d23379 ), [Roy Riojas](https://github.com/Roy Riojas), 08/01/2019 16:25:11
14
104
 
15
105
 
16
106
  - **Other changes**
17
- - Replace circular-json with flatted ([#36](https://github.com/royriojas/flat-cache/issues/36)) - [b93aced]( https://github.com/royriojas/flat-cache/commit/b93aced ), [C. K. Tang](https://github.com/C. K. Tang), 08/01/2019 20:03:01
107
+ - Replace circular-json with flatted ([#36](https://github.com/royriojas/flat-cache/issues/36)) - [b93aced]( https://github.com/royriojas/flat-cache/commit/b93aced ), [C. K. Tang](https://github.com/C. K. Tang), 08/01/2019 17:03:01
18
108
 
19
109
 
20
- - Change JSON parser from circular-json to flatted & 1 more changes ([#37](https://github.com/royriojas/flat-cache/issues/37)) - [745e65a]( https://github.com/royriojas/flat-cache/commit/745e65a ), [Andy Chen](https://github.com/Andy Chen), 08/01/2019 19:17:20
110
+ - Change JSON parser from circular-json to flatted & 1 more changes ([#37](https://github.com/royriojas/flat-cache/issues/37)) - [745e65a]( https://github.com/royriojas/flat-cache/commit/745e65a ), [Andy Chen](https://github.com/Andy Chen), 08/01/2019 16:17:20
21
111
 
22
112
  * Change JSON parser from circular-json to flatted & 1 more changes
23
113
 
@@ -37,16 +127,16 @@
37
127
 
38
128
  ## v1.3.4
39
129
  - **Refactoring**
40
- - Add del.js and utils.js to the list of files to be beautified - [9d0ca9b]( https://github.com/royriojas/flat-cache/commit/9d0ca9b ), [Roy Riojas](https://github.com/Roy Riojas), 14/11/2018 15:19:02
130
+ - Add del.js and utils.js to the list of files to be beautified - [9d0ca9b]( https://github.com/royriojas/flat-cache/commit/9d0ca9b ), [Roy Riojas](https://github.com/Roy Riojas), 14/11/2018 12:19:02
41
131
 
42
132
 
43
133
  ## v1.3.3
44
134
  - **Refactoring**
45
- - Make sure package-lock.json is up to date - [a7d2598]( https://github.com/royriojas/flat-cache/commit/a7d2598 ), [Roy Riojas](https://github.com/Roy Riojas), 14/11/2018 14:36:08
135
+ - Make sure package-lock.json is up to date - [a7d2598]( https://github.com/royriojas/flat-cache/commit/a7d2598 ), [Roy Riojas](https://github.com/Roy Riojas), 14/11/2018 11:36:08
46
136
 
47
137
 
48
138
  - **Other changes**
49
- - Removed the need for del ([#33](https://github.com/royriojas/flat-cache/issues/33)) - [c429012]( https://github.com/royriojas/flat-cache/commit/c429012 ), [S. Gilroy](https://github.com/S. Gilroy), 13/11/2018 16:56:37
139
+ - Removed the need for del ([#33](https://github.com/royriojas/flat-cache/issues/33)) - [c429012]( https://github.com/royriojas/flat-cache/commit/c429012 ), [S. Gilroy](https://github.com/S. Gilroy), 13/11/2018 13:56:37
50
140
 
51
141
  * Removed the need for del
52
142
 
@@ -62,30 +152,30 @@
62
152
 
63
153
  ## v1.3.2
64
154
  - **Refactoring**
65
- - remove yarn.lock file - [704c6c4]( https://github.com/royriojas/flat-cache/commit/704c6c4 ), [Roy Riojas](https://github.com/Roy Riojas), 07/11/2018 18:41:08
155
+ - remove yarn.lock file - [704c6c4]( https://github.com/royriojas/flat-cache/commit/704c6c4 ), [Roy Riojas](https://github.com/Roy Riojas), 07/11/2018 15:41:08
66
156
 
67
157
 
68
- - **undefined**
69
- - replace circular-json with flatted ([#23](https://github.com/royriojas/flat-cache/issues/23))" - [db12d74]( https://github.com/royriojas/flat-cache/commit/db12d74 ), [Roy Riojas](https://github.com/Roy Riojas), 07/11/2018 18:40:39
158
+ - **Other changes**
159
+ - replace circular-json with flatted ([#23](https://github.com/royriojas/flat-cache/issues/23))" - [db12d74]( https://github.com/royriojas/flat-cache/commit/db12d74 ), [Roy Riojas](https://github.com/Roy Riojas), 07/11/2018 15:40:39
70
160
 
71
161
  This reverts commit 00f689277a75e85fef28e6a048fad227afc525e6.
72
162
 
73
163
  ## v1.3.1
74
164
  - **Refactoring**
75
- - upgrade deps to remove some security warnings - [f405719]( https://github.com/royriojas/flat-cache/commit/f405719 ), [Roy Riojas](https://github.com/Roy Riojas), 06/11/2018 15:07:31
165
+ - upgrade deps to remove some security warnings - [f405719]( https://github.com/royriojas/flat-cache/commit/f405719 ), [Roy Riojas](https://github.com/Roy Riojas), 06/11/2018 12:07:31
76
166
 
77
167
 
78
168
  - **Bug Fixes**
79
- - replace circular-json with flatted ([#23](https://github.com/royriojas/flat-cache/issues/23)) - [00f6892]( https://github.com/royriojas/flat-cache/commit/00f6892 ), [Terry](https://github.com/Terry), 05/11/2018 21:44:16
169
+ - replace circular-json with flatted ([#23](https://github.com/royriojas/flat-cache/issues/23)) - [00f6892]( https://github.com/royriojas/flat-cache/commit/00f6892 ), [Terry](https://github.com/Terry), 05/11/2018 18:44:16
80
170
 
81
171
 
82
- - **undefined**
83
- - update del to v3.0.0 ([#26](https://github.com/royriojas/flat-cache/issues/26)) - [d42883f]( https://github.com/royriojas/flat-cache/commit/d42883f ), [Patrick Silva](https://github.com/Patrick Silva), 03/11/2018 03:00:44
172
+ - **Other changes**
173
+ - update del to v3.0.0 ([#26](https://github.com/royriojas/flat-cache/issues/26)) - [d42883f]( https://github.com/royriojas/flat-cache/commit/d42883f ), [Patrick Silva](https://github.com/Patrick Silva), 03/11/2018 01:00:44
84
174
 
85
175
  Closes <a target="_blank" class="info-link" href="https://github.com/royriojas/flat-cache/issues/25"><span>#25</span></a>
86
176
  ## v1.3.0
87
177
  - **Other changes**
88
- - Added #all method ([#16](https://github.com/royriojas/flat-cache/issues/16)) - [12293be]( https://github.com/royriojas/flat-cache/commit/12293be ), [Ozair Patel](https://github.com/Ozair Patel), 25/09/2017 16:46:38
178
+ - Added #all method ([#16](https://github.com/royriojas/flat-cache/issues/16)) - [12293be]( https://github.com/royriojas/flat-cache/commit/12293be ), [Ozair Patel](https://github.com/Ozair Patel), 25/09/2017 14:46:38
89
179
 
90
180
  * Added #all method
91
181
 
@@ -99,12 +189,12 @@
99
189
 
100
190
  * Beautified file
101
191
 
102
- - fix changelog title style ([#14](https://github.com/royriojas/flat-cache/issues/14)) - [af8338a]( https://github.com/royriojas/flat-cache/commit/af8338a ), [前端小武](https://github.com/前端小武), 19/12/2016 23:34:48
192
+ - fix changelog title style ([#14](https://github.com/royriojas/flat-cache/issues/14)) - [af8338a]( https://github.com/royriojas/flat-cache/commit/af8338a ), [前端小武](https://github.com/前端小武), 19/12/2016 20:34:48
103
193
 
104
194
 
105
195
  ## v1.2.2
106
196
  - **Bug Fixes**
107
- - Do not crash if cache file is invalid JSON. ([#13](https://github.com/royriojas/flat-cache/issues/13)) - [87beaa6]( https://github.com/royriojas/flat-cache/commit/87beaa6 ), [Roy Riojas](https://github.com/Roy Riojas), 19/12/2016 21:03:35
197
+ - Do not crash if cache file is invalid JSON. ([#13](https://github.com/royriojas/flat-cache/issues/13)) - [87beaa6]( https://github.com/royriojas/flat-cache/commit/87beaa6 ), [Roy Riojas](https://github.com/Roy Riojas), 19/12/2016 18:03:35
108
198
 
109
199
  Fixes <a target="_blank" class="info-link" href="https://github.com/royriojas/flat-cache/issues/12"><span>#12</span></a>
110
200
 
@@ -115,186 +205,124 @@
115
205
  If the cache is somehow not valid the cache will be discarded an a
116
206
  a new cache will be stored instead
117
207
  - **Other changes**
118
- - Added travis ci support for modern node versions ([#11](https://github.com/royriojas/flat-cache/issues/11)) - [1c2b1f7]( https://github.com/royriojas/flat-cache/commit/1c2b1f7 ), [Amila Welihinda](https://github.com/Amila Welihinda), 11/11/2016 02:47:52
208
+ - Added travis ci support for modern node versions ([#11](https://github.com/royriojas/flat-cache/issues/11)) - [1c2b1f7]( https://github.com/royriojas/flat-cache/commit/1c2b1f7 ), [Amila Welihinda](https://github.com/Amila Welihinda), 10/11/2016 23:47:52
119
209
 
120
210
 
121
- - Bumping `circular-son` version ([#10](https://github.com/royriojas/flat-cache/issues/10)) - [4d5e861]( https://github.com/royriojas/flat-cache/commit/4d5e861 ), [Andrea Giammarchi](https://github.com/Andrea Giammarchi), 02/08/2016 09:13:52
211
+ - Bumping `circular-son` version ([#10](https://github.com/royriojas/flat-cache/issues/10)) - [4d5e861]( https://github.com/royriojas/flat-cache/commit/4d5e861 ), [Andrea Giammarchi](https://github.com/Andrea Giammarchi), 02/08/2016 07:13:52
122
212
 
123
213
  As mentioned in https://github.com/WebReflection/circular-json/issues/25 `circular-json` wan't rightly implementing the license field.
124
214
 
125
215
  Latest version bump changed only that bit so that ESLint should now be happy.
126
216
  ## v1.2.1
127
217
  - **Bug Fixes**
128
- - Add missing utils.js file to the package. closes [#8](https://github.com/royriojas/flat-cache/issues/8) - [ec10cf2]( https://github.com/royriojas/flat-cache/commit/ec10cf2 ), [Roy Riojas](https://github.com/Roy Riojas), 01/08/2016 04:18:57
218
+ - Add missing utils.js file to the package. closes [#8](https://github.com/royriojas/flat-cache/issues/8) - [ec10cf2]( https://github.com/royriojas/flat-cache/commit/ec10cf2 ), [Roy Riojas](https://github.com/Roy Riojas), 01/08/2016 02:18:57
129
219
 
130
220
 
131
221
  ## v1.2.0
132
222
  - **Documentation**
133
- - Add documentation about noPrune option - [23e11f9]( https://github.com/royriojas/flat-cache/commit/23e11f9 ), [Roy Riojas](https://github.com/Roy Riojas), 01/08/2016 04:06:49
223
+ - Add documentation about noPrune option - [23e11f9]( https://github.com/royriojas/flat-cache/commit/23e11f9 ), [Roy Riojas](https://github.com/Roy Riojas), 01/08/2016 02:06:49
134
224
 
135
225
 
136
- ## v1.1.0
226
+ ## v1.0.11
137
227
  - **Features**
138
- - Add noPrune option to cache.save() method. closes [#7](https://github.com/royriojas/flat-cache/issues/7) - [2c8016a]( https://github.com/royriojas/flat-cache/commit/2c8016a ), [Roy Riojas](https://github.com/Roy Riojas), 01/08/2016 04:00:29
228
+ - Add noPrune option to cache.save() method. closes [#7](https://github.com/royriojas/flat-cache/issues/7) - [2c8016a]( https://github.com/royriojas/flat-cache/commit/2c8016a ), [Roy Riojas](https://github.com/Roy Riojas), 01/08/2016 02:00:29
139
229
 
140
230
 
141
- - Add json read and write utility based on circular-json - [c31081e]( https://github.com/royriojas/flat-cache/commit/c31081e ), [Jean Ponchon](https://github.com/Jean Ponchon), 28/07/2016 10:58:17
231
+ - Add json read and write utility based on circular-json - [c31081e]( https://github.com/royriojas/flat-cache/commit/c31081e ), [Jean Ponchon](https://github.com/Jean Ponchon), 28/07/2016 08:58:17
142
232
 
143
233
 
144
234
  - **Bug Fixes**
145
- - Remove UTF16 BOM stripping - [4a41e22]( https://github.com/royriojas/flat-cache/commit/4a41e22 ), [Jean Ponchon](https://github.com/Jean Ponchon), 29/07/2016 04:18:06
235
+ - Remove UTF16 BOM stripping - [4a41e22]( https://github.com/royriojas/flat-cache/commit/4a41e22 ), [Jean Ponchon](https://github.com/Jean Ponchon), 29/07/2016 02:18:06
146
236
 
147
237
  Since we control both writing and reading of JSON stream, there no needs
148
238
  to handle unicode BOM.
149
- - Use circular-json to handle circular references (fix [#5](https://github.com/royriojas/flat-cache/issues/5)) - [cd7aeed]( https://github.com/royriojas/flat-cache/commit/cd7aeed ), [Jean Ponchon](https://github.com/Jean Ponchon), 25/07/2016 13:11:59
239
+ - Use circular-json to handle circular references (fix [#5](https://github.com/royriojas/flat-cache/issues/5)) - [cd7aeed]( https://github.com/royriojas/flat-cache/commit/cd7aeed ), [Jean Ponchon](https://github.com/Jean Ponchon), 25/07/2016 11:11:59
150
240
 
151
241
 
152
242
  - **Tests Related fixes**
153
- - Add missing file from eslint test - [d6fa3c3]( https://github.com/royriojas/flat-cache/commit/d6fa3c3 ), [Jean Ponchon](https://github.com/Jean Ponchon), 29/07/2016 04:15:51
243
+ - Add missing file from eslint test - [d6fa3c3]( https://github.com/royriojas/flat-cache/commit/d6fa3c3 ), [Jean Ponchon](https://github.com/Jean Ponchon), 29/07/2016 02:15:51
154
244
 
155
245
 
156
- - Add test for circular json serialization / deserialization - [07d2ddd]( https://github.com/royriojas/flat-cache/commit/07d2ddd ), [Jean Ponchon](https://github.com/Jean Ponchon), 28/07/2016 10:59:36
246
+ - Add test for circular json serialization / deserialization - [07d2ddd]( https://github.com/royriojas/flat-cache/commit/07d2ddd ), [Jean Ponchon](https://github.com/Jean Ponchon), 28/07/2016 08:59:36
157
247
 
158
248
 
159
249
  - **Refactoring**
160
- - Remove unused read-json-sync - [2be1c24]( https://github.com/royriojas/flat-cache/commit/2be1c24 ), [Jean Ponchon](https://github.com/Jean Ponchon), 28/07/2016 10:59:18
250
+ - Remove unused read-json-sync - [2be1c24]( https://github.com/royriojas/flat-cache/commit/2be1c24 ), [Jean Ponchon](https://github.com/Jean Ponchon), 28/07/2016 08:59:18
161
251
 
162
252
 
163
253
  - **Build Scripts Changes**
164
- - travis tests on 0.12 and 4x - [3a613fd]( https://github.com/royriojas/flat-cache/commit/3a613fd ), [royriojas](https://github.com/royriojas), 15/11/2015 17:34:40
254
+ - travis tests on 0.12 and 4x - [3a613fd]( https://github.com/royriojas/flat-cache/commit/3a613fd ), [royriojas](https://github.com/royriojas), 15/11/2015 14:34:40
165
255
 
166
256
 
167
- - add eslint-fix task - [fd29e52]( https://github.com/royriojas/flat-cache/commit/fd29e52 ), [royriojas](https://github.com/royriojas), 01/11/2015 18:04:08
257
+ ## v1.0.10
258
+ - **Build Scripts Changes**
259
+ - add eslint-fix task - [fd29e52]( https://github.com/royriojas/flat-cache/commit/fd29e52 ), [royriojas](https://github.com/royriojas), 01/11/2015 15:04:08
168
260
 
169
261
 
170
- - make sure the test script also verify beautification and linting of files before running tests - [e94e176]( https://github.com/royriojas/flat-cache/commit/e94e176 ), [royriojas](https://github.com/royriojas), 01/11/2015 14:54:48
262
+ - make sure the test script also verify beautification and linting of files before running tests - [e94e176]( https://github.com/royriojas/flat-cache/commit/e94e176 ), [royriojas](https://github.com/royriojas), 01/11/2015 11:54:48
171
263
 
172
264
 
173
265
  - **Other changes**
174
- - add clearAll for cacheDir - [97383d9]( https://github.com/royriojas/flat-cache/commit/97383d9 ), [xieyaowu](https://github.com/xieyaowu), 31/10/2015 23:02:18
266
+ - add clearAll for cacheDir - [97383d9]( https://github.com/royriojas/flat-cache/commit/97383d9 ), [xieyaowu](https://github.com/xieyaowu), 31/10/2015 21:02:18
175
267
 
176
268
 
177
269
  ## v1.0.9
178
270
  - **Bug Fixes**
179
- - wrong default values for changelogx user repo name - [7bb52d1]( https://github.com/royriojas/flat-cache/commit/7bb52d1 ), [royriojas](https://github.com/royriojas), 11/09/2015 17:59:30
271
+ - wrong default values for changelogx user repo name - [7bb52d1]( https://github.com/royriojas/flat-cache/commit/7bb52d1 ), [royriojas](https://github.com/royriojas), 11/09/2015 15:59:30
180
272
 
181
273
 
182
274
  ## v1.0.8
183
275
  - **Build Scripts Changes**
184
- - test against node 4 - [c395b66]( https://github.com/royriojas/flat-cache/commit/c395b66 ), [royriojas](https://github.com/royriojas), 11/09/2015 17:51:39
276
+ - test against node 4 - [c395b66]( https://github.com/royriojas/flat-cache/commit/c395b66 ), [royriojas](https://github.com/royriojas), 11/09/2015 15:51:39
185
277
 
186
278
 
187
279
  ## v1.0.7
188
280
  - **Other changes**
189
- - Move dependencies into devDep - [7e47099]( https://github.com/royriojas/flat-cache/commit/7e47099 ), [Bogdan Chadkin](https://github.com/Bogdan Chadkin), 11/09/2015 17:10:57
281
+ - Move dependencies into devDep - [7e47099]( https://github.com/royriojas/flat-cache/commit/7e47099 ), [Bogdan Chadkin](https://github.com/Bogdan Chadkin), 11/09/2015 15:10:57
190
282
 
191
283
 
192
284
  - **Documentation**
193
- - Add missing changelog link - [f51197a]( https://github.com/royriojas/flat-cache/commit/f51197a ), [royriojas](https://github.com/royriojas), 11/09/2015 16:48:05
285
+ - Add missing changelog link - [f51197a]( https://github.com/royriojas/flat-cache/commit/f51197a ), [royriojas](https://github.com/royriojas), 11/09/2015 14:48:05
194
286
 
195
287
 
196
288
  ## v1.0.6
197
289
  - **Build Scripts Changes**
198
- - Add helpers/code check scripts - [bdb82f3]( https://github.com/royriojas/flat-cache/commit/bdb82f3 ), [royriojas](https://github.com/royriojas), 11/09/2015 16:44:31
290
+ - Add helpers/code check scripts - [bdb82f3]( https://github.com/royriojas/flat-cache/commit/bdb82f3 ), [royriojas](https://github.com/royriojas), 11/09/2015 14:44:31
199
291
 
200
292
 
201
293
  ## v1.0.5
202
294
  - **Documentation**
203
- - better description for the module - [436817f]( https://github.com/royriojas/flat-cache/commit/436817f ), [royriojas](https://github.com/royriojas), 11/09/2015 16:35:33
295
+ - better description for the module - [436817f]( https://github.com/royriojas/flat-cache/commit/436817f ), [royriojas](https://github.com/royriojas), 11/09/2015 14:35:33
204
296
 
205
297
 
206
298
  - **Other changes**
207
- - Update dependencies - [be88aa3]( https://github.com/royriojas/flat-cache/commit/be88aa3 ), [Bogdan Chadkin](https://github.com/Bogdan Chadkin), 11/09/2015 15:47:41
208
-
209
-
210
- ## v1.0.11
211
- - **Features**
212
- - Add noPrune option to cache.save() method. closes [#7](https://github.com/royriojas/flat-cache/issues/7) - [2c8016a]( https://github.com/royriojas/flat-cache/commit/2c8016a ), [Roy Riojas](https://github.com/Roy Riojas), 01/08/2016 04:00:29
213
-
214
-
215
- - Add json read and write utility based on circular-json - [c31081e]( https://github.com/royriojas/flat-cache/commit/c31081e ), [Jean Ponchon](https://github.com/Jean Ponchon), 28/07/2016 10:58:17
216
-
217
-
218
- - **Bug Fixes**
219
- - Remove UTF16 BOM stripping - [4a41e22]( https://github.com/royriojas/flat-cache/commit/4a41e22 ), [Jean Ponchon](https://github.com/Jean Ponchon), 29/07/2016 04:18:06
220
-
221
- Since we control both writing and reading of JSON stream, there no needs
222
- to handle unicode BOM.
223
- - Use circular-json to handle circular references (fix [#5](https://github.com/royriojas/flat-cache/issues/5)) - [cd7aeed]( https://github.com/royriojas/flat-cache/commit/cd7aeed ), [Jean Ponchon](https://github.com/Jean Ponchon), 25/07/2016 13:11:59
224
-
225
-
226
- - **Tests Related fixes**
227
- - Add missing file from eslint test - [d6fa3c3]( https://github.com/royriojas/flat-cache/commit/d6fa3c3 ), [Jean Ponchon](https://github.com/Jean Ponchon), 29/07/2016 04:15:51
228
-
229
-
230
- - Add test for circular json serialization / deserialization - [07d2ddd]( https://github.com/royriojas/flat-cache/commit/07d2ddd ), [Jean Ponchon](https://github.com/Jean Ponchon), 28/07/2016 10:59:36
299
+ - Update dependencies - [be88aa3]( https://github.com/royriojas/flat-cache/commit/be88aa3 ), [Bogdan Chadkin](https://github.com/Bogdan Chadkin), 11/09/2015 13:47:41
231
300
 
232
301
 
302
+ ## v1.0.4
233
303
  - **Refactoring**
234
- - Remove unused read-json-sync - [2be1c24]( https://github.com/royriojas/flat-cache/commit/2be1c24 ), [Jean Ponchon](https://github.com/Jean Ponchon), 28/07/2016 10:59:18
235
-
236
-
237
- - **Build Scripts Changes**
238
- - travis tests on 0.12 and 4x - [3a613fd]( https://github.com/royriojas/flat-cache/commit/3a613fd ), [royriojas](https://github.com/royriojas), 15/11/2015 17:34:40
239
-
240
-
241
- ## v1.0.10
242
- - **Build Scripts Changes**
243
- - add eslint-fix task - [fd29e52]( https://github.com/royriojas/flat-cache/commit/fd29e52 ), [royriojas](https://github.com/royriojas), 01/11/2015 18:04:08
244
-
245
-
246
- - make sure the test script also verify beautification and linting of files before running tests - [e94e176]( https://github.com/royriojas/flat-cache/commit/e94e176 ), [royriojas](https://github.com/royriojas), 01/11/2015 14:54:48
247
-
248
-
249
- - test against node 4 - [c395b66]( https://github.com/royriojas/flat-cache/commit/c395b66 ), [royriojas](https://github.com/royriojas), 11/09/2015 17:51:39
250
-
251
-
252
- - Add helpers/code check scripts - [bdb82f3]( https://github.com/royriojas/flat-cache/commit/bdb82f3 ), [royriojas](https://github.com/royriojas), 11/09/2015 16:44:31
253
-
254
-
255
- - **Other changes**
256
- - add clearAll for cacheDir - [97383d9]( https://github.com/royriojas/flat-cache/commit/97383d9 ), [xieyaowu](https://github.com/xieyaowu), 31/10/2015 23:02:18
257
-
258
-
259
- - Move dependencies into devDep - [7e47099]( https://github.com/royriojas/flat-cache/commit/7e47099 ), [Bogdan Chadkin](https://github.com/Bogdan Chadkin), 11/09/2015 17:10:57
260
-
261
-
262
- - Update dependencies - [be88aa3]( https://github.com/royriojas/flat-cache/commit/be88aa3 ), [Bogdan Chadkin](https://github.com/Bogdan Chadkin), 11/09/2015 15:47:41
263
-
264
-
265
- - **Bug Fixes**
266
- - wrong default values for changelogx user repo name - [7bb52d1]( https://github.com/royriojas/flat-cache/commit/7bb52d1 ), [royriojas](https://github.com/royriojas), 11/09/2015 17:59:30
304
+ - load a cache file using the full filepath - [b8f68c2]( https://github.com/royriojas/flat-cache/commit/b8f68c2 ), [Roy Riojas](https://github.com/Roy Riojas), 30/08/2015 04:19:14
267
305
 
268
306
 
269
307
  - **Documentation**
270
- - Add missing changelog link - [f51197a]( https://github.com/royriojas/flat-cache/commit/f51197a ), [royriojas](https://github.com/royriojas), 11/09/2015 16:48:05
271
-
272
-
273
- - better description for the module - [436817f]( https://github.com/royriojas/flat-cache/commit/436817f ), [royriojas](https://github.com/royriojas), 11/09/2015 16:35:33
274
-
275
-
276
- - Add documentation about `clearAll` and `clearCacheById` - [13947c1]( https://github.com/royriojas/flat-cache/commit/13947c1 ), [Roy Riojas](https://github.com/Roy Riojas), 02/03/2015 02:44:05
277
-
278
-
279
- - **Refactoring**
280
- - load a cache file using the full filepath - [b8f68c2]( https://github.com/royriojas/flat-cache/commit/b8f68c2 ), [Roy Riojas](https://github.com/Roy Riojas), 30/08/2015 06:19:14
308
+ - Add documentation about `clearAll` and `clearCacheById` - [13947c1]( https://github.com/royriojas/flat-cache/commit/13947c1 ), [Roy Riojas](https://github.com/Roy Riojas), 01/03/2015 23:44:05
281
309
 
282
310
 
283
311
  - **Features**
284
- - Add methods to remove the cache documents created - [af40443]( https://github.com/royriojas/flat-cache/commit/af40443 ), [Roy Riojas](https://github.com/Roy Riojas), 02/03/2015 02:39:27
312
+ - Add methods to remove the cache documents created - [af40443]( https://github.com/royriojas/flat-cache/commit/af40443 ), [Roy Riojas](https://github.com/Roy Riojas), 01/03/2015 23:39:27
285
313
 
286
314
 
287
315
  ## v1.0.1
288
316
  - **Other changes**
289
- - Update README.md - [c2b6805]( https://github.com/royriojas/flat-cache/commit/c2b6805 ), [Roy Riojas](https://github.com/Roy Riojas), 26/02/2015 07:28:07
317
+ - Update README.md - [c2b6805]( https://github.com/royriojas/flat-cache/commit/c2b6805 ), [Roy Riojas](https://github.com/Roy Riojas), 26/02/2015 04:28:07
290
318
 
291
319
 
292
320
  ## v1.0.0
293
321
  - **Refactoring**
294
- - flat-cache v.1.0.0 - [c984274]( https://github.com/royriojas/flat-cache/commit/c984274 ), [Roy Riojas](https://github.com/Roy Riojas), 26/02/2015 07:11:50
322
+ - flat-cache v.1.0.0 - [c984274]( https://github.com/royriojas/flat-cache/commit/c984274 ), [Roy Riojas](https://github.com/Roy Riojas), 26/02/2015 04:11:50
295
323
 
296
324
 
297
325
  - **Other changes**
298
- - Initial commit - [d43cccf]( https://github.com/royriojas/flat-cache/commit/d43cccf ), [Roy Riojas](https://github.com/Roy Riojas), 26/02/2015 04:12:16
326
+ - Initial commit - [d43cccf]( https://github.com/royriojas/flat-cache/commit/d43cccf ), [Roy Riojas](https://github.com/Roy Riojas), 26/02/2015 01:12:16
299
327
 
300
328
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flat-cache",
3
- "version": "2.0.1",
3
+ "version": "3.0.4",
4
4
  "description": "A stupidly simple key/value storage using files to persist some data",
5
5
  "repository": "royriojas/flat-cache",
6
6
  "license": "MIT",
@@ -8,14 +8,14 @@
8
8
  "name": "Roy Riojas",
9
9
  "url": "http://royriojas.com"
10
10
  },
11
- "main": "cache.js",
11
+ "main": "src/cache.js",
12
12
  "files": [
13
- "cache.js",
14
- "utils.js",
15
- "del.js"
13
+ "src/cache.js",
14
+ "src/del.js",
15
+ "src/utils.js"
16
16
  ],
17
17
  "engines": {
18
- "node": ">=4"
18
+ "node": "^10.12.0 || >=12.0.0"
19
19
  },
20
20
  "precommit": [
21
21
  "npm run verify --silent"
@@ -24,13 +24,11 @@
24
24
  "npm run verify --silent"
25
25
  ],
26
26
  "scripts": {
27
- "beautify": "esbeautifier 'cache.js' 'utils.js' 'del.js' 'test/specs/**/*.js'",
28
- "beautify-check": "npm run beautify -- -k",
29
- "eslint": "eslinter 'cache.js' 'utils.js' 'del.js' 'specs/**/*.js'",
27
+ "eslint": "eslint --cache --cache-location=node_modules/.cache/ ./src/**/*.js ./test/**/*.js",
30
28
  "eslint-fix": "npm run eslint -- --fix",
31
- "autofix": "npm run beautify && npm run eslint-fix",
32
- "check": "npm run beautify-check && npm run eslint",
33
- "verify": "npm run check && npm run test:cache",
29
+ "autofix": "npm run eslint-fix",
30
+ "check": "npm run eslint",
31
+ "verify": "npm run eslint && npm run test:cache",
34
32
  "install-hooks": "prepush install && changelogx install-hook && precommit install",
35
33
  "changelog": "changelogx -f markdown -o ./changelog.md",
36
34
  "do-changelog": "npm run changelog && git add ./changelog.md && git commit -m 'DOC: Generate changelog' --no-verify",
@@ -65,23 +63,22 @@
65
63
  "projectName": "flat-cache"
66
64
  },
67
65
  "devDependencies": {
68
- "chai": "^3.2.0",
69
- "changelogx": "3.0.0",
70
- "esbeautifier": "10.1.1",
71
- "eslinter": "^3.2.1",
72
- "glob-expand": "0.2.1",
73
- "istanbul": "0.4.5",
74
- "mocha": "5.2.0",
75
- "precommit": "^1.1.5",
76
- "prepush": "^3.1.4",
77
- "proxyquire": "^1.7.2",
78
- "sinon": "^1.16.1",
79
- "sinon-chai": "^2.8.0",
80
- "watch-run": "^1.2.2"
66
+ "chai": "^4.2.0",
67
+ "changelogx": "^5.0.6",
68
+ "eslint": "^7.13.0",
69
+ "eslint-config-prettier": "^6.15.0",
70
+ "eslint-plugin-mocha": "^8.0.0",
71
+ "eslint-plugin-prettier": "^3.1.4",
72
+ "glob-expand": "^0.2.1",
73
+ "istanbul": "^0.4.5",
74
+ "mocha": "^8.2.1",
75
+ "precommit": "^1.2.2",
76
+ "prepush": "^3.1.11",
77
+ "prettier": "^2.1.2",
78
+ "watch-run": "^1.2.5"
81
79
  },
82
80
  "dependencies": {
83
- "flatted": "^2.0.0",
84
- "rimraf": "2.6.3",
85
- "write": "1.0.3"
81
+ "flatted": "^3.1.0",
82
+ "rimraf": "^3.0.2"
86
83
  }
87
84
  }
@@ -1,7 +1,7 @@
1
- var path = require( 'path' );
2
- var fs = require( 'fs' );
3
- var utils = require( './utils' );
4
- var del = require( './del' );
1
+ var path = require('path');
2
+ var fs = require('fs');
3
+ var utils = require('./utils');
4
+ var del = require('./del');
5
5
  var writeJSON = utils.writeJSON;
6
6
 
7
7
  var cache = {
@@ -14,15 +14,15 @@ var cache = {
14
14
  * @param docId {String} the id of the cache, would also be used as the name of the file cache
15
15
  * @param [cacheDir] {String} directory for the cache entry
16
16
  */
17
- load: function ( docId, cacheDir ) {
17
+ load: function (docId, cacheDir) {
18
18
  var me = this;
19
19
 
20
- me._visited = { };
21
- me._persisted = { };
22
- me._pathToFile = cacheDir ? path.resolve( cacheDir, docId ) : path.resolve( __dirname, './.cache/', docId );
20
+ me._visited = {};
21
+ me._persisted = {};
22
+ me._pathToFile = cacheDir ? path.resolve(cacheDir, docId) : path.resolve(__dirname, '../.cache/', docId);
23
23
 
24
- if ( fs.existsSync( me._pathToFile ) ) {
25
- me._persisted = utils.tryParse( me._pathToFile, { } );
24
+ if (fs.existsSync(me._pathToFile)) {
25
+ me._persisted = utils.tryParse(me._pathToFile, {});
26
26
  }
27
27
  },
28
28
 
@@ -31,12 +31,12 @@ var cache = {
31
31
  * @method loadFile
32
32
  * @param {String} pathToFile the path to the file containing the info for the cache
33
33
  */
34
- loadFile: function ( pathToFile ) {
34
+ loadFile: function (pathToFile) {
35
35
  var me = this;
36
- var dir = path.dirname( pathToFile );
37
- var fName = path.basename( pathToFile );
36
+ var dir = path.dirname(pathToFile);
37
+ var fName = path.basename(pathToFile);
38
38
 
39
- me.load( fName, dir );
39
+ me.load(fName, dir);
40
40
  },
41
41
 
42
42
  /**
@@ -49,7 +49,7 @@ var cache = {
49
49
  },
50
50
 
51
51
  keys: function () {
52
- return Object.keys( this._persisted );
52
+ return Object.keys(this._persisted);
53
53
  },
54
54
  /**
55
55
  * sets a key to a given value
@@ -57,18 +57,18 @@ var cache = {
57
57
  * @param key {string} the key to set
58
58
  * @param value {object} the value of the key. Could be any object that can be serialized with JSON.stringify
59
59
  */
60
- setKey: function ( key, value ) {
61
- this._visited[ key ] = true;
62
- this._persisted[ key ] = value;
60
+ setKey: function (key, value) {
61
+ this._visited[key] = true;
62
+ this._persisted[key] = value;
63
63
  },
64
64
  /**
65
65
  * remove a given key from the cache
66
66
  * @method removeKey
67
67
  * @param key {String} the key to remove from the object
68
68
  */
69
- removeKey: function ( key ) {
70
- delete this._visited[ key ]; // esfmt-ignore-line
71
- delete this._persisted[ key ]; // esfmt-ignore-line
69
+ removeKey: function (key) {
70
+ delete this._visited[key]; // esfmt-ignore-line
71
+ delete this._persisted[key]; // esfmt-ignore-line
72
72
  },
73
73
  /**
74
74
  * Return the value of the provided key
@@ -76,9 +76,9 @@ var cache = {
76
76
  * @param key {String} the name of the key to retrieve
77
77
  * @returns {*} the value from the key
78
78
  */
79
- getKey: function ( key ) {
80
- this._visited[ key ] = true;
81
- return this._persisted[ key ];
79
+ getKey: function (key) {
80
+ this._visited[key] = true;
81
+ return this._persisted[key];
82
82
  },
83
83
 
84
84
  /**
@@ -89,20 +89,20 @@ var cache = {
89
89
  */
90
90
  _prune: function () {
91
91
  var me = this;
92
- var obj = { };
92
+ var obj = {};
93
93
 
94
- var keys = Object.keys( me._visited );
94
+ var keys = Object.keys(me._visited);
95
95
 
96
96
  // no keys visited for either get or set value
97
- if ( keys.length === 0 ) {
97
+ if (keys.length === 0) {
98
98
  return;
99
99
  }
100
100
 
101
- keys.forEach( function ( key ) {
102
- obj[ key ] = me._persisted[ key ];
103
- } );
101
+ keys.forEach(function (key) {
102
+ obj[key] = me._persisted[key];
103
+ });
104
104
 
105
- me._visited = { };
105
+ me._visited = {};
106
106
  me._persisted = obj;
107
107
  },
108
108
 
@@ -112,11 +112,11 @@ var cache = {
112
112
  * @param [noPrune=false] {Boolean} whether to remove from cache the non visited files
113
113
  * @method save
114
114
  */
115
- save: function ( noPrune ) {
115
+ save: function (noPrune) {
116
116
  var me = this;
117
117
 
118
- (!noPrune) && me._prune();
119
- writeJSON( me._pathToFile, me._persisted );
118
+ !noPrune && me._prune();
119
+ writeJSON(me._pathToFile, me._persisted);
120
120
  },
121
121
 
122
122
  /**
@@ -125,7 +125,7 @@ var cache = {
125
125
  * @return {Boolean} true or false if the file was successfully deleted
126
126
  */
127
127
  removeCacheFile: function () {
128
- return del( this._pathToFile );
128
+ return del(this._pathToFile);
129
129
  },
130
130
  /**
131
131
  * Destroy the file cache and cache content.
@@ -133,11 +133,11 @@ var cache = {
133
133
  */
134
134
  destroy: function () {
135
135
  var me = this;
136
- me._visited = { };
137
- me._persisted = { };
136
+ me._visited = {};
137
+ me._persisted = {};
138
138
 
139
139
  me.removeCacheFile();
140
- }
140
+ },
141
141
  };
142
142
 
143
143
  module.exports = {
@@ -149,28 +149,28 @@ module.exports = {
149
149
  * @param [cacheDir] {String} directory for the cache entry
150
150
  * @returns {cache} cache instance
151
151
  */
152
- load: function ( docId, cacheDir ) {
153
- return this.create( docId, cacheDir );
152
+ load: function (docId, cacheDir) {
153
+ return this.create(docId, cacheDir);
154
154
  },
155
155
 
156
156
  /**
157
- * Load a cache identified by the given Id. If the element does not exists, then initialize an empty
158
- * cache storage.
159
- *
160
- * @method create
161
- * @param docId {String} the id of the cache, would also be used as the name of the file cache
162
- * @param [cacheDir] {String} directory for the cache entry
163
- * @returns {cache} cache instance
164
- */
165
- create: function ( docId, cacheDir ) {
166
- var obj = Object.create( cache );
167
- obj.load( docId, cacheDir );
157
+ * Load a cache identified by the given Id. If the element does not exists, then initialize an empty
158
+ * cache storage.
159
+ *
160
+ * @method create
161
+ * @param docId {String} the id of the cache, would also be used as the name of the file cache
162
+ * @param [cacheDir] {String} directory for the cache entry
163
+ * @returns {cache} cache instance
164
+ */
165
+ create: function (docId, cacheDir) {
166
+ var obj = Object.create(cache);
167
+ obj.load(docId, cacheDir);
168
168
  return obj;
169
169
  },
170
170
 
171
- createFromFile: function ( filePath ) {
172
- var obj = Object.create( cache );
173
- obj.loadFile( filePath );
171
+ createFromFile: function (filePath) {
172
+ var obj = Object.create(cache);
173
+ obj.loadFile(filePath);
174
174
  return obj;
175
175
  },
176
176
  /**
@@ -181,17 +181,17 @@ module.exports = {
181
181
  * @param cacheDir {String} the directory where the cache file was written
182
182
  * @returns {Boolean} true if the cache folder was deleted. False otherwise
183
183
  */
184
- clearCacheById: function ( docId, cacheDir ) {
185
- var filePath = cacheDir ? path.resolve( cacheDir, docId ) : path.resolve( __dirname, './.cache/', docId );
186
- return del( filePath );
184
+ clearCacheById: function (docId, cacheDir) {
185
+ var filePath = cacheDir ? path.resolve(cacheDir, docId) : path.resolve(__dirname, '../.cache/', docId);
186
+ return del(filePath);
187
187
  },
188
188
  /**
189
189
  * Remove all cache stored in the cache directory
190
190
  * @method clearAll
191
191
  * @returns {Boolean} true if the cache folder was deleted. False otherwise
192
192
  */
193
- clearAll: function ( cacheDir ) {
194
- var filePath = cacheDir ? path.resolve( cacheDir ) : path.resolve( __dirname, './.cache/' );
195
- return del( filePath );
196
- }
193
+ clearAll: function (cacheDir) {
194
+ var filePath = cacheDir ? path.resolve(cacheDir) : path.resolve(__dirname, '../.cache/');
195
+ return del(filePath);
196
+ },
197
197
  };
package/src/del.js ADDED
@@ -0,0 +1,13 @@
1
+ var rimraf = require('rimraf').sync;
2
+ var fs = require('fs');
3
+
4
+ module.exports = function del(file) {
5
+ if (fs.existsSync(file)) {
6
+ //if rimraf doesn't throw then the file has been deleted or didn't exist
7
+ rimraf(file, {
8
+ glob: false,
9
+ });
10
+ return true;
11
+ }
12
+ return false;
13
+ };
package/src/utils.js ADDED
@@ -0,0 +1,44 @@
1
+ var fs = require('fs');
2
+ var path = require('path');
3
+ var flatted = require('flatted');
4
+
5
+ module.exports = {
6
+ tryParse: function (filePath, defaultValue) {
7
+ var result;
8
+ try {
9
+ result = this.readJSON(filePath);
10
+ } catch (ex) {
11
+ result = defaultValue;
12
+ }
13
+ return result;
14
+ },
15
+
16
+ /**
17
+ * Read json file synchronously using flatted
18
+ *
19
+ * @method readJSON
20
+ * @param {String} filePath Json filepath
21
+ * @returns {*} parse result
22
+ */
23
+ readJSON: function (filePath) {
24
+ return flatted.parse(
25
+ fs.readFileSync(filePath, {
26
+ encoding: 'utf8',
27
+ })
28
+ );
29
+ },
30
+
31
+ /**
32
+ * Write json file synchronously using circular-json
33
+ *
34
+ * @method writeJSON
35
+ * @param {String} filePath Json filepath
36
+ * @param {*} data Object to serialize
37
+ */
38
+ writeJSON: function (filePath, data) {
39
+ fs.mkdirSync(path.dirname(filePath), {
40
+ recursive: true,
41
+ });
42
+ fs.writeFileSync(filePath, flatted.stringify(data));
43
+ },
44
+ };
package/del.js DELETED
@@ -1,13 +0,0 @@
1
- var rimraf = require( 'rimraf' ).sync;
2
- var fs = require( 'fs' );
3
-
4
- module.exports = function del( file ) {
5
- if ( fs.existsSync( file ) ) {
6
- //if rimraf doesn't throw then the file has been deleted or didn't exist
7
- rimraf( file, {
8
- glob: false
9
- } );
10
- return true;
11
- }
12
- return false;
13
- };
package/utils.js DELETED
@@ -1,39 +0,0 @@
1
- var fs = require( 'fs' );
2
- var write = require( 'write' );
3
- var flatted = require( 'flatted' );
4
-
5
- module.exports = {
6
- tryParse: function ( filePath, defaultValue ) {
7
- var result;
8
- try {
9
- result = this.readJSON( filePath );
10
- } catch (ex) {
11
- result = defaultValue;
12
- }
13
- return result;
14
- },
15
-
16
- /**
17
- * Read json file synchronously using flatted
18
- *
19
- * @method readJSON
20
- * @param {String} filePath Json filepath
21
- * @returns {*} parse result
22
- */
23
- readJSON: function ( filePath ) {
24
- return flatted.parse( fs.readFileSync( filePath, {
25
- encoding: 'utf8'
26
- } ) );
27
- },
28
-
29
- /**
30
- * Write json file synchronously using circular-json
31
- *
32
- * @method writeJSON
33
- * @param {String} filePath Json filepath
34
- * @param {*} data Object to serialize
35
- */
36
- writeJSON: function ( filePath, data ) {
37
- write.sync( filePath, flatted.stringify( data ) );
38
- }
39
- };