New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

jpex

Package Overview
Dependencies
Maintainers
0
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jpex - npm Package Compare versions

Comparing version 5.1.0 to 5.2.0

dist/ts/resolver/getFactory.d.ts

70

dist/cjs/jpex.js

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

};
const unique = arr => [...new Set(arr)];
const trackDeps = (jpex, dependencies) => {
jpex.$$deps = unique([...jpex.$$deps, ...(dependencies || [])]);
};
const isNode = () => {

@@ -56,2 +60,3 @@ let _process;

const hasLength = arr => arr != null && arr.length > 0;
const last = arr => arr[arr.length - 1];

@@ -84,2 +89,3 @@ function constant(name, obj) {

};
trackDeps(this, dependencies);
if (opts.alias) {

@@ -153,4 +159,4 @@ ensureArray(opts.alias).forEach(alias => this.alias(alias, name));

const len = GLOBAL_TYPE_PREFIX.length;
const inferred = name.substr(len);
const inferredLower = inferred.charAt(0).toLowerCase() + inferred.substr(1);
const inferred = name.substring(len);
const inferredLower = inferred.charAt(0).toLowerCase() + inferred.substring(1);
return (_global$inferredLower = global[inferredLower]) != null ? _global$inferredLower : global[inferred];

@@ -204,2 +210,19 @@ }

};
const checkStack = (jpex, name, stack) => {
if (!hasLength(stack)) {
return 'new';
}
if (!stack.includes(name)) {
return 'new';
}
if (last(stack) === name) {
var _jpex$$$parent;
const parent = (_jpex$$$parent = jpex.$$parent) == null ? void 0 : _jpex$$$parent.$$factories[name];
if (parent != null) {
return 'inherit';
}
}
return 'recursive';
};
const cacheResult = (jpex, name, factory, value, namedParameters, withArg) => {

@@ -211,2 +234,3 @@ switch (factory.lifecycle || jpex.$$config.lifecycle) {

factory.with = withArg;
namedParameters[name] = value;
break;

@@ -219,2 +243,3 @@ case 'container':

};
namedParameters[name] = value;
break;

@@ -229,19 +254,2 @@ case 'none':

};
const checkStack = (jpex, name, stack) => {
if (!hasLength(stack)) {
return false;
}
if (!stack.includes(name)) {
return false;
}
if (stack[stack.length - 1] === name) {
var _jpex$$$parent;
const parent = (_jpex$$$parent = jpex.$$parent) == null ? void 0 : _jpex$$$parent.$$factories[name];
if (parent != null) {
return true;
}
}
throw new Error(`Recursive loop for dependency ${name} encountered`);
};
const getNamedParameters = (namedParameters, opts = {}) => {

@@ -261,3 +269,3 @@ if (namedParameters) {

}
const keys = [...new Set([...Object.keys(opts.with || {}), ...Object.keys(factory.with || {})])];
const keys = unique([...Object.keys(opts.with || {}), ...Object.keys(factory.with || {})]);
return keys.every(key => {

@@ -299,4 +307,7 @@ var _opts$with, _factory$with;

}
if (checkStack(jpex, name, stack)) {
return resolveOne(jpex.$$parent, name, namedParameters, opts, []);
switch (checkStack(jpex, name, stack)) {
case 'inherit':
return resolveOne(jpex.$$parent, name, namedParameters, opts, []);
case 'recursive':
throw new Error(`Recursive loop for dependency ${name} encountered`);
}

@@ -326,5 +337,7 @@ const factory = getFactory(jpex, name, opts);

function resolve(name, opts) {
trackDeps(this, [name]);
return resolveOne(this, name, void 0, opts, []);
}
function resolveAsync(name, opts) {
trackDeps(this, [name]);
return resolveOne(this, name, void 0, { ...opts,

@@ -335,6 +348,6 @@ async: true

function resolveDependencies(definition, opts) {
trackDeps(this, definition.dependencies);
return resolveMany(this, definition, void 0, opts, []);
}
function isResolved(dependency) {
var _this$$$factories$dep;
if (!isString(dependency)) {

@@ -346,3 +359,6 @@ return false;

}
return ((_this$$$factories$dep = this.$$factories[dependency]) == null ? void 0 : _this$$$factories$dep.resolved) === true;
if (this.$$factories[dependency]) {
return this.$$factories[dependency].resolved === true;
}
return false;
}

@@ -356,2 +372,3 @@ function allResolved(dependencies) {

let result;
trackDeps(jpex, dependencies);
const invokeFn = (deps, args) => {

@@ -379,4 +396,4 @@ result = fn.apply(jpex, deps);

function clearCache(...names) {
names = ensureArray(names);
function clearCache(..._names) {
const names = ensureArray(_names);
for (const key in this.$$factories) {

@@ -414,2 +431,3 @@ if (!hasLength(names) || names.includes(key)) {

$$alias: parent && inherit ? Object.create(parent.$$alias) : {},
$$deps: parent && inherit ? parent.$$deps : [],
constant,

@@ -416,0 +434,0 @@ factory,

@@ -29,2 +29,6 @@ const isString = obj => typeof obj === 'string';

};
const unique = arr => [...new Set(arr)];
const trackDeps = (jpex, dependencies) => {
jpex.$$deps = unique([...jpex.$$deps, ...(dependencies || [])]);
};
const isNode = () => {

@@ -52,2 +56,3 @@ let _process;

const hasLength = arr => arr != null && arr.length > 0;
const last = arr => arr[arr.length - 1];

@@ -80,2 +85,3 @@ function constant(name, obj) {

};
trackDeps(this, dependencies);
if (opts.alias) {

@@ -149,4 +155,4 @@ ensureArray(opts.alias).forEach(alias => this.alias(alias, name));

const len = GLOBAL_TYPE_PREFIX.length;
const inferred = name.substr(len);
const inferredLower = inferred.charAt(0).toLowerCase() + inferred.substr(1);
const inferred = name.substring(len);
const inferredLower = inferred.charAt(0).toLowerCase() + inferred.substring(1);
return (_global$inferredLower = global[inferredLower]) != null ? _global$inferredLower : global[inferred];

@@ -200,2 +206,19 @@ }

};
const checkStack = (jpex, name, stack) => {
if (!hasLength(stack)) {
return 'new';
}
if (!stack.includes(name)) {
return 'new';
}
if (last(stack) === name) {
var _jpex$$$parent;
const parent = (_jpex$$$parent = jpex.$$parent) == null ? void 0 : _jpex$$$parent.$$factories[name];
if (parent != null) {
return 'inherit';
}
}
return 'recursive';
};
const cacheResult = (jpex, name, factory, value, namedParameters, withArg) => {

@@ -207,2 +230,3 @@ switch (factory.lifecycle || jpex.$$config.lifecycle) {

factory.with = withArg;
namedParameters[name] = value;
break;

@@ -215,2 +239,3 @@ case 'container':

};
namedParameters[name] = value;
break;

@@ -225,19 +250,2 @@ case 'none':

};
const checkStack = (jpex, name, stack) => {
if (!hasLength(stack)) {
return false;
}
if (!stack.includes(name)) {
return false;
}
if (stack[stack.length - 1] === name) {
var _jpex$$$parent;
const parent = (_jpex$$$parent = jpex.$$parent) == null ? void 0 : _jpex$$$parent.$$factories[name];
if (parent != null) {
return true;
}
}
throw new Error(`Recursive loop for dependency ${name} encountered`);
};
const getNamedParameters = (namedParameters, opts = {}) => {

@@ -257,3 +265,3 @@ if (namedParameters) {

}
const keys = [...new Set([...Object.keys(opts.with || {}), ...Object.keys(factory.with || {})])];
const keys = unique([...Object.keys(opts.with || {}), ...Object.keys(factory.with || {})]);
return keys.every(key => {

@@ -295,4 +303,7 @@ var _opts$with, _factory$with;

}
if (checkStack(jpex, name, stack)) {
return resolveOne(jpex.$$parent, name, namedParameters, opts, []);
switch (checkStack(jpex, name, stack)) {
case 'inherit':
return resolveOne(jpex.$$parent, name, namedParameters, opts, []);
case 'recursive':
throw new Error(`Recursive loop for dependency ${name} encountered`);
}

@@ -322,5 +333,7 @@ const factory = getFactory(jpex, name, opts);

function resolve(name, opts) {
trackDeps(this, [name]);
return resolveOne(this, name, void 0, opts, []);
}
function resolveAsync(name, opts) {
trackDeps(this, [name]);
return resolveOne(this, name, void 0, { ...opts,

@@ -331,6 +344,6 @@ async: true

function resolveDependencies(definition, opts) {
trackDeps(this, definition.dependencies);
return resolveMany(this, definition, void 0, opts, []);
}
function isResolved(dependency) {
var _this$$$factories$dep;
if (!isString(dependency)) {

@@ -342,3 +355,6 @@ return false;

}
return ((_this$$$factories$dep = this.$$factories[dependency]) == null ? void 0 : _this$$$factories$dep.resolved) === true;
if (this.$$factories[dependency]) {
return this.$$factories[dependency].resolved === true;
}
return false;
}

@@ -352,2 +368,3 @@ function allResolved(dependencies) {

let result;
trackDeps(jpex, dependencies);
const invokeFn = (deps, args) => {

@@ -375,4 +392,4 @@ result = fn.apply(jpex, deps);

function clearCache(...names) {
names = ensureArray(names);
function clearCache(..._names) {
const names = ensureArray(_names);
for (const key in this.$$factories) {

@@ -410,2 +427,3 @@ if (!hasLength(names) || names.includes(key)) {

$$alias: parent && inherit ? Object.create(parent.$$alias) : {},
$$deps: parent && inherit ? parent.$$deps : [],
constant,

@@ -412,0 +430,0 @@ factory,

@@ -70,2 +70,8 @@ 'use strict';

};
var unique = function unique(arr) {
return [].concat(new Set(arr));
};
var trackDeps = function trackDeps(jpex, dependencies) {
jpex.$$deps = unique([].concat(jpex.$$deps, dependencies || []));
};
var isNode = function isNode() {

@@ -95,2 +101,5 @@ var _process;

};
var last = function last(arr) {
return arr[arr.length - 1];
};

@@ -129,2 +138,3 @@ function constant(name, obj) {

};
trackDeps(this, dependencies);
if (opts.alias) {

@@ -206,4 +216,4 @@ ensureArray(opts.alias).forEach(function (alias) {

var len = GLOBAL_TYPE_PREFIX.length;
var inferred = name.substr(len);
var inferredLower = inferred.charAt(0).toLowerCase() + inferred.substr(1);
var inferred = name.substring(len);
var inferredLower = inferred.charAt(0).toLowerCase() + inferred.substring(1);
return (_global$inferredLower = global[inferredLower]) != null ? _global$inferredLower : global[inferred];

@@ -262,2 +272,19 @@ }

};
var checkStack = function checkStack(jpex, name, stack) {
if (!hasLength(stack)) {
return 'new';
}
if (!stack.includes(name)) {
return 'new';
}
if (last(stack) === name) {
var _jpex$$$parent;
var parent = (_jpex$$$parent = jpex.$$parent) == null ? void 0 : _jpex$$$parent.$$factories[name];
if (parent != null) {
return 'inherit';
}
}
return 'recursive';
};
var cacheResult = function cacheResult(jpex, name, factory, value, namedParameters, withArg) {

@@ -269,2 +296,3 @@ switch (factory.lifecycle || jpex.$$config.lifecycle) {

factory.with = withArg;
namedParameters[name] = value;
break;

@@ -277,2 +305,3 @@ case 'container':

});
namedParameters[name] = value;
break;

@@ -287,19 +316,2 @@ case 'none':

};
var checkStack = function checkStack(jpex, name, stack) {
if (!hasLength(stack)) {
return false;
}
if (!stack.includes(name)) {
return false;
}
if (stack[stack.length - 1] === name) {
var _jpex$$$parent;
var parent = (_jpex$$$parent = jpex.$$parent) == null ? void 0 : _jpex$$$parent.$$factories[name];
if (parent != null) {
return true;
}
}
throw new Error("Recursive loop for dependency " + name + " encountered");
};
var getNamedParameters = function getNamedParameters(namedParameters, opts) {

@@ -324,3 +336,3 @@ if (opts === void 0) {

}
var keys = [].concat(new Set([].concat(Object.keys(opts.with || {}), Object.keys(factory.with || {}))));
var keys = unique([].concat(Object.keys(opts.with || {}), Object.keys(factory.with || {})));
return keys.every(function (key) {

@@ -362,4 +374,7 @@ var _opts$with, _factory$with;

}
if (checkStack(jpex, name, stack)) {
return resolveOne(jpex.$$parent, name, namedParameters, opts, []);
switch (checkStack(jpex, name, stack)) {
case 'inherit':
return resolveOne(jpex.$$parent, name, namedParameters, opts, []);
case 'recursive':
throw new Error("Recursive loop for dependency " + name + " encountered");
}

@@ -392,5 +407,7 @@ var factory = getFactory(jpex, name, opts);

function resolve(name, opts) {
trackDeps(this, [name]);
return resolveOne(this, name, void 0, opts, []);
}
function resolveAsync(name, opts) {
trackDeps(this, [name]);
return resolveOne(this, name, void 0, _extends({}, opts, {

@@ -401,6 +418,6 @@ async: true

function resolveDependencies(definition, opts) {
trackDeps(this, definition.dependencies);
return resolveMany(this, definition, void 0, opts, []);
}
function isResolved(dependency) {
var _this$$$factories$dep;
if (!isString(dependency)) {

@@ -412,3 +429,6 @@ return false;

}
return ((_this$$$factories$dep = this.$$factories[dependency]) == null ? void 0 : _this$$$factories$dep.resolved) === true;
if (this.$$factories[dependency]) {
return this.$$factories[dependency].resolved === true;
}
return false;
}

@@ -423,2 +443,3 @@ function allResolved(dependencies) {

var result;
trackDeps(jpex, dependencies);
var invokeFn = function invokeFn(deps, args) {

@@ -452,6 +473,6 @@ result = fn.apply(jpex, deps);

function clearCache() {
for (var _len = arguments.length, names = new Array(_len), _key = 0; _key < _len; _key++) {
names[_key] = arguments[_key];
for (var _len = arguments.length, _names = new Array(_len), _key = 0; _key < _len; _key++) {
_names[_key] = arguments[_key];
}
names = ensureArray(names);
var names = ensureArray(_names);
for (var key in this.$$factories) {

@@ -487,2 +508,3 @@ if (!hasLength(names) || names.includes(key)) {

$$alias: parent && inherit ? Object.create(parent.$$alias) : {},
$$deps: parent && inherit ? parent.$$deps : [],
constant: constant,

@@ -489,0 +511,0 @@ factory: factory,

import { JpexInstance } from './types';
export default function clearCache(this: JpexInstance, ...names: any[]): any;
export default function clearCache(this: JpexInstance, ..._names: any[]): any;
import { JpexInstance, Dependency, ResolveOpts, Factory } from '../types';
export { getFactory } from './utils';
export { default as getFactory } from './getFactory';
export declare function resolve(this: JpexInstance, name: Dependency, opts?: ResolveOpts): any;

@@ -4,0 +4,0 @@ export declare function resolveAsync(this: JpexInstance, name: Dependency, opts?: ResolveOpts): any;

import { JpexInstance, Dependency, NamedParameters, ResolveOpts, Factory } from '../types';
export declare const cacheResult: (jpex: JpexInstance, name: string, factory: Factory, value: any, namedParameters: NamedParameters, withArg: Record<string, any>) => void;
export declare const resolveOne: (jpex: JpexInstance, name: Dependency, initialParameters: NamedParameters, opts: ResolveOpts, stack: string[]) => any | Promise<any>;
export declare const resolveMany: (jpex: JpexInstance, definition: Factory, namedParameters: NamedParameters, opts: ResolveOpts, stack?: string[]) => any[] | Promise<any[]>;

@@ -101,2 +101,3 @@ import type { Lifecycle, AnyFunction, Dependency, AnyConstructor, Factory, Precedence } from './base';

};
$$deps: Dependency[];
$$config: {

@@ -103,0 +104,0 @@ lifecycle: Lifecycle;

@@ -10,2 +10,4 @@ import { Dependency, JpexInstance, Precedence } from '../types';

export declare const instantiate: (context: any, args: any[]) => any;
export declare const unique: <T>(arr: T[]) => T[];
export declare const trackDeps: (jpex: JpexInstance, dependencies: Dependency[]) => void;
export declare const isNode: () => boolean;

@@ -15,1 +17,2 @@ export declare const unsafeRequire: (target: string) => any;

export declare const hasLength: <T>(arr: T[]) => boolean;
export declare const last: <T>(arr: T[]) => T;
{
"name": "jpex",
"version": "5.1.0",
"version": "5.2.0",
"description": "Javascript Prototype Extension",

@@ -5,0 +5,0 @@ "main": "dist/cjs/jpex.js",

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