utils.js

Taek·2020년 6월 13일
0
post-custom-banner

1. pipe

const pipe = (...functions) => 
(args) => functions.reduce((arg, nextFn) => nextFn(arg), args)

2. 천단위 콤마

const numberComma = (number) => 
number.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
const setCookie = (key, value, days) => 
  {
      var exdate = new Date();
      exdate.setDate(exdate.getDate() + days);

      var cookie_value = escape(value) + ((days == null) ? '' : ';    expires=' + exdate.toUTCString());
      document.cookie = key + '=' + cookie_value;
  }

const getCookie = (key) => 
  {
      var value = "; " + document.cookie;
      var parts = value.split("; " + key + "=");
      if (parts.length == 2) return
      parts.pop().split(";").shift();
  };

const deleteCookie = (key) => 
  {
      document.cookie = key + "=; expires=Thu, 01 Jan 1999 00:00:10 GMT;";
  };
post-custom-banner

0개의 댓글