From ad653e70dd7f49a594916887aea8b7bc1b903bb9 Mon Sep 17 00:00:00 2001 From: devlinjd Date: Sat, 26 Sep 2015 15:05:37 -0400 Subject: [PATCH] Package string utils. --- src/fluentcmd.js | 9 +-------- src/utils/string.js | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 src/utils/string.js diff --git a/src/fluentcmd.js b/src/fluentcmd.js index c5af92f..93c94a8 100644 --- a/src/fluentcmd.js +++ b/src/fluentcmd.js @@ -13,12 +13,9 @@ module.exports = function () { , path = require( 'path' ) , extend = require( './utils/extend' ) , _ = require('underscore') + , unused = require('./utils/string') , FLUENT = require('fluentlib'); - String.prototype.endsWith = function(suffix) { - return this.indexOf(suffix, this.length - suffix.length) !== -1; - }; - var rez; /** @@ -35,10 +32,6 @@ module.exports = function () { _opts.theme = theme; dst = (dst && dst.length && dst) || ['resume.all']; - // console.log( src ); - // console.log( dst ); - // console.log( theme ); - // Assemble output resume targets var targets = []; dst.forEach( function(t) { diff --git a/src/utils/string.js b/src/utils/string.js new file mode 100644 index 0000000..905fc43 --- /dev/null +++ b/src/utils/string.js @@ -0,0 +1,18 @@ +/** +String utility functions. +@license Copyright (c) 2015 by James M. Devlin. All rights reserved. +*/ + +/** +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; +};