Q1: Write Jest tests for the following
matchObjectsfunction.Use
describeandtestas Jest primitives and formulate the test title using thegiven $CONTEXT, $DO-ACTION should $EXPECT-RESULTpattern.export type MatchObjects = <T extends Record<string, unknown>>( matcher: Partial<T>, input: T ) => boolean;
I have various versions of useCrudState hook around but never published a
package of it. I used ChatGPT to see how far I can
get and what the experience is by "just dictating".
I needed multiple sessions since at some point ChatGPT got stuck middle-way and stopped outputting. In between sessions, I sometimes reordered or do some cosmetics that I would do faster.
While Functional Programming teaches you to focus on more "what" as oposed to "how", working together with ChatGPT takes this to a different level.
Havent worked in a long time and today didnt promise to be any different.
At some point I opened my desktop pc and Firefox was opened at https://chat.openai.com ... so I went for it :)
Kept at it for more than 7 hours, rewriting questions, reverting from tangents etc.
# Slugify a string, with ChatGPTs helpWhen you don’t want to repeat yourself, sometimes a type needs to be based on another type.
Mapped types build on the syntax for index signatures, which are used to declare the types of properties which has not been declared ahead of time:
type CalcTotalByFieldType = <T, F extends keyof T>(| const axios = require("axios") | |
| const { map, pipe, pipeP, reduce, sortWith, read } = require("@asd14/m") // replace with ramda or underscore | |
| const CORRECTIONS_URL = "https://spellchecker.glitch.me/corrections" | |
| const CHECKSPELLING_URL = "https://spellchecker.glitch.me/checkspelling" | |
| /** | |
| * Given a string, return a list of misspelled words and their positions | |
| * | |
| * @param {string} source |
| const { | |
| when, | |
| equals, | |
| pipe, | |
| map, | |
| mapMatrix, | |
| join, | |
| read, | |
| converge, | |
| reduce, |
| #!/usr/bin/fish | |
| # The typematic delay indicates the amount of time (typically in miliseconds) | |
| # a key needs to be pressed and held in order for the repeating process to | |
| # begin. After the repeating process has been triggered, the character will be | |
| # repeated with a certain frequency (usually given in Hz) specified by the | |
| # typematic rate. Note that these settings are configured seperately for Xorg | |
| # and for the virtual console. | |
| xset r rate 170 25 |
| Find and Replace (with Regular Expressions) | |
| find : ^(.*),(.*),(".*"),(".*"),(".*")$ | |
| where : <current file> | |
| replace: {"id": $1, "other_id": $2, "name": $3, "date_updated": $4, "date_created": $5}, |
| const { sep } = require("path") | |
| const { trim, split, push, join, dropLast } = require("@codemachiner/m") | |
| const removeTrailingSlash = source => | |
| source[source.length - 1] === sep ? source.slice(0, -1) : source | |
| /** | |
| * Rename a file. Removes trailing slashes. | |
| * | |
| * @param {string} newName New file name |
| const { count, filter } = require("functial-lib") | |
| const todos = [{isDone: true, ...}, {...}] | |
| const todosIsDoneCount = todos | |
| |> filter(todosFilterElm => todosFilterElm.isDone === true) | |
| |> count |