Comparing version 1.2.1 to 1.3.0
1.3.0 / 2015-01-31 | ||
================== | ||
* feat(string): add string replace | ||
1.2.1 / 2014-11-14 | ||
@@ -3,0 +8,0 @@ ================== |
@@ -61,1 +61,19 @@ /*! | ||
}; | ||
/** | ||
* Replace string | ||
* | ||
* @param {String} str | ||
* @param {String|RegExp} substr | ||
* @param {String|Function} newSubstr | ||
* @return {String} | ||
*/ | ||
exports.replace = function replace(str, substr, newSubstr) { | ||
var replaceFunction = newSubstr; | ||
if (typeof replaceFunction !== 'function') { | ||
replaceFunction = function () { | ||
return newSubstr; | ||
}; | ||
} | ||
return str.replace(substr, replaceFunction); | ||
}; |
{ | ||
"name": "utility", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"description": "A collection of useful utilities.", | ||
"main": "index.js", | ||
"main": "lib/utility.js", | ||
"scripts": { | ||
@@ -19,2 +19,5 @@ "test": "mocha -R spec -t 5000 test/*.test.js", | ||
}, | ||
"files": [ | ||
"lib" | ||
], | ||
"devDependencies": { | ||
@@ -21,0 +24,0 @@ "autod": "*", |
@@ -168,2 +168,5 @@ utility | ||
utils.split('foo,bar,,,'); // ['foo', 'bar'] | ||
// replace string work with special chars which `String.prototype.replace` can't handle | ||
utils.replace('<body> hi', '<body>', '$& body'); // '$& body hi' | ||
``` | ||
@@ -226,23 +229,2 @@ | ||
(The MIT License) | ||
Copyright (c) 2012 - 2014 fengmk2 <fengmk2@gmail.com> and other contributors | ||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
'Software'), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
MIT |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
27619
621
15
229