-
Notifications
You must be signed in to change notification settings - Fork 387
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,6 +74,46 @@ var main = function() { | |
} | ||
}); | ||
|
||
defineProperties(String, { | ||
raw: function() { | ||
var callSite = arguments[0]; | ||
var substitutions = Array.prototype.slice.call(arguments, 1); | ||
/*var cooked = Object(callSite); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
dekajp
Author
Contributor
|
||
var rawValue = cooked.raw; | ||
var raw = Object(rawValue); | ||
var len = raw.length; | ||
var literalsegments = ToUint32(len);*/ | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
var literalsegments = callSite.length; | ||
|
||
if (literalsegments === 0){return '';} | ||
|
||
var stringElements = []; | ||
var nextIndex = 0; | ||
|
||
var nextKey , next, nextSeg, nextSub ; | ||
while (nextIndex < literalsegments) { | ||
nextKey = nextIndex.toString(); | ||
next = callSite[nextKey]; | ||
nextSeg = next.toString(); | ||
|
||
stringElements.push(nextSeg); | ||
|
||
if (nextIndex + 1 >= literalsegments || nextIndex >= substitutions.length){ | ||
break; | ||
} | ||
next = substitutions[nextKey]; | ||
nextSub = next.toString(); | ||
stringElements.push(nextSub); | ||
|
||
nextIndex++; | ||
|
||
} | ||
|
||
return stringElements.join(''); | ||
} | ||
}); | ||
|
||
defineProperties(String.prototype, { | ||
// Fast repeat, uses the `Exponentiation by squaring` algorithm. | ||
repeat: function(times) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 comment
on commit 998fa49
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is the new code - d32a97e . thanks for your assistance and help :). I will submit a pull request
also, why is this whole section commented out?