Skip to content

Instantly share code, notes, and snippets.

View yyssjj33's full-sized avatar
🎯
Focusing

Ji Yang yyssjj33

🎯
Focusing
  • Los Angeles
View GitHub Profile
const debounce = (fn, wait) => {
let timeout = null;
wait = wait || 250; // Default to 250ms
return (...args) => {
const delayed = () => {
timeout = null;
fn.apply(null, args);
};
@yyssjj33
yyssjj33 / order.js
Created July 10, 2017 20:18
demo for web sql
var order = {
orderId: 100314, format_city: "New York, NY, USA",
lat: 40.7127837, lng: -74.0059413,
price: 150, createTime: "2017-06-08"
};
const db = window.openDatabase("order_test", "1.0", "order map data", 2*1024*1024)
db.transaction(function(tx){
tx.executeSql( "create table if not exists order_data(order_id primary key, format_city, lat, lng, price, create_time)", [], null,
@yyssjj33
yyssjj33 / leftpad.js
Created April 6, 2016 19:57
A 11 lines important npm module, left-pad
module.exports = leftpad;
function leftpad (str, len, ch) {
str = String(str);
var i = -1;
if (!ch && ch !== 0) ch = ' ';
len = len - str.length;