npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@push.rocks/lik

v6.1.0

Published

Provides a collection of lightweight helpers and utilities for Node.js projects.

Downloads

789

Readme

@push.rocks/lik

light little helpers for node

Install

To install @push.rocks/lik, you can use npm (Node Package Manager). Simply run the following command in your terminal:

npm install @push.rocks/lik --save

This will download @push.rocks/lik and add it to your project's package.json dependencies.

Usage

@push.rocks/lik is a versatile package offering a variety of helper classes designed to simplify common tasks in Node.js development. From managing asynchronous operations to handling collections efficiently, this library provides lightweight solutions to enhance your coding workflow. Below, we explore several key features of @push.rocks/lik, presenting TypeScript examples to demonstrate their practical application in real-world scenarios.

AsyncExecutionStack

AsyncExecutionStack allows for managing asynchronous task execution with exclusive and non-exclusive slots, ensuring effective handling of resource-intensive operations.

import { AsyncExecutionStack } from '@push.rocks/lik';

const myAsyncStack = new AsyncExecutionStack();

// Exclusive execution ensures this task doesn't run in parallel with others
await myAsyncStack.getExclusiveExecutionSlot(async () => {
  // some asynchronous operation
}, 2500);

// Non-exclusive slots can run in parallel
myAsyncStack.getNonExclusiveExecutionSlot(async () => {
  // another asynchronous operation
}, 1500);

FastMap

FastMap offers a high-performance, key-value map optimized for rapid access and modifications, ideal for scenarios requiring frequent read/write operations.

import { FastMap } from '@push.rocks/lik';

const myFastMap = new FastMap<string>();

// Add items
myFastMap.addToMap('key1', 'value1');
myFastMap.addToMap('key2', 'value2');

// Retrieve item
const value = myFastMap.getByKey('key1'); // 'value1'

LimitedArray

LimitedArray enforces a maximum size on an array, automatically managing its length to prevent it from exceeding a defined limit.

import { LimitedArray } from '@push.rocks/lik';

const myLimitedArray = new LimitedArray<number>(5); // limit size to 5

myLimitedArray.addMany([1, 2, 3, 4, 5, 6]);
console.log(myLimitedArray.array); // [2, 3, 4, 5, 6]

LoopTracker

LoopTracker helps detect and prevent infinite loops by tracking object references during iterations.

import { LoopTracker } from '@push.rocks/lik';

const myLoopTracker = new LoopTracker<object>();
const obj1 = {};

if (myLoopTracker.checkAndTrack(obj1)) {
  // proceed with operation
} else {
  // potential loop detected
}

ObjectMap

ObjectMap facilitates object management, providing functionalities for adding, finding, and removing objects with ease.

import { ObjectMap } from '@push.rocks/lik';

interface MyObject {
  id: number;
  name: string;
}

const myObjectMap = new ObjectMap<MyObject>();
const obj: MyObject = { id: 1, name: 'Test Object' };

// Add object
myObjectMap.add(obj);

// Find object
const found = myObjectMap.findSync(item => item.id === 1);

StringMap

StringMap simplifies string collection management, allowing you to add, remove, and query strings effectively.

import { Stringmap } from '@push.rocks/lik';

const myStringMap = new Stringmap();

// Add strings
myStringMap.addString('hello');
myStringMap.addStringArray(['world', 'example']);

// Check string presence
const exists = myStringMap.checkString('hello'); // true

TimedAggregator

TimedAggregator batches operations over a specified time interval, useful for aggregating logs, metrics, or any data points over time.

import { TimedAggregtor } from '@push.rocks/lik';

const myAggregator = new TimedAggregtor<string>({
  aggregationIntervalInMillis: 5000, // 5 seconds
  functionForAggregation: (items) => {
    console.log('Aggregated items:', items);
  }
});

// Add items
myAggregator.add('item1');
myAggregator.add('item2');

// After 5 seconds, the functionForAggregation will log the aggregated items

InterestMap and Tree

InterestMap provides a structure for managing subscriptions or interests in certain events or entities, optimizing notification mechanisms.

import { InterestMap } from '@push.rocks/lik';

const myInterestMap = new InterestMap<string, number>((str) => str);

myInterestMap.addInterest('event1').then((interest) => {
  interest.fullfillInterest(42);
});

Tree offers a way to handle hierarchical data structures, allowing for the composition and traversal of tree-like data sets.

import { Tree } from '@push.rocks/lik';

class TreeNode {
  constructor(public value: string) {}
}

const myTree = new Tree<TreeNode>();
const rootNode = new TreeNode('root');
myTree.initialize(rootNode);

// Add child nodes
const childNode = new TreeNode('child');
myTree.appendChild(rootNode, childNode);

Utilizing @push.rocks/lik in Your Project

With @push.rocks/lik, you gain access to a comprehensive set of lightweight utilities that can significantly simplify and expedite the development process in Node.js environments. By leveraging the library's classes and functions, you can implement efficient data structures, manage asynchronous operations gracefully, and streamline complex logic with ease.

By integrating @push.rocks/lik into your project, you'll benefit from improved code clarity, reduced boilerplate, and enhanced performance, allowing you to focus on developing the core functionalities of your application. Whether you're managing various collections, executing asynchronous tasks in controlled manners, or dealing with hierarchical data, @push.rocks/lik provides the tools you need to achieve your objectives with minimal overhead.

Remember, continuous exploration of @push.rocks/lik's capabilities and experimenting with its various components in different scenarios will help you unlock its full potential. As your familiarity with the library grows, you'll discover even more ways to optimize your codebase and streamline your development workflow.

License and Legal Information

This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the license file within this repository.

Please note: The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.

Trademarks

This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.

Company Information

Task Venture Capital GmbH
Registered at District court Bremen HRB 35230 HB, Germany

For any legal inquiries or if you require further information, please contact us via email at [email protected].

By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.