Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@paravano/utils

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@paravano/utils

A set of JavaScript utils

  • 1.16.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Build Status Coverage Status

@paravano/utils

This library contains es5 and es6 implementations in the deliverable and is fully tree-shakable for es6. Simply import your utils as named imports like this:

import { isNilOrEmpty, take } from '@paravano/utils';

Version: 1.16.1

Click on each function name for details and examples

Array

FunctionDescription
atGets the item at the specified index of an array
countCounts the number of items that match the condition
dropImmutably drops the first or last specified number of items of an array
fillCreates a new array of the specified size and fills each index with the item
findIndexesFinds the indexes of an array that match the predicate
findLastIndexFinds the last index in an array that matches the predicate
firstGets the first item of an array
insertAtImmutably inserts the item(s) at the specified index
lastGets the last item of an array
limitImmutably inserts an item into the array if the size of the array has not reached the specified limit
limitItemImmutably inserts an item into the array if the occurrence of the item in the array has not reached the specified limit
moveImmutably moves an item from one index to another
padImmutably pads the array with {size} number of {item}
pluckGets an array of items given a set of indexes
removeAtImmutably removes an item at the specified index of the array
removeIfImmutably removes an item or items based on the predicate
replaceAtImmutably replaces an item at the specified index of the array
replaceIfImmutably replaces an item or items based on the predicate
reverseImmutably reverse an array
searchSearches an array of objects and returns the items that match the search
spliceImmutably adds/removes items from within the array
takeGets the first or last specified number of items of an array
toggleImmutably adds the item to the array if it's not already included; removes it if it's already included

Function

FunctionDescription
executionTimeCalculates the execution time of a function in milliseconds
pipeExecutes a queue of nested functions where the result of each function is fed as an argument into the subsequent function in the queue

Keyboard

FunctionDescription
altKeyPressedVerifies that the Alt key was pressed
backspaceKeyPressedVerifies that the Backspace key was pressed
ctrlKeyPressedVerifies that the Ctrl key was pressed
deleteKeyPressedVerifies that the Delete key was pressed
downKeyPressedVerifies that the down arrow key was pressed
enterKeyPressedVerifies that the Enter key was pressed
escKeyPressedVerifies that the Escape key was pressed
insertKeyPressedVerifies that the Insert key was pressed
keyPressedVerifies that at least one of the provided keys was pressed
leftKeyPressedVerifies that the left arrow key was pressed
rightKeyPressedVerifies that the right arrow key was pressed
shiftKeyPressedVerifies that the Shift key was pressed
spaceKeyPressedVerifies that the Space key was pressed
tabKeyPressedVerifies that the Tab key was pressed
upKeyPressedVerifies that the up arrow key was pressed

Logic

FunctionDescription
allReturns true if all values in {args} match the {check}
anyReturns true if any value in {args} matches the {check}
iifPerforms an inline if and returns either {whenTrue} or {whenFalse}
orReturns true if {value} has equality with any item in {args}

Number

FunctionDescription
commaStringCreates a comma separated number string
rangeDetermines whether or not the value is within the numeric range
roundRounds a number to a maximum specified number of significant digits

Object

FunctionDescription
assignImmutably assigns or adds (if it doesn't exist) the specified key and value to the input object
getGets the value at the specified path of the object
hasChecks if the path is a direct property of obj
keysGets a string array of the object's own keys
onlyCreates an object from another with only the specified keys
removeKeysImmutably removes a set of key from an object
sortKeysImmutably sorts the object keys
symbolsGets a string array of the object's own symbols

Sorting

FunctionDescription
sortReduceReduces to an object's key value for sorting
sortReduceDateReduces an object's key value (Date or string representation of a date) to a sortable string
sortReduceSemverReduces an object's key value (Semver) to a sortable string
sortReduceStringReduces an object's key value to a sortable string

String

FunctionDescription
camelConverts the string to camel case
capitalizeCapitalizes every word in the string
fuzzyMatchDetermines if a string has a fuzzy match to given search terms
initialsReturns the person's initials
kebabConverts the string to kebab case
leadingZeroAdds a leading zero to a value if the value is less than 10
removeRemoves a matching string or RegExp
splitCamelCaseSplits a camel-cased string apart and capitalizes each word
trimTrims the start and the end of a string by whitespace (default), specified string, or array of possible strings
trimEndTrims the end of a string by whitespace (default), specified string, or array of possible strings
trimStartTrims the start of a string by whitespace (default), specified string, or array of possible strings

Type

FunctionDescription
isReturns true if the type of value is the same as the provided type
isArrayReturns true if the value is an array
isBooleanReturns true if the value is a boolean
isDateReturns true if the value is an instance of Date
isFunctionReturns true if the value is a function
isNumberReturns true if the value is a number
isObjectReturns true if the value is an object
isStringReturns true if the value is a string
isSymbolReturns true if the value is a symbol
typeReturns a string representation of the type which also differentiates between 'object', 'array', 'date'

Value

FunctionDescription
defaultEmptyToReturns a default value if the original value is null, undefined, or empty
defaultToReturns a default value if the original value is null or undefined
isEmptyReturns true if the value is empty
isNilReturns true if the value is null or undefined
isNilOrEmptyReturns true if the value is null, undefined, or empty
isNotEmptyReturns true if the value is NOT empty
isNotNilReturns true if the value is NOT null or undefined
isNotNilOrEmptyReturns true if the value is NOT null, undefined, or empty

License

MIT

Author

Michael Paravano

Dependencies

None

Keywords

FAQs

Package last updated on 28 Apr 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc