projecte_ionic/node_modules/core-js/modules/es.regexp.sticky.js
2022-02-09 18:30:03 +01:00

23 lines
890 B
JavaScript
Executable file

var DESCRIPTORS = require('../internals/descriptors');
var UNSUPPORTED_Y = require('../internals/regexp-sticky-helpers').UNSUPPORTED_Y;
var defineProperty = require('../internals/object-define-property').f;
var getInternalState = require('../internals/internal-state').get;
var RegExpPrototype = RegExp.prototype;
// `RegExp.prototype.sticky` getter
// https://tc39.es/ecma262/#sec-get-regexp.prototype.sticky
if (DESCRIPTORS && UNSUPPORTED_Y) {
defineProperty(RegExpPrototype, 'sticky', {
configurable: true,
get: function () {
if (this === RegExpPrototype) return undefined;
// We can't use InternalStateModule.getterFor because
// we don't add metadata for regexps created by a literal.
if (this instanceof RegExp) {
return !!getInternalState(this).sticky;
}
throw TypeError('Incompatible receiver, RegExp required');
}
});
}