Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@travetto/registry

Package Overview
Dependencies
Maintainers
1
Versions
290
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@travetto/registry - npm Package Compare versions

Comparing version 0.0.20 to 0.0.21

2

package.json

@@ -18,3 +18,3 @@ {

"scripts": {},
"version": "0.0.20"
"version": "0.0.21"
}

@@ -0,1 +1,3 @@

import { deepMerge } from '@travetto/base';
import { Registry } from './registry';

@@ -9,46 +11,2 @@ import { ChangeEvent } from '../source';

export function isPrimitive(el: any) {
const type = typeof el;
return (type === 'string' || type === 'boolean' || type === 'number' || el instanceof RegExp);
}
export function merge<T extends any, U extends any>(a: T, b: U): T & U {
const isEmptyA = a === undefined || a === null;
const isEmptyB = b === undefined || b === null;
const isArrA = Array.isArray(a);
const isArrB = Array.isArray(b);
if (!isEmptyB) {
if (isPrimitive(b)) {
if (isEmptyA || isPrimitive(a)) {
return b as (T & U);
} else {
throw new Error(`Cannot merge primitive ${b} with ${a}`);
}
} else if (isArrB) {
const bArr = b as any as any[];
if (a === undefined) {
return bArr.slice(0) as any as T & U;
} else if (isArrA) {
const aArr = (a as any as any[]).slice(0);
for (let i = 0; i < bArr.length; i++) {
aArr[i] = merge(aArr[i], bArr[i]);
}
return aArr as any as T & U;
} else {
throw new Error(`Cannot merge ${a} with ${b}`);
}
} else {
if (isEmptyA || isArrA || isPrimitive(a)) {
throw new Error(`Cannot merge ${b} onto ${a}`);
}
for (const key of Object.keys(b)) {
a[key] = merge(a[key], b[key]);
}
return a as (T & U);
}
}
return a as (T & U);
}
export abstract class MetadataRegistry<C extends { class: Class }, M = any> extends Registry {

@@ -122,3 +80,3 @@

const conf = this.getOrCreatePending(cls);
merge(conf, pconfig);
deepMerge(conf, pconfig);
}

@@ -128,3 +86,3 @@

const conf = this.getOrCreatePendingMethod(cls, method);
merge(conf, pconfig);
deepMerge(conf, pconfig);
}

@@ -131,0 +89,0 @@

require('@travetto/base/bootstrap').run()
.then(x => {
//require('./simpleReg');
//require('./simple');
require('./merge');
require('./simpleReg');
require('./simple');
});
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