This app provides monitoring and information features for the common freifunk user and the technical stuff of a freifunk community.
Code base is taken from a TUM Practical Course project and added here to see if Freifunk Altdorf can use it.
https://www.freifunk-altdorf.de
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
918 B
39 lines
918 B
'use strict'; |
|
|
|
var has = require('has'); |
|
var regexExec = RegExp.prototype.exec; |
|
var gOPD = Object.getOwnPropertyDescriptor; |
|
|
|
var tryRegexExecCall = function tryRegexExec(value) { |
|
try { |
|
var lastIndex = value.lastIndex; |
|
value.lastIndex = 0; |
|
|
|
regexExec.call(value); |
|
return true; |
|
} catch (e) { |
|
return false; |
|
} finally { |
|
value.lastIndex = lastIndex; |
|
} |
|
}; |
|
var toStr = Object.prototype.toString; |
|
var regexClass = '[object RegExp]'; |
|
var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol'; |
|
|
|
module.exports = function isRegex(value) { |
|
if (!value || typeof value !== 'object') { |
|
return false; |
|
} |
|
if (!hasToStringTag) { |
|
return toStr.call(value) === regexClass; |
|
} |
|
|
|
var descriptor = gOPD(value, 'lastIndex'); |
|
var hasLastIndexDataProperty = descriptor && has(descriptor, 'value'); |
|
if (!hasLastIndexDataProperty) { |
|
return false; |
|
} |
|
|
|
return tryRegexExecCall(value); |
|
};
|
|
|