daily pastebin goal
62%
SHARE
TWEET

Untitled

a guest May 16th, 2018 103 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. [‘“bc’, ‘defg’] → ‘?????’  → [‘abc’,’defg’]
  2.  
  3. json.stringify([‘“bc’, ‘defg’]) -> “[‘\”bc’,’defg’]”
  4.  
  5. [999, 123] -> “[999,123]”
  6.  
  7. N elements , <= L L+5
  8.  
  9. 0-9 ->1
  10. 10-99 -> 2
  11. 100-999 -> 3
  12.  
  13. string length is (2+ ((2*N) -1) + (N * log(10, L)))
  14.  
  15. function wrap(action, msec) : wrapped_action
  16.  
  17. function wrap(action, msec) {
  18.  
  19.    let lastTime = 0;
  20.  
  21.    const fn = () => {
  22.      const now = new Date().getTime();
  23.  
  24.      if( now >= lastTime + msec ){
  25.      action();
  26.      lastTime = now;
  27.      } else {
  28.        setTimeout( fn, now - (lastTime + msec) )
  29.      }
  30.    }
  31.  
  32.    return fn;
  33.  
  34. }
RAW Paste Data
Top