Skip to content

Instantly share code, notes, and snippets.

View emkis's full-sized avatar

Nicolas Jardim emkis

View GitHub Profile
@emkis
emkis / toFixedWithoutRounding.test.ts
Last active July 14, 2021 17:29
Number.toFixed but without rounding the numbers
describe('toFixedWithoutRounding()', () => {
it('should return a string', () => {
const result = toFixedWithoutRounding(3271.24);
expect(typeof result).toBe('string');
});
it('should return expected numbers', () => {
expect(toFixedWithoutRounding(7933.2982426892, 1)).toBe('7933.2');
expect(toFixedWithoutRounding(7933.2982426892, 2)).toBe('7933.29');
expect(toFixedWithoutRounding(7933.2982426892, 3)).toBe('7933.298');
@emkis
emkis / Comment.vue
Last active May 15, 2021 22:25
Dynamic Attachments in Vue.js 3
<template>
<h1>This is my comment</h1>
<p>
Current attachment type: <strong>{{ attachment.type }}</strong>
</p>
<button @click="() => (attachment.type = 'fake-type')">Invalid type</button>
<button @click="() => (attachment.type = 'Default')">Default</button>
<button @click="() => (attachment.type = 'Button')">Button</button>