dav
dav copied to clipboard
Please don't change Array.prototype, it may interfere with other libraries.
- This is generally a bad practice.
- After an hour of debugging my app, I found the cause is in
dav:angry:
Example:
$ npm i phone dav
$ node
> var phone = require('phone')
undefined
> phone('+79167045979')
[ '+79167045979', 'RUS' ]
> var dav = require('dav')
undefined
> phone('+79167045979')
SyntaxError: Invalid regular expression: /^7function (predicate) {
if (this == null) {
throw new TypeError('Array.prototype.find called on null or undefined');
}
if (typeof predicate !== 'function') {
throw new TypeError('predicate must be a function');
}
var list = Object(this);
var length = list.length >>> 0;
var thisArg = arguments[1];
var value;
for (var i = 0; i < length; i++) {
value = list[i];
if (predicate.call(thisArg, value, i, list)) {
return value;
}
}
return undefined;
}/: Nothing to repeat
at new RegExp (<anonymous>)
at get_iso3166_by_phone (/Users/ksaitor/www/ksaitor/meetapp/api/node_modules/phone/lib/index.js:337:22)
at module.exports (/Users/ksaitor/www/ksaitor/meetapp/api/node_modules/phone/lib/index.js:425:14)
at repl:1:2
at REPLServer.self.eval (repl.js:110:21)
at Interface.<anonymous> (repl.js:239:12)
at Interface.emit (events.js:95:17)
at Interface._onLine (readline.js:203:10)
at Interface._line (readline.js:532:8)
at Interface._ttyWrite (readline.js:761:14)
This is a common issue, but we can still polyfill by not assigning to the prototype directly but creating a non-enumerable property on it using Object.defineProperty.