How to use the underscore.isString function in underscore

To help you get started, we’ve selected a few underscore examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github geneontology / noctua / barista.js View on Github external
function _gel_session(token, uri, user_type,
			  nickname, groups, accounts, email){

	// token and uri are super critical.
	if( ! us.isString(token) ){
	    throw new Error('bad user token');
	}
	if( ! us.isString(uri) ){
	    throw new Error('bad user uri');
	}

	// Double check user type.
	if( ! us.contains(known_user_types, user_type) ){
	    throw new Error('unknown user type: ' + user_type);
	}

	// Well, name is unimportant technically if we have the uri.
	console.log(nickname);
	if( ! us.isString(nickname) ){
	    nickname = '???';
	}
github nrkno / tv-automation-server-core / meteor / client / ui / SegmentTimeline / SourceLayerItem.tsx View on Github external
render () {
		if (this.isInsideViewport()) {

			this._placeHolderElement = false

			const typeClass = RundownUtils.getSourceLayerClassName(this.props.layer.type)

			return (
				<div> 0,
					'with-out-transition': !this.props.relative &amp;&amp; this.props.piece.transitions &amp;&amp; this.props.piece.transitions.outTransition &amp;&amp; (this.props.piece.transitions.outTransition.duration || 0) &gt; 0,

					'hide-overflow-labels': this.state.leftAnchoredWidth &gt; 0 &amp;&amp; this.state.rightAnchoredWidth &gt; 0 &amp;&amp; ((this.state.leftAnchoredWidth + this.state.rightAnchoredWidth) &gt; this.state.elementWidth),

					'infinite': (this.props.piece.playoutDuration === undefined &amp;&amp; this.props.piece.userDuration === undefined &amp;&amp; this.props.piece.infiniteMode) as boolean, // 0 is a special value
					'next-is-touching': !!(this.props.piece.cropped || (this.props.piece.enable.end &amp;&amp; _.isString(this.props.piece.enable.end))),

					'source-missing': this.props.piece.status === RundownAPI.PieceStatusCode.SOURCE_MISSING || this.props.piece.status === RundownAPI.PieceStatusCode.SOURCE_NOT_SET,
					'source-broken': this.props.piece.status === RundownAPI.PieceStatusCode.SOURCE_BROKEN,
					'unknown-state': this.props.piece.status === RundownAPI.PieceStatusCode.UNKNOWN,
					'disabled': this.props.piece.disabled
				})}
					data-obj-id={this.props.piece._id}
					ref={this.setRef}
					onClick={this.itemClick}
					onDoubleClick={this.itemDblClick}
					onMouseUp={this.itemMouseUp}
					onMouseMove={(e) =&gt; this.moveMiniInspector(e)}
					onMouseOver={(e) =&gt; !this.props.outputGroupCollapsed &amp;&amp; this.toggleMiniInspector(e, true)}
					onMouseLeave={(e) =&gt; this.toggleMiniInspector(e, false)}
					style={this.getItemStyle()}&gt;
					{this.renderInsideItem(typeClass)}</div>
github KRMAssociatesInc / eHMP / ehmp / product / production / vx-sync / handlers / record-enrichment-request / record-enrichment-vital-xformer.js View on Github external
function addInMissingFields(record) {

	// Kind
	//------
	record.kind = 'Vital Sign';

	// Summary
	//--------
	var summary = '';
	if (_.isString(record.typeName)) {
		summary = record.typeName;
	}
	if (_.isString(record.result)) {
		summary += ' ' + record.result;
	}
	if (_.isString(record.interpretationCode)) {
		summary += ' ' + record.interpretationCode;
	}
	if (_.isString(record.units)) {
		summary += ' ' + record.units;
	}
	record.summary = summary;

	// Qualified Name
	//---------------
	record.qualifiedName = record.typeName;
github ecomfe / esui-family / dep / ub-ria-ui / 1.0.0-beta.2 / src / MultiCalendar.js View on Github external
convertToRaw: function (value, defaultRange) {
                    var format = this.paramFormat;
                    if (u.isString(value)) {
                        var strDates = value.split(',');
                        return {
                            begin: strDates[0] ? moment(strDates[0], format).toDate() : defaultRange.begin,
                            end: strDates[1] ? moment(strDates[1], format).toDate() : defaultRange.end
                        };
                    }
                    return {
                        begin: value.begin ? value.begin : defaultRange.begin,
                        end: value.end ? value.end : defaultRange.end
                    };
                },
github tinysec / jsrt / src / jsrt_modules / core / fs.js View on Github external
function fs_writeFile( arg_fd_or_name  )
{
	var param_fd = 0;

	var param_buffer = 0;

	var param_encoding = "utf-8";

	var writedSize = 0;

	assert( arguments.length &gt;= 2 , "invalid arguments" );

	if ( arguments.length &gt;= 3 )
	{
		assert( _.isString( arguments[2] ) , "arguments 2 must be string as encoding or nothing" );
		
		param_encoding = arguments[2];
	}

	if ( _.isNumber( arguments[0] ) )
	{
		param_fd = arg_fd_or_name;
	}
	else if ( _.isString( arguments[0] ) )
	{
		param_fd = fs_open( arguments[0] , "w" , S_IWRITE );
		
		if ( param_fd &lt;= 0 )
		{
			return 0;
		}
github Synbiota / GENtle2 / public / scripts / library / utils / smart_memoize_and_clear.js View on Github external
export default function smartMemoizeAndClear(obj, methodName, eventName, listenTarget) {
  listenTarget = listenTarget || obj;
  if(isString(listenTarget)) listenTarget = obj[listenTarget];

  if(typeof methodName === 'object') {
    return Object.keys(methodName).map((_methodName) => {
      smartMemoizeAndClear(listenTarget, _methodName, methodName[_methodName], obj);
    });
  } else {
    if(isFunction(obj[methodName])) {
      obj[methodName] = memoize(obj[methodName]);
      let callback = () => obj[methodName].clearCache();

      if(typeof obj.listenTo !== 'undefined') {
        obj.listenTo(listenTarget, eventName, callback);
      } else {
        listenTarget.on(eventName, callback);
      }
github KRMAssociatesInc / eHMP / ehmp / product / production / vx-sync / handlers / record-enrichment-request / record-enrichment-vital-xformer.js View on Github external
function isDodVitals(record) {
	return ((_.isString(record.uid)) && (record.uid.indexOf(':DOD:') >= 0));
}
github sdelrio0 / pyrope / lib / actions.js View on Github external
constructor(opts) {
    const { tablePrefix, tableName, tableSuffix } = opts;
    
    if(!tableName || !isString(tableName)) throw new Error(`PyropeActions#constructor(): 'tableName' is undefined or not a string.`);
    
    this.tablePrefix = tablePrefix || '';
    this.tableName = tableName;
    this.tableSuffix = tableSuffix || '';
    this.fullTableName = this.tablePrefix + this.tableName + this.tableSuffix;
  }
github RocketChat / Rocket.Chat / app / markdown / lib / parser / marked / marked.js View on Github external
const out = this.options.highlight(code, lang);
		if (out != null &amp;&amp; out !== code) {
			escaped = true;
			code = out;
		}
	}

	let text = null;

	if (!lang) {
		text = `<pre><code class="code-colors hljs">${ escaped ? code : s.escapeHTML(code, true) }</code></pre>`;
	} else {
		text = `<pre><code class="code-colors hljs ${ escape(lang, true) }">${ escaped ? code : s.escapeHTML(code, true) }</code></pre>`;
	}

	if (_.isString(msg)) {
		return text;
	}

	const token = `=!=${ Random.id() }=!=`;
	msg.tokens.push({
		highlight: true,
		token,
		text,
	});

	return token;
};
github pwagener / backbone.conduit / src / Boss.js View on Github external
makePromise: function(details) {
        if (!_.isString(details.method)) {
            throw new Error("Must provide 'method'");
        }

        if (this.terminateTimeoutHandle) {
            clearTimeout(this.terminateTimeoutHandle);
            delete this.terminateTimeoutHandle;
        }

        var self = this;

        return this._ensureWorker().then(function (worker) {
            var requestId = _.uniqueId('cReq');

            var requestDetails = _.extend({}, details, {
                requestId: requestId,
                objectId: self.objectId