-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Breaking] conform to the es-shim API.
- Loading branch information
Showing
6 changed files
with
55 additions
and
21 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
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
'use strict'; | ||
|
||
var bind = require('function-bind'); | ||
var replace = bind.call(Function.call, String.prototype.replace); | ||
|
||
var leftWhitespace = /^[\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]*/; | ||
|
||
module.exports = function trimLeft() { | ||
return replace(this, leftWhitespace, ''); | ||
}; |
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
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
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
'use strict'; | ||
|
||
var implementation = require('./implementation'); | ||
|
||
module.exports = function getPolyfill() { | ||
if (!String.prototype.trimLeft) { | ||
return implementation; | ||
} | ||
var zeroWidthSpace = '\u200b'; | ||
if (zeroWidthSpace.trimLeft() !== zeroWidthSpace) { | ||
return implementation; | ||
} | ||
return String.prototype.trimLeft; | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
'use strict'; | ||
|
||
var define = require('define-properties'); | ||
var getPolyfill = require('./polyfill'); | ||
|
||
module.exports = function shimTrimLeft() { | ||
var polyfill = getPolyfill(); | ||
define( | ||
String.prototype, | ||
{ trimLeft: polyfill }, | ||
{ trimLeft: function () { return String.prototype.trimLeft !== polyfill; } } | ||
); | ||
return polyfill; | ||
}; |