@endpass/utils
Advanced tools
Comparing version 1.8.7 to 1.9.0
46
date.js
@@ -7,2 +7,3 @@ 'use strict'; | ||
var relativeTime = _interopDefault(require('dayjs/plugin/relativeTime')); | ||
var weekOfYear = _interopDefault(require('dayjs/plugin/weekOfYear')); | ||
@@ -14,18 +15,33 @@ /** | ||
dayjs.extend(relativeTime); | ||
dayjs.extend(weekOfYear); | ||
var formateDate = function formateDate(date) { | ||
var template = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'YYYY-MM-DD H:mm'; | ||
return dayjs(date).format(template); | ||
}; | ||
var fromNow = function fromNow(date) { | ||
return dayjs(date).fromNow(); | ||
}; | ||
var fromTo = function fromTo(fromDate, toDate) { | ||
var start = dayjs(fromDate); | ||
return start.to(dayjs(toDate)); | ||
}; | ||
var addToDate = function addToDate(date, value) { | ||
var unit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 's'; | ||
return dayjs(date).add(value, unit).toDate(); | ||
}; | ||
var getWeek = function getWeek(date) { | ||
return dayjs(date).week(); | ||
}; | ||
module.exports = { | ||
formateDate: function formateDate(date) { | ||
var template = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'YYYY-MM-DD H:mm'; | ||
return dayjs(date).format(template); | ||
}, | ||
fromNow: function fromNow(date) { | ||
return dayjs(date).fromNow(); | ||
}, | ||
fromTo: function fromTo(fromDate, toDate) { | ||
var start = dayjs(fromDate); | ||
return start.to(dayjs(toDate)); | ||
}, | ||
addToDate: function addToDate(date, value) { | ||
var unit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 's'; | ||
return dayjs(date).add(value, unit).toDate(); | ||
} | ||
formateDate: formateDate, | ||
fromNow: fromNow, | ||
fromTo: fromTo, | ||
addToDate: addToDate, | ||
getWeek: getWeek | ||
}; |
'use strict'; | ||
// eslint-disable-next-line | ||
module.exports.isNumeric = function (n) { | ||
var isNumeric = function isNumeric(n) { | ||
return !isNaN(parseFloat(n)) && isFinite(n); | ||
}; | ||
var toFixed = function toFixed(num) { | ||
return !num ? '0' : (num / 100).toFixed(2); | ||
}; | ||
module.exports = { | ||
isNumeric: isNumeric, | ||
toFixed: toFixed | ||
}; |
{ | ||
"name": "@endpass/utils", | ||
"version": "1.8.7", | ||
"version": "1.9.0", | ||
"description": "Utils and helper functions", | ||
@@ -5,0 +5,0 @@ "author": "Endpass, Inc", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
39050
1122