Merge pull request #1760 from thelounge/astorije/rm-object.assign-polyfill

Get rid of `Object.assign` polyfill
This commit is contained in:
Pavel Djundik 2018-02-19 18:29:45 +02:00 committed by GitHub
commit 13a53706f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,26 +3,13 @@
const anyIntersection = require("./anyIntersection"); const anyIntersection = require("./anyIntersection");
const fill = require("./fill"); const fill = require("./fill");
let Object_assign = Object.assign;
if (typeof Object_assign !== "function") {
Object_assign = function(target) {
Array.prototype.slice.call(arguments, 1).forEach(function(obj) {
Object.keys(obj).forEach(function(key) {
target[key] = obj[key];
});
});
return target;
};
}
// Merge text part information within a styling fragment // Merge text part information within a styling fragment
function assign(textPart, fragment) { function assign(textPart, fragment) {
const fragStart = fragment.start; const fragStart = fragment.start;
const start = Math.max(fragment.start, textPart.start); const start = Math.max(fragment.start, textPart.start);
const end = Math.min(fragment.end, textPart.end); const end = Math.min(fragment.end, textPart.end);
return Object_assign({}, fragment, { return Object.assign({}, fragment, {
start: start, start: start,
end: end, end: end,
text: fragment.text.slice(start - fragStart, end - fragStart), text: fragment.text.slice(start - fragStart, end - fragStart),