Skip to content

Instantly share code, notes, and snippets.

@Sk-OmarFaruque
Last active April 3, 2018 04:58
Show Gist options
  • Save Sk-OmarFaruque/e523d05180fccae1cb8851eb9656741c to your computer and use it in GitHub Desktop.
Save Sk-OmarFaruque/e523d05180fccae1cb8851eb9656741c to your computer and use it in GitHub Desktop.
// find inside array
let res = await this.state.categories.find(data => {
return data.CategoryName === value
})
// empty object
Object.keys(this.q).forEach(key => {
this.q[key] = ''
})
//merge two objects
Object.assign(obj1,obj2)
//delete element from object
delete obj.id
// conver time to day,hour,min sec
helper.calcDayHourMin = function secondsToString (seconds) {
var numdays = Math.floor(seconds / 86400)
var numhours = Math.floor((seconds % 86400) / 3600)
var numminutes = Math.floor(((seconds % 86400) % 3600) / 60)
var numseconds = ((seconds % 86400) % 3600) % 60
return numdays + 'days' + numhours + 'hr' + numminutes + 'mins'
}
// file extension
let fileName = file.name
var nameLen = fileName.length
var lastDotPos = fileName.lastIndexOf('.')
var fileNameSub = false
if (lastDotPos === -1) {
fileNameSub = false
} else {
fileNameSub = fileName.substr(lastDotPos + 1, nameLen)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment