How to use is-string - 7 common examples

To help you get started, we’ve selected a few is-string 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 colejd / guify / src / gui.js View on Github external
this.hasRoot = opts.root !== undefined;

        opts.width = opts.width || 300;
        opts.root = opts.root || document.body;
        opts.align = opts.align || 'left'; // Can be 'left' or 'right'
        opts.opacity = opts.opacity || 1.0;
        opts.barMode = opts.barMode || 'offset'; // Can be 'none', 'above', 'offset', or 'overlay'
        opts.panelMode = opts.panelMode || 'inner';
        opts.pollRateMS = opts.pollRateMS || 100;
        opts.open = opts.open || false;

        // Set theme global from opts
        let chosenTheme = opts.theme;
        if(opts.theme === undefined) chosenTheme = themes.dark;
        if(isstring(opts.theme)) {
            if(themes[opts.theme] === undefined) {
                console.error(`There is no theme preset with the name '${opts.theme}'! Defaulting to dark theme.`);
                chosenTheme = themes.dark;
            }
            else chosenTheme = themes[opts.theme];
        }
        theme.Set(chosenTheme);

        this._ConstructElements();
        this._LoadStyles();

        this.componentManager = new ComponentManager();

        this.loadedComponents = [];

        // Begin component update loop
github GameDistribution / GD-HTML5 / src / components / Macros.js View on Github external
transformValue(value, options) {
        if (isPlainObject(value) || isArray(value)) { // ?
            for (let objKey in value) {
                value[objKey] = this.transformValue(value[objKey], options);
            }
        } else if (isString(value)) {
            // replace params here
            let regex = /\{\{(\w+)\}\}/g;
            let matched;
            let replaceItems = [];
            do {
                matched = regex.exec(value);
                if (matched) {
                    let macro = matched[0];
                    let macroKey = matched[1];
                    let macroValue = this.getMacroKeyValue(macroKey, options);
                    if (typeof macroValue !== "undefined") {
                        replaceItems.push({ key: macroKey, value: macroValue })
                    }
                }
            } while (matched);
            if (replaceItems.length > 0) {
github nashdot / accounting-js / lib / formatColumn.js View on Github external
return formatted.map((val) => {
    // Only if this is a string (not a nested array, which would have already been padded)
    if (isString(val) && val.length < maxLength) {
      // Depending on symbol position, pad after symbol or at index 0
      return padAfterSymbol ?
        val.replace(opts.symbol, opts.symbol + (new Array(maxLength - val.length + 1).join(' '))) :
        (new Array(maxLength - val.length + 1).join(' ')) + val;
    }
    return val;
  });
}
github nashdot / accounting-js / lib / internal / checkCurrencyFormat.js View on Github external
function checkCurrencyFormat(format) {
  // Format should be a string, in which case `value` ('%v') must be present
  if (isString(format) && format.match('%v')) {
    // Create and return positive, negative and zero formats
    return {
      pos: format,
      neg: format.replace('-', '').replace('%v', '-%v'),
      zero: format
    };
  }

  // Otherwise, assume format was fine
  return format;
}
github stevenvachon / broken-link-checker / lib / public / HtmlChecker.js View on Github external
return "BLC_ROBOTS";
		}
		else if (matchURL(href, excludedKeywords))
		{
			return "BLC_KEYWORD";
		}
		else if (includedKeywords.length>0 && !matchURL(href, includedKeywords))
		{
			return "BLC_KEYWORD";
		}
		else
		{
			const filterResult = includeLink(link);

			// Undocumented support for strings (from `SiteChecker`)
			if (isString(filterResult) && filterResult in reasons)
			{
				return filterResult;
			}
			else if (!filterResult)
			{
				return "BLC_CUSTOM";
			}
			else
			{
				// Not excluded
			}
		}
	}
github airbnb / enzyme / packages / enzyme / src / Debug.js View on Github external
function propString(prop, options) {
  if (isString(prop)) {
    return inspect(String(prop), { quoteStyle: 'double' });
  }
  if (isNumber(prop)) {
    return `{${inspect(Number(prop))}}`;
  }
  if (isBoolean(prop)) {
    return `{${inspect(booleanValue(prop))}}`;
  }
  if (isCallable(prop)) {
    return `{${inspect(prop)}}`;
  }
  if (typeof prop === 'object') {
    if (options.verbose) {
      return `{${inspect(prop)}}`;
    }
github dleitee / fetches / src / utils / normalize-url.js View on Github external
const hasHTTPProtocol = url => isString(url) && url.startsWith('http')

is-string

Is this value a JS String object or primitive? This module works cross-realm/iframe, and despite ES6 @@toStringTag.

MIT
Latest version published 3 years ago

Package Health Score

67 / 100
Full package analysis

Popular is-string functions