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

regenerate

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

regenerate - npm Package Compare versions

Comparing version 1.2.1 to 1.3.0

2

package.json
{
"name": "regenerate",
"version": "1.2.1",
"version": "1.3.0",
"description": "Generate JavaScript-compatible regular expressions based on a given set of Unicode symbols or code points.",

@@ -5,0 +5,0 @@ "homepage": "https://mths.be/regenerate",

@@ -1,2 +0,2 @@

/*! https://mths.be/regenerate v1.2.0 by @mathias | MIT license */
/*! https://mths.be/regenerate v1.3.0 by @mathias | MIT license */
;(function(root) {

@@ -11,3 +11,3 @@

// Detect free variable `global`, from Node.js or Browserified code,
// Detect free variable `global`, from Node.js/io.js or Browserified code,
// and use it as `root`.

@@ -34,4 +34,4 @@ var freeGlobal = typeof global == 'object' && global;

// In Regenerate output, `\0` will never be preceded by `\` because we sort
// by code point value, so let’s keep this regular expression simple.
// In Regenerate output, `\0` is never preceded by `\` because we sort by
// code point value, so let’s keep this regular expression simple.
var regexNull = /\\x00([^0123456789]|$)/g;

@@ -585,2 +585,9 @@

var codePointToStringUnicode = function(codePoint) {
if (codePoint <= 0xFFFF) {
return codePointToString(codePoint);
}
return '\\u{' + codePoint.toString(16).toUpperCase() + '}';
};
var symbolToCodePoint = function(symbol) {

@@ -629,2 +636,27 @@ var length = symbol.length;

var createUnicodeCharacterClasses = function(data) {
// Iterate over the data per `(start, end)` pair.
var result = '';
var index = 0;
var start;
var end;
var length = data.length;
if (dataIsSingleton(data)) {
return codePointToStringUnicode(data[0]);
}
while (index < length) {
start = data[index];
end = data[index + 1] - 1; // Note: the `- 1` makes `end` inclusive.
if (start == end) {
result += codePointToStringUnicode(start);
} else if (start + 1 == end) {
result += codePointToStringUnicode(start) + codePointToStringUnicode(end);
} else {
result += codePointToStringUnicode(start) + '-' + codePointToStringUnicode(end);
}
index += 2;
}
return '[' + result + ']';
};
var splitAtBMP = function(data) {

@@ -965,3 +997,6 @@ // Iterate over the data per `(start, end)` pair.

var createCharacterClassesFromData = function(data, bmpOnly) {
var createCharacterClassesFromData = function(data, bmpOnly, hasUnicodeFlag) {
if (hasUnicodeFlag) {
return createUnicodeCharacterClasses(data);
}
var result = [];

@@ -1007,3 +1042,5 @@

result.push(
// Make sure the low surrogates aren’t part of a surrogate pair.
// It is not possible to accurately assert the low surrogates aren’t
// part of a surrogate pair, since JavaScript regular expressions do
// not support lookbehind.
'(?:[^\\uD800-\\uDBFF]|^)' +

@@ -1032,3 +1069,3 @@ createBMPCharacterClasses(loneLowSurrogates)

regenerate.version = '1.2.0';
regenerate.version = '1.3.0';

@@ -1130,3 +1167,4 @@ var proto = regenerate.prototype;

this.data,
options ? options.bmpOnly : false
options ? options.bmpOnly : false,
options ? options.hasUnicodeFlag : false
);

@@ -1137,3 +1175,8 @@ // Use `\0` instead of `\x00` where possible.

'toRegExp': function(flags) {
return RegExp(this.toString(), flags || '');
var pattern = this.toString(
flags && flags.indexOf('u') != -1 ?
{ 'hasUnicodeFlag': true } :
null
);
return RegExp(pattern, flags || '');
},

@@ -1140,0 +1183,0 @@ 'valueOf': function() { // Note: `valueOf` is aliased as `toArray`.

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