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

@yelmer-samples/iptiq-task-manager

v1.0.15

Published

iptiQ Task Manager

Downloads

11

Readme

iptiQ - Task Manager Project

A software component that is designed for handling multiple processes inside an operating system

Standards

  • Language: TS
  • Eslint: Yes
  • Static Code Analysis: Yes IntelliJ Code Inspections
  • DDD - Document Driven: Yes
  • DDD - Domain Driven: Yes
  • EDD - Exception Driven: Yes
  • TDD - Test Driven: Yes go to test folder
  • LDD - Log Driven: No
  • 12FA - 12 Factor-App: 50% Partially

Commands

  • npm run clear // clears "dist" folder
  • npm run lint // runs eslint for static code analysis
  • npm run test // runs test files in "test" folder
  • npm run build // builds JS files at "dist" folder
  • npm run publix // publishes "dist" folder to npm

Dependencies

  • uuid to generate unique pid

Install

npm i @yelmer-samples/iptiq-task-manager

Samples

Import

const {taskManager} = require('@yelmer-samples/iptiq-task-manager');
// ES6: import {taskManager} from "@yelmer-samples/iptiq-task-manager";

Initialize

Initializes the task manager with core attributes

Default - capacity is 1000

Default - mode is default

/**
* @param {number} capacity - first parameter
* @param {('default'|'fifo'|'priority')} mode - second parameter
* 
* @returns {void}
* 
* @throws {InvalidCapacityError} - if capacity is not valid positive integer
* @throws {InvalidModeError} - if mode is not any of [default, fifo, priority]
*/
taskManager.initialize(1000, 'default');

Add

Creates a new task with given priority

/**
* @param {{priority: 'low'|'medium'|'high'}} dto
* 
* @returns {TaskItem} - {pid: string, priority: 'low'|'medium'|'high', createdAt: number}
* 
* @throws {InvalidPriorityError} - if priority is not any of [low, medium, high]
* @throws {MaximumCapacityError} - if maxium capacity is reached when mode:default
*/
const task = taskManager.add({priority: 'low'});

List

Lists all tasks with sorting createdAt

/**
* @param nothing
* 
* @returns {Array<TaskItem>} - Array<{pid: string, priority: 'low'|'medium'|'high', createdAt: number}>
* 
* @throws nothing
* 
* @todo pagination, offset, page 
*/

const tasks = taskManager.list();

Kill All

Kills/removes all tasks

/**
* @param nothing
* 
* @returns {number} - killed task count
* 
* @throws nothing
*/

const killedCount = taskManager.killAll();

Kill by Group

Kills/removes tasks which' priority equals to given

/**
* @param {('low'|'medium'|'high')} priority
* 
* @returns {number} - killed task count
* 
* @throws nothing
*/
const killedCount = taskManager.killGroup('medium');

Kill by Pid

Kills/removes task with given pid

/**
* @param {string} pid
* 
* @returns {boolean} - is task killed?
* 
* @throws nothing
*/
const isKilled = taskManager.kill('e85ade4f-f170-49b4-87ca-132de86b2c5f');

Kill Direct

Kills/removes selected task

/**
* @param nothing
* 
* @returns {boolean} - is task killed?
* 
* @throws nothing
*/
const isKilled = taskManager.items[0].kill();

Get properties

Returns readonly properties

/**
* @returns {('default'|'fifo'|'priority')} - current mode
*/
const mode = taskManager.mode;

/**
* @returns {number} - current task capacity
*/
const capacity = taskManager.capacity;

/**
* @returns {Array<TaskItem>} - tasks
*/
const items = taskManager.items;

/**
* @returns {number} - short-cut for taskManager.items.length 
*/
const size = taskManager.size;

/**
* @returns {boolean} - short-cut for taskManager.items.length >= taskManager.capacity
*/
const isOverloaded = taskManager.isOverloaded;

Reset Mode

Reset mode in runtime

Note - Clears all tasks (or kill)

/**
* 
* @param {('default'|'fifo'|'priority')} mode
* 
* @returns {number} - killed task count
* 
* @throws {InvalidModeError} - if mode is not any of [default, fifo, priority]
*/
const killedCount = taskManager.resetMode('default');

Reset Capacity

Reset capacity in runtime

Note - Clears all tasks (or kill)

/**
* @param {number} capacity
* 
* @returns {number} - killed task count
* 
* @throws {InvalidCapacityError} - if capacity is not valid positive integer
*/
const killedCount = taskManager.resetCapacity(1000);

Prepared by

  • Mustafa Yelmer
  • mustafayelmer(at)gmail.com
  • 2021-09-21