This file contains 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
// FooData型とBarData型の値を流すことを考えてみる | |
interface FooData { | |
foo: string; | |
} | |
interface BarData { | |
bar: number; | |
} |
This file contains 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
async function main() { | |
const response = await fetch(url1); | |
const arrayBuffer1 = await response.arrayBuffer(); | |
const response2 = await fetch(arrayBuffer1.url); | |
const arrayBuffer2 = await response2.arrayBuffer(); | |
console.log(arrayBuffer1, arrayBuffer2); | |
} | |
main(); |
This file contains 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 class IteratorUtil { | |
/** | |
* 引数の配列を無限にループするイテレータの生成 | |
* @param {Array<T>} array | |
* @param {boolean} skipNullValue: nullの値をスキップするかどうか | |
* @returns {Iterator<T>} | |
* | |
* 使い方 | |
* | |
* const myArray = [1, 2, 3]; |
This file contains 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
* { | |
accelerator: true !important; | |
azimuth: center !important; | |
background: red !important; | |
background-attachment: scroll !important; | |
background-color: red !important; | |
background-image: linear-gradient(to bottom, red, blue); | |
background-position: 2000cm 2000cm !important; | |
background-position-x: 2000cm !important; | |
background-position-y: 2000cm !important; |
This file contains 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
/** | |
* イージング定数。cubic-bezier()で使用する | |
* | |
* # 使用例 | |
* const fooElement = document.querySelector(".foo") as HTMLElement; | |
* fooElement.style.transitionTimingFunction = `cubic-bezier(${Easing._6_ExpoOut})`; | |
* | |
* # 参考 | |
* アニメーションをデザインしよう! 知っておきたいCSSイージングのお手本 | |
* ICS MEDIA https://ics.media/entry/18730 |
This file contains 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
/** | |
* イージング定数。cubic-bezier()で使用する | |
* | |
* # 使用例 | |
* const fooElement = document.querySelector(".foo"); | |
* fooElement.style.transitionTimingFunction = `cubic-bezier(${Easing._6_ExpoOut})`; | |
* | |
* # 参考 | |
* アニメーションをデザインしよう! 知っておきたいCSSイージングのお手本 | |
* ICS MEDIA https://ics.media/entry/18730 |
This file contains 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"; | |
/** | |
* Node.jsでキャッシュなしにJSONを読み込む | |
* | |
* 使用例 | |
* import path from "path"; | |
* | |
* const myStubJson = parseJsonWithoutCache( | |
* path.resolve(__dirname, "relative_path_to_json") |
This file contains 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 library = myLibrary(); | |
// library.foo(); | |
// Hybrid Typesでモックを作る | |
interface IMyLibrary { | |
(): void; | |
foo(): void; | |
bar(buz: number): string; | |
} |
This file contains 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
/** EventTargetを継承したクラス */ | |
class MyClass extends EventTarget { | |
start() { | |
// 2秒後に「運命の出逢い」イベントを発生させる | |
setTimeout(() => { | |
this.dispatchEvent(new CustomEvent("運命の出逢い")); | |
}, 2000); | |
} | |
} |
This file contains 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
class MyClass { | |
foo = "パブリックなフィールド"; | |
#bar = "プライベートなフィールド"; | |
constructor() { | |
console.log(this.foo); | |
console.log(this.#bar); // クラス内からはアクセス可能 | |
} | |
} |
OlderNewer