|
1 | 1 | 'use strict'; |
2 | 2 |
|
3 | | -let async = require('async'); |
4 | | -let config = require('./config/config'); |
5 | | -let path = require('path'); |
6 | | -let maxmind = require('maxmind'); |
7 | | -let ipaddr = require('ipaddr.js'); |
| 3 | +const async = require('async'); |
| 4 | +const config = require('./config/config'); |
| 5 | +const maxmind = require('maxmind'); |
| 6 | +const ipaddr = require('ipaddr.js'); |
| 7 | +const cloneDeep = require('lodash.clonedeep'); |
8 | 8 |
|
9 | 9 | let Logger; |
10 | 10 | let cityLookup = null; |
@@ -148,18 +148,6 @@ function _getCountryCode(cityData) { |
148 | 148 | return 'O1'; |
149 | 149 | } |
150 | 150 |
|
151 | | -const cloneDeep = (entity, cache = new WeakMap()) => { |
152 | | - const referenceTypes = ['Array', 'Object']; |
153 | | - const entityType = Object.prototype.toString.call(entity); |
154 | | - if (!new RegExp(referenceTypes.join('|')).test(entityType)) return entity; |
155 | | - if (cache.has(entity)) { |
156 | | - return cache.get(entity); |
157 | | - } |
158 | | - const c = new entity.constructor(); |
159 | | - cache.set(entity, c); |
160 | | - return Object.assign(c, ...Object.keys(entity).map((prop) => ({ [prop]: cloneDeep(entity[prop], cache) }))); |
161 | | -}; |
162 | | - |
163 | 151 | function _lookupIp(entityObj, countryBlacklist, countryWhitelist, options, cb) { |
164 | 152 | let cityData = cityLookup.getWithRoutingPrefix(entityObj.value); |
165 | 153 | let asnData = asnLookup.getWithRoutingPrefix(entityObj.value); |
|
0 commit comments