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.8.8 to 0.8.9

11

lib/di.es.js

@@ -199,5 +199,6 @@ const Scope = {

get(tokenORObject) {
var _a;
var _a, _b;
let token;
let optional = false;
let multi = false;
if (typeof tokenORObject === 'string') {

@@ -209,2 +210,3 @@ token = tokenORObject;

optional = tokenORObject.optional;
multi = ((_a = token.options) === null || _a === void 0 ? void 0 : _a.multi) || false;
}

@@ -216,6 +218,11 @@ else {

const record = this.getRecord(token);
if (!record && ((_a = this.fallback) === null || _a === void 0 ? void 0 : _a.getRecord(token))) {
if (!record && ((_b = this.fallback) === null || _b === void 0 ? void 0 : _b.getRecord(token))) {
return this.fallback.get(tokenORObject);
}
if (!record && optional) {
// return empty array for optional multi token
if (multi) {
return [];
}
// for legacy string tokens we cannot know if the token is multi or not
return null;

@@ -222,0 +229,0 @@ }

@@ -203,5 +203,6 @@ 'use strict';

get(tokenORObject) {
var _a;
var _a, _b;
let token;
let optional = false;
let multi = false;
if (typeof tokenORObject === 'string') {

@@ -213,2 +214,3 @@ token = tokenORObject;

optional = tokenORObject.optional;
multi = ((_a = token.options) === null || _a === void 0 ? void 0 : _a.multi) || false;
}

@@ -220,6 +222,11 @@ else {

const record = this.getRecord(token);
if (!record && ((_a = this.fallback) === null || _a === void 0 ? void 0 : _a.getRecord(token))) {
if (!record && ((_b = this.fallback) === null || _b === void 0 ? void 0 : _b.getRecord(token))) {
return this.fallback.get(tokenORObject);
}
if (!record && optional) {
// return empty array for optional multi token
if (multi) {
return [];
}
// for legacy string tokens we cannot know if the token is multi or not
return null;

@@ -226,0 +233,0 @@ }

2

package.json
{
"name": "@tinkoff/dippy",
"version": "0.8.8",
"version": "0.8.9",
"initialVersion": "0.7.27",

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

@@ -165,7 +165,7 @@ # @tinkoff/dippy

// with special `optional` utility
// string | null
// `string` | `null` if not found
const foo1 = container.get(optional(FOO_TOKEN));
// without `optional` utility
// string | null
// `string` | `null` if not found
const foo2 = container.get({ token: FOO_TOKEN, optional: true });

@@ -183,2 +183,11 @@ ```

Multi optional token:
```ts
const LIST_TOKEN = createToken<{ key: string }>('list', { multi: true });
// `{ key: string }[]` | empty `[]` if not found
const list = container.get(optional(LIST_TOKEN));
```
##### container.register(provider)

@@ -185,0 +194,0 @@

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