Skip to content

Commit

Permalink
String#repeat to its own block
Browse files Browse the repository at this point in the history
Former-commit-id: fcb7858e3e489dc9027c235af30a89261e863f5a [formerly ccdf6c6622ea7720154237f34a030cc471d7b339]
Former-commit-id: dbdbb355831485e7599884202aac656694681970
  • Loading branch information
andrewplummer committed Aug 25, 2013
1 parent c1d981c commit 282add8
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 57 deletions.
35 changes: 18 additions & 17 deletions lib/string.js
Expand Up @@ -137,6 +137,24 @@
}
}

extend(string, true, false, {
/***
* @method repeat([num] = 0)
* @returns String
* @short Returns the string repeated [num] times.
* @example
*
* 'jumpy'.repeat(2) -> 'jumpyjumpy'
* 'a'.repeat(5) -> 'aaaaa'
* 'a'.repeat(0) -> ''
*
***/
'repeat': function(num) {
num = checkRepeatRange(num);
return repeatString(this, num);
}

});

extend(string, true, function(reg) { return isRegExp(reg) || arguments.length > 2; }, {

Expand Down Expand Up @@ -186,7 +204,6 @@

});


extend(string, true, true, {

/***
Expand Down Expand Up @@ -799,22 +816,6 @@
return this.substr(start);
},

/***
* @method repeat([num] = 0)
* @returns String
* @short Returns the string repeated [num] times.
* @example
*
* 'jumpy'.repeat(2) -> 'jumpyjumpy'
* 'a'.repeat(5) -> 'aaaaa'
* 'a'.repeat(0) -> ''
*
***/
'repeat': function(num) {
num = checkRepeatRange(num);
return repeatString(this, num);
},

/***
* @method toNumber([base] = 10)
* @returns Number
Expand Down
55 changes: 29 additions & 26 deletions release/sugar-full.development.js
@@ -1,5 +1,5 @@
/*
* Sugar Library vedge
* Sugar Library v1.4.0
*
* Freely distributable and licensed under the MIT-style license.
* Copyright (c) 2013 Andrew Plummer
Expand Down Expand Up @@ -6631,6 +6631,24 @@
}
}

extend(string, true, false, {
/***
* @method repeat([num] = 0)
* @returns String
* @short Returns the string repeated [num] times.
* @example
*
* 'jumpy'.repeat(2) -> 'jumpyjumpy'
* 'a'.repeat(5) -> 'aaaaa'
* 'a'.repeat(0) -> ''
*
***/
'repeat': function(num) {
num = checkRepeatRange(num);
return repeatString(this, num);
}

});

extend(string, true, function(reg) { return isRegExp(reg) || arguments.length > 2; }, {

Expand Down Expand Up @@ -6680,7 +6698,6 @@

});


extend(string, true, true, {

/***
Expand Down Expand Up @@ -7293,22 +7310,6 @@
return this.substr(start);
},

/***
* @method repeat([num] = 0)
* @returns String
* @short Returns the string repeated [num] times.
* @example
*
* 'jumpy'.repeat(2) -> 'jumpyjumpy'
* 'a'.repeat(5) -> 'aaaaa'
* 'a'.repeat(0) -> ''
*
***/
'repeat': function(num) {
num = checkRepeatRange(num);
return repeatString(this, num);
},

/***
* @method toNumber([base] = 10)
* @returns Number
Expand Down Expand Up @@ -7901,14 +7902,16 @@

// Support for converting character widths and katakana to hiragana.

var HALF_WIDTH_TO_FULL_WIDTH_TRAVERSAL = 65248;

var widthConversionRanges = [
{ type: 'a', shift: 65248, start: 65, end: 90 },
{ type: 'a', shift: 65248, start: 97, end: 122 },
{ type: 'n', shift: 65248, start: 48, end: 57 },
{ type: 'p', shift: 65248, start: 33, end: 47 },
{ type: 'p', shift: 65248, start: 58, end: 64 },
{ type: 'p', shift: 65248, start: 91, end: 96 },
{ type: 'p', shift: 65248, start: 123, end: 126 }
{ type: 'a', start: 65, end: 90 },
{ type: 'a', start: 97, end: 122 },
{ type: 'n', start: 48, end: 57 },
{ type: 'p', start: 33, end: 47 },
{ type: 'p', start: 58, end: 64 },
{ type: 'p', start: 91, end: 96 },
{ type: 'p', start: 123, end: 126 }
];

var WidthConversionTable;
Expand Down Expand Up @@ -7945,7 +7948,7 @@
widthConversionRanges.forEach(function(r) {
simpleRepeat(r.end - r.start + 1, function(n) {
n += r.start;
setWidthConversion(r.type, chr(n), chr(n + r.shift));
setWidthConversion(r.type, chr(n), chr(n + HALF_WIDTH_TO_FULL_WIDTH_TRAVERSAL));
});
});
zenkakuKatakana.each(function(c, i) {
Expand Down
19 changes: 9 additions & 10 deletions release/sugar-full.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 282add8

Please sign in to comment.