Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'parse-duration' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.
public async mute(
message: Message,
member: GuildMember,
duration: number,
reason: string
) {
const dbMember = await DBGuildMember.findOne({
where: { id: member.id }
});
const dbGuild = await DBGuild.findOne({
where: { id: member.guild.id }
});
if (!dbMember) await DBGuildMember.createOrUpdate(member, dbGuild!);
duration = Math.floor(parse(duration) / 60000); // parse to minutes
console.log(duration);
await member.addRole(this.muteRole);
await getPublicLogger().send({
type: "mute",
duration,
member,
moderator: message.author,
reason
});
// Shorter equivalent of `valueOf` (returns a Unix timestamp).
let unmuteAt = Math.floor(+new Date() / 1000);
// Add minutes to the timestamp.
unmuteAt += duration * 60;
onTimeChanged (worklog, editedTime) {
if (editedTime != '') {
let ms = parseDuration(editedTime)
// Is the timer entered valid?
if (ms > 0)
this.props.updateWorkLogTime(worklog, Math.round(ms / 1000))
}
this.onResetEditTime()
}
onTimeChanged (timerId, editedTime) {
if (editedTime != '') {
let ms = parseDuration(editedTime)
// Is the timer entered valid?
if (ms > 0)
this.props.updateTimer(timerId, ms)
}
this.onResetEditTime()
}
console.log(`Found existing build ${build.id}. Cancelling.`);
cloudbuild.projects.builds.cancel({ projectId, id: build.id });
});
}
} catch (e) {
console.log(
'Error fetching existing builds, not cancelling existing builds.',
);
}
console.log(`Starting cloud build for pull request ${pull.number}.`);
const cloudbuildConfig: Build = config.repos[repo].cloudbuild;
const sanitizedConfig: Build = cloudbuildConfig.timeout
? {
...cloudbuildConfig,
timeout: `${parseDuration(cloudbuildConfig.timeout) /
MILLIS_IN_SECOND}s`,
}
: cloudbuildConfig;
await cloudbuild.projects.builds.create({
projectId,
requestBody: {
...sanitizedConfig,
options: {
...sanitizedConfig.options,
substitutionOption: 'ALLOW_LOOSE',
},
substitutions,
tags,
},
});
const parseNumber = (v) => {
const n = typeof v === 'number'
? v
: parseDuration(v)
if (isNaN(n)) throw new Error(`Invalid number: ${v}`)
return n / 1000
}