Socket
Socket
Sign inDemoInstall

zone.js

Package Overview
Dependencies
Maintainers
1
Versions
124
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zone.js - npm Package Compare versions

Comparing version 0.4.1 to 0.4.2

scripts/sauce/sauce_connect_block.sh

15

karma-sauce.conf.js

@@ -27,7 +27,13 @@ // Karma configuration

config.set({
captureTimeout: 120000,
browserNoActivityTimeout: 1500000,
sauceLabs: {
testName: 'Dom Interceptor Unit Tests',
startConnect: true,
options: {
'selenium-version': '2.37.0'
testName: 'Zone.js',
startConnect: false,
options: {
'selenium-version': '2.41.0',
'command-timeout': 600,
'idle-timeout': 600,
'max-duration': 5400
}

@@ -49,3 +55,2 @@ },

if (process.env.TRAVIS) {

@@ -52,0 +57,0 @@ config.sauceLabs.build = 'TRAVIS #' + process.env.TRAVIS_BUILD_NUMBER + ' (' + process.env.TRAVIS_BUILD_ID + ')';

@@ -7,6 +7,6 @@ // Karma configuration

files: [
'test/util.js',
'zone.js',
'*-zone.js',
//'test/lib/brick.js',
'test/util.js',
'test/**/*.spec.js',

@@ -13,0 +13,0 @@ {pattern: 'test/assets/**/*.html', watched: true, served: true, included: false}

@@ -49,8 +49,10 @@ /*

var zone = this;
if (zone.stackFramesFilter) {
trace.push(exception.stack.split('\n').
filter(zone.stackFramesFilter).
join('\n'));
} else {
trace.push(exception.stack);
if (exception) {
if (zone.stackFramesFilter) {
trace.push(exception.stack.split('\n').
filter(zone.stackFramesFilter).
join('\n'));
} else {
trace.push(exception.stack);
}
}

@@ -57,0 +59,0 @@ var now = Date.now();

{
"name": "zone.js",
"version": "0.4.1",
"version": "0.4.2",
"description": "Zones for JavaScript",

@@ -5,0 +5,0 @@ "main": "zone.js",

@@ -87,16 +87,2 @@ # Zone.js

### Tracking VM Turns
Run some function at the end of each VM turn:
```javascript
zone.fork({
afterTask: function () {
// do some cleanup
}
}).run(function () {
// do stuff
});
```
### Overriding A Zone's Hook

@@ -168,3 +154,3 @@

someZone.fork({
'+afterTask': function (parentOnLeave) {
'+afterTask': function () {
console.log('cya l8r');

@@ -199,5 +185,8 @@ }

zone.fork({
onZoneCreated: function () {},
beforeTask: function () {},
afterTask: function () {},
onError: function () {},
enqueueTask: function() {},
dequeueTask: function() {},
setTimeout: function () {},

@@ -204,0 +193,0 @@ setInterval: function () {},

@@ -49,2 +49,6 @@ 'use strict';

});
it('should expose LST via getLogStackTrace', function () {
expect(lstz.getLongStacktrace()).toBeDefined();
});
});
'use strict';
function supportsImports() {
return 'import' in document.createElement('link');
}
supportsImports.message = 'HTML Imports';
describe('HTML Imports', ifEnvSupports(supportsImports, function () {

@@ -41,6 +46,1 @@

}));
function supportsImports() {
return 'import' in document.createElement('link');
}
supportsImports.message = 'HTML Imports';
'use strict';
describe('Promise', function () {
describe('Promise', ifEnvSupports('Promise', function () {
it('should work with .then', function (done) {
if (!window.Promise) {
console.log('WARNING: skipping Promise test (missing this API)');
return;
}
new Promise(function (resolve) {

@@ -20,6 +15,2 @@ resolve();

it('should work with .catch', function (done) {
if (!window.Promise) {
return;
}
new Promise(function (resolve, reject) {

@@ -33,2 +24,2 @@ reject();

});
}));

@@ -8,2 +8,7 @@ /*

function registerElement() {
return ('registerElement' in document);
}
registerElement.message = 'document.registerElement';
describe('document.registerElement', ifEnvSupports(registerElement, function () {

@@ -114,6 +119,1 @@

}));
function registerElement() {
return ('registerElement' in document);
}
registerElement.message = 'document.registerElement';

@@ -24,1 +24,4 @@

};
// useful for testing mocks
window.__setTimeout = window.setTimeout;

@@ -9,2 +9,10 @@ 'use strict';

it('should have an id', function () {
expect(zone.$id).toBeDefined();
});
it('forked zones should have a greater id than their parent', function () {
expect(zone.fork().$id).toBeGreaterThan(zone.$id);
});
describe('hooks', function () {

@@ -136,2 +144,28 @@

describe('bindPromiseFn', function () {
var mockPromise = function() {
return {
then: function (a, b) {
window.__setTimeout(a, 0);
return mockPromise();
}
};
};
it('should return a method that returns promises that run in the correct zone', function (done) {
zone.fork({ mark: 'a' }).run(function () {
var patched = Zone.bindPromiseFn(function() {
return mockPromise();
});
patched().then(function () {
expect(zone.mark).toBe('a');
}).then(function () {
expect(zone.mark).toBe('a');
done();
});
});
});
});
});

@@ -138,0 +172,0 @@

@@ -48,2 +48,4 @@ 'use strict';

zone.$id = ++Zone.nextId;
return zone;

@@ -116,35 +118,22 @@ }

var setName = 'set' + name;
var clearName = 'clear' + name;
var delegate = obj[setName];
if (delegate) {
var clearName = 'clear' + name;
var ids = {};
if (setName === 'setInterval') {
zone[setName] = function (fn) {
var id;
arguments[0] = function () {
delete ids[id];
return fn.apply(this, arguments);
};
var args = Zone.bindArguments(arguments);
id = delegate.apply(obj, args);
ids[id] = true;
return id;
var bindArgs = setName === 'setInterval' ? Zone.bindArguments : Zone.bindArgumentsOnce;
zone[setName] = function (fn) {
var id;
arguments[0] = function () {
delete ids[id];
return fn.apply(this, arguments);
};
} else {
zone[setName] = function (fn) {
var id;
arguments[0] = function () {
delete ids[id];
return fn.apply(this, arguments);
};
var args = Zone.bindArgumentsOnce(arguments);
id = delegate.apply(obj, args);
ids[id] = true;
return id;
};
}
var args = bindArgs(arguments);
id = delegate.apply(obj, args);
ids[id] = true;
return id;
};
obj[setName] = function () {

@@ -171,3 +160,5 @@ return zone[setName].apply(this, arguments);

Zone.nextId = 1;
Zone.patchSetFn = function (obj, fnNames) {

@@ -223,2 +214,48 @@ fnNames.forEach(function (name) {

/*
* patch a fn that returns a promise
*/
Zone.bindPromiseFn = (function() {
// if the browser natively supports Promises, we can just return a native promise
if (window.Promise) {
return function (delegate) {
return function() {
var delegatePromise = delegate.apply(this, arguments);
if (delegatePromise instanceof Promise) {
return delegatePromise;
} else {
return new Promise(function(resolve, reject) {
delegatePromise.then(resolve, reject);
});
}
};
};
} else {
// if the browser does not have native promises, we have to patch each promise instance
return function (delegate) {
return function () {
return patchThenable(delegate.apply(this, arguments));
};
};
}
function patchThenable(thenable) {
var then = thenable.then;
thenable.then = function () {
var args = Zone.bindArguments(arguments);
var nextThenable = then.apply(thenable, args);
return patchThenable(nextThenable);
};
var ocatch = thenable.catch;
thenable.catch = function () {
var args = Zone.bindArguments(arguments);
var nextThenable = ocatch.apply(thenable, args);
return patchThenable(nextThenable);
};
return thenable;
}
}());
Zone.patchableFn = function (obj, fnNames) {

@@ -225,0 +262,0 @@ fnNames.forEach(function (name) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc