How to use the sprintf-js.sprintf.apply function in sprintf-js

To help you get started, we’ve selected a few sprintf-js 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 paaatrick / playball / lib / print.js View on Github external
error: function() {
    console.log(chalk.bold.red(sprintf.apply(undefined, arguments)));
  },
github google / santa-tracker-web / gulp_scripts / i18n_replace / index.js View on Github external
return function(var_args) {
    const message = format.apply(this, arguments);
    if (strict) {
      throw new gutil.PluginError('i18n_replace', message);
    } else {
      gutil.log('WARNING[i18n_replace]:', message);
    }
  }
}
github mgechev / codelyzer / src / noAccessMissingMemberRule.ts View on Github external
tmp = tmp.receiver;
      } else if (ExpTypes.PropertyWrite(tmp)) {
        tmp = tmp.receiver;
      } else if (ExpTypes.SafeMethodCall(tmp)) {
        tmp = tmp.receiver;
      } else if (ExpTypes.SafePropertyRead(tmp)) {
        tmp = tmp.receiver;
      } else if (ExpTypes.MethodCall(tmp)) {
        tmp = tmp.receiver;
      } else {
        break;
      }
    }

    if (ast.name && !available[ast.name]) {
      let failureString = sprintf.apply(this, [Rule.FAILURE, symbolType, ast.name]);
      const top = this.getTopSuggestion(Object.keys(available), ast.name);
      const getSuggestion = (list: string[]) => {
        if (list.length === 1) {
          return `"${list[0]}"`;
        }
        let result = `"${list.shift()}"`;
        while (list.length > 1) {
          result += `, "${list.shift()}"`;
        }
        result += ` or "${list.shift()}"`;
        return result;
      };
      if (top.length && top[0].distance <= 2) {
        failureString += ` Probably you mean: ${getSuggestion(top.map(s => s.element))}.`;
      }
      const width = ast.name.length;
github Evinyatar / pith / lib / upnp.js View on Github external
function format(n, parts, f) {
    const out = [];
    let nn = n;
    while(parts.length) {
        const p = parts.pop(), pn = nn % p;
        out.unshift(pn);
        nn = (nn - pn) / p;
    }
    out.unshift(nn);
    out.unshift(f);
    return sprintf.apply(null, out);
}
github google / santa-tracker-web / gulp_scripts / i18n_replace / index.js View on Github external
function error(var_args) {
  const message = format.apply(this, arguments);
  throw new gutil.PluginError('i18n_replace', message);
}
github tableflip / guvnor / web / client / helpers / notification.js View on Github external
module.exports = function (options) {
  if (!Array.isArray(options.message)) {
    options.message = [options.message]
  }

  window.$.growl('<h4>' + options.header + '</h4>' + sprintf.apply(null, options.message), {
    type: options.type ? options.type : 'info',
    offset: 15
  })
}
github optimizely / javascript-sdk / packages / optimizely-sdk / lib / utils / sprintf.js View on Github external
var sprintf = function(message, moduleName, data) {
  if (typeof data === 'object') {
    var dataValues = Object.keys(data).map(function(k) { return data[k]; });
    try {
      return Object.assign({}, data, {
        message: sprintf2.apply(sprintf2, [message, moduleName].concat(dataValues)),
      });
    } catch (error) {}
  }
  return {
    message: sprintf2(message, moduleName),
  };
};
github sigoden / htte / packages / htte-reporter-cli / src / utils.js View on Github external
function print() {
  let string = arguments[0];
  if (arguments.length !== 1) {
    string = sprintf.apply(sprintf, arguments);
  }
  process.stdout.write(string + os.EOL);
}

sprintf-js

JavaScript sprintf implementation

BSD-3-Clause
Latest version published 8 months ago

Package Health Score

76 / 100
Full package analysis

Similar packages