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

@xyo-network/base

Package Overview
Dependencies
Maintainers
6
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@xyo-network/base - npm Package Compare versions

Comparing version 0.26.0 to 0.29.0

3

dist/@types/index.d.ts

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

export interface ISimpleCache {
getOrCreate<T>(name: string, initializer: () => T): T;
}
//# sourceMappingURL=index.d.ts.map

3

dist/@types/index.js

@@ -8,7 +8,6 @@ "use strict";

* @Last modified by: ryanxyo
* @Last modified time: Monday, 10th December 2018 1:22:44 pm
* @Last modified time: Wednesday, 6th March 2019 1:42:35 pm
* @License: All Rights Reserved
* @Copyright: Copyright XY | The Findables Company
*/
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=index.js.map

@@ -17,4 +17,10 @@ import { XyoLogger } from "@xyo-network/logger";

static stringify(value: any): string;
private cache;
protected getOrCreate<T>(name: string, initializer: () => T): T;
static unschedule(): void;
static timeout(fn: (...args: any[]) => void, timeMs: number, description?: string): () => void;
static interval(fn: (...args: any[]) => void, timeMs: number, description?: string): () => void;
static immediate(fn: (...args: any[]) => void, description?: string): () => void;
private static timeoutIds;
private static intervalIds;
private static immediateIds;
private static schedule;
/** Logs to the `info` level */

@@ -21,0 +27,0 @@ protected logInfo(message?: any, ...optionalParams: any[]): void;

@@ -8,3 +8,3 @@ "use strict";

* @Last modified by: ryanxyo
* @Last modified time: Wednesday, 16th January 2019 2:54:11 pm
* @Last modified time: Wednesday, 6th March 2019 4:29:22 pm
* @License: All Rights Reserved

@@ -19,3 +19,2 @@ * @Copyright: Copyright XY | The Findables Company

const fast_safe_stringify_1 = __importDefault(require("fast-safe-stringify"));
const xyo_simple_cache_1 = require("./xyo-simple-cache");
/**

@@ -41,15 +40,30 @@ * A general purpose base class that can be used to incorporate

}
getOrCreate(name, initializer) {
if (!this.cache) {
this.cache = new xyo_simple_cache_1.XyoSimpleCache();
}
return this.cache.getOrCreate(name, initializer);
static unschedule() {
Object.values(this.immediateIds).forEach(v => clearImmediate(v));
Object.values(this.timeoutIds).forEach(v => clearTimeout(v));
Object.values(this.intervalIds).forEach(v => clearInterval(v));
}
// protected async getOrCreateAsync<T>(name: string, initializer: () => Promise<T>): Promise<T> {
// if (!this.cache) {
// this.cache = new XyoSimpleCache()
// }
// const t = await this.cache.getOrCreate(name, initializer)
// return t
// }
static timeout(fn, timeMs, description) {
return this.schedule(setTimeout, clearTimeout, fn, timeMs, this.timeoutIds, description);
}
static interval(fn, timeMs, description) {
return this.schedule(setInterval, clearInterval, fn, timeMs, this.intervalIds, description);
}
static immediate(fn, description) {
return this.schedule(setImmediate, clearImmediate, fn, 0, this.immediateIds, description);
}
static schedule(scheduler, unscheduler, fn, timeMs, aggregator, description) {
const key = String(new Date().valueOf() + Math.random());
const t = scheduler(() => {
delete this.timeoutIds[key];
if (description)
XyoBase.logger.info(`Scheduler resolved: ${description} after ${timeMs}ms`);
fn();
}, timeMs);
aggregator[key] = t;
return () => {
delete aggregator[key];
unscheduler(t);
};
}
/** Logs to the `info` level */

