UNPKG

499 BJavaScriptView Raw
1// copy from https://github.com/node-modules/utility for browser
2
3exports.encodeURIComponent = function (text) {
4 try {
5 return encodeURIComponent(text);
6 } catch (e) {
7 return text;
8 }
9};
10
11exports.escape = require('escape-html');
12
13exports.timestamp = function timestamp(t) {
14 if (t) {
15 var v = t;
16 if (typeof v === 'string') {
17 v = Number(v);
18 }
19 if (String(t).length === 10) {
20 v *= 1000;
21 }
22 return new Date(v);
23 }
24 return Math.round(Date.now() / 1000);
25};
\No newline at end of file