Skip to content

Commit

Permalink
chore(*): replace setImmediate and remove core-js-pure
Browse files Browse the repository at this point in the history
  • Loading branch information
onlyexeption committed Aug 3, 2020
1 parent a858f05 commit 57accfb
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 8 deletions.
3 changes: 3 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ This is a commercial product, requiring a valid paid-for license for commercial
This product is free to use for non-commercial educational use for students in K through 12 grades
or University programs, and for educators to use in a classroom setting as examples / tools in their curriculum.

This repository includes files originally copied from https://github.com/zloirock/core-js
under setImmediate.ts. The original versions of the files are MIT licensed. See the file headers for details.

In order for us to verify your eligibility for free usage, please register for trial at
https://Infragistics.com/Angular and open a support ticket with a request for free license.

Expand Down
5 changes: 0 additions & 5 deletions package-lock.json

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

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
"@types/source-map": "0.5.2",
"classlist.js": "^1.1.20150312",
"core-js": "^2.6.11",
"core-js-pure": "^3.6.5",
"hammerjs": "^2.0.8",
"igniteui-trial-watermark": "^1.0.3",
"jszip": "^3.5.0",
Expand Down
1 change: 0 additions & 1 deletion projects/igniteui-angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
],
"dependencies": {
"@types/hammerjs": "^2.0.36",
"core-js-pure": "^3.6.5",
"hammerjs": "^2.0.8",
"jszip": "^3.5.0",
"tslib": "^2.0.0",
Expand Down
69 changes: 69 additions & 0 deletions projects/igniteui-angular/src/lib/core/setImmediate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/* Copyright (c) 2014-2020 Denis Pushkarev
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE
*/

// Note: Originally copied from core-js-pure package and modified. (https://github.com/zloirock/core-js)
const windowLocation = window.location;
let counter = 0;
const queue = {};

const run = function (id) {
if (queue.hasOwnProperty(id)) {
const fn = queue[id];
delete queue[id];
fn();
}
};

const listener = function (event) {
run(event.data);
};

export function setImmediate(cb: any) {
if (window.setImmediate) {
window.setImmediate(cb);
return;
}

const args = [];
let i = 1;

while (arguments.length > i) {
args.push(arguments[i++]);
}

queue[++counter] = function () {
(typeof cb === 'function' ? cb : Function(cb)).apply(undefined, args);
};

window.postMessage(counter + '', windowLocation.protocol + '//' + windowLocation.host);
window.addEventListener('message', listener, false);

return counter;
}

export function clearImmediate(id: any) {
if (window.clearImmediate) {
window.clearImmediate(id);
return;
}

delete queue[id];
}
2 changes: 1 addition & 1 deletion projects/igniteui-angular/src/lib/core/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Injectable, PLATFORM_ID, Inject } from '@angular/core';
import { isPlatformBrowser } from '@angular/common';
import { Observable } from 'rxjs';
import ResizeObserver from 'resize-observer-polyfill';
import { setImmediate } from 'core-js-pure';
import { setImmediate } from './setImmediate';
import merge from 'lodash.merge';

/**
Expand Down

0 comments on commit 57accfb

Please sign in to comment.