Methods
- 
			
<static> camel( target ) → {string}
Converts the given
targetto camel case. - 
	
Parameters
Name Type Description targetstring The string to camel case.
Returns
Examples
// alias the FooGallery.utils.str namespace var _str = FooGallery.utils.str; console.log( _str.camel( "max-width" ) ); // => "maxWidth" console.log( _str.camel( "max--width" ) ); // => "maxWidth" console.log( _str.camel( "max Width" ) ); // => "maxWidth" console.log( _str.camel( "Max_width" ) ); // => "maxWidth" console.log( _str.camel( "MaxWidth" ) ); // => "maxWidth" console.log( _str.camel( "Abbreviations like CSS are left intact" ) ); // => "abbreviationsLikeCSSAreLeftIntact"Details
 - 
			
<static> contains( target, substr [, ignoreCase ] ) → {boolean}
Checks if the
targetcontains the givensubstr. - 
	
Parameters
Name Type Attributes Default Description targetstring The string to check.
substrstring The string to check for.
ignoreCaseboolean <optional> false Whether or not to ignore casing when performing the check.
Returns
Examples
// alias the FooGallery.utils.str namespace var _str = FooGallery.utils.str, // create a string to test target = "To be, or not to be, that is the question."; console.log( _str.contains( target, "To be" ) ); // => true console.log( _str.contains( target, "question" ) ); // => true console.log( _str.contains( target, "no" ) ); // => true console.log( _str.contains( target, "nonexistent" ) ); // => false console.log( _str.contains( target, "TO BE" ) ); // => false console.log( _str.contains( target, "TO BE", true ) ); // => trueDetails
 - 
			
<static> containsWord( target, word [, ignoreCase ] ) → {boolean}
Checks if the
targetcontains the givenword. - 
	
Description
This method differs from FooGallery.utils.str.contains in that it searches for whole words by splitting the
targetstring on word boundaries (\b) and then comparing the individual parts.Parameters
Name Type Attributes Default Description targetstring The string to check.
wordstring The word to check for.
ignoreCaseboolean <optional> false Whether or not to ignore casing when performing the check.
Returns
Examples
// alias the FooGallery.utils.str namespace var _str = FooGallery.utils.str, // create a string to test target = "To be, or not to be, that is the question."; console.log( _str.containsWord( target, "question" ) ); // => true console.log( _str.containsWord( target, "no" ) ); // => false console.log( _str.containsWord( target, "NOT" ) ); // => false console.log( _str.containsWord( target, "NOT", true ) ); // => true console.log( _str.containsWord( target, "nonexistent" ) ); // => falseDetails
 - 
			
<static> endsWith( target, substr ) → {boolean}
Checks if the
targetends with the givensubstr. - 
	
Parameters
Name Type Description targetstring The string to check.
substrstring The substr to check for.
Returns
Examples
// alias the FooGallery.utils.str namespace var _str = FooGallery.utils.str; console.log( _str.endsWith( "something", "g" ) ); // => true console.log( _str.endsWith( "something", "ing" ) ); // => true console.log( _str.endsWith( "something", "no" ) ); // => falseDetails
 - 
			
<static> escapeRegExp( target ) → {string}
Escapes the
targetfor use in a regular expression. - 
	
Parameters
Name Type Description targetstring The string to escape.
Returns
Details
 - 
			
<static> fnv1a( target ) → {number}
Generates a 32 bit FNV-1a hash from the given
target. - 
	
Parameters
Name Type Description targetstring The string to generate a hash from.
Returns
Examples
// alias the FooGallery.utils.str namespace var _str = FooGallery.utils.str; console.log( _str.fnv1a( "Some string to generate a hash for." ) ); // => 207568994 console.log( _str.fnv1a( "Some string to generate a hash for" ) ); // => 1350435704Details
 - 
			
<static> from( target, substr ) → {string}
Returns the remainder of the
targetsplit on the first index of the givensubstr. - 
	
Parameters
Name Type Description targetstring The string to split.
substrstring The substring to split on.
Returns
Examples
// alias the FooGallery.utils.str namespace var _str = FooGallery.utils.str, // create a string to test target = "To be, or not to be, that is the question."; console.log( _str.from( target, "no" ) ); // => "t to be, that is the question." console.log( _str.from( target, "that" ) ); // => " is the question." console.log( _str.from( target, "question" ) ); // => "." console.log( _str.from( target, "nonexistent" ) ); // => nullDetails
 - 
			
<static> join( separator, part [, ...partN ] ) → {string}
Joins any number of strings using the given
separator. - 
	
