Common utility functions used throughout the vandium projects.
Install via npm.
npm install vandium-utils --save
Clones an object. If the value is not an object or null
then the existing value
is returned.
Creates an ISO string for a given date.
Determines if a values is an array. This implementation uses Array.isArray()
.
Determines if a value is a function.
Determines if a value is null
or undefined
.
Determines if a value is an Object
.
Determines if the object is empty
Determines if a value is a Promise
Determines if a value is a string
Parses a value to a boolean result. Values can be:
- "on" "yes", "true", "off", "no", "false" (case insensitive)
true
,false
Creates a string from a template
and substitutes values from obj
.
const { templateString } = require( 'vandium-utils' );
// str1 = "Hello Fred"
let str1 = templateString( 'Hello ${name}', { name: 'Fred' } );
// str2 = "Hello Fred, I see you live in Toronto"
let str = templateString( 'Hello ${name}, I see you live in ${place.city}', {
name: 'Fred',
place: {
city: 'Toronto'
}
});
We'd love to get feedback on how to make this tool better. Feel free to contact us at [email protected]