Socket
Socket
Sign inDemoInstall

@loopback/context

Package Overview
Dependencies
1
Maintainers
17
Versions
192
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.0.0-alpha.20 to 4.0.0-alpha.21

11

CHANGELOG.md

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

<a name="4.0.0-alpha.21"></a>
# [4.0.0-alpha.21](https://github.com/strongloop/loopback-next/compare/@loopback/context@4.0.0-alpha.20...@loopback/context@4.0.0-alpha.21) (2017-11-29)
### Features
* **context:** Allow patterns to be RegExp ([991cf38](https://github.com/strongloop/loopback-next/commit/991cf38))
<a name="4.0.0-alpha.20"></a>

@@ -8,0 +19,0 @@ # [4.0.0-alpha.20](https://github.com/strongloop/loopback-next/compare/@loopback/context@4.0.0-alpha.19...@loopback/context@4.0.0-alpha.20) (2017-11-14)

8

dist/src/context.d.ts

@@ -33,10 +33,10 @@ import { Binding, BoundValue, ValueOrPromise } from './binding';

* Find bindings using the key pattern
* @param pattern Key pattern with optional `*` wildcards
* @param pattern Key regexp or pattern with optional `*` wildcards
*/
find(pattern?: string): Binding[];
find(pattern?: string | RegExp): Binding[];
/**
* Find bindings using the tag pattern
* @param pattern Tag pattern with optional `*` wildcards
* @param pattern Tag name regexp or pattern with optional `*` wildcards
*/
findByTag(pattern: string): Binding[];
findByTag(pattern: string | RegExp): Binding[];
protected _mergeWithParent(childList: Binding[], parentList?: Binding[]): Binding[];

@@ -43,0 +43,0 @@ /**

@@ -63,10 +63,16 @@ "use strict";

* Find bindings using the key pattern
* @param pattern Key pattern with optional `*` wildcards
* @param pattern Key regexp or pattern with optional `*` wildcards
*/
find(pattern) {
let bindings = [];
if (pattern) {
let glob = undefined;
if (typeof pattern === 'string') {
// TODO(@superkhau): swap with production grade glob to regex lib
binding_1.Binding.validateKey(pattern);
const glob = new RegExp('^' + pattern.split('*').join('.*') + '$');
glob = new RegExp('^' + pattern.split('*').join('.*') + '$');
}
else if (pattern instanceof RegExp) {
glob = pattern;
}
if (glob) {
this.registry.forEach(binding => {

@@ -86,3 +92,3 @@ const isMatch = glob.test(binding.key);

* Find bindings using the tag pattern
* @param pattern Tag pattern with optional `*` wildcards
* @param pattern Tag name regexp or pattern with optional `*` wildcards
*/

@@ -92,3 +98,5 @@ findByTag(pattern) {

// TODO(@superkhau): swap with production grade glob to regex lib
const glob = new RegExp('^' + pattern.split('*').join('.*') + '$');
const glob = typeof pattern === 'string'
? new RegExp('^' + pattern.split('*').join('.*') + '$')
: pattern;
this.registry.forEach(binding => {

@@ -95,0 +103,0 @@ const isMatch = Array.from(binding.tags).some(tag => glob.test(tag));

@@ -33,10 +33,10 @@ import { Binding, BoundValue, ValueOrPromise } from './binding';

* Find bindings using the key pattern
* @param pattern Key pattern with optional `*` wildcards
* @param pattern Key regexp or pattern with optional `*` wildcards
*/
find(pattern?: string): Binding[];
find(pattern?: string | RegExp): Binding[];
/**
* Find bindings using the tag pattern
* @param pattern Tag pattern with optional `*` wildcards
* @param pattern Tag name regexp or pattern with optional `*` wildcards
*/
findByTag(pattern: string): Binding[];
findByTag(pattern: string | RegExp): Binding[];
protected _mergeWithParent(childList: Binding[], parentList?: Binding[]): Binding[];

@@ -43,0 +43,0 @@ /**

@@ -63,10 +63,16 @@ "use strict";

* Find bindings using the key pattern
* @param pattern Key pattern with optional `*` wildcards
* @param pattern Key regexp or pattern with optional `*` wildcards
*/
find(pattern) {
let bindings = [];
if (pattern) {
let glob = undefined;
if (typeof pattern === 'string') {
// TODO(@superkhau): swap with production grade glob to regex lib
binding_1.Binding.validateKey(pattern);
const glob = new RegExp('^' + pattern.split('*').join('.*') + '$');
glob = new RegExp('^' + pattern.split('*').join('.*') + '$');
}
else if (pattern instanceof RegExp) {
glob = pattern;
}
if (glob) {
this.registry.forEach(binding => {

@@ -86,3 +92,3 @@ const isMatch = glob.test(binding.key);

* Find bindings using the tag pattern
* @param pattern Tag pattern with optional `*` wildcards
* @param pattern Tag name regexp or pattern with optional `*` wildcards
*/

@@ -92,3 +98,5 @@ findByTag(pattern) {

// TODO(@superkhau): swap with production grade glob to regex lib
const glob = new RegExp('^' + pattern.split('*').join('.*') + '$');
const glob = typeof pattern === 'string'
? new RegExp('^' + pattern.split('*').join('.*') + '$')
: pattern;
this.registry.forEach(binding => {

@@ -95,0 +103,0 @@ const isMatch = Array.from(binding.tags).some(tag => glob.test(tag));

{
"name": "@loopback/context",
"version": "4.0.0-alpha.20",
"version": "4.0.0-alpha.21",
"description": "LoopBack's container for Inversion of Control",

@@ -28,4 +28,4 @@ "engines": {

"devDependencies": {
"@loopback/build": "^4.0.0-alpha.5",
"@loopback/testlab": "^4.0.0-alpha.14",
"@loopback/build": "^4.0.0-alpha.6",
"@loopback/testlab": "^4.0.0-alpha.15",
"@types/bluebird": "^3.5.18",

@@ -32,0 +32,0 @@ "bluebird": "^3.5.0"

@@ -31,4 +31,3 @@ # @loopback/context

// consider this.ctx here
constructor(@inject('defaultName') name) { // injecting dependency using context
this.name = name;
constructor(@inject('defaultName') private name: string) { // injecting dependency using context
}

@@ -35,0 +34,0 @@ greet(name) {

@@ -68,12 +68,17 @@ // Copyright IBM Corp. 2013,2017. All Rights Reserved.

* Find bindings using the key pattern
* @param pattern Key pattern with optional `*` wildcards
* @param pattern Key regexp or pattern with optional `*` wildcards
*/
find(pattern?: string): Binding[] {
find(pattern?: string | RegExp): Binding[] {
let bindings: Binding[] = [];
if (pattern) {
let glob: RegExp | undefined = undefined;
if (typeof pattern === 'string') {
// TODO(@superkhau): swap with production grade glob to regex lib
Binding.validateKey(pattern);
const glob = new RegExp('^' + pattern.split('*').join('.*') + '$');
glob = new RegExp('^' + pattern.split('*').join('.*') + '$');
} else if (pattern instanceof RegExp) {
glob = pattern;
}
if (glob) {
this.registry.forEach(binding => {
const isMatch = glob.test(binding.key);
const isMatch = glob!.test(binding.key);
if (isMatch) bindings.push(binding);

@@ -91,8 +96,11 @@ });

* Find bindings using the tag pattern
* @param pattern Tag pattern with optional `*` wildcards
* @param pattern Tag name regexp or pattern with optional `*` wildcards
*/
findByTag(pattern: string): Binding[] {
findByTag(pattern: string | RegExp): Binding[] {
const bindings: Binding[] = [];
// TODO(@superkhau): swap with production grade glob to regex lib
const glob = new RegExp('^' + pattern.split('*').join('.*') + '$');
const glob =
typeof pattern === 'string'
? new RegExp('^' + pattern.split('*').join('.*') + '$')
: pattern;
this.registry.forEach(binding => {

@@ -99,0 +107,0 @@ const isMatch = Array.from(binding.tags).some(tag => glob.test(tag));

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