Comparing version 3.0.1 to 3.0.2
@@ -367,2 +367,6 @@ /*global window*/ | ||
if (typeof regexp === 'string') { | ||
regexp = new RegExp(utils.escapeRegExp(regexp), 'g'); | ||
} | ||
if (typeof cb === 'string') { | ||
@@ -369,0 +373,0 @@ var text = cb; |
@@ -56,2 +56,6 @@ var utils = { | ||
}, | ||
escapeRegExp: function (text){ | ||
return text.replace(/([.*+?^${}()|\[\]\/\\])/g, "\\$1"); | ||
} | ||
@@ -58,0 +62,0 @@ }; |
@@ -610,2 +610,6 @@ /*! | ||
if (typeof regexp === 'string') { | ||
regexp = new RegExp(utils.escapeRegExp(regexp), 'g'); | ||
} | ||
if (typeof cb === 'string') { | ||
@@ -756,2 +760,6 @@ var text = cb; | ||
}, | ||
escapeRegExp: function (text){ | ||
return text.replace(/([.*+?^${}()|\[\]\/\\])/g, "\\$1"); | ||
} | ||
@@ -758,0 +766,0 @@ }; |
{ | ||
"name": "magicpen", | ||
"version": "3.0.1", | ||
"version": "3.0.2", | ||
"description": "Styled output in both consoles and browsers", | ||
@@ -5,0 +5,0 @@ "main": "./lib/MagicPen.js", |
@@ -168,3 +168,3 @@ /*global describe, it, beforeEach*/ | ||
describe('with a given pattern and a callback', function () { | ||
describe('with given a pattern and a callback', function () { | ||
it('replaces text content maching pattern', function () { | ||
@@ -180,3 +180,3 @@ pen.red('Hello').sp().green('world!').replaceText(/[a-z]{3}/, function (styles, text) { | ||
describe('with a given pattern and a string', function () { | ||
describe('with given a pattern and a string', function () { | ||
it('replaces text content maching pattern', function () { | ||
@@ -189,2 +189,10 @@ pen.text('Hello ').green('<placeholder>!').replaceText(/<placeholder>/, 'Jane Doe'); | ||
describe('with given a string and a string', function () { | ||
it('replaces text content maching string', function () { | ||
pen.text('Hello ').green('<placeholder>!').replaceText('<placeholder>', 'Jane Doe'); | ||
expect(pen, 'to equal', | ||
magicpen().text('Hello ').green('Jane Doe!')); | ||
}); | ||
}); | ||
it('collapses entries with similar styles', function () { | ||
@@ -191,0 +199,0 @@ pen.green('Hello').sp().green('world!').replaceText(/ /, function (styles, text) { |
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
462761
2555