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

@logzio-node-toolbox/utils

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@logzio-node-toolbox/utils

collection of nice utils

  • 0.0.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

handy utils

Observable

simplified observable pattern class

import { Observable }  from '@logz/utils';
const data = {
  num: 2
}
const observable = new Observable(data);

const unsubscribe = observable.subscribe((newData => console.log(newData));

observable.set({num : 3}) // wii invoke all subscribes


unsubscribe() // will remove subscriber from object

Monitor

using the observable pattern implement with timeouts can monitor changes constructor params: interval: number (default 5000) | interval time to iterate on the callback afterFinish: boolean (default false) | should start next iteration timer after callback function finished monitor: fn (optional can also be pass on the start method)

methods: start: { monitor: fn, interval: number (default from class) onCall: fn } | start the interval stop: | stop interval subscribe: fn | call on each interval unSubscribe: fn | remove fn from subscribes destroy: | stop interval the remove all subscribes

import { Monitor }  from '@logz/utils';

const sum = 0;
const toMonitorCallback = () => {
  sum = sum + 20
  delay(2000)
  return sum
}

// in this case afterFinish will cause interval be 5000 (delay from monitor + interval time) instead of 3000
const monitor = new Monitor({ interval: 3000, afterFinish: true, monitor: toMonitorCallback });

const subscriber2 = newData => console.log(newData);

monitor.subscribe(subscriber2);

const unsubscriber1 = monitor.subscribe((newData => console.log(newData)));

monitor.start(); // wii invoke all subscribers each call

monitor.unsubscribe(subscriber2);
unsubscriber1(); // will remove subscriber from object

monitor.destroy();

FAQs

Package last updated on 06 Sep 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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