Socket
Socket
Sign inDemoInstall

@loopback/context

Package Overview
Dependencies
10
Maintainers
7
Versions
192
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.2.0 to 3.3.0

16

CHANGELOG.md

@@ -6,2 +6,18 @@ # Change Log

# [3.3.0](https://github.com/strongloop/loopback-next/compare/@loopback/context@3.2.0...@loopback/context@3.3.0) (2020-04-08)
### Bug Fixes
* **context:** fix context observer to catch errors by waitUntilPendingNotificationsDone ([3dad6c0](https://github.com/strongloop/loopback-next/commit/3dad6c0c22ef23506daf6f7d7ad28c247e6080c5))
### Features
* remove Node.js 8.x polyfill for Symbol.asyncIterator ([eeb8772](https://github.com/strongloop/loopback-next/commit/eeb877276cf62d32856eb7227d78618ab4c93c2e))
# [3.2.0](https://github.com/strongloop/loopback-next/compare/@loopback/context@3.1.0...@loopback/context@3.2.0) (2020-03-24)

@@ -8,0 +24,0 @@

2

dist/binding-config.js
"use strict";
// Copyright IBM Corp. 2019. All Rights Reserved.
// Copyright IBM Corp. 2019,2020. All Rights Reserved.
// Node module: @loopback/context

@@ -4,0 +4,0 @@ // This file is licensed under the MIT License.

"use strict";
// Copyright IBM Corp. 2018,2019. All Rights Reserved.
// Copyright IBM Corp. 2018,2020. All Rights Reserved.
// Node module: @loopback/context

@@ -4,0 +4,0 @@ // This file is licensed under the MIT License.

@@ -10,18 +10,5 @@ "use strict";

const events_1 = require("events");
const p_event_1 = require("p-event");
const debug = debug_1.default('loopback:context:subscription');
/**
* Polyfill Symbol.asyncIterator as required by TypeScript for Node 8.x.
* See https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-3.html
*/
if (!Symbol.asyncIterator) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Symbol.asyncIterator = Symbol.for('Symbol.asyncIterator');
}
/**
* WARNING: This following import must happen after the polyfill. The
* `auto-import` by an IDE such as VSCode may move the import before the
* polyfill. It must be then fixed manually.
*/
const p_event_1 = require("p-event");
/**
* An implementation of `Subscription` interface for context events

@@ -151,3 +138,7 @@ */

// Create an async iterator for the `notification` event as a queue
this.notificationQueue = p_event_1.iterator(this, 'notification');
this.notificationQueue = p_event_1.iterator(this, 'notification', {
// Do not end the iterator if an error event is emitted on the
// subscription manager
rejectionEvents: [],
});
return this.processNotifications();

@@ -197,7 +188,15 @@ }

catch (err) {
this.pendingNotifications--;
// Do not reduce the pending notification count so that errors
// can be captured by waitUntilPendingNotificationsDone
this._debug('Error caught from observers', err);
// Errors caught from observers. Emit it to the current context.
// If no error listeners are registered, crash the process.
this.emitError(err);
// Errors caught from observers.
if (this.listenerCount('error') > 0) {
// waitUntilPendingNotificationsDone may be called
this.emitError(err);
}
else {
// Emit it to the current context. If no error listeners are
// registered, crash the process.
this.handleNotificationError(err);
}
}

@@ -248,2 +247,3 @@ }

const count = this.pendingNotifications;
debug('Number of pending notifications: %d', count);
if (count === 0)

@@ -250,0 +250,0 @@ return;

@@ -0,1 +1,27 @@

/**
* Facilities to manage artifacts and their dependencies using {@link Context}
* in your Node.js applications. It can be used independent of the LoopBack
* framework.
*
* @remarks
* This package exposes TypeScript/JavaScript APIs and decorators to register
* artifacts, declare dependencies, and resolve artifacts by keys. The
* {@link Context} also serves as an IoC container to support dependency
* injection.
* Context and Binding are the two core concepts. A context is a registry of
* bindings and each binding represents a resolvable artifact by the key.
*
* - Bindings can be fulfilled by a constant, a factory function, a class, or a
* provider.
* - Bindings can be grouped by tags and searched by tags.
* - Binding scopes can be used to control how a resolved binding value is
* shared.
* - Bindings can be resolved synchronously or asynchronously.
* - Provide {@link inject | @inject} and other variants of decorators to
* express dependencies.
* - Support Constructor, property, and method injections.
* - Allow contexts to form a hierarchy to share or override bindings.
*
* @pakageDocumentation
*/
export * from '@loopback/metadata';

@@ -20,2 +46,3 @@ export * from './binding';

export * from './invocation';
export * from './json-types';
export * from './keys';

@@ -26,2 +53,1 @@ export * from './provider';

export * from './value-promise';
export * from './json-types';

@@ -8,2 +8,28 @@ "use strict";

const tslib_1 = require("tslib");
/**
* Facilities to manage artifacts and their dependencies using {@link Context}
* in your Node.js applications. It can be used independent of the LoopBack
* framework.
*
* @remarks
* This package exposes TypeScript/JavaScript APIs and decorators to register
* artifacts, declare dependencies, and resolve artifacts by keys. The
* {@link Context} also serves as an IoC container to support dependency
* injection.
* Context and Binding are the two core concepts. A context is a registry of
* bindings and each binding represents a resolvable artifact by the key.
*
* - Bindings can be fulfilled by a constant, a factory function, a class, or a
* provider.
* - Bindings can be grouped by tags and searched by tags.
* - Binding scopes can be used to control how a resolved binding value is
* shared.
* - Bindings can be resolved synchronously or asynchronously.
* - Provide {@link inject | @inject} and other variants of decorators to
* express dependencies.
* - Support Constructor, property, and method injections.
* - Allow contexts to form a hierarchy to share or override bindings.
*
* @pakageDocumentation
*/
tslib_1.__exportStar(require("@loopback/metadata"), exports);

@@ -10,0 +36,0 @@ tslib_1.__exportStar(require("./binding"), exports);

"use strict";
// Copyright IBM Corp. 2019. All Rights Reserved.
// Copyright IBM Corp. 2019,2020. All Rights Reserved.
// Node module: @loopback/context

@@ -4,0 +4,0 @@ // This file is licensed under the MIT License.

"use strict";
// Copyright IBM Corp. 2019. All Rights Reserved.
// Copyright IBM Corp. 2019,2020. All Rights Reserved.
// Node module: @loopback/context

@@ -4,0 +4,0 @@ // This file is licensed under the MIT License.

"use strict";
// Copyright IBM Corp. 2018,2019. All Rights Reserved.
// Copyright IBM Corp. 2018,2020. All Rights Reserved.
// Node module: @loopback/context

@@ -4,0 +4,0 @@ // This file is licensed under the MIT License.

@@ -1,2 +0,2 @@

// Copyright IBM Corp. 2017,2019. All Rights Reserved.
// Copyright IBM Corp. 2017,2020. All Rights Reserved.
// Node module: @loopback/context

@@ -3,0 +3,0 @@ // This file is licensed under the MIT License.

@@ -1,2 +0,2 @@

// Copyright IBM Corp. 2017,2019. All Rights Reserved.
// Copyright IBM Corp. 2017,2020. All Rights Reserved.
// Node module: @loopback/context

@@ -3,0 +3,0 @@ // This file is licensed under the MIT License.

{
"name": "@loopback/context",
"version": "3.2.0",
"version": "3.3.0",
"description": "LoopBack's container for Inversion of Control",

@@ -21,15 +21,15 @@ "engines": {

"dependencies": {
"@loopback/metadata": "^2.0.2",
"@loopback/metadata": "^2.0.3",
"debug": "^4.1.1",
"p-event": "^4.1.0",
"tslib": "^1.11.1",
"uuid": "^7.0.2"
"uuid": "^7.0.3"
},
"devDependencies": {
"@loopback/build": "^5.0.0",
"@loopback/eslint-config": "^6.0.2",
"@loopback/testlab": "^2.0.2",
"@loopback/build": "^5.0.1",
"@loopback/eslint-config": "^6.0.3",
"@loopback/testlab": "^3.0.0",
"@types/bluebird": "^3.5.30",
"@types/debug": "^4.1.5",
"@types/node": "^10.17.17",
"@types/node": "^10.17.19",
"@types/uuid": "^7.0.2",

@@ -60,3 +60,3 @@ "bluebird": "^3.7.2"

},
"gitHead": "020ed59b8bed8b38e1e4cede06a22b234effdb57"
"gitHead": "744a85c76a2dd260f6dc21e5b497f14eccaf099d"
}

@@ -1,2 +0,2 @@

// Copyright IBM Corp. 2019. All Rights Reserved.
// Copyright IBM Corp. 2019,2020. All Rights Reserved.
// Node module: @loopback/context

@@ -3,0 +3,0 @@ // This file is licensed under the MIT License.

@@ -1,2 +0,2 @@

// Copyright IBM Corp. 2018,2019. All Rights Reserved.
// Copyright IBM Corp. 2018,2020. All Rights Reserved.
// Node module: @loopback/context

@@ -3,0 +3,0 @@ // This file is licensed under the MIT License.

@@ -8,2 +8,3 @@ // Copyright IBM Corp. 2019,2020. All Rights Reserved.

import {EventEmitter} from 'events';
import {iterator, multiple} from 'p-event';
import {Context} from './context';

@@ -16,20 +17,6 @@ import {ContextEvent, ContextEventListener} from './context-event';

} from './context-observer';
const debug = debugFactory('loopback:context:subscription');
/**
* Polyfill Symbol.asyncIterator as required by TypeScript for Node 8.x.
* See https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-3.html
*/
if (!Symbol.asyncIterator) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(Symbol as any).asyncIterator = Symbol.for('Symbol.asyncIterator');
}
/**
* WARNING: This following import must happen after the polyfill. The
* `auto-import` by an IDE such as VSCode may move the import before the
* polyfill. It must be then fixed manually.
*/
import {iterator, multiple} from 'p-event';
/**
* Subscription of context events. It's modeled after

@@ -226,3 +213,7 @@ * https://github.com/tc39/proposal-observable.

// Create an async iterator for the `notification` event as a queue
this.notificationQueue = iterator(this, 'notification');
this.notificationQueue = iterator(this, 'notification', {
// Do not end the iterator if an error event is emitted on the
// subscription manager
rejectionEvents: [],
});

@@ -276,7 +267,14 @@ return this.processNotifications();

} catch (err) {
this.pendingNotifications--;
// Do not reduce the pending notification count so that errors
// can be captured by waitUntilPendingNotificationsDone
this._debug('Error caught from observers', err);
// Errors caught from observers. Emit it to the current context.
// If no error listeners are registered, crash the process.
this.emitError(err);
// Errors caught from observers.
if (this.listenerCount('error') > 0) {
// waitUntilPendingNotificationsDone may be called
this.emitError(err);
} else {
// Emit it to the current context. If no error listeners are
// registered, crash the process.
this.handleNotificationError(err);
}
}

@@ -320,2 +318,3 @@ }

const count = this.pendingNotifications;
debug('Number of pending notifications: %d', count);
if (count === 0) return;

@@ -322,0 +321,0 @@ await multiple(this, 'observersNotified', {count, timeout});

@@ -6,2 +6,29 @@ // Copyright IBM Corp. 2017,2020. All Rights Reserved.

/**
* Facilities to manage artifacts and their dependencies using {@link Context}
* in your Node.js applications. It can be used independent of the LoopBack
* framework.
*
* @remarks
* This package exposes TypeScript/JavaScript APIs and decorators to register
* artifacts, declare dependencies, and resolve artifacts by keys. The
* {@link Context} also serves as an IoC container to support dependency
* injection.
* Context and Binding are the two core concepts. A context is a registry of
* bindings and each binding represents a resolvable artifact by the key.
*
* - Bindings can be fulfilled by a constant, a factory function, a class, or a
* provider.
* - Bindings can be grouped by tags and searched by tags.
* - Binding scopes can be used to control how a resolved binding value is
* shared.
* - Bindings can be resolved synchronously or asynchronously.
* - Provide {@link inject | @inject} and other variants of decorators to
* express dependencies.
* - Support Constructor, property, and method injections.
* - Allow contexts to form a hierarchy to share or override bindings.
*
* @pakageDocumentation
*/
export * from '@loopback/metadata';

@@ -26,2 +53,3 @@ export * from './binding';

export * from './invocation';
export * from './json-types';
export * from './keys';

@@ -32,2 +60,1 @@ export * from './provider';

export * from './value-promise';
export * from './json-types';

@@ -1,2 +0,2 @@

// Copyright IBM Corp. 2019. All Rights Reserved.
// Copyright IBM Corp. 2019,2020. All Rights Reserved.
// Node module: @loopback/context

@@ -3,0 +3,0 @@ // This file is licensed under the MIT License.

@@ -1,2 +0,2 @@

// Copyright IBM Corp. 2019. All Rights Reserved.
// Copyright IBM Corp. 2019,2020. All Rights Reserved.
// Node module: @loopback/context

@@ -3,0 +3,0 @@ // This file is licensed under the MIT License.

@@ -1,2 +0,2 @@

// Copyright IBM Corp. 2018,2019. All Rights Reserved.
// Copyright IBM Corp. 2018,2020. All Rights Reserved.
// Node module: @loopback/context

@@ -3,0 +3,0 @@ // This file is licensed under the MIT License.

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

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc