2015-09-26 20:05:37 +01:00
|
|
|
/**
|
2015-12-17 15:15:59 +00:00
|
|
|
Definitions of string utility functions.
|
|
|
|
@license MIT. Copyright (c) 2015 James Devlin / FluentDesk.
|
|
|
|
@module string.js
|
2015-09-26 20:05:37 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
Determine if the string is null, empty, or whitespace.
|
|
|
|
See: http://stackoverflow.com/a/32800728/4942583
|
|
|
|
@method isNullOrWhitespace
|
|
|
|
*/
|
|
|
|
|
|
|
|
String.isNullOrWhitespace = function( input ) {
|
|
|
|
return !input || !input.trim();
|
|
|
|
};
|
|
|
|
|
|
|
|
String.prototype.endsWith = function(suffix) {
|
|
|
|
return this.indexOf(suffix, this.length - suffix.length) !== -1;
|
|
|
|
};
|
2015-12-20 23:42:02 +00:00
|
|
|
|
|
|
|
String.is = function( val ) {
|
|
|
|
return typeof val === 'string' || val instanceof String;
|
|
|
|
};
|