bugfix and updated docs
This commit is contained in:
@@ -54,21 +54,6 @@
|
|||||||
<pre
|
<pre
|
||||||
class="sunlight-highlight-javascript linenums">'use strict';
|
class="sunlight-highlight-javascript linenums">'use strict';
|
||||||
|
|
||||||
var wildstring = (function (name, definition) {
|
|
||||||
if (typeof(module) !== 'undefined') {
|
|
||||||
module.exports = definition();
|
|
||||||
}
|
|
||||||
else if (typeof(define) === 'function' && typeof(define.amd) === 'object') {
|
|
||||||
define(definition);
|
|
||||||
}
|
|
||||||
else if (typeof(this) !== 'undefined') {
|
|
||||||
this[name] = definition();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return definition();
|
|
||||||
}
|
|
||||||
}('wildstring', function () {
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @namespace wildstring
|
* @namespace wildstring
|
||||||
* @property {string} wildcard the wildcard to use in your strings, defaults to '*'
|
* @property {string} wildcard the wildcard to use in your strings, defaults to '*'
|
||||||
@@ -76,8 +61,7 @@ var wildstring = (function (name, definition) {
|
|||||||
*/
|
*/
|
||||||
var wildstring = {
|
var wildstring = {
|
||||||
wildcard: '*',
|
wildcard: '*',
|
||||||
caseSensitive: true
|
caseSensitive: true,
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When a match doesn't continue to the end of the string, this function rolls back to try again with the rest of the string
|
* When a match doesn't continue to the end of the string, this function rolls back to try again with the rest of the string
|
||||||
@@ -86,7 +70,7 @@ var wildstring = {
|
|||||||
* @param {string[]} rollbackStrings The list of substrings that appeared prior to the current match
|
* @param {string[]} rollbackStrings The list of substrings that appeared prior to the current match
|
||||||
* @param {string[]} patternSubstrings The matching list of pattens that need to be matched before the current pattern
|
* @param {string[]} patternSubstrings The matching list of pattens that need to be matched before the current pattern
|
||||||
*/
|
*/
|
||||||
function checkRollbackStrings (rollbackStrings, patternSubstrings) {
|
checkRollbackStrings: function (rollbackStrings, patternSubstrings) {
|
||||||
for (var s = 0; s < rollbackStrings.length; ++s) {
|
for (var s = 0; s < rollbackStrings.length; ++s) {
|
||||||
var currentString = rollbackStrings[s].string; // starting with the rolled back string
|
var currentString = rollbackStrings[s].string; // starting with the rolled back string
|
||||||
var patternIndex = rollbackStrings[s].index;
|
var patternIndex = rollbackStrings[s].index;
|
||||||
@@ -126,7 +110,7 @@ function checkRollbackStrings (rollbackStrings, patternSubstrings) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a string matches a pattern
|
* Check if a string matches a pattern
|
||||||
@@ -134,7 +118,7 @@ function checkRollbackStrings (rollbackStrings, patternSubstrings) {
|
|||||||
* @param {string} pattern The pattern to match using the configured wildcard
|
* @param {string} pattern The pattern to match using the configured wildcard
|
||||||
* @param {string} string The string to test for a match
|
* @param {string} string The string to test for a match
|
||||||
*/
|
*/
|
||||||
wildstring.match = function (pattern, string) {
|
match: function (pattern, string) {
|
||||||
// if there are no wildcards, must be exact
|
// if there are no wildcards, must be exact
|
||||||
if (pattern.indexOf(wildstring.wildcard) === -1) {
|
if (pattern.indexOf(wildstring.wildcard) === -1) {
|
||||||
return pattern === string;
|
return pattern === string;
|
||||||
@@ -166,7 +150,7 @@ wildstring.match = function (pattern, string) {
|
|||||||
|
|
||||||
while (patternIndex < patternSubstrings.length) {
|
while (patternIndex < patternSubstrings.length) {
|
||||||
if (currentString.indexOf(patternSubstrings[patternIndex]) === -1) {
|
if (currentString.indexOf(patternSubstrings[patternIndex]) === -1) {
|
||||||
return checkRollbackStrings(rollbackStrings, patternSubstrings);
|
return wildstring.checkRollbackStrings(rollbackStrings, patternSubstrings);
|
||||||
}
|
}
|
||||||
|
|
||||||
// create a queue of strings to roll back and try again if we fail later
|
// create a queue of strings to roll back and try again if we fail later
|
||||||
@@ -194,11 +178,11 @@ wildstring.match = function (pattern, string) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return checkRollbackStrings(rollbackStrings, patternSubstrings);
|
return wildstring.checkRollbackStrings(rollbackStrings, patternSubstrings);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replace wildcards in a pattern with strings (string interpolation)
|
* Replace wildcards in a pattern with strings (string interpolation)
|
||||||
@@ -211,7 +195,7 @@ wildstring.match = function (pattern, string) {
|
|||||||
* @throws You need to pass both parameters
|
* @throws You need to pass both parameters
|
||||||
* @throws You need to pass the right types
|
* @throws You need to pass the right types
|
||||||
*/
|
*/
|
||||||
wildstring.replace = function (pattern, strings) {
|
replace: function (pattern, strings) {
|
||||||
if (pattern === undefined || strings === undefined) {
|
if (pattern === undefined || strings === undefined) {
|
||||||
throw new Error('wildstring.replace takes the pattern as one parameter and either a string or an array of strings as the second. You didn\'t pass enough parameters.');
|
throw new Error('wildstring.replace takes the pattern as one parameter and either a string or an array of strings as the second. You didn\'t pass enough parameters.');
|
||||||
}
|
}
|
||||||
@@ -239,10 +223,12 @@ wildstring.replace = function (pattern, strings) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return wildstring;
|
if (typeof(module) !== 'undefined') { module.exports = wildstring; }
|
||||||
}));
|
if (typeof(angular) !== 'undefined') { angular.module('wildstring').factory = wildstring; }
|
||||||
|
if (typeof(define) !== 'undefined') { define([], wildstring); }
|
||||||
</pre>
|
</pre>
|
||||||
</article>
|
</article>
|
||||||
</section>
|
</section>
|
||||||
@@ -272,7 +258,7 @@ return wildstring;
|
|||||||
|
|
||||||
<span class="jsdoc-message">
|
<span class="jsdoc-message">
|
||||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.2</a>
|
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.2</a>
|
||||||
on Sun Aug 9th 2015 using the <a
|
on Wed Aug 12th 2015 using the <a
|
||||||
href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
|
href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
|
||||||
</span>
|
</span>
|
||||||
</footer>
|
</footer>
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ grunt</code></pre><p>grunt will run all the tests and jshint, so just make sure
|
|||||||
|
|
||||||
<span class="jsdoc-message">
|
<span class="jsdoc-message">
|
||||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.2</a>
|
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.2</a>
|
||||||
on Sun Aug 9th 2015 using the <a
|
on Wed Aug 12th 2015 using the <a
|
||||||
href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
|
href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
|
||||||
</span>
|
</span>
|
||||||
</footer>
|
</footer>
|
||||||
|
|||||||
@@ -165,7 +165,7 @@
|
|||||||
|
|
||||||
<span class="jsdoc-message">
|
<span class="jsdoc-message">
|
||||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.2</a>
|
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.2</a>
|
||||||
on Sun Aug 9th 2015 using the <a
|
on Wed Aug 12th 2015 using the <a
|
||||||
href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
|
href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
|
||||||
</span>
|
</span>
|
||||||
</footer>
|
</footer>
|
||||||
|
|||||||
@@ -176,7 +176,7 @@
|
|||||||
<ul class="dummy">
|
<ul class="dummy">
|
||||||
<li>
|
<li>
|
||||||
<a href="F__Git_wildstring_wildstring.js.html">F:/Git/wildstring/wildstring.js</a>,
|
<a href="F__Git_wildstring_wildstring.js.html">F:/Git/wildstring/wildstring.js</a>,
|
||||||
<a href="F__Git_wildstring_wildstring.js.html#sunlight-1-line-18">line 18</a>
|
<a href="F__Git_wildstring_wildstring.js.html#sunlight-1-line-3">line 3</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</dd>
|
</dd>
|
||||||
@@ -339,7 +339,7 @@
|
|||||||
<ul class="dummy">
|
<ul class="dummy">
|
||||||
<li>
|
<li>
|
||||||
<a href="F__Git_wildstring_wildstring.js.html">F:/Git/wildstring/wildstring.js</a>,
|
<a href="F__Git_wildstring_wildstring.js.html">F:/Git/wildstring/wildstring.js</a>,
|
||||||
<a href="F__Git_wildstring_wildstring.js.html#sunlight-1-line-35">line 35</a>
|
<a href="F__Git_wildstring_wildstring.js.html#sunlight-1-line-19">line 19</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</dd>
|
</dd>
|
||||||
@@ -498,7 +498,7 @@
|
|||||||
<ul class="dummy">
|
<ul class="dummy">
|
||||||
<li>
|
<li>
|
||||||
<a href="F__Git_wildstring_wildstring.js.html">F:/Git/wildstring/wildstring.js</a>,
|
<a href="F__Git_wildstring_wildstring.js.html">F:/Git/wildstring/wildstring.js</a>,
|
||||||
<a href="F__Git_wildstring_wildstring.js.html#sunlight-1-line-83">line 83</a>
|
<a href="F__Git_wildstring_wildstring.js.html#sunlight-1-line-67">line 67</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</dd>
|
</dd>
|
||||||
@@ -662,7 +662,7 @@
|
|||||||
<ul class="dummy">
|
<ul class="dummy">
|
||||||
<li>
|
<li>
|
||||||
<a href="F__Git_wildstring_wildstring.js.html">F:/Git/wildstring/wildstring.js</a>,
|
<a href="F__Git_wildstring_wildstring.js.html">F:/Git/wildstring/wildstring.js</a>,
|
||||||
<a href="F__Git_wildstring_wildstring.js.html#sunlight-1-line-160">line 160</a>
|
<a href="F__Git_wildstring_wildstring.js.html#sunlight-1-line-144">line 144</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</dd>
|
</dd>
|
||||||
@@ -761,7 +761,7 @@
|
|||||||
|
|
||||||
<span class="jsdoc-message">
|
<span class="jsdoc-message">
|
||||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.2</a>
|
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.2</a>
|
||||||
on Sun Aug 9th 2015 using the <a
|
on Wed Aug 12th 2015 using the <a
|
||||||
href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
|
href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
|
||||||
</span>
|
</span>
|
||||||
</footer>
|
</footer>
|
||||||
|
|||||||
@@ -175,5 +175,3 @@ var wildstring = {
|
|||||||
if (typeof(module) !== 'undefined') { module.exports = wildstring; }
|
if (typeof(module) !== 'undefined') { module.exports = wildstring; }
|
||||||
if (typeof(angular) !== 'undefined') { angular.module('wildstring').factory = wildstring; }
|
if (typeof(angular) !== 'undefined') { angular.module('wildstring').factory = wildstring; }
|
||||||
if (typeof(define) !== 'undefined') { define([], wildstring); }
|
if (typeof(define) !== 'undefined') { define([], wildstring); }
|
||||||
|
|
||||||
return wildstring;
|
|
||||||
|
|||||||
Reference in New Issue
Block a user