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

string-matches

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

string-matches - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

20

dist/index.js

@@ -5,12 +5,18 @@ /* STRING MATCHES */

function stringMatches(str, regex) {
var matches = [];
var match;
regex.lastIndex = 0;
while (match = regex.exec(str)) {
matches.push(match);
if (regex.flags.indexOf('g') >= 0) {
var matches = [];
var match = void 0;
regex.lastIndex = 0;
while (match = regex.exec(str)) {
matches.push(match);
}
return matches;
}
return matches;
else {
var match = regex.exec(str);
return match ? [match] : [];
}
}
/* EXPORT */
exports.default = stringMatches;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0Esb0JBQW9COzs7QUFFcEIsdUJBQXlCLEdBQVcsRUFBRSxLQUFhO0lBRWpELElBQU0sT0FBTyxHQUFzQixFQUFFLENBQUM7SUFFdEMsSUFBSSxLQUFLLENBQUM7SUFFVixLQUFLLENBQUMsU0FBUyxHQUFHLENBQUMsQ0FBQztJQUVwQixPQUFRLEtBQUssR0FBRyxLQUFLLENBQUMsSUFBSSxDQUFHLEdBQUcsQ0FBRSxFQUFHLENBQUM7UUFFcEMsT0FBTyxDQUFDLElBQUksQ0FBRyxLQUFLLENBQUUsQ0FBQztJQUV6QixDQUFDO0lBRUQsTUFBTSxDQUFDLE9BQU8sQ0FBQztBQUVqQixDQUFDO0FBRUQsWUFBWTtBQUVaLGtCQUFlLGFBQWEsQ0FBQyJ9
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0Esb0JBQW9COzs7QUFFcEIsdUJBQXlCLEdBQVcsRUFBRSxLQUFhO0lBRWpELEVBQUUsQ0FBQyxDQUFFLEtBQUssQ0FBQyxLQUFLLENBQUMsT0FBTyxDQUFHLEdBQUcsQ0FBRSxJQUFJLENBQUUsQ0FBQyxDQUFDLENBQUM7UUFFdkMsSUFBTSxPQUFPLEdBQXNCLEVBQUUsQ0FBQztRQUV0QyxJQUFJLEtBQUssU0FBQSxDQUFDO1FBRVYsS0FBSyxDQUFDLFNBQVMsR0FBRyxDQUFDLENBQUM7UUFFcEIsT0FBUSxLQUFLLEdBQUcsS0FBSyxDQUFDLElBQUksQ0FBRyxHQUFHLENBQUUsRUFBRyxDQUFDO1lBRXBDLE9BQU8sQ0FBQyxJQUFJLENBQUcsS0FBSyxDQUFFLENBQUM7UUFFekIsQ0FBQztRQUVELE1BQU0sQ0FBQyxPQUFPLENBQUM7SUFFakIsQ0FBQztJQUFDLElBQUksQ0FBQyxDQUFDO1FBRU4sSUFBTSxLQUFLLEdBQUcsS0FBSyxDQUFDLElBQUksQ0FBRyxHQUFHLENBQUUsQ0FBQztRQUVqQyxNQUFNLENBQUMsS0FBSyxHQUFHLENBQUMsS0FBSyxDQUFDLEdBQUcsRUFBRSxDQUFDO0lBRTlCLENBQUM7QUFFSCxDQUFDO0FBRUQsWUFBWTtBQUVaLGtCQUFlLGFBQWEsQ0FBQyJ9
{
"name": "string-matches",
"version": "1.0.2",
"version": "1.0.3",
"description": "Retrieves all the matches of a regex in a string.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -6,16 +6,26 @@

const matches: RegExpExecArray[] = [];
if ( regex.flags.indexOf ( 'g' ) >= 0 ) {
let match;
const matches: RegExpExecArray[] = [];
regex.lastIndex = 0;
let match;
while ( match = regex.exec ( str ) ) {
regex.lastIndex = 0;
matches.push ( match );
while ( match = regex.exec ( str ) ) {
matches.push ( match );
}
return matches;
} else {
const match = regex.exec ( str );
return match ? [match] : [];
}
return matches;
}

@@ -22,0 +32,0 @@

@@ -22,2 +22,11 @@

it ( 'Work with non-global regexes too', t => {
const test = 'A tidy tiger tied a tighter tie to tidy her tiny tail',
matches = stringMatches ( test, /tidy/ );
t.is ( matches.length, 1 );
});
});
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