Description
This method differs from using the standard
Array.prototype.joinfunction to join strings in that it ignores empty parts and checks to see if each starts with the suppliedseparator. If the part starts with theseparatorit is removed before appending it to the final result.Parameters
Name Type Attributes Description separatorstring The separator to use to join the strings.
partstring The first string to join.
partNstring <optional> 
<repeatable>Any number of additional strings to join.
Returns
Examples
// alias the FooGallery.utils.str namespace var _str = FooGallery.utils.str; console.log( _str.join( "_", "all", "in", "one" ) ); // => "all_in_one" console.log( _str.join( "_", "all", "_in", "one" ) ); // => "all_in_one" console.log( _str.join( "/", "http://", "/example.com/", "/path/to/image.png" ) ); // => "http://example.com/path/to/image.png" console.log( _str.join( "/", "http://", "/example.com", "/path/to/image.png" ) ); // => "http://example.com/path/to/image.png" console.log( _str.join( "/", "http://", "example.com", "path/to/image.png" ) ); // => "http://example.com/path/to/image.png"Details
 - 
			
<static> startsWith( target, substr ) → {boolean}
Checks if the
targetstarts with the givensubstr. - 
	
Parameters
Name Type Description targetstring The string to check.
substrstring The substr to check for.
Returns
Examples
// alias the FooGallery.utils.str namespace var _str = FooGallery.utils.str; console.log( _str.startsWith( "something", "s" ) ); // => true console.log( _str.startsWith( "something", "some" ) ); // => true console.log( _str.startsWith( "something", "no" ) ); // => falseDetails
 - 
			
<static> until( target, substr ) → {string}
Returns the first part of the
targetsplit on the first index of the givensubstr. - 
	
Parameters
Name Type Description targetstring The string to split.
substrstring The substring to split on.
Returns
Examples
// alias the FooGallery.utils.str namespace var _str = FooGallery.utils.str, // create a string to test target = "To be, or not to be, that is the question."; console.log( _str.until( target, "no" ) ); // => "To be, or " console.log( _str.until( target, "that" ) ); // => "To be, or not to be, " console.log( _str.until( target, "question" ) ); // => "To be, or not to be, that is the " console.log( _str.until( target, "nonexistent" ) ); // => "To be, or not to be, that is the question."Details
 - 
			
<static> format( target, arg1 [, ...argN ] ) → {string}
A basic string formatter that can use both index and name based placeholders but handles only string or number replacements.
 - 
	
Description
This method allows you to supply the replacements as an object when using named placeholders or as an array or additional arguments when using index placeholders.
This does not perform a simultaneous replacement of placeholders, which is why it's referred to as a basic formatter. This means replacements that contain placeholders within there value could end up being replaced themselves as seen in the last example.
Parameters
Name Type Attributes Description targetstring The format string containing any placeholders to replace.
arg1string | number | Object | Array The first value to format the target with. If an object is supplied it's properties are used to match named placeholders. If an array, string or number is supplied it's values are used to match any index placeholders.
argNstring | number <optional> 
<repeatable>Any number of additional strings or numbers to format the target with.
Returns
Examples
The following shows how to use index placeholders.
// alias the FooGallery.utils.str namespace var _str = FooGallery.utils.str, // create a format string using index placeholders format = "Hello, {0}, are you feeling {1}?"; console.log( _str.format( format, "Steve", "OK" ) ); // => "Hello, Steve, are you feeling OK?" // or console.log( _str.format( format, [ "Steve", "OK" ] ) ); // => "Hello, Steve, are you feeling OK?"While the above works perfectly fine the downside is that the placeholders provide no clues as to what should be supplied as a replacement value, this is were supplying an object and using named placeholders steps in.
// alias the FooGallery.utils.str namespace var _str = FooGallery.utils.str, // create a format string using named placeholders format = "Hello, {name}, are you feeling {adjective}?"; console.log( _str.format( format, {name: "Steve", adjective: "OK"} ) ); // => "Hello, Steve, are you feeling OK?"The following demonstrates the issue with not performing a simultaneous replacement of placeholders.
// alias the FooGallery.utils.str namespace var _str = FooGallery.utils.str; console.log( _str.format("{0}{1}", "{1}", "{0}") ); // => "{0}{0}" // If the replacement happened simultaneously the result would be "{1}{0}" but this method executes // replacements synchronously as seen below: // "{0}{1}".replace( "{0}", "{1}" ) // => "{1}{1}".replace( "{1}", "{0}" ) // => "{0}{0}"Details