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

@tinkoff/dippy

Package Overview
Dependencies
Maintainers
16
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tinkoff/dippy - npm Package Compare versions

Comparing version 0.7.43 to 0.7.44

4

lib/ChildContainer.d.ts

@@ -15,3 +15,3 @@ import type { RecordProvide } from './Container.h';

*/
getRecord<T>(token: string): RecordProvide<T> | undefined;
getRecord<T>(token: symbol): RecordProvide<T> | undefined;
getValue<T>(record: RecordProvide<any>): any;

@@ -24,3 +24,3 @@ /**

protected hydrateDeps<T>(record: RecordProvide<T>): any;
protected hydrate<T>(record: RecordProvide<T>, token: string, optional: boolean): T | null;
protected hydrate<T>(record: RecordProvide<T>, token: symbol, optional: boolean): T | null;
}

@@ -12,3 +12,3 @@ import type { RecordProvide } from './Container.h';

*/
protected records: Map<string, RecordProvide<any>>;
protected records: Map<symbol, RecordProvide<any>>;
protected recordValues: Map<RecordProvide<any>, any>;

@@ -41,3 +41,3 @@ private readonly fallback?;

getOfDeps<T extends ProviderDeps>(deps: T): ProvideDepsIterator<T>;
getRecord<T>(token: string): RecordProvide<T> | undefined;
getRecord<T>(token: symbol): RecordProvide<T> | undefined;
has(token: any): boolean;

@@ -52,3 +52,3 @@ borrowToken(from: Container, token: any): void;

