Sha256: 6b4072fd7f721f7da0c26473e73a80667e80bc0ad45bd6523cdafc19b935933a

Contents?: true

Size: 773 Bytes

Versions: 40

Compression:

Stored size: 773 Bytes

Contents

// https://github.com/ljharb/proposal-string-pad-left-right
var toLength = require('./$.to-length')
  , repeat   = require('./$.string-repeat')
  , defined  = require('./$.defined');

module.exports = function(that, maxLength, fillString, left){
  var S            = String(defined(that))
    , stringLength = S.length
    , fillStr      = fillString === undefined ? ' ' : String(fillString)
    , intMaxLength = toLength(maxLength);
  if(intMaxLength <= stringLength)return S;
  if(fillStr == '')fillStr = ' ';
  var fillLen = intMaxLength - stringLength
    , stringFiller = repeat.call(fillStr, Math.ceil(fillLen / fillStr.length));
  if(stringFiller.length > fillLen)stringFiller = stringFiller.slice(0, fillLen);
  return left ? stringFiller + S : S + stringFiller;
};

Version data entries

40 entries across 18 versions & 7 rubygems

Version Path
babel-schmooze-sprockets-0.1.2 node_modules/core-js/modules/$.string-pad.js
babel-schmooze-sprockets-0.1.2 node_modules/core-js/library/modules/$.string-pad.js
babel-schmooze-sprockets-0.1.1 node_modules/core-js/modules/$.string-pad.js
babel-schmooze-sprockets-0.1.1 node_modules/core-js/library/modules/$.string-pad.js
babel-schmooze-sprockets-0.1.0 node_modules/core-js/library/modules/$.string-pad.js
babel-schmooze-sprockets-0.1.0 node_modules/core-js/modules/$.string-pad.js
babel-schmooze-sprockets-0.1.0.alpha.3 node_modules/core-js/library/modules/$.string-pad.js
babel-schmooze-sprockets-0.1.0.alpha.3 node_modules/core-js/modules/$.string-pad.js
babel-schmooze-sprockets-0.1.0.alpha.2 node_modules/core-js/library/modules/$.string-pad.js
babel-schmooze-sprockets-0.1.0.alpha.2 node_modules/core-js/modules/$.string-pad.js
es6_tilt-0.1.2 test/dummy/node_modules/core-js/library/modules/$.string-pad.js
es6_tilt-0.1.2 test/dummy/app/assets/javascripts/node_modules/core-js/library/modules/$.string-pad.js
es6_tilt-0.1.2 test/dummy/app/assets/javascripts/node_modules/core-js/modules/$.string-pad.js
es6_tilt-0.1.2 test/dummy/node_modules/core-js/modules/$.string-pad.js
es6_tilt-0.1.1 test/dummy/app/assets/javascripts/node_modules/core-js/modules/$.string-pad.js
es6_tilt-0.1.1 test/dummy/app/assets/javascripts/node_modules/core-js/library/modules/$.string-pad.js
es6_tilt-0.1.1 test/dummy/node_modules/core-js/library/modules/$.string-pad.js
es6_tilt-0.1.1 test/dummy/node_modules/core-js/modules/$.string-pad.js
es6_tilt-0.1.0 test/dummy/app/assets/javascripts/node_modules/core-js/modules/$.string-pad.js
es6_tilt-0.1.0 test/dummy/app/assets/javascripts/node_modules/core-js/library/modules/$.string-pad.js