regexp.prototype.flags (1.5.4)
Published 2026-02-24 14:04:14 +00:00 by atheaadmin
Installation
registry=npm install regexp.prototype.flags@1.5.4"regexp.prototype.flags": "1.5.4"About this package
An ES6 spec-compliant RegExp.prototype.flags shim. Invoke its "shim" method to shim RegExp.prototype.flags if it is unavailable.
Note: RegExp#flags requires a true ES5 environment - specifically, one with ES5 getters.
This package implements the es-shim API interface. It works in an ES5-supported environment and complies with the spec.
Most common usage:
var flags = require('regexp.prototype.flags');
var assert = require('assert');
assert(flags(/a/) === '');
assert(flags(new RegExp('a')) === '');
assert(flags(/a/mig) === 'gim');
assert(flags(new RegExp('a', 'mig')) === 'gim');
if (!RegExp.prototype.flags) {
flags.shim();
}
assert(flags(/a/) === /a/.flags);
assert(flags(new RegExp('a')) === new RegExp('a').flags);
assert(flags(/a/mig) === /a/mig.flags);
assert(flags(new RegExp('a', 'mig')) === new RegExp('a', 'mig').flags);
Tests
Simply clone the repo, npm install, and run npm test
Dependencies
Dependencies
| ID | Version |
|---|---|
| call-bind | ^1.0.8 |
| define-properties | ^1.2.1 |
| es-errors | ^1.3.0 |
| get-proto | ^1.0.1 |
| gopd | ^1.2.0 |
| set-function-name | ^2.0.2 |
Development Dependencies
| ID | Version |
|---|---|
| @es-shims/api | ^2.5.1 |
| @ljharb/eslint-config | ^21.1.1 |
| auto-changelog | ^2.5.0 |
| available-regexp-flags | ^1.0.4 |
| eclint | ^2.8.1 |
| encoding | ^0.1.13 |
| es-value-fixtures | ^1.5.0 |
| eslint | =8.8.0 |
| evalmd | ^0.0.19 |
| for-each | ^0.3.3 |
| functions-have-names | ^1.2.3 |
| has-strict-mode | ^1.0.1 |
| hasown | ^2.0.2 |
| in-publish | ^2.0.1 |
| npmignore | ^0.3.1 |
| nyc | ^10.3.2 |
| object-inspect | ^1.13.3 |
| safe-publish-latest | ^2.0.0 |
| tape | ^5.9.0 |
Keywords
RegExp.prototype.flags
regex
regular expression
ES6
shim
flag
flags
regexp
RegExp#flags
polyfill
es-shim API