protected hydrateDeps<T>(record: RecordProvide<T>): ProvideDepsIterator<Record<string, Provider<any, any>>>;
protected hydrate<T>(record: RecordProvide<T>, token: string, optional: boolean): T | null;
protected hydrate<T>(record: RecordProvide<T>, token: symbol, optional: boolean): T | null;
}
import type { TokenType, TokenOptions } from './createToken.h';
/**
* @private
*/
export declare const TOKENS_SYMBOL_BY_STRING_NAME_REGISTRY: Map<string, symbol>;
/**
* @private
*/
export declare function tokenToString(token: symbol): string;
export declare class TokenClass<T> implements TokenType<T> {

@@ -6,7 +14,7 @@ /**

*/
name: string;
name: symbol;
options: TokenOptions;
isToken: true;
isModernToken: true;
constructor(name: string, options?: TokenOptions);
constructor(name?: string, options?: TokenOptions);
/**

@@ -26,3 +34,3 @@ * toString будет использоваться для получения индитификатора токена

export declare type TokenInterface<T = any> = BaseTokenInterface<T> | MultiTokenInterface<T>;
export declare function createToken<Type = any>(name: string): BaseTokenInterface<Type>;
export declare function createToken<Type = any>(name?: string): BaseTokenInterface<Type>;
export declare function createToken<Type = any>(name: string, options: {

@@ -29,0 +37,0 @@ multi: true;

export interface TokenType<T> {
name: string;
name: symbol;
options: TokenOptions;

@@ -4,0 +4,0 @@ isToken: true;

@@ -21,2 +21,12 @@ const Scope = {

/**
* @private
*/
const TOKENS_SYMBOL_BY_STRING_NAME_REGISTRY = new Map();
/**
* @private
*/
function tokenToString(token) {
return token.toString().replace(/^Symbol\((.+)\)$/, '$1');
}
class TokenClass {

@@ -27,4 +37,14 @@ constructor(name, options = {}) {

this.isModernToken = true;
this.name = name;
this.name = name ? Symbol.for(name) : Symbol('token');
this.options = options;
if (process.env.NODE_ENV === 'development') {
if (name) {
if (!TOKENS_SYMBOL_BY_STRING_NAME_REGISTRY.has(name)) {
TOKENS_SYMBOL_BY_STRING_NAME_REGISTRY.set(name, this.name);
}
else {
console.error(`Token with name "${name}" already created!`);
}
}
}
}

@@ -35,3 +55,3 @@ /**

toString() {
return this.name;
return tokenToString(this.name);
}

@@ -62,10 +82,14 @@ }

const CIRCULAR = '__CIRCULAR__MARKER';
function tokenToKey(token) {
return token.isModernToken ? token.name : Symbol.for(token.toString());
}
/* eslint-disable no-underscore-dangle */
function proxyHydrationError(token, e) {
const name = tokenToString(token);
if (!e.__extendedWithStack) {
e.__extendedWithStack = true;
e.message = `${e.message} at "${token}"`;
e.message = `${e.message} at "${name}"`;
}
else {
e.message += ` < ${token}`;
e.message += ` < ${name}`;
}

@@ -110,3 +134,4 @@ if (Object.hasOwnProperty.call(e, 'stack') && typeof e.stack === 'string') {

if (record === undefined) {
throw createError(`Token not found "${token}"`, {
const name = tokenToString(token);
throw createError(`Token not found "${name}"`, {
type: Errors.NOT_FOUND,

@@ -118,3 +143,4 @@ });

if (value === CIRCULAR) {
throw createError(`Circular dep for "${token}"`, {
const name = tokenToString(token);
throw createError(`Circular dep for "${name}"`, {
type: Errors.CIRCULAR_DEP,

@@ -193,3 +219,3 @@ stack: record.stack,

}
token = token.toString();
token = tokenToKey(token);
const record = this.getRecord(token);

@@ -219,10 +245,10 @@ if (!record && ((_a = this.fallback) === null || _a === void 0 ? void 0 : _a.getRecord(token))) {

has(token) {
return !!this.getRecord(token.toString());
return !!this.getRecord(tokenToKey(token));
}
borrowToken(from, token) {
const tokenStr = token.toString();
if (!this.getRecord(tokenStr)) {
const record = from.getRecord(tokenStr);
const tokenKey = tokenToKey(token);
if (!this.getRecord(tokenKey)) {
const record = from.getRecord(tokenKey);
if (record) {
this.records.set(tokenStr, record);
this.records.set(tokenKey, record);
this.recordValues.set(record, NOT_YET);

@@ -247,3 +273,3 @@ }

var _a;
const token = provider.provide.toString();
const token = tokenToKey(provider.provide);
const record = providerToRecord(provider);

@@ -257,3 +283,3 @@ const value = providerToValue(provider);

if (multiRecord.multi === undefined) {
throw createError(`Mixed multi-provider for ${token}`, {
throw createError(`Mixed multi-provider for ${tokenToString(token)}`, {
type: Errors.MIXED_MULTI,

@@ -260,0 +286,0 @@ stack: provider.__stack,

@@ -25,2 +25,12 @@ 'use strict';

/**
* @private
*/
const TOKENS_SYMBOL_BY_STRING_NAME_REGISTRY = new Map();
/**
* @private
*/
function tokenToString(token) {
return token.toString().replace(/^Symbol\((.+)\)$/, '$1');
}
class TokenClass {

@@ -31,4 +41,14 @@ constructor(name, options = {}) {

this.isModernToken = true;
this.name = name;
this.name = name ? Symbol.for(name) : Symbol('token');
this.options = options;
if (process.env.NODE_ENV === 'development') {
if (name) {
if (!TOKENS_SYMBOL_BY_STRING_NAME_REGISTRY.has(name)) {
TOKENS_SYMBOL_BY_STRING_NAME_REGISTRY.set(name, this.name);
}
else {
console.error(`Token with name "${name}" already created!`);
}
}
}
}

@@ -39,3 +59,3 @@ /**

toString() {
return this.name;
return tokenToString(this.name);
}

@@ -66,10 +86,14 @@ }

const CIRCULAR = '__CIRCULAR__MARKER';
function tokenToKey(token) {
return token.isModernToken ? token.name : Symbol.for(token.toString());
}
/* eslint-disable no-underscore-dangle */
function proxyHydrationError(token, e) {
const name = tokenToString(token);
if (!e.__extendedWithStack) {
e.__extendedWithStack = true;
e.message = `${e.message} at "${token}"`;
e.message = `${e.message} at "${name}"`;
}
else {
e.message += ` < ${token}`;
e.message += ` < ${name}`;
}

@@ -114,3 +138,4 @@ if (Object.hasOwnProperty.call(e, 'stack') && typeof e.stack === 'string') {

if (record === undefined) {
throw createError(`Token not found "${token}"`, {
const name = tokenToString(token);
throw createError(`Token not found "${name}"`, {
type: Errors.NOT_FOUND,

@@ -122,3 +147,4 @@ });

if (value === CIRCULAR) {
throw createError(`Circular dep for "${token}"`, {
const name = tokenToString(token);
throw createError(`Circular dep for "${name}"`, {
type: Errors.CIRCULAR_DEP,

@@ -197,3 +223,3 @@ stack: record.stack,

}
token = token.toString();
token = tokenToKey(token);
const record = this.getRecord(token);

@@ -223,10 +249,10 @@ if (!record && ((_a = this.fallback) === null || _a === void 0 ? void 0 : _a.getRecord(token))) {

has(token) {
return !!this.getRecord(token.toString());
return !!this.getRecord(tokenToKey(token));
}
borrowToken(from, token) {
const tokenStr = token.toString();
if (!this.getRecord(tokenStr)) {
const record = from.getRecord(tokenStr);
const tokenKey = tokenToKey(token);
if (!this.getRecord(tokenKey)) {
const record = from.getRecord(tokenKey);
if (record) {
this.records.set(tokenStr, record);
this.records.set(tokenKey, record);
this.recordValues.set(record, NOT_YET);

@@ -251,3 +277,3 @@ }

var _a;
const token = provider.provide.toString();
const token = tokenToKey(provider.provide);
const record = providerToRecord(provider);

@@ -261,3 +287,3 @@ const value = providerToValue(provider);

if (multiRecord.multi === undefined) {
throw createError(`Mixed multi-provider for ${token}`, {
throw createError(`Mixed multi-provider for ${tokenToString(token)}`, {
type: Errors.MIXED_MULTI,

@@ -264,0 +290,0 @@ stack: provider.__stack,

{
"name": "@tinkoff/dippy",
"version": "0.7.43",
"version": "0.7.44",
"initialVersion": "0.7.27",

@@ -5,0 +5,0 @@ "description": "",

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