Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

scoped-regex

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

scoped-regex - npm Package Compare versions

Comparing version 2.1.0 to 3.0.0

49

index.d.ts

@@ -1,37 +0,26 @@

declare namespace scopedRegex {
interface Options {
/**
Only match an exact string. By default, it matches any scoped package names in a string. Useful with `RegExp#test()` to check if a string is a scoped package name.
export interface Options {
/**
Only match an exact string. By default, it matches any scoped package names in a string. Useful with `RegExp#test()` to check if a string is a scoped package name.
@default false
*/
readonly exact?: boolean;
}
@default false
*/
readonly exact?: boolean;
}
declare const scopedRegex: {
/**
Regular expression for matching [scoped npm package names](https://docs.npmjs.com/misc/scope).
/**
Regular expression for matching [scoped npm package names](https://docs.npmjs.com/misc/scope).
@returns A `RegExp` for matching scoped package names.
@returns A `RegExp` for matching scoped package names.
@example
```
import scopedRegex = require('scoped-regex');
@example
```
import scopedRegex from 'scoped-regex';
scopedRegex({exact: true}).test('@sindresorhus/df');
//=> true
scopedRegex({exact: true}).test('@sindresorhus/df');
//=> true
'foo @sindresorhus/df bar'.match(scopedRegex());
//=> ['@sindresorhus/df']
```
*/
(options?: scopedRegex.Options): RegExp;
// TODO: Remove this for the next major release, refactor the whole definition to:
// declare function scopedRegex(options?: scopedRegex.Options): RegExp;
// export = scopedRegex;
default: typeof scopedRegex;
};
export = scopedRegex;
'foo @sindresorhus/df bar'.match(scopedRegex());
//=> ['@sindresorhus/df']
```
*/
export default function scopedRegex(options?: Options): RegExp;

@@ -1,12 +0,7 @@

'use strict';
const regex = '@[a-z\\d][\\w-.]+/[a-z\\d][\\w-.]*';
const scopedRegex = options =>
options && options.exact ?
export default function scopedRegex(options) {
return options && options.exact ?
new RegExp(`^${regex}$`, 'i') :
new RegExp(regex, 'gi');
module.exports = scopedRegex;
// TODO: Remove this for the next major release
module.exports.default = scopedRegex;
}
{
"name": "scoped-regex",
"version": "2.1.0",
"version": "3.0.0",
"description": "Regular expression for matching scoped npm package names",
"license": "MIT",
"repository": "sindresorhus/scoped-regex",
"funding": "https://github.com/sponsors/sindresorhus",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
"url": "https://sindresorhus.com"
},
"type": "module",
"exports": "./index.js",
"engines": {
"node": ">=8"
"node": ">=12"
},

@@ -33,6 +36,6 @@ "scripts": {

"devDependencies": {
"ava": "^1.4.1",
"tsd": "^0.7.2",
"xo": "^0.24.0"
"ava": "^3.15.0",
"tsd": "^0.14.0",
"xo": "^0.38.2"
}
}

@@ -1,6 +0,5 @@

# scoped-regex [![Build Status](https://travis-ci.org/sindresorhus/scoped-regex.svg?branch=master)](https://travis-ci.org/sindresorhus/scoped-regex)
# scoped-regex
> Regular expression for matching [scoped npm package names](https://docs.npmjs.com/misc/scope)
## Install

@@ -12,7 +11,6 @@

## Usage
```js
const scopedRegex = require('scoped-regex');
import scopedRegex from 'scoped-regex';

@@ -26,6 +24,5 @@ scopedRegex({exact: true}).test('@sindresorhus/df');

## API
### scopedRegex([options])
### scopedRegex(options?)

@@ -36,7 +33,7 @@ Returns a `RegExp` for matching scoped package names.

Type: `Object`
Type: `object`
##### exact
Type: `boolean`<br>
Type: `boolean`\
Default: `false` *(Matches any scoped package names in a string)*

@@ -46,10 +43,4 @@

## Related
- [is-scoped](https://github.com/sindresorhus/is-scoped) - Check if a string is a scoped npm package name
## License
MIT © [Sindre Sorhus](https://sindresorhus.com)

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc