Skip to content

Instantly share code, notes, and snippets.

@think49
think49 / deep-copy-object.js
Last active August 23, 2017 08:28
deep-copy-object.js: オブジェクトをディープコピー
/**
* deep-copy-object.js
*
* Deep copy objects.
*
* @version 1.0.0
* @author think49
* @url https://gist.github.com/think49/96e8fc064b917287cadb1dfacc39695c
* @license http://www.opensource.org/licenses/mit-license.php (The MIT License)
*/
@think49
think49 / es6-object-assign.js
Last active August 23, 2017 08:01
Object.assign(): オブジェクトをシャローコピー(ES6 Polyfill)
/**
* es6-object-assign.js
*
* Object.assign( target, ...sources )
* The assign function is used to copy the values of all of the enumerable own properties from one or more source objects to a target object. When the assign function is called, the following steps are taken. (ECMA-262 6th Edition / ECMAScript 2015)
*
* @version 1.0.0
* @author think49
* @url https://gist.github.com/think49/a615978e85f44cb0ef5c7cbdd3cca942
* @license http://www.opensource.org/licenses/mit-license.php (The MIT License)
@think49
think49 / multidimensional-map-1.0.0.js
Last active July 19, 2017 11:20
multidimensional-map.js : 多次元Mapを生成
/**
* multidimensional-map.js
*
* @version 1.0.0
* @author think49
* @url https://gist.github.com/think49/00326b750d48f5f9c48a042f1b19a1c2
* @license http://www.opensource.org/licenses/mit-license.php (The MIT License)
*/
function createMultidimensionalMap (mapData) {
@think49
think49 / readme.md
Last active July 13, 2017 14:05
virtual-dom.js: DOM API互換の Interface で仮想DOMオブジェクトを生成する

virtual-dom.js

概要

DOM API互換の Interface で仮想DOMオブジェクトを生成する。

使い方

p要素ノードを生成し、id属性値を付与する。

@think49
think49 / create-qa-form.html
Last active July 12, 2017 11:38
出題フォームを生成する (URL Standard)
<!DOCTYPE html>
<html id="root">
<head>
<meta charset="UTF-8">
<title>出題フォームを生成する</title>
<body>
<h1>出題フォームを生成する</h1>
<h2>実装</h2>
@think49
think49 / readme.md
Last active June 21, 2017 01:45
swap-node.js: 2つのノードの位置を入れ替えます

swap-node.js

概要

2つのノードの位置を入れ替えます。

制約

内部的に Node#replaceChild, Node#appendChild, Node#insertBefore を使用している関係上、下記制約があります。

@think49
think49 / find-corresponding-from-string.js
Last active May 2, 2021 07:23
find-corresponding-from-string.js: 「開始文字列」と「終了文字列」で括られた対応関係を最長一致でマッチします。
/**
* find-corresponding-from-string.js
*
* @version 1.0.0
* @author think49
* @url https://gist.github.com/think49/53b4a2cedfcff3c1a1ea40390a7ff3d8
* @license http://www.opensource.org/licenses/mit-license.php (The MIT License)
*/
'use strict';
@think49
think49 / array-findwordall.js
Last active January 31, 2017 17:53
array-findwordall.js: 配列から指定した文字列リスト全てを含む要素を抽出します (要ES5)
/**
* array-findwordall.js
*
* @version 1.0.0
* @author think49
* @url https://gist.github.com/think49/811ac93dae801a4cec2e58a70a9b961a
* @license http://www.opensource.org/licenses/mit-license.php (The MIT License)
*/
var findWordAll = (function (RegExp, call, test, replace) {
@think49
think49 / calculation-sample.html
Last active November 13, 2016 15:53
calculation-sample.js: LLmanさんのアドバイスを元に書いたコード。SyntaxErrorのエラー検出処理と数値演算処理を別関数に分割した。
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>calculation-sample.js</title>
<script>
/**
* calculation-sample.js
* evaluate calculation formula.
*
@think49
think49 / eval-calculation-map-sample.html
Last active November 13, 2016 15:10
eval-calculation-map-sample: Chironian さんのアドバイスを元に書いてみたコード。new Map(['value', '演算結果となる数値'], ['errors', [new SyntaxError('エラー1'), new SyntaxError('エラー2')]]) を返り値とする。
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>eval-calculation-map-sample.js</title>
<script>
/**
* eval-calculation-map-sample.js
* evaluate calculation formula.
*