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 { useCallback, useEffect, useState } from 'react'; | |
| type AddonKey = | |
| | 'control' | |
| | 'theme' | |
| | 'mode' | |
| | 'width' | |
| | 'rtl' | |
| | 'source' | |
| | 'a11y' |
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 default function CustomAddon({ children, id }: PropsWithChildren<{ id: string }>) { | |
| const element = | |
| document.getElementById(id) || | |
| (() => { | |
| const addonsContainer = document.querySelector(".ladle-addons > ul"); | |
| const element = document.createElement("li"); | |
| element.id = id; | |
| addonsContainer?.prepend(element); | |
| return element; | |
| })(); |
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 { resolve } from 'path'; | |
| import { promises, readFileSync } from 'fs'; | |
| const { readdir } = promises; | |
| const ignoreFolders = ['__generated__', '__tests__']; | |
| const notImported: string[] = ['/webpack.config', '/globals.d']; | |
| const fileContent: Record<string, 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 isEqualish from './isEqualish'; | |
| describe('compare', () => { | |
| it('arrays should be true when different order', () => { | |
| const obj1 = { x: 1, y: 2 }; | |
| const obj2 = { x: 3, y: 4 }; | |
| const a = [obj1, obj2]; | |
| const b = [obj2, obj1]; |
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 fs from 'fs'; | |
| import https from 'https'; | |
| async function filesDownloader(url: (iterator: number) => string, response: (iterator: number, data: string) => void, iteratorMax: number, iteratorStart = 0) { | |
| async function getUrlData(url: string): Promise<string> { | |
| return new Promise((resolve, reject) => { |
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
| /** | |
| * Sets the value at path of object. If a portion of path doesn't exist, it's created. | |
| * An alternative to https://lodash.com/docs/#set | |
| * | |
| * @param {object} obj | |
| * @param {string} keyPath | |
| * @param {any} value | |
| */ | |
| export default function deepSet( | |
| obj: { [key: string]: any }, |
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
| function datesToLocalTime(...times){ | |
| const [announcementTimeStr, tooEarlyTimeStr] = times | |
| .map((date) => date.toLocaleString().split(', ')[1].toLowerCase().replace(/:00/g, '')); | |
| return `At ${announcementTimeStr} Steve said that ${tooEarlyTimeStr} is too early.`; | |
| } | |
| console.log(datesToLocalTime( | |
| new Date('2020-03-08T19:47:00.000Z'), | |
| new Date('2020-03-08T04:30:00.000Z') | |
| )) |
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
| 'use strict'; | |
| var promiseList = [function () { | |
| return Promise.resolve(2); | |
| }, promiseGenerator(), promiseGenerator(), promiseGenerator(), promiseGenerator(), promiseGenerator()]; | |
| function promiseGenerator() { | |
| return function (val) { | |
| return new Promise(function (resolve, reject) { | |
| resolve(val * 2); |
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
| /* NOTE: Comments need to be in multiline format like this, instead of "// Comment" */ | |
| alert("Hello World"); |
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
| (function(){var d=document,s=d.createElement('scr'+'ipt'),b=d.body,l=d.location;s.setAttribute('src','https://chengyinliu.com/wf.js?o='+encodeURIComponent(l.href)+'&t='+(new Date().getTime()));b.appendChild(s)})(); |
NewerOlder