View clone.js
function clone(obj) { return Object.create(obj); }
View debounce.js
function debounce(fn, wait, immediate) {
var timeout;
return function() {
var context = this, args = arguments;
var later = function() {
timeout = null;
if (!immediate) fn.apply(context, args);
};
var callNow = immediate && !timeout;
clearTimeout(timeout);
View es6_remove.js
const remove = (index, array) =>
[...array.slice(0, index),
...array.slice(index + 1, array.length)];
View sorted_union.js
const sortedUnion = (a, b) => {
const c = {};
[...a, ...b].forEach(i => c[i] = i);
return Object.keys(c);
};
View es6_insert.js
const insert = (item, index, array) =>
[...array.slice(0, index),
...item,
...array.slice(index, array.length)];
View insert.js
function insert(item, index, array) {
array.splice(index, 0, item);
return array;
}
View defer.js
function defer(fn) { return setTimeout(fn, 0); }
View text-overflow.css
.text-overflowed {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
View chart.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width" />
<link rel="stylesheet" type="text/css" href="main.css" />
<title>CSS Chart</title>
</head>
<body>
<div class="bars-wrapper">
View xhr_promise.js
function get(url) {
return new Promise(function(resolve, reject) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url);
xhr.onload = function() {
if (xhr.status === 200) {
resolve(xhr.response);
} else {
reject(Error(xhr.statusText));