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

mostaza-utils

v1.2.1

Published

Mostaza's utilities

Downloads

17

Readme

mostaza-utils

Our own utilities

Setup

This library is available on npm, install it with: npm install --save mostaza-utils

API

delay ⇒ Promise.<void>

Simple syntactic sugar over setTimeout that looks good when using the async/await pattern.

Kind: global variable Returns: Promise.<void> - A promise that resolves when the given time has ended.

| Param | Type | Description | | --- | --- | --- | | number | ms | Time to wait for in milliseconds. |

formatMacAddress ⇒ String

Formats a numeric string MAC address by adding the the right colon charactes.

Kind: global variable Returns: String - The MAC address with the colon characters.

| Param | Type | Description | | --- | --- | --- | | plainMacAddress | String | The MAC address without the colon characters. |

numberToHex ⇒ String

Transforms a number to its hexadecimal representation.

Kind: global variable Returns: String - The hexadecimal representation of the input number.

| Param | Type | Description | | --- | --- | --- | | num | Number | The number to convert. |

hexToNumber ⇒ Number

Transforms an hexadecimal numeric string to its numeric value.

Kind: global variable Returns: Number - The numeric representation of the input string.

| Param | Type | Description | | --- | --- | --- | | hex | String | The hexadecimal string to convert. |

append ⇒ Array.<any>

Returns a new array containing the contents of the array list, followed by the given element/s.

Kind: global variable Returns: Array.<any> - The new array.

| Param | Type | Description | | --- | --- | --- | | array | Array.<any> | The array. | | el | any/any | The value/values to push. |

remove ⇒ Array.<any>

Removes an element from the array (returns a new array). Doesn't work with collections (array of objects).

Kind: global variable Returns: Array.<any> - The new array.

| Param | Type | Description | | --- | --- | --- | | array | Array.<any> | The array. | | el | any | The value to pull. |

removeBy ⇒ Array.<any>

Iterates over elements of the array/collection, deleting the first element predicate returns truthy for and returning a new array. See Lodash.find() for more info on the quey param.

Kind: global variable Returns: Array.<any> - The new array (without the found elements).

| Param | Type | Description | | --- | --- | --- | | array | Array.<any> | The collection to inspect. | | query | Object | The function invoked per iteration / Object used for the query. |

appendOrRemove ⇒ Array.<any>

Removes an element from an array if it exists in it, otherwise pushes it (aka toggles it). Returns a new array.

Kind: global variable Returns: Array.<any> - The new array.

| Param | Type | Description | | --- | --- | --- | | array | Array.<any> | The array to inspect and update. | | el | any | The value to push/pull. |

toInt ⇒ Number

Parses a string to an integer. Useful for converting environment variable (while maintaing the 0 values).

Kind: global variable Returns: Number - The integer output.

| Param | Type | Description | | --- | --- | --- | | input | Number | String | The string to convert to integer. | | defaultOutput | Number | Returned if the string is not a valid number. |

omitUndefined ⇒ Object

Creates a new object composed of all the properties of the input object that do not have an undefined value.

Kind: global variable Returns: Object - A new object without properties with undefined values.

| Param | Type | Description | | --- | --- | --- | | obj | Object | The input object. |

omitNull ⇒ Object

Creates a new object composed of all the properties of the input object that do not have an null value.

Kind: global variable Returns: Object - A new object without properties with null values.

| Param | Type | Description | | --- | --- | --- | | obj | Object | The input object. |

omitNil ⇒ Object

Creates a new object composed of all the properties of the input object that do not have an undefined or null value.

Kind: global variable Returns: Object - A new object without properties with undefined and null values.

| Param | Type | Description | | --- | --- | --- | | obj | Object | The input object. |

formatBytes ⇒ String

Formats bytes in a readable string.

Kind: global variable Returns: String - The formatted bytes.

| Param | Type | Description | | --- | --- | --- | | bytes | Number | The bytes to format. |