regexp-support
Advanced tools
Comparing version
/** | ||
* Created by user on 2018/4/26/026. | ||
*/ | ||
import lib from './lib'; | ||
import libPattern from './lib/pattern'; | ||
import { hasSupportFlag, testFlag } from './lib'; | ||
import { FlagsName } from './lib/flags'; | ||
import { testPattern } from './lib/pattern'; | ||
export declare const support: Readonly<{ | ||
@@ -83,6 +84,14 @@ nativeFlags: string; | ||
}; | ||
symbol: { | ||
species: boolean; | ||
match: boolean; | ||
replace: boolean; | ||
search: boolean; | ||
split: boolean; | ||
}; | ||
}>; | ||
export import hasSupportFlag = lib.hasSupportFlag; | ||
export import testFlag = lib.testFlag; | ||
export import testPattern = libPattern.testPattern; | ||
export import FlagsName = FlagsName; | ||
export { hasSupportFlag }; | ||
export { testFlag }; | ||
export { testPattern }; | ||
export default support; |
19
index.js
@@ -7,14 +7,18 @@ "use strict"; | ||
const lib_1 = require("./lib"); | ||
exports.hasSupportFlag = lib_1.hasSupportFlag; | ||
exports.testFlag = lib_1.testFlag; | ||
const flags_1 = require("./lib/flags"); | ||
const index_1 = require("./lib/index"); | ||
const pattern_1 = require("./lib/pattern"); | ||
exports.testPattern = pattern_1.testPattern; | ||
const prototype_1 = require("./lib/proto/prototype"); | ||
const static_1 = require("./lib/proto/static"); | ||
const symbol_1 = require("./lib/symbol"); | ||
const _support = { | ||
nativeFlags: '', | ||
/** | ||
* flag support with name | ||
* flag support with name and pattern test | ||
*/ | ||
flags: Object | ||
.keys(flags_1.default) | ||
.keys(flags_1.FlagsName) | ||
.reduce(function (a, flags) { | ||
@@ -25,7 +29,7 @@ let bool = false; | ||
} | ||
else if (flags_1.default[flags] in a) { | ||
bool = a[flags_1.default[flags]]; | ||
else if (flags_1.FlagsName[flags] in a) { | ||
bool = a[flags_1.FlagsName[flags]]; | ||
} | ||
else { | ||
bool = lib_1.hasSupportFlag(flags_1.default[flags]); | ||
bool = lib_1.hasSupportFlag(flags_1.FlagsName[flags]); | ||
} | ||
@@ -49,2 +53,3 @@ a[flags] = bool; | ||
static: static_1.testStatic(), | ||
symbol: symbol_1.testSymbol(), | ||
}; | ||
@@ -61,5 +66,3 @@ _support.nativeFlags = Object | ||
exports.support = Object.freeze(_support); | ||
exports.hasSupportFlag = lib_1.default.hasSupportFlag; | ||
exports.testFlag = lib_1.default.testFlag; | ||
exports.testPattern = pattern_1.default.testPattern; | ||
exports.FlagsName = flags_1.FlagsName; | ||
exports.default = exports.support; |
15
index.ts
@@ -6,3 +6,3 @@ /** | ||
import lib, { hasSupportFlag, testFlag, ICreateRegExp, IFlagsAll, ITypeCreateRegExp } from './lib'; | ||
import FlagsName from './lib/flags'; | ||
import { FlagsName } from './lib/flags'; | ||
import { testFlagsAll } from './lib/index'; | ||
@@ -12,2 +12,3 @@ import libPattern, { PatternSupport, testPattern, IPatternTestFn, IPatternTestRow } from './lib/pattern'; | ||
import { testStatic } from './lib/proto/static'; | ||
import { testSymbol } from './lib/symbol'; | ||
@@ -19,3 +20,3 @@ const _support = { | ||
/** | ||
* flag support with name | ||
* flag support with name and pattern test | ||
*/ | ||
@@ -67,2 +68,4 @@ flags: Object | ||
static: testStatic(), | ||
symbol: testSymbol(), | ||
}; | ||
@@ -86,8 +89,10 @@ | ||
export import hasSupportFlag = lib.hasSupportFlag | ||
export import testFlag = lib.testFlag | ||
export import testPattern = libPattern.testPattern | ||
export import FlagsName = FlagsName | ||
export { hasSupportFlag }; | ||
export { testFlag }; | ||
export { testPattern }; | ||
type valueof<T> = T[keyof T]; | ||
export default support |
@@ -9,10 +9,68 @@ /** | ||
export declare type IRegExpStatic = typeof RegExp & { | ||
/** | ||
* RegExp.input ($_) | ||
* | ||
* The non-standard input property is a static property of regular expressions that contains the string against which a regular expression is matched. | ||
* RegExp.$_ is an alias for this property. | ||
* | ||
* @code var re = /hi/g; | ||
re.test('hi there!'); | ||
RegExp.input; // "hi there!" | ||
re.test('foo'); // new test, non-matching | ||
RegExp.$_; // "hi there!" | ||
re.test('hi world!'); // new test, matching | ||
RegExp.$_; // "hi world!" | ||
*/ | ||
input: string; | ||
$_: string; | ||
/** | ||
* RegExp.lastMatch ($&) | ||
* | ||
* The non-standard lastMatch property is a static and read-only property of regular expressions that contains the last matched characters. | ||
* RegExp.$& is an alias for this property. | ||
* | ||
* @code var re = /hi/g; | ||
re.test('hi there!'); | ||
RegExp.lastMatch; // "hi" | ||
RegExp['$&']; // "hi" | ||
*/ | ||
lastMatch: string; | ||
'$&': string; | ||
/** | ||
* RegExp.lastParen ($+) | ||
* | ||
* The non-standard lastParen property is a static and read-only property of regular expressions that contains the last parenthesized substring match, if any. | ||
* RegExp.$+ is an alias for this property. | ||
* | ||
* @code var re = /(hi)/g; | ||
re.test('hi there!'); | ||
RegExp.lastParen; // "hi" | ||
RegExp['$+']; // "hi" | ||
*/ | ||
lastParen: string; | ||
'$+': string; | ||
/** | ||
* RegExp.leftContext ($`) | ||
* | ||
* The non-standard leftContext property is a static and read-only property of regular expressions that contains the substring preceding the most recent match. | ||
* RegExp.$` is an alias for this property. | ||
* | ||
* @code var re = /world/g; | ||
re.test('hello world!'); | ||
RegExp.leftContext; // "hello " | ||
RegExp['$`']; // "hello " | ||
*/ | ||
leftContext: string; | ||
'$`': string; | ||
/** | ||
* RegExp.rightContext ($') | ||
* | ||
* The non-standard rightContext property is a static and read-only property of regular expressions that contains the substring following the most recent match. | ||
* RegExp.$' is an alias for this property. | ||
* | ||
* @code var re = /hello/g; | ||
re.test('hello world!'); | ||
RegExp.rightContext; // " world!" | ||
RegExp["$'"]; // " world!" | ||
*/ | ||
rightContext: string; | ||
@@ -19,0 +77,0 @@ '$\'': string; |
@@ -16,5 +16,5 @@ "use strict"; | ||
$9: false, | ||
lastMatch: false, | ||
input: false, | ||
$_: false, | ||
lastMatch: false, | ||
'$&': false, | ||
@@ -21,0 +21,0 @@ lastParen: false, |
@@ -13,11 +13,72 @@ /** | ||
/** | ||
* RegExp.input ($_) | ||
* | ||
* The non-standard input property is a static property of regular expressions that contains the string against which a regular expression is matched. | ||
* RegExp.$_ is an alias for this property. | ||
* | ||
* @code var re = /hi/g; | ||
re.test('hi there!'); | ||
RegExp.input; // "hi there!" | ||
re.test('foo'); // new test, non-matching | ||
RegExp.$_; // "hi there!" | ||
re.test('hi world!'); // new test, matching | ||
RegExp.$_; // "hi world!" | ||
*/ | ||
input: string, | ||
$_: string, | ||
/** | ||
* RegExp.lastMatch ($&) | ||
* | ||
* The non-standard lastMatch property is a static and read-only property of regular expressions that contains the last matched characters. | ||
* RegExp.$& is an alias for this property. | ||
* | ||
* @code var re = /hi/g; | ||
re.test('hi there!'); | ||
RegExp.lastMatch; // "hi" | ||
RegExp['$&']; // "hi" | ||
*/ | ||
lastMatch: string, | ||
'$&': string, | ||
/** | ||
* RegExp.lastParen ($+) | ||
* | ||
* The non-standard lastParen property is a static and read-only property of regular expressions that contains the last parenthesized substring match, if any. | ||
* RegExp.$+ is an alias for this property. | ||
* | ||
* @code var re = /(hi)/g; | ||
re.test('hi there!'); | ||
RegExp.lastParen; // "hi" | ||
RegExp['$+']; // "hi" | ||
*/ | ||
lastParen: string, | ||
'$+': string, | ||
/** | ||
* RegExp.leftContext ($`) | ||
* | ||
* The non-standard leftContext property is a static and read-only property of regular expressions that contains the substring preceding the most recent match. | ||
* RegExp.$` is an alias for this property. | ||
* | ||
* @code var re = /world/g; | ||
re.test('hello world!'); | ||
RegExp.leftContext; // "hello " | ||
RegExp['$`']; // "hello " | ||
*/ | ||
leftContext: string, | ||
'$`': string, | ||
/** | ||
* RegExp.rightContext ($') | ||
* | ||
* The non-standard rightContext property is a static and read-only property of regular expressions that contains the substring following the most recent match. | ||
* RegExp.$' is an alias for this property. | ||
* | ||
* @code var re = /hello/g; | ||
re.test('hello world!'); | ||
RegExp.rightContext; // " world!" | ||
RegExp["$'"]; // " world!" | ||
*/ | ||
rightContext: string, | ||
@@ -47,12 +108,14 @@ '$\'': string, | ||
lastMatch: false, | ||
input: false, | ||
$_: false, | ||
$_: false, | ||
lastMatch: false, | ||
'$&': false, | ||
lastParen: false, | ||
'$+': false, | ||
leftContext: false, | ||
'$`': false, | ||
rightContext: false, | ||
@@ -59,0 +122,0 @@ '$\'': false, |
{ | ||
"name": "regexp-support", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"description": "check RegExp ( regular expressions ) support", | ||
@@ -35,3 +35,3 @@ "keywords": [ | ||
"author": "", | ||
"main": "index.js", | ||
"main": "index", | ||
"directories": { | ||
@@ -38,0 +38,0 @@ "lib": "lib", |
45786
15.5%26
13.04%1555
14.84%