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

mesh-ioc

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mesh-ioc - npm Package Compare versions

Comparing version 2.2.3 to 3.1.3

out/main/decorators/dep.js.map

3

out/main/decorators/dep.d.ts
import 'reflect-metadata';
import { DepMetadata } from '../types';
import { DepMetadata } from '../types.js';
export declare const depMetadata: DepMetadata[];
export interface DepOptions {
key?: string;
cache?: boolean;
}
export declare function dep(options?: DepOptions): (target: any, propertyName: string) => void;

@@ -1,18 +0,15 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.dep = exports.depMetadata = void 0;
require("reflect-metadata");
const errors_1 = require("../errors");
const mesh_1 = require("../mesh");
exports.depMetadata = [];
function dep(options = {}) {
import 'reflect-metadata';
import { DepInstanceNotConnected, DepKeyNotInferred } from '../errors.js';
import { MESH_REF } from '../mesh.js';
export const depMetadata = [];
export function dep(options = {}) {
return function (target, propertyName) {
var _a;
const className = target.constructor.name;
const designType = Reflect.getMetadata('design:type', target, propertyName);
const key = (_a = options.key) !== null && _a !== void 0 ? _a : designType === null || designType === void 0 ? void 0 : designType.name;
const key = options.key ?? designType?.name;
const cache = options.cache ?? true;
if (!key) {
throw new errors_1.DepKeyNotInferred(className, propertyName);
throw new DepKeyNotInferred(className, propertyName);
}
exports.depMetadata.push({
depMetadata.push({
class: target.constructor,

@@ -24,12 +21,20 @@ propertyName,

Object.defineProperty(target, propertyName, {
configurable: true,
get() {
const mesh = this[mesh_1.MESH_REF];
const mesh = this[MESH_REF];
if (!mesh) {
throw new errors_1.DepInstanceNotConnected(className, propertyName);
throw new DepInstanceNotConnected(className, propertyName);
}
return mesh.resolve(key);
}
const value = mesh.resolve(key);
if (cache) {
Object.defineProperty(this, propertyName, {
configurable: true,
value
});
}
return value;
},
});
};
}
exports.dep = dep;
//# sourceMappingURL=dep.js.map

@@ -1,4 +0,1 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MeshInvalidBinding = exports.MeshBindingNotFound = exports.DepInstanceNotConnected = exports.DepKeyNotInferred = void 0;
class BaseError extends Error {

@@ -10,3 +7,3 @@ constructor() {

}
class DepKeyNotInferred extends BaseError {
export class DepKeyNotInferred extends BaseError {
constructor(className, propertyName) {

@@ -20,4 +17,3 @@ super(`${className}.${propertyName}: ` +

}
exports.DepKeyNotInferred = DepKeyNotInferred;
class DepInstanceNotConnected extends BaseError {
export class DepInstanceNotConnected extends BaseError {
constructor(className, propertyName) {

@@ -30,4 +26,3 @@ super(`${className}.${propertyName}: ` +

}
exports.DepInstanceNotConnected = DepInstanceNotConnected;
class MeshBindingNotFound extends BaseError {
export class MeshBindingNotFound extends BaseError {
constructor(meshName, serviceKey) {

@@ -37,4 +32,3 @@ super(`"${serviceKey}" not found in Mesh "${meshName}"`);

}
exports.MeshBindingNotFound = MeshBindingNotFound;
class MeshInvalidBinding extends BaseError {
export class MeshInvalidBinding extends BaseError {
constructor(key) {

@@ -47,2 +41,2 @@ super(`Invalid binding "${key}". Valid bindings are: ` +

}
exports.MeshInvalidBinding = MeshInvalidBinding;
//# sourceMappingURL=errors.js.map

@@ -1,4 +0,4 @@

export * from './decorators/dep';
export * from './errors';
export * from './mesh';
export * from './types';
export * from './decorators/dep.js';
export * from './errors.js';
export * from './mesh.js';
export * from './types.js';

@@ -1,16 +0,5 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./decorators/dep"), exports);
__exportStar(require("./errors"), exports);
__exportStar(require("./mesh"), exports);
__exportStar(require("./types"), exports);
export * from './decorators/dep.js';
export * from './errors.js';
export * from './mesh.js';
export * from './types.js';
//# sourceMappingURL=index.js.map

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

import { AbstractClass, Binding, Middleware, ServiceConstructor, ServiceKey } from './types';
import { AbstractClass, Binding, Middleware, ServiceConstructor, ServiceKey } from './types.js';
export declare const MESH_REF: unique symbol;

@@ -3,0 +3,0 @@ /**

@@ -1,7 +0,4 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Mesh = exports.MESH_REF = void 0;
const errors_1 = require("./errors");
const util_1 = require("./util");
exports.MESH_REF = Symbol.for('MESH_REF');
import { MeshBindingNotFound, MeshInvalidBinding } from './errors.js';
import { keyToString } from './util.js';
export const MESH_REF = Symbol.for('MESH_REF');
/**

@@ -18,3 +15,3 @@ * An IoC container.

*/
class Mesh {
export class Mesh {
constructor(name = 'default', parent = undefined) {

@@ -38,3 +35,3 @@ this.name = name;

service(key, impl) {
const k = util_1.keyToString(key);
const k = keyToString(key);
if (typeof impl === 'function') {

@@ -48,6 +45,6 @@ this.bindings.set(k, { type: 'service', class: impl });

}
throw new errors_1.MeshInvalidBinding(String(key));
throw new MeshInvalidBinding(String(key));
}
constant(key, value) {
const k = util_1.keyToString(key);
const k = keyToString(key);
this.bindings.set(k, { type: 'constant', value });

@@ -57,4 +54,4 @@ return this;

alias(key, referenceKey) {
const k = util_1.keyToString(key);
const refK = util_1.keyToString(referenceKey);
const k = keyToString(key);
const refK = keyToString(referenceKey);
this.bindings.set(k, { type: 'alias', key: refK });

@@ -66,4 +63,4 @@ return this;

if (instance === undefined) {
const k = util_1.keyToString(key);
throw new errors_1.MeshBindingNotFound(this.name, k);
const k = keyToString(key);
throw new MeshBindingNotFound(this.name, k);
}

@@ -73,3 +70,3 @@ return instance;

tryResolve(key, recursive = true) {
const k = util_1.keyToString(key);
const k = keyToString(key);
let instance = this.instances.get(k);

@@ -132,3 +129,3 @@ if (instance) {

}
Object.defineProperty(value, exports.MESH_REF, {
Object.defineProperty(value, MESH_REF, {
get: () => this,

@@ -140,2 +137,2 @@ enumerable: false,

}
exports.Mesh = Mesh;
//# sourceMappingURL=mesh.js.map

@@ -1,23 +0,23 @@

export declare type Constructor<T> = {
export type Constructor<T> = {
new (...args: any[]): T;
};
export declare type ServiceConstructor<T> = {
export type ServiceConstructor<T> = {
new (): T;
};
export declare type AbstractClass<T> = {
export type AbstractClass<T> = {
name: string;
prototype: T;
};
export declare type ServiceKey<T> = ServiceConstructor<T> | AbstractClass<T> | string;
export declare type Middleware = (instance: any) => any;
export declare type Binding<T> = ConstantBinding<T> | ServiceBinding<T> | AliasBinding;
export declare type ConstantBinding<T> = {
export type ServiceKey<T> = ServiceConstructor<T> | AbstractClass<T> | string;
export type Middleware = (instance: any) => any;
export type Binding<T> = ConstantBinding<T> | ServiceBinding<T> | AliasBinding;
export type ConstantBinding<T> = {
type: 'constant';
value: T;
};
export declare type ServiceBinding<T> = {
export type ServiceBinding<T> = {
type: 'service';
class: ServiceConstructor<T>;
};
export declare type AliasBinding = {
export type AliasBinding = {
type: 'alias';

@@ -24,0 +24,0 @@ key: string;

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

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
export {};
//# sourceMappingURL=types.js.map

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

import { ServiceKey } from './types';
import { ServiceKey } from './types.js';
export declare function keyToString<T>(key: ServiceKey<T>): string;

@@ -1,7 +0,4 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.keyToString = void 0;
function keyToString(key) {
export function keyToString(key) {
return typeof key === 'string' ? key : key.name;
}
exports.keyToString = keyToString;
//# sourceMappingURL=util.js.map
{
"name": "mesh-ioc",
"version": "2.2.3",
"description": "Mesh: Powerful and Lightweight IoC Library",
"version": "3.1.3",
"description": "Powerful and Lightweight IoC Library",
"type": "module",
"sideEffects": false,
"exports": {
".": "./out/main/index.js"
},
"main": "out/main/index.js",

@@ -12,3 +17,3 @@ "types": "out/main/index.d.ts",

"clean": "rm -rf out *.tsbuildinfo",
"dev": "tsc -b -w",
"dev": "npm run clean && tsc -b -w",
"compile": "tsc -b",

@@ -26,3 +31,3 @@ "lint": "eslint --ext=.js,.ts,.vue --cache .",

"type": "git",
"url": "git+ssh://git@github.com/inca/mesh-ioc.git"
"url": "git+ssh://git@github.com/MeshIoc/mesh-ioc.git"
},

@@ -39,7 +44,7 @@ "keywords": [

"devDependencies": {
"@nodescript/eslint-config": "^1.0.0",
"@types/mocha": "^8.2.3",
"@types/node": "^16.3.1",
"@ubio/eslint-config": "^1.1.6",
"chalk": "^4.1.2",
"eslint": "^7.30.0",
"eslint": "^8.24.0",
"mocha": "^9.0.2",

@@ -46,0 +51,0 @@ "pre-commit": "^1.2.2",

@@ -9,8 +9,12 @@ # Mesh IoC

- 🔥 Zero dependencies
- 👗 Very slim — about 2KB minified, few hundred bytes gzipped
- 💻 Works in browser
- 🌳 Ergonomic
- 🗜 Tidy and compact
- 🔬 Strongly typed and introspectable
- ⚡️ Blazing fast
- 🧩 Flexible and composable
- 🌿 Ergonomic
- 🕵️‍♀️ Provides APIs for dependency analysis
- 🐓 🥚 Tolerates circular dependencies
- 🕵️‍♀️ Provides APIs for dependency analysis

@@ -17,0 +21,0 @@ ## API Cheatsheet

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