回答編集履歴
1
追記
test
CHANGED
@@ -91,3 +91,93 @@
|
|
91
91
|
}
|
92
92
|
|
93
93
|
```
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
### 追記
|
98
|
+
|
99
|
+
↓これでレーベンシュタイン距離を23にすることができました!
|
100
|
+
|
101
|
+
```js
|
102
|
+
|
103
|
+
let Looptest = function() {
|
104
|
+
|
105
|
+
this.num = 0;
|
106
|
+
|
107
|
+
}
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
Looptest.prototype = {
|
112
|
+
|
113
|
+
aaa: function() {
|
114
|
+
|
115
|
+
let defer = $.Deferred();
|
116
|
+
|
117
|
+
setTimeout(function() {
|
118
|
+
|
119
|
+
console.log('setTimeout')
|
120
|
+
|
121
|
+
defer.resolve();
|
122
|
+
|
123
|
+
}, 500);
|
124
|
+
|
125
|
+
return defer.promise();
|
126
|
+
|
127
|
+
},
|
128
|
+
|
129
|
+
bbb: function(defer) {
|
130
|
+
|
131
|
+
let self = this;
|
132
|
+
|
133
|
+
letdefer = $.Deferred();
|
134
|
+
|
135
|
+
let promise = self.aaa();
|
136
|
+
|
137
|
+
promise.done(function() {
|
138
|
+
|
139
|
+
// 5に達したら、resolveさせたい
|
140
|
+
|
141
|
+
self.num = self.num + 1;
|
142
|
+
|
143
|
+
if (self.num < 5) {
|
144
|
+
|
145
|
+
console.log(self.num)
|
146
|
+
|
147
|
+
self.bbb(defer);
|
148
|
+
|
149
|
+
}
|
150
|
+
|
151
|
+
else {
|
152
|
+
|
153
|
+
defer.resolve();
|
154
|
+
|
155
|
+
}
|
156
|
+
|
157
|
+
});
|
158
|
+
|
159
|
+
return defer.promise();
|
160
|
+
|
161
|
+
}
|
162
|
+
|
163
|
+
}
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
function xxx() {
|
168
|
+
|
169
|
+
let lt = new Looptest();
|
170
|
+
|
171
|
+
let promise = lt.bbb($.Deferred());
|
172
|
+
|
173
|
+
promise.done(function() {
|
174
|
+
|
175
|
+
console.log('success!');
|
176
|
+
|
177
|
+
})
|
178
|
+
|
179
|
+
}
|
180
|
+
|
181
|
+
```
|
182
|
+
|
183
|
+
(ネタです)
|