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

@internetarchive/promised-singleton

Package Overview
Dependencies
Maintainers
11
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@internetarchive/promised-singleton - npm Package Compare versions

Comparing version 0.2.0-alpha.1 to 0.2.0

5

dist/src/promised-singleton.js

@@ -37,2 +37,3 @@ import { __awaiter } from "tslib";

if (this.cachedResponse) {
console.debug('cachedResponse found, returning');
return this.cachedResponse;

@@ -42,3 +43,5 @@ }

if (this.previousPromise) {
console.debug('previousPromise found, chaining');
this.previousPromise = this.previousPromise.then(response => {
console.debug('previousPromise completed, returning');
return response;

@@ -55,3 +58,5 @@ });

return __awaiter(this, void 0, void 0, function* () {
console.debug('generateSingleton start');
const result = yield this.generator();
console.debug('singleton generated');
this.cachedResponse = result;

@@ -58,0 +63,0 @@ return result;

2

package.json
{
"name": "@internetarchive/promised-singleton",
"version": "0.2.0-alpha.1",
"version": "0.2.0",
"description": "A class for lazy-loading singletons.",

@@ -5,0 +5,0 @@ "author": "promised-singleton",

@@ -39,4 +39,4 @@ [![Build Status](https://travis-ci.com/internetarchive/iaux-promised-singleton.svg?branch=master)](https://travis-ci.com/internetarchive/iaux-promised-singleton) [![codecov](https://codecov.io/gh/internetarchive/iaux-promised-singleton/branch/master/graph/badge.svg)](https://codecov.io/gh/internetarchive/iaux-promised-singleton)

// Use the PromisedSingleton object with the type of object you will be returning
fooService: PromisedSingleton<FooService> = new PromisedSingleton<FooService>({
// Using a Promise
fooService = new PromisedSingleton<FooService>({
generator: (): Promise<FooService> => new Promise(resolve => {

@@ -49,4 +49,4 @@ const service = new FooService();

// Using an async function
barService: PromisedSingleton<BarService> = new PromisedSingleton<BarService>({
generator: async (): Promise<FooService> => {
barService = new PromisedSingleton<BarService>({
generator: async (): Promise<BarService> => {
const service = new BarService();

@@ -53,0 +53,0 @@ await service.setup();

Sorry, the diff of this file is not supported yet

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