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

@debut/plugin-utils

v2.0.3

Published

Debut utilites for core and plugins

Downloads

85

Readme

@debut/plugin-utils

A set of indispensable utilities for the Debut ecosystem.

Installation

npm install @debut/plugin-utils --save

CLI - Command Line Interface utilities

requireUncached(module: string)

Allows the specified module to be connected without the standard Node caching. Instead of a native call to require(module: string)

getBotsSchema()

Get the contents of schema.json file

getBotData(name: string, schema = getBotsSchema())

Getting the bot's meta data by the name of the constructor.

getArgs<T>()

Gets the arguments passed at startup. Returns an object key-value.

Example: node ./myscript.js --arg1=foo --arg2=bar.

import { cli } from '@debut/plugin-utils`;

const args = getArgs(); // { arg1: "foo", arg2: "bar" }

getTokens().

Getting an object with private keys to work with the broker's API. From the file .tokens.json in the working directory of the project.

Date - Utilities for working with dates

isSameDay(d1: Date, d2: Date)

Are the two dates the same day

isWeekend(d: string | number | Date)

Is the date the same day off

toIsoString(d: string | number | Date)

Convert date to custom ISO format to work with tinkoff API.

getWeekDay(stamp: number)

Get the day of the week in UTC time stamp

intervalToMs(interval: TimeFrame)

Converting candlestick timeframe into a value in milliseconds

Debug - Debugging utilities

logDebug(...data: any[])

Logging with event time information

File - Utilities for working with files

saveFile(path: string, data: any)

saveFile(path: string: data: any) ## Save the transferred data to the path path

ensureFile(path: string)

Checks if the path exists; if it does not, creates it

readFile(path: string)

Safely reads a file

isDir(path: string)

Is the path a directory

Math - Calculation utilities

clamp(num: number, min: number, max: number)

Clamping a number between a minimum and a maximum value

getPrecision(number: number | string)

Getting the precision of a floating point number calculation

percentChange(current: number, prev: number)

Percentage difference between two numbers

toFixed(num: number, precision = 2)

A quick fix for the accuracy of a calculation, without losing type

getRandomArbitrary(min: number, max: number, odd?: boolean)

Generation of a random number in the range [min, max] and optionally an odd number

getRandomInt(min: number, max: number, odd?: boolean)

Generation of a random integer in the range [min, max], optionally odd

Orders - Utilities for working with deals

inverseType(type: OrderType)

Inverts the type of a trade

syntheticOrderId(order: ExecutedOrder | OrderOptions)

Synthetic random identifier for a trade

getMinIncrementValue(price: number | string)

Minimum value in the accuracy of the passed number

getCurrencyProfit(order: ExecutedOrder, price: number)

Counting the current profit in the currency of the trade

getCurrencyBatchProfit(orders: ExecutedOrder[], price: number)

Counting current profit in the currency of the trade for several orders simultaneously

getCurrencyComissions(orders: ExecutedOrder[], price: number, fee: number)

Counting current commision for single order based on predicatable fee number

getCurrencyBatchComissions(orders: ExecutedOrder[], price: number, fee: number)

Counting current commision for several orders order based on predicatable fee number

Promise

sleep(ms: number)

Initializes downtime for some time in milliseconds