Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@doodle/tracking / dist / esm / src / helpers / utils.js
Size: Mime:
/**
 * Checks if an object's type is undefined
 *
 * @param {*} obj - The object reference to be checked
 * @return {boolean}
 */
var isUndefined = function isUndefined(obj) {
  return typeof obj === 'undefined';
};
/**
 * Helper to pluralize words in error messages
 *
 * @param {string} word - A string that will be suffixed with an 's' if collection has more than 1 member
 * @param {Array} arr - The group of items
 * @return {string} Either the word sufixed with a simple plural, 's', or the provided original
 */


var pluralize = function pluralize(word, arr) {
  return arr.length > 1 ? "".concat(word, "s") : word;
};
/**
 * Computes a flag based on given probability thresholds and a sampling rate
 *
 * @param {TrackingApiServices} services An HTML element to inspect
 * @param {Number|Boolean} samplingRate A number from 0 to 1 (inclusive), or a boolean
 * @return {TrackingApiServices}
 */


var sampleServices = function sampleServices(services, samplingRate) {
  return Object.keys(services).reduce(function (acc, cur) {
    var serviceThreshold = services[cur];
    acc[cur] = serviceThreshold >= samplingRate;
    return acc;
  }, {});
};

export { isUndefined, pluralize, sampleServices };
//# sourceMappingURL=utils.js.map