File tree Expand file tree Collapse file tree 6 files changed +35
-3
lines changed Expand file tree Collapse file tree 6 files changed +35
-3
lines changed Original file line number Diff line number Diff line change 15
15
uses : fastify/workflows/.github/workflows/plugins-ci.yml@v3
16
16
with :
17
17
license-check : true
18
+ lint : true
Original file line number Diff line number Diff line change
1
+ package-lock = false
Original file line number Diff line number Diff line change 3
3
const parse = require ( 'ret' )
4
4
const types = parse . types
5
5
6
- module . exports = function ( re , opts ) {
6
+ function safeRegex ( re , opts ) {
7
7
if ( ! opts ) opts = { }
8
8
const replimit = opts . limit === undefined ? 25 : opts . limit
9
9
@@ -46,3 +46,7 @@ module.exports = function (re, opts) {
46
46
function isRegExp ( x ) {
47
47
return { } . toString . call ( x ) === '[object RegExp]'
48
48
}
49
+
50
+ module . exports = safeRegex
51
+ module . exports . default = safeRegex
52
+ module . exports . safeRegex = safeRegex
Original file line number Diff line number Diff line change 3
3
"version" : " 3.0.0" ,
4
4
"description" : " detect possibly catastrophic, exponential-time regular expressions" ,
5
5
"main" : " index.js" ,
6
+ "types" : " types/index.d.ts" ,
6
7
"dependencies" : {
7
8
"ret" : " ~0.4.0"
8
9
},
9
10
"devDependencies" : {
10
11
"standard" : " ^17.0.0" ,
11
- "tape" : " ^5.0.0"
12
+ "tape" : " ^5.0.0" ,
13
+ "tsd" : " ^0.25.0"
12
14
},
13
15
"scripts" : {
14
- "test" : " standard && tape test/*.js"
16
+ "lint" : " standard" ,
17
+ "test" : " npm run test:unit" ,
18
+ "test:typescript" : " tsd" ,
19
+ "test:unit" : " tape test/*.js"
15
20
},
16
21
"repository" : {
17
22
"type" : " git" ,
Original file line number Diff line number Diff line change
1
+ type SafeRegex2 = ( re : string | RegExp , opts ?: { limit ?: number } ) => boolean
2
+
3
+ declare namespace safeRegex {
4
+ export const safeRegex : SafeRegex2
5
+ export { safeRegex as default }
6
+ }
7
+
8
+ declare function safeRegex ( ...params : Parameters < SafeRegex2 > ) : ReturnType < SafeRegex2 >
9
+ export = safeRegex
Original file line number Diff line number Diff line change
1
+ import safeRegex , { safeRegex as safeRegexNamed } from '..'
2
+ import { expectType } from 'tsd'
3
+
4
+ expectType < boolean > ( safeRegex ( 'regex' ) )
5
+ expectType < boolean > ( safeRegex ( / r e g e x / ) )
6
+ expectType < boolean > ( safeRegex ( '^([a-zA-Z0-9]+\\s?)+$' ) )
7
+ expectType < boolean > ( safeRegex ( / ^ ( [ a - z A - Z 0 - 9 ] + \s ? ) + $ / g) )
8
+
9
+ expectType < boolean > ( safeRegexNamed ( 'regex' ) )
10
+ expectType < boolean > ( safeRegexNamed ( / r e g e x / ) )
11
+ expectType < boolean > ( safeRegexNamed ( '^([a-zA-Z0-9]+\\s?)+$' ) )
12
+ expectType < boolean > ( safeRegexNamed ( / ^ ( [ a - z A - Z 0 - 9 ] + \s ? ) + $ / g) )
You can’t perform that action at this time.
0 commit comments