This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createEventEmitter } from './event-emitter' | |
type ExampleEvents = { | |
add_todo: { id: string; text: string } | |
complete_todo: { id: string } | |
delete_todo: { id: string } | |
} | |
beforeEach(jest.clearAllMocks) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export type SerializedString = string; | |
export type SafeQueryParamOptions<Value> = { | |
getUnsafeQueryParam(): SerializedString | undefined; | |
serialize(safeValue: Value): SerializedString; | |
deserialize(unsafeValue: SerializedString): Value; | |
parse(unsafeValue: Value): Value; | |
onParseError(error: unknown): void; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint-disable @typescript-eslint/no-explicit-any */ | |
type CallBack<Params extends any[]> = { | |
(...args: Params): void; | |
}; | |
export function callAll<Params extends any[]>(...fns: Array<CallBack<Params> | undefined>) { | |
return (...args: Params) => fns.forEach((fn) => typeof fn === 'function' && fn(...args)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import packageJson from '../package.json' | |
import { writeFile } from 'fs/promises' | |
import { resolve } from 'node:path' | |
const unwantedProperties = ['keywords', 'files', 'scripts', 'devDependencies'] | |
unwantedProperties.forEach(deleteProperty) | |
rewritePackageJson() | |
function deleteProperty(key: string) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { composeValidation, v } from './validation' | |
const validateRequirement = composeValidation([ | |
v.min(10, 'cannot be empty'), | |
v.hasUpperCase('at least one uppercase letter'), | |
v.hasNumber('at least one number character'), | |
v.hasSpecialCharacter('at least one special character'), | |
v.max(64, 'max character limit (64) reached'), | |
]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type ShallowObject = Record<string, string | number | boolean> | |
type User = Partial<{ | |
name: string | |
email: string | |
}> & ShallowObject | |
type UserBuilder = { | |
addName: (name: string) => UserBuilder | |
addEmail: (email: string) => UserBuilder |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.CoolButton { | |
/* Your regular Button styles */ | |
background: #000; | |
padding: 16px 32px; | |
border-radius: 8px; | |
color: #fff; | |
font-size: 16px; | |
font-weight: bold; | |
box-sizing: border-box; | |
border: 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let isRateRunning = false | |
init() | |
function init() { | |
removeAnimations() | |
watchKeyboardShortcut() | |
} | |
function watchKeyboardShortcut() { | |
const { start, stop } = setAutomaticRate() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); |
NewerOlder