tbranyen/combyne

View on GitHub
lib/support/string/trim_left.js

Summary

Maintainability
A
2 hrs
Test Coverage
/**
 * Legacy support for browsers that don't support String.prototype.trimLeft.
 *
 * @module: support/string/trim_left
 */
define(function(require, exports, module) {
  "use strict";

  // This polyfill isn't necessary.
  if (String.prototype.trimLeft) {
    return trimLeft;
  }

  /**
   * A polyfill for String#trimLeft.  Modified from MDN.
   *
   * @memberOf module:support/string/trim_left
   * @returns {string} The trimmed String.
   */
  function trimLeft() {
    return this.replace(/^\s+/, "");
  }

  module.exports = String.prototype.trimLeft = trimLeft;
});