Last change
on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
890 bytes
|
Line | |
---|
1 | var DESCRIPTORS = require('../internals/descriptors');
|
---|
2 | var UNSUPPORTED_Y = require('../internals/regexp-sticky-helpers').UNSUPPORTED_Y;
|
---|
3 | var defineProperty = require('../internals/object-define-property').f;
|
---|
4 | var getInternalState = require('../internals/internal-state').get;
|
---|
5 | var RegExpPrototype = RegExp.prototype;
|
---|
6 |
|
---|
7 | // `RegExp.prototype.sticky` getter
|
---|
8 | // https://tc39.es/ecma262/#sec-get-regexp.prototype.sticky
|
---|
9 | if (DESCRIPTORS && UNSUPPORTED_Y) {
|
---|
10 | defineProperty(RegExpPrototype, 'sticky', {
|
---|
11 | configurable: true,
|
---|
12 | get: function () {
|
---|
13 | if (this === RegExpPrototype) return undefined;
|
---|
14 | // We can't use InternalStateModule.getterFor because
|
---|
15 | // we don't add metadata for regexps created by a literal.
|
---|
16 | if (this instanceof RegExp) {
|
---|
17 | return !!getInternalState(this).sticky;
|
---|
18 | }
|
---|
19 | throw TypeError('Incompatible receiver, RegExp required');
|
---|
20 | }
|
---|
21 | });
|
---|
22 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.