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 eventMap = new WeakMap(); | |
const asyncOnSymbol = Symbol("asyncOn"); | |
const asyncOffSymbol = Symbol("asyncOff"); | |
function asyncOn(type, asyncFunc, useCapture){ | |
const undefined = void 0; | |
if(eventMap.has(asyncFunc)) return; | |
return new Promise((resolve, reject)=>{ |
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
<!DOCTYPE html> | |
<html lang="ja"> | |
<head> | |
<!-- 省略 --> | |
<script src="widget.js"></script> | |
<script src="index.js"></script> | |
</head> | |
</html> |
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
function milkbox(uri){ | |
// 文字列としてエレメントを定義 | |
var eleStr = function(){/* | |
<div id="milkbox_body" class="milk_wrap"> | |
<div class="milkbox_container"> | |
<div class="milkbox_content"> | |
<img src="CONTENT_URI"> | |
<div class="milkbox_button">x</div> | |
<div id="loader_id" class="loader"> | |
<img src="img/load.gif"> |
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 drawHueCircle = Symbol("drawHueCircle"); | |
const drawSVRect = Symbol("drawSVRect"); | |
Object.defineProperties(CanvasRenderingContext2D.prototype, { | |
[drawHueCircle]: { | |
value(x, y, rIn, rOut, splitNum=180){ | |
// 描画半径を計算で求める | |
const r = 2 * rOut; | |
// 直前のスタイル情報のバックアップ | |
const oldStrokeStyle = this.strokeStyle; |
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
//RGBの情報から、HSVの情報を得る汎用メソッド | |
//「http://p.tl/YDI3」のJavaソースコードをJSに移植しただけです。 | |
function GetHSVColorByRGBColor(rgb){ | |
var hue,saturation,value; | |
var max = Math.max(rgb.r,rgb.g,rgb.b); | |
var min = Math.min(rgb.r,rgb.g,rgb.b); | |
//hue | |
if(max == min){ | |
hue = 0; |
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
function stableSort(arr, callback){ | |
var indexMap = new Map(null); | |
for(var i=0;i<arr.length;i++){ | |
indexMap.set(arr[i], i); | |
} | |
var result; | |
arr.sort(function compare(a, b){ | |
result = (callback) ? callback(a, b) : false; |
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 Human{ | |
constructor(name, age){ | |
this.name = name; | |
this.age = age; | |
} | |
static clone(obj){ return new this(obj.name, obj.age); } | |
} | |
class Woman extends Human{} |
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 queue = Symbol("queue"); | |
const sync = Symbol("sync"); | |
const createAwaiter = Symbol("createAwaiter"); | |
const addQueue = Symbol("addQueue"); | |
const syncMethods = Symbol("syncMethods"); | |
const Awaiter = ((Base)=> { | |
class Awaiter extends Base{ | |
constructor(...args){ | |
super(...args); |
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
"use strict"; | |
const resolverSymbol = Symbol("resolver"); | |
const notifierListSymbol = Symbol("notifierList"); | |
const cancelSymbol = Symbol("cancel"); | |
class Gaobservable{ | |
constructor(resolver){ | |
if(typeof(resolver) !== "function") throw new TypeError(`Gaobservable resolver ${resolver} is not a function`); | |
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
function consume(reader, length) { | |
var total = 0; | |
return (function pump() { | |
console.log(`${total} / ${length}`); | |
return reader.read().then(function(args) { | |
if (!args.done) { | |
total += args.value.byteLength; | |
return pump(); | |
} |