Skip to content

Commit 463f9c1

Browse files
committed
fix(prh): Add RegExp.prototype.flags workaround for Node.js v4
prh/prh#30
1 parent 4c17df6 commit 463f9c1

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/textlint-rule-prh.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
// LICENSE : MIT
22
"use strict";
33
import { RuleHelper } from "textlint-rule-helper";
4+
/**
5+
* RegExp#flags polyfill
6+
*/
7+
if (RegExp.prototype.flags === undefined) {
8+
Object.defineProperty(RegExp.prototype, "flags", {
9+
configurable: true,
10+
get: function() {
11+
return this.toString().match(/[gimuy]*$/)[0];
12+
}
13+
});
14+
}
415

516
const prh = require("prh");
617
const path = require("path");

0 commit comments

Comments
 (0)