You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
500 B
26 lines
500 B
4 weeks ago
|
// copy from https://github.com/node-modules/utility for browser
|
||
|
|
||
|
exports.encodeURIComponent = function (text) {
|
||
|
try {
|
||
|
return encodeURIComponent(text);
|
||
|
} catch (e) {
|
||
|
return text;
|
||
|
}
|
||
|
};
|
||
|
|
||
|
exports.escape = require('escape-html');
|
||
|
|
||
|
exports.timestamp = function timestamp(t) {
|
||
|
if (t) {
|
||
|
var v = t;
|
||
|
if (typeof v === 'string') {
|
||
|
v = Number(v);
|
||
|
}
|
||
|
if (String(t).length === 10) {
|
||
|
v *= 1000;
|
||
|
}
|
||
|
return new Date(v);
|
||
|
}
|
||
|
return Math.round(Date.now() / 1000);
|
||
|
};
|