Skip to content

Commit

Permalink
add flatmap support
Browse files Browse the repository at this point in the history
  • Loading branch information
ArrayIterator authored and song940 committed Nov 13, 2023
1 parent ee73604 commit b2fdf66
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packet.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ const fromIPv6 = (address) => {
if (digits[digits.length - 1] === '') {
digits.pop();
}
// node js 10 does not support Array.prototype.flatMap
if (!Array.prototype.flatMap) {
// eslint-disable-next-line no-extend-native
Array.prototype.flatMap = function(f, ctx) {
return this.reduce((r, x, i, a) => r.concat(f.call(ctx, x, i, a)), []);
};
}

// CAVEAT we have to take into account
// the extra space used by the empty string
const missingFields = 8 - digits.length + 1;
Expand Down

0 comments on commit b2fdf66

Please sign in to comment.