Skip to content

Instantly share code, notes, and snippets.

@think49
think49 / deep-freeze-from-object-1.0.0.js
Last active April 10, 2018 12:30
deep-freeze-from-object.js: オブジェクトのプロパティを含めて、Object.freeze
/**
* deep-freeze-from-object-1.0.0.js
* Freeze the deep objects in the object.
*
* @version 1.0.0
* @author think49
* @url https://gist.github.com/think49/2aa2f7a19ddc3f2030dd288839c29f2b
* @license http://www.opensource.org/licenses/mit-license.php (The MIT License)
*/
@think49
think49 / [正規表現] AND条件を一つの正規表現で実装する方法.md
Created April 10, 2018 10:20
AND条件を一つの正規表現で実装する方法

[正規表現] AND条件を一つの正規表現で実装する方法

概要

"ABC" かつ "XYZ" を含む文字列にマッチさせる場合において、一つの正規表現で実現する方法を考えます。 なお、"ABC" と "XYZ" のどちらが先に出現するかは決まっていません。

肯定先読み (?=pattern)

肯定先読みでAND条件の一つ目の条件(ABC)を先読みする事で、2つ目の条件(XYZ)を検索する事が出来ます。

@think49
think49 / delete-duplicate-line-0.2.1.js
Last active January 28, 2018 08:11
delete-duplicate-line.js: 文字列における重複行を削除する
/**
* delete-duplicate-line-0.2.1.js
* Delete duplicate line.
*
* @version 0.2.1
* @author think49
* @url https://gist.github.com/think49/9ccf52aa1f2d01e4417b6f0fb2d37ce9
* @license http://www.opensource.org/licenses/mit-license.php (The MIT License)
*/
@think49
think49 / nodelist-prototype-foreach-1.0.0.js
Last active October 29, 2017 12:12
nodelist-prototype-foreach.js: Web IDL 既定の NodeList.prototype.forEach の Polyfill(互換コード)
/**
* nodelist-prototype-foreach.js
* The forEach() method of the NodeList interface calls the callback given in parameter once for each value pair in the list, in insertion order.
*
* @version 1.0.0
* @author think49
* @url https://gist.github.com/think49/df8c54a9aa421db3b650a3c1cab9b4a9
* @license http://www.opensource.org/licenses/mit-license.php (The MIT License)
* @see <a href="https://heycam.github.io/webidl/#es-forEach">3.6.9.2. forEach - Web IDL</a>
*/
@think49
think49 / [JavaScript] Number 型に変換する方法まとめ.md
Created October 2, 2017 14:13
[JavaScript] Number 型に変換する方法まとめ

Number 型に変換する方法まとめ

ECMAScript 2017

ECMAScript とは JavaScript の根幹となる仕様の名称です。 型変換は ECMAScript 仕様に準じており、ここでは ECMAScript 2017 に沿った説明をしています。

数値リテラル (NumericLiteral)

ECMAScript 2017 では Number 型を表すリテラル表現として、NumericLiteral の文法を定義しており、NumericLiteral は更に次の4種類に分かれます。

@think49
think49 / readme.md
Last active October 1, 2017 16:58
string-prototype-includes.js: String.prototype.includes の Polyfill (ECMAScript 2017 準拠)

string-prototype-includes.js

概要

ECMAScript 2015 (ECMA-262 6th Edition) から既定の String.prototype.includes の Polyfill(互換コード)を提供します。 (ES6 で作られたメソッドですが、参考にした仕様は ECMAScript 2017 (ES8) になります。)

使い方

@think49
think49 / create-square-aa-1.0.1.js
Last active February 2, 2019 06:24
create-square-aa.js: 四角形のASCII Artを生成する
/**
* create-square-aa-1.0.1.js
* create ASCII art square.
*
* @version 1.0.1
* @author think49
* @url https://gist.github.com/think49/2a30b4e865f3dca4043440fb9b99a448
* @license http://www.opensource.org/licenses/mit-license.php (The MIT License)
*/
@think49
think49 / readme.md
Last active September 13, 2017 08:14
toISOLocalString(): 現在のロケールに対応した「ISO 8601 拡張形式」の日付文字列を返します

to-iso-local-string.js

概要

現在のロケールに対応したISO 8601 拡張形式の日付文字列を返します。 現在のロケールが UTC (協定世界時) であるなら、Date.prototype.toISOString() と同じ文字列を返します。

使い方

@think49
think49 / Webブラウザのウインドウのスクロール量を取得する.md
Last active October 4, 2021 03:29
Webブラウザのウインドウのスクロール量を取得する.md
@think49
think49 / json-for-date-1.0.2.js
Last active September 17, 2021 03:05
json-for-date.js: DateオブジェクトをJSON拡張形式にシリアライズ/パースの相互変換
/**
* json-for-date-1.0.2.js
* JSON which can serialize Date object
*
* @version 1.0.2
* @author think49
* @url https://gist.github.com/think49/26fcddaaa63cd0d6b27de8ef9c514c41
* @license http://www.opensource.org/licenses/mit-license.php (The MIT License)
*/