@@ -86,4 +100,7 @@ logInfo(message, ...optionalParams) {

}
XyoBase.timeoutIds = {};
XyoBase.intervalIds = {};
XyoBase.immediateIds = {};
exports.XyoBase = XyoBase;
XyoBase.logger = new logger_1.XyoLogger(process.env.ENABLE_LOGGING_FILES !== undefined, process.env.ENABLE_LOGGING_FILES !== undefined);
//# sourceMappingURL=xyo-base.js.map
{
"name": "@xyo-network/base",
"version": "0.26.0",
"version": "0.29.0",
"description": "A base class for the Xyo Network",

@@ -10,3 +10,3 @@ "main": "dist/index.js",

"dependencies": {
"@xyo-network/logger": "^0.26.0",
"@xyo-network/logger": "^0.29.0",
"fast-safe-stringify": "^2.0.6"

@@ -23,3 +23,3 @@ },

},
"gitHead": "b86b8078d87e72f0a132bc5e1d6c87aa29e00b7b"
"gitHead": "6d3ef6cac153314b05cda28efed3bac7efeaa55d"
}

@@ -7,9 +7,5 @@ /*

* @Last modified by: ryanxyo
* @Last modified time: Monday, 10th December 2018 1:22:44 pm
* @Last modified time: Wednesday, 6th March 2019 1:42:35 pm
* @License: All Rights Reserved
* @Copyright: Copyright XY | The Findables Company
*/
export interface ISimpleCache {
getOrCreate<T>(name: string, initializer: () => T): T
}

@@ -7,3 +7,3 @@ /*

* @Last modified by: ryanxyo
* @Last modified time: Wednesday, 16th January 2019 2:54:11 pm
* @Last modified time: Wednesday, 6th March 2019 4:29:22 pm
* @License: All Rights Reserved

@@ -15,4 +15,2 @@ * @Copyright: Copyright XY | The Findables Company

import safeStringify from 'fast-safe-stringify'
import { ISimpleCache } from "./@types"
import { XyoSimpleCache } from "./xyo-simple-cache"

@@ -45,21 +43,45 @@ /**

private cache: ISimpleCache | undefined
public static unschedule() {
Object.values(this.immediateIds).forEach(v => clearImmediate(v))
Object.values(this.timeoutIds).forEach(v => clearTimeout(v))
Object.values(this.intervalIds).forEach(v => clearInterval(v))
}
protected getOrCreate<T>(name: string, initializer: () => T): T {
if (!this.cache) {
this.cache = new XyoSimpleCache()
}
public static timeout(fn: (...args: any[]) => void, timeMs: number, description?: string) {
return this.schedule(setTimeout, clearTimeout, fn, timeMs, this.timeoutIds, description)
}
return this.cache.getOrCreate(name, initializer)
public static interval(fn: (...args: any[]) => void, timeMs: number, description?: string) {
return this.schedule(setInterval, clearInterval, fn, timeMs, this.intervalIds, description)
}
// protected async getOrCreateAsync<T>(name: string, initializer: () => Promise<T>): Promise<T> {
// if (!this.cache) {
// this.cache = new XyoSimpleCache()
// }
public static immediate(fn: (...args: any[]) => void, description?: string) {
return this.schedule(setImmediate, clearImmediate, fn, 0, this.immediateIds, description)
}
// const t = await this.cache.getOrCreate(name, initializer)
// return t
// }
private static timeoutIds: {[s: string]: NodeJS.Timeout} = {}
private static intervalIds: {[s: string]: NodeJS.Timeout} = {}
private static immediateIds: {[s: string]: NodeJS.Immediate} = {}
private static schedule<T>(
scheduler: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => T,
unscheduler: (t: T) => void,
fn: (...args: any[]) => void,
timeMs: number,
aggregator: {[s: string]: T},
description?: string
) {
const key = String(new Date().valueOf() + Math.random())
const t = scheduler(() => {
delete this.timeoutIds[key]
if (description) XyoBase.logger.info(`Scheduler resolved: ${description} after ${timeMs}ms`)
fn()
}, timeMs)
aggregator[key] = t
return () => {
delete aggregator[key]
unscheduler(t)
}
}
/** Logs to the `info` level */

@@ -66,0 +88,0 @@ protected logInfo(message?: any, ...optionalParams: any[]) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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