hanspell 0.9.3 → 0.9.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.
@@ -66,6 +66,7 @@ function parseJSON(response) {
66
66
 
67
67
  const DAUM_URL = 'https://dic.daum.net/grammar_checker.do';
68
68
  const DAUM_MAX_CHARS = 1000;
69
+ const DAUM_MIN_INTERVAL = 400;
69
70
 
70
71
  // Splits a long sentence, and makes spell check requests to the server.
71
72
  // `check` is called at each short sentence with the parsed JSON parameter.
@@ -101,18 +102,27 @@ function spellCheck(sentence, timeout, check, end, error) {
101
102
  if (count === 0 && end !== null) end();
102
103
  };
103
104
 
104
- data.forEach((part) =>
105
+ let i = 0;
106
+
107
+ function post() {
105
108
  request.post(
106
109
  {
107
110
  url: DAUM_URL,
108
111
  timeout,
109
112
  form: {
110
- sentence: part,
113
+ sentence: data[i],
111
114
  },
112
115
  },
113
116
  getResponse,
114
- ),
115
- );
117
+ );
118
+
119
+ i++;
120
+ if (i < data.length) {
121
+ setTimeout(post, DAUM_MIN_INTERVAL);
122
+ }
123
+ }
124
+
125
+ post();
116
126
  }
117
127
 
118
128
  module.exports = spellCheck;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hanspell",
3
- "version": "0.9.3",
3
+ "version": "0.9.4",
4
4
  "description": "(주)다음과 부산대학교 인공지능연구실/(주)나라인포테크의 온라인 서비스를 이용한 한글 맞춤법 검사기.",
5
5
  "homepage": "https://github.com/9beach/hanspell",
6
6
  "author": {
@@ -42,7 +42,7 @@
42
42
  "html-entities": "^1.2.1",
43
43
  "minimatch": "^3.0.4",
44
44
  "readline": "^1.3.0",
45
- "request": "^2.87.0",
45
+ "request": "^2.65.0",
46
46
  "unescape": "^1.0.1"
47
47
  },
48
48
  "devDependencies": {