-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
d97d020
commit d4953d3
Showing
6 changed files
with
71 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,20 @@ | ||
"use strict"; | ||
|
||
Promise.reflect = function (promises) { | ||
return Promise.all(promises.map(function (promise) { | ||
return promise.then(function (v) { | ||
return { v: v, status: "fulfilled" }; | ||
}, function (e) { | ||
return { e: e, status: "rejected" }; | ||
}); | ||
})); | ||
}; | ||
|
||
Promise.prototype.state = function () { | ||
var promiseCheck = {}; | ||
return Promise.race([this, promiseCheck]).then(function (value) { | ||
return value === promiseCheck ? "pending" : "fulfilled"; | ||
}, function () { | ||
return "rejected"; | ||
}); | ||
}; |
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,46 @@ | ||
"use strict"; | ||
|
||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
|
||
String.prototype.removeAfter = function (character) { | ||
var self = this; | ||
if (!Array.isArray(character)) { | ||
character = [character]; | ||
} | ||
character.forEach(function (element) { | ||
self = self.substring(0, self.indexOf(element) >= 0 && element.length > 0 ? self.indexOf(element) : self.length); | ||
}); | ||
self = IEObjectToString(self); | ||
return self; | ||
}; | ||
|
||
String.prototype.removeBefore = function (character) { | ||
var self = this; | ||
if (!Array.isArray(character)) { | ||
character = [character]; | ||
} | ||
character.forEach(function (element) { | ||
if (element) { | ||
self = self.substring(self.lastIndexOf(element[element.length - 1]) >= 0 && element.length > 0 ? self.lastIndexOf(element[element.length - 1]) + 1 : 0); | ||
} | ||
}); | ||
self = IEObjectToString(self); | ||
return self; | ||
}; | ||
|
||
// IE 9 fix where String.removeAfter and String.removeBefore returned an object when passing an empty array in, this function will convert that object back to a string | ||
function IEObjectToString(string) { | ||
/* istanbul ignore if */ | ||
if ((typeof string === "undefined" ? "undefined" : _typeof(string)) == "object") { | ||
string = Object.keys(string).filter(function (item) { | ||
return !isNaN(parseInt(item)); | ||
}).sort(function (a, b) { | ||
return a > b; | ||
}).map(function (value) { | ||
return string[value]; | ||
}).reduce(function (a, b) { | ||
return a + b; | ||
}); | ||
} | ||
return string; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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