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

@alwaystudios/as-utils

v1.0.16

Published

https://www.npmjs.com/package/@alwaystudios/as-utils

Downloads

40

Readme

as-utils

https://www.npmjs.com/package/@alwaystudios/as-utils

yarn add @alwaystudios/as-utils

promiseRetry

Retry a promise for customizable delay time and number of attempts

Defaults: attempts = 10, timeout = 200

  const result = await promiseRetry()(someAsyncFunction)

  const result = await promiseRetry({ attempts: 2, timeout: 200 })(someAsyncFunction)

promiseTimeout

setTimeout as a promise

  await promiseTimeout(2000)

processTimer

time the duration of a process

  const start = new Date().getTime()
  const stopTimer = processTimer()
  await promiseTimeout(200)
  const duration = stopTimer()

concatenate

concatenates a variable array of strings ignoring falsy values

  concatenate('a', 'b', '', null, false, undefined, 'c') // = 'a b c'

encrypt

encrypts a string using aes-256-cbc

  const hash = encrypt(dataToEncrypt, key)

decrypt

decrypts a string using aes-256-cbc

  const hash = encrypt(dataToEncrypt, key)
  const decryptedData = decrypt(hash, key)

createSubscriberProcess

creates a subscriber process that will run a poller process on a given interval and then process that data

  createSubscriberProcess(pollerProcessAsyncFunction, processDataFunction, processErrorFunction, 200)

batchProcessor

Processes data in batches (default batch size = 100)

  await batchProcessor(data, func, batchSize)

csvBatchRunner

Reads a csv and runs a processor function (default batch size = 100)

  await csvBatchRunner({ filename, f, onError: onErrorFunction, batchSize })

readCsv

Reads data from a csv file

  const data = await readCsv(filename, onErrorFunction)

isPlainObject

  if(isPlainObject({ test: 'test' })) {
    // do something
  }

kebabify, dekebabify

normal text kebabified-text

sentenceCase

Capitalise the first character of the first word in a sentence

truthy

  [1, 2, undefined, null, 0].filter(truthy) // returns [1, 2]

waitUntil

  await waitUntil(() => expect(mock).toHaveBeenCalledTimes(1))

removeUndefined

Removes undefined keys from an object

debounce

Debounce a function with a given timeout (default = 500)

  const timeout = 1000
  const debouncedFunc = debounce(myFunc, timeout)

  debouncedFunc(1)
  debouncedFunc(2)
  debouncedFunc(3) // myFunc is called with 3

deepPartialDiff

  const data = {
    topKey1: {
      midKey1: 'value midKey 1',
      midKey2: 3,
    },
    topKey2: {
      midKey1: 33,
      midKey2: 'value midKey 2',
      midKey3: {
        lowKey: 444,
      },
    },
  }

  deepPartialDiff({ topKey1: {} }, data) // = data

  deepPartialDiff(
        {
          topKey1: {
            midKey1: 'value midKey 1',
            midKey2: 3,
          },
          topKey2: {
            midKey1: 33,
            midKey2: 'value midKey 2',
            midKey3: {},
          },
        },
        data,
      ) // = {
      topKey2: {
        midKey3: {
          lowKey: 444,
        },
      },
    }

TaskQueue

A limited parallel execution, asynchronous task queue

  const queue = new TaskQueue(concurrencyLimit)
  queue.addTask(fn)