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

next-core-utilities

v3.4.1

Published

Augmented Next Core - Utilities and Functions.

Downloads

195

Readme

next-core-utilities

Augmented Next Core - Utilities and Functions

API

Table of Contents

isString

isString - checks if a value is a String

Parameters

Returns boolean true if value is a string

isFunction

isFunction - returns true if called name is a function simular to jQuery .isFunction method

Parameters

  • name function The name of the function to test

Returns any true if called name is a function

has

has

Parameters

Returns boolean Returns true of the key exists

isObject

isObject

Parameters

Returns boolean Returns true of the param is an object

allKeys

Augmented.allKeys

Parameters

Returns array Returns the array of ALL keys including prototyped

create

Augmented.create

Parameters

  • prototype object The input prototype
  • props object The properties (optional)

Returns object Returns the created object

result

Augmented.result - returns named property in an object simular to underscore .result method

Returns any named property in an object

arrayhas

Array.has - returns is a property is in the array (very fast return)

Parameters

Returns any true if property is included in an array

exec

exec method - Execute a function by name

Parameters

  • functionName string The name of the function
  • context object The context to call from
  • args object Arguments

isDefined

isDefined - Checks and returns if a passed variable is defined

Parameters

Returns boolean true if value is defined

prettyPrint

Prints an object nicely

Parameters

  • obj object The object to print
  • spaces boolean Use spaces instead of tabs (optional, default false)
  • number number Number spaces to use (if spaces is true) (optional, default 2)

Returns string formatted JSON string

prettyPrintHTML

Prints an object nicely in HTML

Parameters

  • obj object The object to print
  • indent (optional, default 0)
  • array (optional, default false)
  • last (optional, default true)

Returns string formatted JSON string in HTML

shuffle

Shuffles an Array with Fisher-Yates Shuffle algorithm

Parameters

  • array array The array to shuffle

Returns array A new shuffled array

binarySearch

Performs a binary search on the host array. vs indexOf Binary Search is a complexity of O(n log n) vs O(n) with indexOf

Parameters

  • arr Array The array.
  • find Any The item to search for within the array.
  • comparator function The comparator to use

Returns Number The index of the element which defaults to -1 when not found.

TransformerType

Augmented.Utility.TransformerType Transformer type for use in the transformer

Type: Symbol

Properties

Transformer

Augmented.Utility.Transformer Transform an object, type, or array to another type, object, or array

transform

The transformer type enum

Type: Augmented.Utility.TransformerType

Parameters

  • source
  • type

transform

Transform an object, primitive, or array to another object, primitive, or array

Parameters

  • source object Source primitive to transform
  • type Augmented.Utility.TransformerType Type to transform to

Returns object returns a transformed object or primitive

isType

Returns a Augmented.Utility.TransformerType of a passed object

Parameters

  • source object The source primitive

Returns Augmented.Utility.TransformerType type of source as Augmented.Utility.TransformerType

wrap

Wrap method to handle wrapping functions (simular to _.wrap)

Parameters

  • fn
  • wrap

filterObject

filter an object from array of values

Parameters

  • object object Object to filter
  • keys array keys to filter from the object

Returns object returns a new object with only these keys

findByMatchingProperties

find an oject from matching properties

Parameters

  • set Array array/set of objects
  • properties object properties to find by

Returns array returns a the objects that matched

sortObjects

Sorts an array of objects by propery in object

Parameters

  • array array The object array to sort
  • key object The property to sort by

Returns array The sorted array

mergeSort

Split the array into halves and merge them recursively

Parameters

  • array array The array to sort

Returns array The sorted array

mergeSort

Insertion sort is a simple sorting algorithm that builds the final sorted array (or list) one item at a time. It is much less efficient on large lists than more advanced algorithms such as quicksort, heapsort, or merge sort.

Parameters

  • array array The array to sort

Returns array The sorted array

mergeSort

Simple sorting algorithm that repeatedly steps through the list to be sorted, compares each pair of adjacent items and swaps them if they are in the wrong order.

Parameters

  • array array The array to sort

Returns array The sorted array

QuickSort

Quick Sort implimentation for Arrays -

Parameters

Returns Array Returns a sorted array

formatBinary

Format a number into binary string at a set precision

Parameters

  • num num The number to format
  • pres pres The bit precision

Returns string The formatted binary string

binaryToHex

Format a binary string into a hex value (two characters)

Parameters

  • binary binary The 8-bit binary string to return as hex characters
  • pad pad Add a zero if under '10'

Returns string The hex value

formatDate

Format a date to US format (MM/DD/YYYY HH:mm AM/PM) or (MM/DD/YYYY) only

Parameters

  • date date The date to format
  • noTime boolean Exclude the time

Returns string The formatted date

filter

Filter a string by removing a char

Parameters

Returns string The filtered string

sizeOf

Returns the size in bytes of an object

Returns Number size in bytes

formatByteSize

Returns the number (in bytes) as a human readable string

Returns String size in formated human readable string

memorySizeOf

Returns the object size as a human readable string

Returns String size in formated human readable string

hammingDistance

The Hamming Distance is the number of different symbols between two strings/numbers (equal length). It can be also considered as the number of changes required to convert from one input to another.

Parameters

Returns number the distance

isEqual

Performs a deep comparison between two values to determine if they are equivalent. This is a simular function to lodash isEquals.

Note: This method supports comparing arrays, array buffers, booleans, dates, error objects, maps, numbers, objects, regexes, sets, strings, symbols, and typed arrays. Objects are compared by their own, not inherited, enumerable properties. Functions are compared by strict equality, i.e. ===. DOM nodes are considered objects and treaked as such as this library does not assume browsers.

Parameters

  • first any The first item
  • second any The second item

Returns boolean Returns true if equal