1.2.1 • Published 4 years ago
@callmekory/utils v1.2.1
const {code, stdout, stderr} = await execAsync('date')
print(stdout) // prints Fri 27 Mar 2020 06:47:24 PM PDTordinalSuffix(2) // add ordinal suffix to number 2Returns
2ndconst someList = ["I'm a blue dog", "I'm a red dog", "I'm a green dog"]
const searchTerms = ["dog", "red"]
filterByKeywords(someList, searchTerms)Returns
["I'm a red dog"]await asyncForEach(array, (item) => {
// callback
})const date = new Date('2020-03-08 05:44:22.185 +00:00') // Random date from a while ago
differenceInHours(date) // Check how many hours ago the date wasReturns
476.69const sampleArray = ["one", "two", "three", "four", "five", "six"]
chunkArray(sampleArray, 3) // Split array into 3 equal chunksReturns
[
["one", "two"],
["three", "four"],
["five", "six"]
]// Find all mp4 files in a directory
findFilesByType("path/to/dir", ".mp4")// Print Hello World with 5 spaces
console.log(`Hello${addSpace(5)}World`)Returns
"Hello World"capitalize("hello")Returns
"Hello"sortByKey(array, "key")const originalArray = [
{
animal: "dog",
color: "brown"
},
{
animal: "dog",
color: "white"
},
{
animal: "cat",
color: "white"
},
]
// Split array based off of the anime type
groupByProperty(originalArray, "animal")Returns
[
dog: [
{ animal: 'dog', color: 'brown' },
{ animal: 'dog', color: 'white' }
],
cat: [ { animal: 'cat', color: 'white' } ]
]const bytes = 1000000 // 1 megabytes in bytes
const converted = bytesToSize(bytes)Returns
"1 MB"// convert 2 minutes in milliseconds to time string
const time = millisecondsToTime(120000) Returns
2:00await sleep(1000) // asynchronously sleeps for 1 second1.2.1
4 years ago
1.2.0
5 years ago
1.1.9
6 years ago
1.1.8
6 years ago
1.1.7
6 years ago
1.1.6
6 years ago
1.1.5
6 years ago
1.1.4
6 years ago
1.1.3
6 years ago
1.1.1
6 years ago
1.1.0
6 years ago
1.1.2
6 years ago
1.0.9
6 years ago
1.0.8
6 years ago
1.0.7
6 years ago
1.0.6
6 years ago
1.0.5
6 years ago
1.0.4
6 years ago
1.0.3
6 years ago
1.0.2
6 years ago
1.0.1
6 years ago
1.0.0
6 years ago