1 | // copy from https://github.com/node-modules/utility for browser
|
2 |
|
3 | exports.encodeURIComponent = function (text) {
|
4 | try {
|
5 | return encodeURIComponent(text);
|
6 | } catch (e) {
|
7 | return text;
|
8 | }
|
9 | };
|
10 |
|
11 | exports.escape = require('escape-html');
|
12 |
|
13 | exports.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 |