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
| const ARGUMENT_NAMES = /([^\s,]+)/g; | |
| function stripeFunction(func: Function) { | |
| const fnStr = func.toString() | |
| const args = fnStr.slice(fnStr.indexOf('(') + 1, fnStr.indexOf(')')).match(ARGUMENT_NAMES); | |
| const body = fnStr.slice(fnStr.indexOf('{') + 1, fnStr.lastIndexOf('}')); | |
| return { | |
| args: args || [] as string[], | |
| body: body |
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
| const ARGUMENT_NAMES = /([^\s,]+)/g; | |
| function stripeFunction(func: Function) { | |
| const fnStr = func.toString() | |
| const args = fnStr.slice(fnStr.indexOf('(') + 1, fnStr.indexOf(')')).match(ARGUMENT_NAMES); | |
| const body = fnStr.slice(fnStr.indexOf('{') + 1, fnStr.lastIndexOf('}')); | |
| return { | |
| args: args || [] as string[], | |
| body: body |
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
| <script> | |
| let twoFactor; | |
| let isCorrect = true; | |
| $: isCorrect | |
| function maybeRight() { | |
| console.log(twoFactor) | |
| Math.random() > 0.5 ? isCorrect = true : isCorrect = false; | |
| } | |
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 ConcatUntil | |
| < | |
| Text extends string, | |
| Delimiter extends string, | |
| Result extends string = '' | |
| > = | |
| Text extends `${infer L}${infer R}` | |
| ? L extends Delimiter | |
| ? Result | |
| : ConcatUntil<R, `${Result}${L}` > |
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 GetParams< | |
| Text extends string, | |
| Result extends string = '' | |
| > = | |
| Text extends `${ infer L }${ infer R }` | |
| ? L extends '/' | |
| ? Result | |
| : GetParams<R, `${ Result }${ L }`> | |
| : Result |
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
| const Module = { | |
| value: 0, | |
| someFn: () => { | |
| return this.value; | |
| }, | |
| okayFn() { | |
| return this.value; | |
| } | |
| } | |
| class Module2 { |
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
| package main | |
| import ( | |
| "fmt" | |
| md "github.com/JohannesKaufmann/html-to-markdown" | |
| "github.com/PuerkitoBio/goquery" | |
| "github.com/charmbracelet/glamour" | |
| "log" | |
| "net/http" | |
| "os" |
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
| // server/server.js | |
| Meteor.methods({ | |
| 'someMethod': async function() { | |
| if (Meteor.isAsyncCall()) { | |
| // here is a when a callAsync | |
| } else { | |
| // when is just call | |
| } | |
| return Meteor.isCallAsync(); | |
| }) |
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
| const cacheMap = new Map<string, Entry>() | |
| interface Entry { | |
| deps: EJSON[] | |
| promise: Promise<unknown> | |
| result?: unknown // here is what your T should be | |
| error?: unknown | |
| } | |
| // you can use isEqual from lodash in this case | |
| function arraysEqual<T>(a: T[], b: T[]): boolean { |
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 { Meteor } from 'meteor/meteor'; | |
| import { Mongo } from 'meteor/mongo'; | |
| import { | |
| useReducer, | |
| useMemo, | |
| useEffect, | |
| Reducer, | |
| DependencyList, | |
| useRef, | |
| } from 'react'; |