Skip to content

Instantly share code, notes, and snippets.

@think49
think49 / to-absolute-url.js
Last active December 1, 2015 03:56
to-absolute-url.js: URL文字列を絶対URLに変換 (※DOM L2 HTML の HTMLAnchorElement#href 依存)
/**
* to-absolute-url.js
*
* @version 1.0.1
* @author think49
* @url https://gist.github.com/think49/1e8944a19a36dd57c829
* @license http://www.opensource.org/licenses/mit-license.php (The MIT License)
*/
'use strict';
@think49
think49 / poker.js
Last active May 30, 2020 05:07
poker.js: 数値添字配列をトランプの手札に見立てて役を求める。4種のマークが存在しないので不完全。とりあえず、作ったので公開してみたレベル。
/**
* poker.js
*
* @version 0.1.1
* @author think49
* @url https://gist.github.com/think49/39c020a54939513cb2fd
* @license http://www.opensource.org/licenses/mit-license.php (The MIT License)
*/
'use strict';
@think49
think49 / readme.md
Last active September 13, 2017 07:36
String.prototype.padStart, String.prototype.padEnd の Polyfill (ECMAScript 2017 / ECMA-262 8th edition)

string-prototype-padstart+padend.js

概要

ECMAScript 2017 (ECMA-262 8th edition) 既定の String.prototype.padStart 及び String.prototype.padEnd の Polyfill(互換コード)を提供します。

使い方

String.prototype.padStart( maxLength [ , fillString ] )

@think49
think49 / debug-code.js
Last active December 9, 2015 16:38
debug-code.js: コードを実行し、評価値or例外エラーをプログラムを強制終了せずに返す
/**
* debug-code.js
*
* @version 1.0.3
* @author think49
* @url https://gist.github.com/think49/bfca562039aa29fa5766
* @license http://www.opensource.org/licenses/mit-license.php (The MIT License)
*/
'use strict';
var DebugCode = (function (Object, keys, defineProperty, String) {
@think49
think49 / es6-weakmap.js
Last active July 1, 2017 21:46
es6-weakmap.js: ECMA-262 6th Edition (ECMAScript 2015) WeakMap polyfill
/**
* es6-weakmap.js
* WeakMap (ECMA-262 6th Edition / ECMAScript 2015)
*
*
* @version 0.9.2
* @author think49
* @url https://gist.github.com/think49/283b7374e352e09fc131
* @license http://www.opensource.org/licenses/mit-license.php (The MIT License)
* @see <a href="http://www.ecma-international.org/ecma-262/6.0/#sec-weakmap-constructor">23.3.1 The WeakMap Constructor – ECMA-262 6th Edition</a>
@think49
think49 / jquery.get-classlist.js
Last active February 17, 2016 03:25
jquery.get-classlist.js: jQuery オブジェクトの最初のインデックスとなる要素ノードから classList (HTML5規定) を得る jQuery plugin
/**
* jquery.get-classlist.js
* get a classList of first index's jQuery object.
*
* @version 1.0
* @author think49
* @url https://gist.github.com/think49/c382098fedd9ae7c6661
* @license http://www.opensource.org/licenses/mit-license.php (The MIT License)
*/
@think49
think49 / ReadMe.md
Last active February 27, 2016 18:24
increment-by-number-range.js: 範囲指定の数字をインクリメントループする(ex: 5 -> 6 -> 7 -> 5 -> 6 ->...)

increment-by-number-range.js

概要

範囲指定内で数字をインクリメントさせます。 例えば、「5 -> 6 -> 7 -> 5 -> 6 ->...」のようにループします。

HowTo

第一引数から「現在値, 開始値, 終了値」を指定し、関数を返します。

@think49
think49 / es6-string-prototype-startswith.js
Last active March 29, 2016 08:51
es6-string-prototype-startswith.js: String.prototype.startsWith の Polyfill (ES6 規定)
/**
* es6-string-prototype-startswith.js
* String.prototype.startsWith (ECMA-262 6th Edition / ECMAScript 2015)
*
*
* @version 1.0.0
* @author think49
* @url https://gist.github.com/think49/908b8d5f08c9945beea7
* @license http://www.opensource.org/licenses/mit-license.php (The MIT License)
* @see <a href="http://www.ecma-international.org/ecma-262/6.0/#sec-string.prototype.startswith">21.1.3.18 String.prototype.startsWith – ECMA-262 6th Edition</a>
@think49
think49 / History.md
Last active July 12, 2022 05:36
csv.js: ES5 規定の JSON と同じインターフェースを持つCSVパーサ

更新履歴 (csv.js)

ver 1.0.3 (2016/05/11)

  • CSV.parse() の内部実装を String.prototype.replace から RegExp.prototype.exec に変更した

ver 1.0.2 (2016/05/11)

  • CSV.parse() で第三引数 reviver が指定された場合、配列化する前にセル値を引数にとるコールバック関数 reviver を呼び出すようにした
  • CSV.stringify() で第三引数 replacer が指定された場合、CSV文字列に変換する前に要素値を引数にとるコールバック関数 replacer を呼び出すようにした

ver 1.0.1 (2016/05/10)

@think49
think49 / ReadMe.md
Last active October 4, 2016 08:04
addholdkeyeventlistener.js: 同時に入力されたキー一覧を取得するイベントリスナ(addEventListener 互換)

addholdkeyeventlistener.js

概要

キーボードからキー入力する場合、キーを押して(keydown)した後にキーを離して(keyup)、キー入力を確定させます。 この仕組みを踏まえ、keyup の瞬間に同時に入力されているキー全てを取得するイベントリスナを実現します。

使い方

"addholdkeyeventlistener.js" を外部スクリプトとして読み込めば、第一引数にDOMノードを指定する以外は addEventListener と同等の感覚で使えます。