Socket
Socket
Sign inDemoInstall

regexp-clone

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

regexp-clone

Clone RegExps with options


Version published
Maintainers
1
Weekly downloads
521,023
decreased by-8.66%

Weekly downloads

Readme

Source

#regexp-clone

Clones RegExps with flag and lastIndex preservation.

const regexpClone = require('regexp-clone');

const a = /somethin/misguy;
console.log(a.global); // true
console.log(a.ignoreCase); // true
console.log(a.multiline); // true
console.log(a.dotAll); // true
console.log(a.unicode); // true
console.log(a.sticky); // true

const b = regexpClone(a);
console.log(b.global); // true
console.log(b.ignoreCase); // true
console.log(b.multiline); // true
console.log(b.dotAll); // true
console.log(b.unicode); // true
console.log(b.sticky); // true

const c = /hi/g;
c.test('this string hi there');
assert.strictEqual(c.lastIndex, 3);

const d = regexpClone(c);
assert.strictEqual(d.lastIndex, 3);
d.test('this string hi there');
assert.strictEqual(d.lastIndex, 14);
assert.strictEqual(c.lastIndex, 3);
npm install regexp-clone

License

MIT

Keywords

FAQs

Last updated on 07 Jun 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc