[6a3a178] | 1 | RegExp.prototype.flags <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
|
---|
| 2 |
|
---|
| 3 | [![Build Status][travis-svg]][travis-url]
|
---|
| 4 | [![dependency status][deps-svg]][deps-url]
|
---|
| 5 | [![dev dependency status][dev-deps-svg]][dev-deps-url]
|
---|
| 6 | [![License][license-image]][license-url]
|
---|
| 7 | [![Downloads][downloads-image]][downloads-url]
|
---|
| 8 |
|
---|
| 9 | [![npm badge][npm-badge-png]][package-url]
|
---|
| 10 |
|
---|
| 11 | [![browser support][testling-svg]][testling-url]
|
---|
| 12 |
|
---|
| 13 | An ES6 spec-compliant `RegExp.prototype.flags` shim. Invoke its "shim" method to shim RegExp.prototype.flags if it is unavailable.
|
---|
| 14 | *Note*: `RegExp#flags` requires a true ES5 environment - specifically, one with ES5 getters.
|
---|
| 15 |
|
---|
| 16 | This package implements the [es-shim API](https://github.com/es-shims/api) interface. It works in an ES5-supported environment and complies with the [spec](http://www.ecma-international.org/ecma-262/6.0/#sec-get-regexp.prototype.flags).
|
---|
| 17 |
|
---|
| 18 | Most common usage:
|
---|
| 19 | ```js
|
---|
| 20 | var flags = require('regexp.prototype.flags');
|
---|
| 21 |
|
---|
| 22 | assert(flags(/a/) === '');
|
---|
| 23 | assert(flags(new RegExp('a') === '');
|
---|
| 24 | assert(flags(/a/mig) === 'gim');
|
---|
| 25 | assert(flags(new RegExp('a', 'mig')) === 'gim');
|
---|
| 26 |
|
---|
| 27 | if (!RegExp.prototype.flags) {
|
---|
| 28 | flags.shim();
|
---|
| 29 | }
|
---|
| 30 |
|
---|
| 31 | assert(flags(/a/) === /a/.flags);
|
---|
| 32 | assert(flags(new RegExp('a') === new RegExp('a').flags);
|
---|
| 33 | assert(flags(/a/mig) === /a/mig.flags);
|
---|
| 34 | assert(flags(new RegExp('a', 'mig')) === new RegExp('a', 'mig').flags);
|
---|
| 35 | ```
|
---|
| 36 |
|
---|
| 37 | ## Tests
|
---|
| 38 | Simply clone the repo, `npm install`, and run `npm test`
|
---|
| 39 |
|
---|
| 40 | [package-url]: https://npmjs.com/package/regexp.prototype.flags
|
---|
| 41 | [npm-version-svg]: http://versionbadg.es/es-shims/RegExp.prototype.flags.svg
|
---|
| 42 | [travis-svg]: https://travis-ci.org/es-shims/RegExp.prototype.flags.svg
|
---|
| 43 | [travis-url]: https://travis-ci.org/es-shims/RegExp.prototype.flags
|
---|
| 44 | [deps-svg]: https://david-dm.org/es-shims/RegExp.prototype.flags.svg
|
---|
| 45 | [deps-url]: https://david-dm.org/es-shims/RegExp.prototype.flags
|
---|
| 46 | [dev-deps-svg]: https://david-dm.org/es-shims/RegExp.prototype.flags/dev-status.svg
|
---|
| 47 | [dev-deps-url]: https://david-dm.org/es-shims/RegExp.prototype.flags#info=devDependencies
|
---|
| 48 | [testling-svg]: https://ci.testling.com/es-shims/RegExp.prototype.flags.png
|
---|
| 49 | [testling-url]: https://ci.testling.com/es-shims/RegExp.prototype.flags
|
---|
| 50 | [npm-badge-png]: https://nodei.co/npm/regexp.prototype.flags.png?downloads=true&stars=true
|
---|
| 51 | [license-image]: http://img.shields.io/npm/l/regexp.prototype.flags.svg
|
---|
| 52 | [license-url]: LICENSE
|
---|
| 53 | [downloads-image]: http://img.shields.io/npm/dm/regexp.prototype.flags.svg
|
---|
| 54 | [downloads-url]: http://npm-stat.com/charts.html?package=regexp.prototype.flags
|
---|