Remove 'includes' API, fix CI build failure#2574
Conversation
| */ | ||
| function isBuffer(val) { | ||
| return ![undefined, null].includes(val) && val.constructor === Buffer; | ||
| if (val === null || val === void 0 || val.constructor === null || val.constructor === void 0 ) return false; |
There was a problem hiding this comment.
what's the difference between using void 0 and undefined?
There was a problem hiding this comment.
undefined is not a reserved word in javascript, so it can be rewritten. void 0 is stricter.
There was a problem hiding this comment.
we rely on type of x === 'undefined' throughout the file, might be better to be consistent, also are there cases where the constructor can be null? could it be sufficient to just check !isUndefined(val.constructor), also we can just use our own helper? isUndefined, what do you think?
There was a problem hiding this comment.
I agree to use isUndefined, and I suggest to replace all the other undefined judgement with our own helper function isUndefined, if you agree, then I will submit a PR.
if constructor has been overwriten with null (extreme paticular case), then typeof val.constructor.isBuffer === 'function' will report an error.
@chinesedfan because we have to obey the 3 rules of eslint:
|
Changes:
Error message: "Object doesn't support property or method 'includes' to equal."
Reason: 'includes' belongs to the API of
ES7,ie11does not support it.https://github.com/axios/axios/blob/master/lib/utils.js#L29
Related PR Remove dependency on is-buffer #1816