难度:★
var data = [
{
name: "Jamestown",
population: 2047,
temperatures: [-34, 67, 101, 87]
},
[ | |
{ | |
"name": "Personal Email", | |
"text": "[email protected]", | |
"keyword": "@@" | |
}, | |
{ | |
"name": "Home Address", | |
"text": "221B Baker St., London" | |
}, |
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc. | |
# Initialization code that may require console input (password prompts, [y/n] | |
# confirmations, etc.) must go above this block; everything else may go below. | |
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then | |
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" | |
fi | |
# If you come from bash you might have to change your $PATH. | |
export PATH=$HOME/bin:/usr/local/bin:$PATH |
console.group('output 🌿') | |
queueMicrotask(() => { | |
console.log('queueMicrotask') | |
}); | |
requestAnimationFrame(() => { | |
console.log('requestAnimationFrame') | |
}) |
import { | |
SyncHook, | |
SyncBailHook, | |
SyncWaterfallHook, | |
SyncLoopHook, | |
AsyncParallelHook, | |
AsyncParallelBailHook, | |
AsyncSeriesHook, | |
AsyncSeriesBailHook, | |
AsyncSeriesWaterfallHook, |
function consoleSplit(description = '') { | |
console.log('-'.repeat(25) + description + '-'.repeat(25)); | |
} | |
consoleSplit('Get, Set, Has, DeleteProperty') | |
const p1 = { | |
name: 'rio', | |
age: 20, | |
} |
/** | |
* html-to-rtf-browser not recognize height/style property of img tag | |
* so, need add height/size to style property to avoid image lose rtf picture size. | |
*/ | |
function attachDimensionStyleForImage(htmlString: string): string { | |
try { | |
const domParser = new DOMParser(); | |
const doc = domParser.parseFromString(htmlString, "text/html"); | |
const images = doc.getElementsByTagName("img"); | |
for (let i = 0; i < images.length; i++) { |
import { useEffect } from "react"; | |
import { useHistory } from "react-router-dom"; | |
export const defaultLevelMessage = | |
"未保存のデータがあります。ページを離れてもよろしいですか。"; | |
function useBlockRouteChange( | |
shouldBlock: boolean, | |
message = defaultLevelMessage, | |
onLevel?: () => void |
TLDR: Use for...of
instead of forEach
in asynchronous code.
Array.prototype.forEach
is not designed for asynchronous code. (It was not suitable for promises, and it is not suitable for async-await.)
For example, the following forEach loop might not do what it appears to do:
puts "start convert file names to hyphen style...." | |
def traverse_dir(fileType) | |
folder_path = File.absolute_path("./") + "/" | |
scheme = folder_path + "*.#{fileType}" | |
puts "find #{Dir.glob(scheme).length} #{fileType} files, start convert...." | |
puts '-' * 50 | |
Dir.glob(scheme).each do |f| | |
filename = File.basename(f, File.extname(f)) | |
File.rename(f, folder_path + filename.downcase.tr(' ', '-') + File.extname(f)) |