haipingzi

Results 13 comments of haipingzi

```javascript Promise.retry = function (callback) { return new this(callback) .then((res) => { return res; }) .catch(() => { return new this(callback); }); }; Promise.retry((resolve, reject) => { setTimeout(() => {...

```javascript Promise.retry = function (callback, count = 1) { const retryHandle = () => { return new this(callback) .then((res) => { return res; }) .catch((error) => { count--; console.log(count); if...

function getIndex(arr) { const [, minIndex] = arr.reduce( ([min, minIndex], el, index) => { if (el > 0 && (minIndex === -1 || min > el)) { return [el, index];...

```javascript function getIndex(arr) { const [, minIndex] = arr.reduce( ([min, minIndex], el, index) => { if (el > 0 && (minIndex === -1 || min > el)) { return [el,...

```javascript function multiRequest(urls, maxNum) { const dl = []; const resArr = []; let maxIndx = 0; function getPromise(i, curIndex) { maxIndx++; return new Promise((resolve, reject) => { console.log("开始" +...

```javascript Array.prototype._indexOf = function (val, start) { if (typeof start !== "number") start = 0; //start 非数字 if (start < 0) start = start + this.length //start 小于零 const index...

```javascript String.prototype._indexOf = function (val, start) { if (typeof start !== "number") start = 0; // start非数字 start = Math.min(Math.max(0, start), this.length) // start大于等于0小于字符串的长度 if (val === '') return start;...

```javascript Array.prototype._splice = function (start, count, ...replaceEl) { if (typeof start !== "number") throw new Error("start not a number"); if (typeof count !== "number") throw new Error("count not a number");...

> ```js > Array.prototype.splice2 = function(start, count, ...addList) { > if (start < 0) { > if (Math.abs(start) > this.length) { > start = 0 > } else { >...

> ```js > Array.prototype._splice = function (start, deleteCount, ...addList) { > if (start < 0) { > if (Math.abs(start) > this.length) { > start = 0 > } else {...