Sha256: 4a1146a5ae0694946b7063779c1522c95439050e41bafdd2a703c785625fe0c8

Contents?: true

Size: 1.25 KB

Versions: 105

Compression:

Stored size: 1.25 KB

Contents

'use strict';

exports.repeat = function (str, num) {
  var result = '';
  for (var i = 0; i < num; i++) { result += str; }
  return result;
};

exports.arrayEqual = function (a, b) {
  if (a.length !== b.length) { return false; }
  for (var i = 0; i < a.length; i++) {
    if (a[i] !== b[i]) { return false; }
  }
  return true;
};

exports.trimChars = function (str, chars) {
  var start = 0;
  var end = str.length - 1;
  while (chars.indexOf(str.charAt(start)) >= 0) { start++; }
  while (chars.indexOf(str.charAt(end)) >= 0) { end--; }
  return str.slice(start, end + 1);
};

exports.capitalize = function (str) {
  return str.charAt(0).toUpperCase() + str.slice(1);
};

exports.arrayUnion = function () {
  var result = [];
  for (var i = 0, values = {}; i < arguments.length; i++) {
    var arr = arguments[i];
    for (var j = 0; j < arr.length; j++) {
      if (!values[arr[j]]) {
        values[arr[j]] = true;
        result.push(arr[j]);
      }
    }
  }
  return result;
};

function has(obj, key) {
  return Object.prototype.hasOwnProperty.call(obj, key);
}

exports.has = has;

exports.extend = function (dest, src) {
  for (var i in src) {
    if (has(src, i)) { dest[i] = src[i]; }
  }
};

exports.trimEnd = function (str) {
  return str.replace(/\s+$/g, '');
};

Version data entries

105 entries across 104 versions & 18 rubygems

Version Path
optimacms-0.1.61 spec/dummy/node_modules/argparse/lib/utils.js
disco_app-0.18.0 test/dummy/node_modules/argparse/lib/utils.js
disco_app-0.18.2 test/dummy/node_modules/argparse/lib/utils.js
appmap-0.72.2 ./node_modules/argparse/lib/utils.js
appmap-0.72.1 ./node_modules/argparse/lib/utils.js
appmap-0.72.0 ./node_modules/argparse/lib/utils.js
appmap-0.71.0 ./node_modules/argparse/lib/utils.js
disco_app-0.16.1 test/dummy/node_modules/argparse/lib/utils.js
appmap-0.70.2 ./node_modules/argparse/lib/utils.js
appmap-0.70.1 ./node_modules/argparse/lib/utils.js
appmap-0.70.0 ./node_modules/argparse/lib/utils.js
appmap-0.69.0 ./node_modules/argparse/lib/utils.js
appmap-0.68.2 ./node_modules/argparse/lib/utils.js
appmap-0.68.1 ./node_modules/argparse/lib/utils.js
disco_app-0.15.2 test/dummy/node_modules/argparse/lib/utils.js
appmap-0.68.0 ./node_modules/argparse/lib/utils.js
appmap-0.67.1 ./node_modules/argparse/lib/utils.js
appmap-0.67.0 ./node_modules/argparse/lib/utils.js
disco_app-0.18.4 test/dummy/node_modules/argparse/lib/utils.js
disco_app-0.18.1 test/dummy/node_modules/argparse/lib/utils.js