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

amq-tools-cjs

v3.0.2

Published

Set of Javascript/Typescript utilities

Downloads

5

Readme

AMQ Toolbox

Build Status semantic-release

A set of tools and utilities for TS / JS development with no external dependencies. Both browsers and node are supported.

This is separated in two kind of components: 3 main modules and many small utils.

Installation

This project can be installed with NPM or used globally for specific cases.

With NPM

All modules can be imported with NPM:

npm install amq-tools

And then imported as CommonJS modules:

const log = require('amq-tools/log');
const Stream = require('amq-tools/stream');
const Timer = require('amq-tools/timer');
const getUrlQuery = require('amq-tools/util/get-url-query');

As ECMAScript module

A ECMAScript 2015 version is available too

npm install amq-tools-es6
import log  from 'amq-tools-es6/log';
import Stream  from 'amq-tools-es6/stream';
import Timer  from 'amq-tools-es6/timer';
import getUrlQuery  from 'amq-tools-es6/util/get-url-query';

Globally

Or globally by including the tag for the module in the HTML:

<script src="http://repos.amatiasq.com/amq-tools/lastest/log.js">
<script src="http://repos.amatiasq.com/amq-tools/lastest/stream.js">
<script src="http://repos.amatiasq.com/amq-tools/lastest/timer.js">
<script src="http://repos.amatiasq.com/amq-tools/lastest/util/get-url-query.js">

In this case the modules will be added to the global amq object:

amq.log(...);
new amq.Stream(...);
new amq.Timer(...);
amq.util.getUrlQuery(...);

All the examples use the imported format but the global amq version works exactly the same way.

Components

Logger

A simple logger tool to intercept method / function calls. Hooks on the passed class / function and logs when it's invoked and the argument list and also the return value. Additionally every console.log() call made during the function execution will be indented in the console.

Read more

Stream

Work in progress

Timer

A class to handle delayed code execution.

You only need to provide the callback and the milliseconds to delay once in the constructor. After that you can schedule the timer as many times as you need to.

Read more

Utilities

A set of small functions for various useful proposes, each one is self-documented.

  • chunks: Splits an array into a two-dimensional array.
  • combinations: Calculates every possible combination of a set of elements.
  • curry: Decorates a function to accept the arguments it needs in different invocations.
  • deep-extend: Extends a complex object with another object.
  • download-canvas: Modifies a link element to download a canvas as a PNG image when clicked.
  • download-url: Asks the browser to download a given URL as a file.
  • edit-object: Allows for easely add and remove properties from an object.
  • get-global: Returns global object on node and window in browser.
  • get-url-query: Reads query parameters of a URL and returns it as a Map.
  • print-jsx: Work in progress Generates a string with the JSX code for a given ReactJS element.
  • route-to-regex: Generates regular expressions for path definitions.
  • split-name: Splits a full name into first and last name using the whitespace closest to the middle of the string.
  • stringify: A simple JSON stringifier. Used to customize the JSON output.

Promise utils

Some utilities specialize on decorating functions that return or accept promises to make them more useful.

  • promise/add-sync-method: Uses sync-version to decorate a object's method and add a object.${method}Sync() version to get the last succesul value.
  • promise/async-params: Decorates a function to not be invoked until all Promise arguments are resolved.
  • promisify: Polyfill for Node8 util.promisify()
  • race-condition: Decoreates a promise returning function to prevent race conditions. That is when a previous execution is resolved after the last one.
  • sync-version: Decorates a promise returning function to cache the last successful value returned.
  • throttle-promise: Decorates a promise returning function to not be called again until the previous returned promise is resolved or rejected.