Giter Site home page Giter Site logo

utils's Introduction

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

Function Description
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

Function Description
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

Function Description
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

Function Description
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

Function Description
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

Function Description
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

Function Description
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

Function Description
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

Function Description
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

Function Description
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

utils's People

Contributors

thespicymeatball avatar amrinea avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.