Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@evokedset/utils

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@evokedset/utils

Utility Library for EvokedSet

latest
Source
npmnpm
Version
0.0.5
Version published
Maintainers
1
Created
Source

@evokedset/utils

General JavaScript we don't care to write again. Written in TypeScript and / or ES6. Because you have to start somewhere. Not very thoughtfully organized into vaguely related files.

Methods

Types and Shapes

getType(input, restricted=false)string

Returns name of type of input. A bit more versatile than typeof in that it will also recognize and return the expected result for any custom type.

ParamTypeRequiredDefault value
input*Yes
restrictedbooleanNofalse

getShape(input, depth=1)string

Returns the 'shape' of the object in the style of react proptypes. Handy for declaring very precise objects.

ParamTypeRequiredDefault value
inputobjectYes
depthnumberNo1

Strings and lists

humanizeList(list, config)string

Transforms ['Tom', 'Dick', 'Harry'] into Tom, Dick and Harry. Takes an array of strings and an optional config object. Also exported as thingCommaThingAndThing for obvious reasons.

ParamTypeRequiredDefault value
listarrayYes
configobjectNo{ oxford: false, and: 'and', andThen: '.' }

Config object:

Param TypeDefaultExplanation
oxfordbooleanfalseUse oxford comma?
andstringandTom, Dick and Harry.
andThenstring.Tom, Dick and Harry.

Dates

isDateInRange(checkDate, startDate, endDate) => boolean

Is checkDate after startDate and before endDate?

Param Typerequired
checkDateDate *true
startDateDate *true
endDateDate *true

isDateBeforeDate(firstDate, secondDate) => boolean

Is firstDate before secondDate?

Param Typerequired
firstDateDate *true
secondDateDate *true

* will accept any value castable to date, such as certain formats of numbers and strings.

FAQs

Package last updated on 15 May 2019

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