How to use the lodash.isString function in lodash

To help you get started, we’ve selected a few lodash 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 nswbmw / koa-await-breakpoint / index.js View on Github external
opt = _.defaults(opt || {}, defaultOpt)
  opt.filter = opt.filter || {}
  opt.filter.ctx = opt.filter.ctx || defaultOpt.filter.ctx
  opt.filter.request = opt.filter.request || defaultOpt.filter.request
  opt.filter.response = opt.filter.response || defaultOpt.filter.response
  debug('options: %j', opt)

  const name = opt.name
  const loggerName = opt.loggerName
  const requestIdPath = opt.requestIdPath
  const files = opt.files
  const exclude_files = opt.exclude_files || []
  const store = opt.store || { save: (record) => console.log('%j', record) }
  const awaitCondition = opt.awaitCondition
  const sourcemap = opt.sourcemap
  assert(requestIdPath && _.isString(requestIdPath), '`requestIdPath` option must be string')
  assert(files && _.isArray(files), '`files`{array} option required')
  assert(_.isArray(exclude_files), '`exclude_files`{array} option required')
  assert(store && _.isFunction(store.save), '`store.save`{function} option required, see: koa-yield-breakpoint-mongodb')
  if (awaitCondition) {
    assert(_.isFunction(awaitCondition), '`awaitCondition` option must be function')
  }

  // add global logger
  global[loggerName] = async function (ctx, fn, fnStr, filename) {
    const originalContext = ctx
    let requestId = _getRequestId()

    const asyncId = async_hooks.executionAsyncId()
    if (!requestId) {
      const _ctx = getCtx(asyncId)
      if (_ctx) {
github clay / clay-kiln / lib / component-data / pubsub.js View on Github external
function convertPubObjects(prop) {
  if (_.isArray(prop)) {
    return _.map(prop, (part) => _.isString(part) ? { name: part } : part);
  } else if (_.isString(prop)) {
    return { name: prop }; // convert to object
  } else {
    return prop; // already an object
  }
}
github ladjs / custom-fonts-in-emails / src / index.js View on Github external
async function setOptions(options) {
  // Clone to prevent interference
  options = _.cloneDeep(options);

  // Set deep defaults
  options = _.defaultsDeep(options, defaults);

  // Ensure `text` is a string
  if (!_.isString(options.text)) throw new Error('`text` must be a String');

  // Ensure `fontNameOrPath` is a string and not blank
  if (!isSANB(options.fontNameOrPath))
    throw new Error('`fontNameOrPath` must be a String and not blank');

  // Convert font size in pixels to number
  // and remove px, so we just convert to digits only
  if (_.isString(options.fontSize))
    options.fontSize = parseFloat(options.fontSize);

  // Round to nearest whole pixel
  options.fontSize = Math.round(options.fontSize);

  // Ensure it's a number greater than 0
  if (!_.isNumber(options.fontSize) || options.fontSize <= 0)
    throw new Error(
github Fannon / mobo / lib / modelToModel / compatibilityLayer.js View on Github external
}

    // If a field links to one or more form, it is always of type string and format Page!
    if (inspect.form && !inspect.format) {
        inspect.type = 'string';
        inspect.format = 'Page';
    }

    // For all items:
    if (obj.items) {
        for (var i = 0; i < obj.items.length; i++) {
            var item = obj.items[i];

            // Add implicit .wikitext file extension to $extends to /smw_tempate/*
            var $extend = item.$extend;
            if ($extend && _.isString($extend) && $extend.indexOf('smw_template') > -1) {
                if ($extend.indexOf('.wikitext') === -1) {
                    obj.items[i].$extend =  $extend + '.wikitext';
                }
            }
        }
    }

    // If there is still no type derived, use sane defaults.
    // Models and Forms are always arrays. For fields, "string" is a good default.
    if (!obj.type) {

        if (obj.$modelPart === 'model' || obj.$modelPart === 'form') {
            obj.type = 'array';
            if (!obj.items) {
                obj.items = [];
            }
github iamdjones / sublime-text-browser-sync / browser-sync / lib / utils.js View on Github external
openBrowser: function (url, options) {

        var open    = options.get("open");
        var browser = options.get("browser");

        if (_.isString(open)) {
            if (options.getIn(["urls", open])) {
                url = options.getIn(["urls", open]);
            }
        }

        if (open) {
            if (browser !== "default") {
                if (utils.isList(browser)) {
                    browser.forEach(function (browser) {
                        utils.open(url, browser);
                    });
                } else {
                    utils.open(url, browser); // single
                }
            } else {
                utils.open(url);
github ElevenGiants / eleven-server / src / comm / slackNotify.js View on Github external
log.debug({args: args}, 'Slack webhook call skipped (not configured)');
		return;
	}
	var webhookParams = {
		icon_emoji: ':bcroc:',
		username: util.format('%s (%s)', cfg.botName, config.getGsid()),
		channel: cfg.channel,
	};
	// function parameter handling
	if (_.isObject(args[0])) {
		webhookParams.channel = args[0].channel || webhookParams.channel;
		args = Array.prototype.slice.call(args, 1);
	}
	// format message content
	var text = util.format.apply(null, args);
	if (_.isString(icon) && icon.length) {
		text = util.format('%s %s', icon, text);
	}
	webhookParams.text = text;
	// invoke webhook
	log.debug(webhookParams, 'calling Slack webhook');
	slack.webhook(webhookParams, function callback(err, res) {
		if (err) {
			log.error(err, 'failed to call Slack webhook');
		}
	});
}
github cmake-js / fastcall / es5 / lib / FunctionDefinition.js View on Github external
var parser = new Parser(library);
        if (_.isString(def) || _.isPlainObject(def)) {
            def = parser.parseFunction(def);
            this.resultType = def.resultType;
            this.name = def.name;
            this.args = Object.freeze(def.args);
        } else if (def.resultType && def.name && def.args) {
            this.resultType = def.resultType;
            this.name = def.name;
            this.args = Object.freeze(def.args);
        } else {
            throw new TypeError('Invalid function definition: ' + def + '.');
        }

        assert(_.isObject(this.resultType));
        assert(_.isString(this.name) && this.name.length);
        assert(_.isArray(this.args));

        this.signature = this._makeSignature();
        this._type = ref.refType(ref.types.void);
        this._type.code = typeCode.getForType(this._type);
        this._type.name = this.name;
    }
github accounts-js / accounts / packages / server / src / accounts-server.ts View on Github external
public async findSessionByAccessToken(accessToken: string): Promise {
    if (!isString(accessToken)) {
      throw new Error('An accessToken is required');
    }

    let sessionToken: string;
    try {
      const decodedAccessToken = jwt.verify(accessToken, this.options.tokenSecret) as {
        data: JwtData;
      };
      sessionToken = decodedAccessToken.data.token;
    } catch (err) {
      throw new Error('Tokens are not valid');
    }

    const session: Session | null = await this.db.findSessionByToken(sessionToken);
    if (!session) {
      throw new Error('Session not found');
github poooi / poi / views / components / settings / about / version-info.es View on Github external
export const VersionInfo = withNamespaces(['setting'])(({ t }) => (
  
    
      
      
        <title>
          &lt;PoiName&gt;{aprilFirst ? 'chiba' : 'poi'}&lt;/PoiName&gt; {POI_VERSION}
        </title>
        
          <div>
            {isString(LATEST_COMMIT) ? (
              &lt;&gt;
                Build {toUpper(LATEST_COMMIT.substring(0, 8))}
              
            ) : (
              DEV
            )}
          </div>
          <div>
            OS {os}
          </div>
          {map(['electron', 'chrome', 'node'], name =&gt; (
            <div>
              {capitalize(name)} {process.versions[name]}
            </div>
          ))}
          <div></div>
github avigoldman / fuse-email / lib / index.js View on Github external
responder.startConversation = function(config, callback) {
      config = _.isString(config) ? { subject: config } : config;

      if (!_.has(config, 'recipients') && !_.has(config, 'cc')) {
        _.defaults(config, {
          subject: inboundMessage.subject,
          recipients: inboundMessage.recipients || [],
          cc: inboundMessage.cc || []
        });

        config = addFromAddress(inboundMessage, config);
        config = removeToAddress(inboundMessage, config);
      }

      var convo = Conversation(fuse, config, callback);

      fuse.convos.push(convo);