@chenshunyu/proxy 1.0.0-beta.31 → 1.0.0-beta.40

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.
Files changed (3) hide show
  1. package/.npmigore +2 -0
  2. package/index.js +14 -2
  3. package/package.json +2 -2
package/.npmigore CHANGED
@@ -1 +1,3 @@
1
1
  *.env.*
2
+ node_modules
3
+ package-lock.json
package/index.js CHANGED
@@ -103,11 +103,23 @@ function start(server) {
103
103
  function watch() {
104
104
  console.log('Watching...')
105
105
  watching = true
106
- fs.watch(filePath, e => {
106
+ fs.watch(filePath, debounce(e => {
107
107
  if (e === 'change') {
108
108
  console.log('File changes, reload...');
109
109
  close?.()
110
110
  read();
111
111
  }
112
- });
112
+ }, 200));
113
+ }
114
+
115
+ function debounce(func, wait) {
116
+ let timeout;
117
+ return function executedFunction(...args) {
118
+ const later = () => {
119
+ clearTimeout(timeout);
120
+ func(...args);
121
+ };
122
+ clearTimeout(timeout);
123
+ timeout = setTimeout(later, wait);
124
+ };
113
125
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chenshunyu/proxy",
3
- "version": "1.0.0-beta.31",
3
+ "version": "1.0.0-beta.40",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -15,6 +15,6 @@
15
15
  "author": "chenshunyu",
16
16
  "license": "ISC",
17
17
  "dependencies": {
18
- "http-proxy": "^1.18.1"
18
+ "http-proxy": "^1"
19
19
  }
20
20
  }