Comparing version 1.21.1 to 1.21.2
{ | ||
"name": "re2", | ||
"version": "1.21.1", | ||
"version": "1.21.2", | ||
"description": "Bindings for RE2: fast, safe alternative to backtracking regular expression engines.", | ||
@@ -31,5 +31,10 @@ "homepage": "https://github.com/uhop/node-re2", | ||
"save-to-github": "save-to-github-cache --artifact build/Release/re2.node", | ||
"install": "install-from-cache --artifact build/Release/re2.node --host-var RE2_DOWNLOAD_MIRROR --skip-path-var RE2_DOWNLOAD_SKIP_PATH --skip-ver-var RE2_DOWNLOAD_SKIP_VER || node-gyp rebuild", | ||
"install": "install-from-cache --artifact build/Release/re2.node --host-var RE2_DOWNLOAD_MIRROR --skip-path-var RE2_DOWNLOAD_SKIP_PATH --skip-ver-var RE2_DOWNLOAD_SKIP_VER || node-gyp -j max rebuild", | ||
"verify-build": "node scripts/verify-build.js", | ||
"rebuild": "node-gyp rebuild" | ||
"build:dev": "node-gyp -j max build --debug", | ||
"build": "node-gyp -j max build", | ||
"rebuild:dev": "node-gyp -j max rebuild --debug", | ||
"rebuild": "node-gyp -j max rebuild", | ||
"clean": "node-gyp clean", | ||
"reconfigure": "node-gyp configure" | ||
}, | ||
@@ -36,0 +41,0 @@ "github": "https://github.com/uhop/node-re2", |
65
re2.js
'use strict'; | ||
const RE2 = require('./build/Release/re2.node'); | ||
// const RE2 = require('./build/Debug/re2.node'); | ||
if (typeof Symbol != 'undefined') { | ||
Symbol.match && | ||
(RE2.prototype[Symbol.match] = function (str) { | ||
return this.match(str); | ||
}); | ||
Symbol.search && | ||
(RE2.prototype[Symbol.search] = function (str) { | ||
return this.search(str); | ||
}); | ||
Symbol.replace && | ||
(RE2.prototype[Symbol.replace] = function (str, repl) { | ||
return this.replace(str, repl); | ||
}); | ||
Symbol.split && | ||
(RE2.prototype[Symbol.split] = function (str, limit) { | ||
return this.split(str, limit); | ||
}); | ||
Symbol.matchAll && | ||
(RE2.prototype[Symbol.matchAll] = function* (str) { | ||
if (!this.global) { | ||
throw TypeError('String.prototype.matchAll called with a non-global RE2 argument'); | ||
} | ||
const re = new RE2(this, this.flags + '\b'); | ||
re.lastIndex = this.lastIndex; | ||
for (;;) { | ||
const result = re.exec(str); | ||
if (!result) break; | ||
if (result[0] === '') ++re.lastIndex; | ||
yield result; | ||
} | ||
}); | ||
} | ||
const setAliases = (object, dict) => { | ||
for (let [name, alias] of Object.entries(dict)) { | ||
Object.defineProperty( | ||
object, | ||
alias, | ||
Object.getOwnPropertyDescriptor(object, name) | ||
); | ||
} | ||
}; | ||
setAliases(RE2.prototype, { | ||
match: Symbol.match, | ||
search: Symbol.search, | ||
replace: Symbol.replace, | ||
split: Symbol.split | ||
}); | ||
RE2.prototype[Symbol.matchAll] = function* (str) { | ||
if (!this.global) | ||
throw TypeError( | ||
'String.prototype.matchAll() is called with a non-global RE2 argument' | ||
); | ||
const re = new RE2(this); | ||
re.lastIndex = this.lastIndex; | ||
for (;;) { | ||
const result = re.exec(str); | ||
if (!result) break; | ||
if (result[0] === '') ++re.lastIndex; | ||
yield result; | ||
} | ||
}; | ||
module.exports = RE2; |
@@ -356,2 +356,3 @@ # node-re2 [![NPM version][npm-img]][npm-url] | ||
- 1.21.2 *Fixed another memory regression reported by [matthewvalentine](https://github.com/matthewvalentine), thx! Updated deps. Added more tests and benchmarks.* | ||
- 1.21.1 *Fixed a memory regression reported by [matthewvalentine](https://github.com/matthewvalentine), thx! Updated deps.* | ||
@@ -358,0 +359,0 @@ - 1.21.0 *Fixed the performance problem reported by [matthewvalentine](https://github.com/matthewvalentine) (thx!). The change improves performance for multiple use cases.* |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
378
11521229
1665
247